Skip to content

Instantly share code, notes, and snippets.

@ryanjdillon
Created December 13, 2019 08:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanjdillon/f3df68c98e4dfcfb50dac9a727f2d7a8 to your computer and use it in GitHub Desktop.
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
# 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