Quick-jump tool made in Zig
at main 70 lines 1.9 kB view raw view rendered
1# Project picker 2 3Presents a filterable list of pre-defined strings from `~/.config/project-picker/projects` for you to select and provide to some shell command. 4Once an item in the list is selected `project-picker` will print the full path to STDOUT. 5 6**Exit codes:** 7 8* If an item is picked `project-picker` will exit with status `0`. 9* If no item is chosen `project-picker` will exit with status `1`. 10* If `Ctrl-C` is used to close `project-picker` instead of selecting an item it will exit with status `1`. 11* If an error occurred `project-picker` will exit with status `74` and an error message is printed to STDERR. 12 13## Usage example: jump between project folders 14 15Add a list of the projects you want easily available to a config file, then run `project-picker`. 16`project-picker` will print the selected project path to STDOUT. 17 18### Add project paths to the config file 19 20``` 21~/projects/project-a 22~/projects/project-b 23/Users/jdoe/projects/project-c 24~/projects/sub-projects/* 25``` 26 27If you end a path with `/*` `project-picker` will list all the directories in that folder. 28 29### Example: jump between projects with cd 30 31Put in a shell script or alias: 32 33```fish 34# ~/.config/fish/functions/pp.fish 35# Fish alias for project-picker, usage: pp 36function pp 37 set dir (project-picker) 38 39 # A non-zero exit code means no project was selected. 40 if test $status -eq 0 41 cd $dir 42 end 43end 44``` 45 46 47## Usage example: pass result to command 48 49This is the quick and dirty way to use `project-picker`. 50If an error occurs or you don't pick an item nothing will be passed to the command. 51 52```bash 53# `cd` to selected item. 54cd $(project-picker) 55 56# Open selected item in vim. 57vim $(project-picker) 58``` 59 60 61## Build `project-picker` 62 63```sh 64# Will place `project-picker` in ./zig-out/bin 65zig build -Doptimize=ReleaseSafe 66 67# Will place `project-picker` in ~/.local/bin 68zig build -Doptimize=ReleaseSafe --prefix ~/.local 69``` 70