Skip to content

Instantly share code, notes, and snippets.

@mccurdyc
Created September 24, 2018 12:20
Show Gist options
  • Save mccurdyc/c7e3c5c10aeed5e05eda3feff1f4d3e7 to your computer and use it in GitHub Desktop.
Save mccurdyc/c7e3c5c10aeed5e05eda3feff1f4d3e7 to your computer and use it in GitHub Desktop.
Open New Terminal Window to Last Working Directory
# original author: https://www.reddit.com/r/i3wm/comments/6ugxvk/set_working_directory_for_terminal/dlsntaw
# Open new terminal in same directory as last terminal:
function cd {
builtin cd $@
pwd > ~/.last_dir
}
# clobber "file exists" warning
# clobber is toggled off below
setopt clobber
# Open new terminal in same directory as last terminal:
if [ -f ~/.last_dir ]; then
cd "`cat ~/.last_dir`"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment