Created
February 22, 2025 14:42
-
-
Save russolsen/427f0783cb10e52e590b0010d95adf23 to your computer and use it in GitHub Desktop.
A set of bash function to navigate here and there in the file system.
This file contains hidden or 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
# Usage | |
# $ cd /some/directory | |
# $ here projet | |
# | |
# ... do lots of stuff, cd'ing all over. | |
# | |
# $ there project | |
# | |
# You are back to /some/directory | |
# | |
# Add the current dir to the here list, with a name | |
function here { | |
id="$1" | |
if [ $# -eq 0 ]; then | |
id='default' | |
fi | |
here_path="$HOME/.here/$id" | |
pwd > $here_path | |
} | |
# Go to the directory named. | |
function there { | |
id="$1" | |
if [ $# -eq 0 ]; then | |
id='default' | |
fi | |
here_path="$HOME/.here/$id" | |
if test -f $here_path; then | |
cat "$here_path" | |
cd `cat "$here_path"` | |
else | |
echo "No saved path $id." | |
fi | |
} | |
# List all of the names and dirs associated with them. | |
function where { | |
if [ $# -eq 0 ]; then | |
#ls $HOME/.here | |
for f in `ls $HOME/.here` | |
do | |
echo $f '==>' `cat $HOME/.here/$f` | |
done | |
else | |
id="$1" | |
here_path="$HOME/.here/$id" | |
cat $here_path | |
fi | |
} | |
# Clear out the directory list. | |
# Warning! There are no warnings. | |
function nowhere { | |
for f in $* | |
do | |
rm "$HOME/.here/$f" | |
done | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment