Created
December 13, 2019 08:51
-
-
Save ryanjdillon/f3df68c98e4dfcfb50dac9a727f2d7a8 to your computer and use it in GitHub Desktop.
Push (skyv) Pull (trekk) to global directory stack file, but keep only one
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
# Functions that push and pull to a singleton working directory...a bare-bones pushd/popd. | |
# For namespace clartiy, Norwegian words were use: skyv (push) and trekk (pull). | |
# Adapted from here https://stackoverflow.com/a/9916812 | |
directory_stack=$HOME/.directory_singleton | |
function skyv() { | |
# Save only one skyv path, overwriting the last | |
echo $(pwd) > $directory_stack | |
} | |
function trekk() { | |
# Pulls the skyv path, but leaves it there | |
[ ! -s $directory_stack ] && return | |
newdir=$(sed -n '$p' $directory_stack) | |
cd $newdir | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment