Skip to content

Instantly share code, notes, and snippets.

@pcdv
Last active March 6, 2024 14:41
Show Gist options
  • Save pcdv/f3ec45c1202f236733e9288d3a74408c to your computer and use it in GitHub Desktop.
Save pcdv/f3ec45c1202f236733e9288d3a74408c to your computer and use it in GitHub Desktop.
Shortened version of g.bash
function g() {
local C="$HOME/.cdirs"
case $1 in
"") nl "$C" || touch "$C";;
-e) ${EDITOR:-vi} "$C";;
.) pwd >> "$C";;
1-9]*) cd "$(sed -ne "${1}p" "$C")";;
*) cd "$(grep "$1" "$C" | head -1)";;
esac
}
@pcdv
Copy link
Author

pcdv commented Jul 28, 2023

Other version, slightly longer and more user-friendly: https://gist.github.com/pcdv/3c52d82f59fe9042793033d5e249b146

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment