Skip to content

Instantly share code, notes, and snippets.

@mrpossoms
Created November 21, 2017 14:54
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 mrpossoms/127e0ed677eff650c0e2db614592a423 to your computer and use it in GitHub Desktop.
Save mrpossoms/127e0ed677eff650c0e2db614592a423 to your computer and use it in GitHub Desktop.
Run this script in the background to remember your last working directory. Useful for ssh sessions when working in deep directory structures.
#!/bin/zsh
shell_pid=$PPID
last_link=$(readlink -f /proc/$shell_pid/cwd)
while true; do
link=$(readlink -f /proc/$shell_pid/cwd)
if [ $link==$last_link ]; then
readlink -f /proc/$PPID/cwd/ > ~/.hole
last_link=$link
fi
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment