Skip to content

Instantly share code, notes, and snippets.

@rn0
Created July 19, 2023 14:15
Show Gist options
  • Save rn0/5a877ee82a025e45833455943f58f530 to your computer and use it in GitHub Desktop.
Save rn0/5a877ee82a025e45833455943f58f530 to your computer and use it in GitHub Desktop.
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