Created
July 19, 2023 14:15
-
-
Save rn0/5a877ee82a025e45833455943f58f530 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function prj --description "Project jumper" | |
if not command -q fzf | |
echo >&2 "prj: fzf command not found. Install with your OS package manager." | |
return 1 | |
end | |
# determine the project home | |
set -q MY_PROJECTS || set -l MY_PROJECTS ~/projects | |
set -l prjfolders (find $MY_PROJECTS -maxdepth 2 -type d -iname ".git" -printf "%h\n") | |
# use fzf to navigate to a project | |
set -l prjlist (string replace $MY_PROJECTS/ "" $prjfolders) | |
set -l selection (printf '%s\n' $prjlist | sort | fzf --layout=reverse-list --query="$argv") | |
test $status -eq 0 || return $status | |
echo "Navigating to '$selection'." | |
cd $MY_PROJECTS/$selection | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment