5 ms·
I have no idea if anyone else does this, but I use tmux a lot for different projects. I usually have vim in one tab, logs in another, and tests in another. Howe
by lucaspiller 13y ago
I have no idea if anyone else does this, but I use tmux a lot for different projects. I usually have vim in one tab, logs in another, and tests in another. However, each tab I open I need to cd into the same directory. As such I came up with this helper for zsh. Every time I change a directory it records it. When I start a new session (new tmux or iTerm tab) it goes straight to that directory:
# record directory in ~/.lastpwd
record_pwd() {
pwd > ~/.lastpwd
}
chpwd_functions=(record_pwd)
# go to last directory when opening a new shell
if [[ -d `cat ~/.lastpwd` ]]; then
cd `cat ~/.lastpwd`
fi
For other shells that don't have something like chpwd_functions you could just alias cd.
- phinze 13y ago> However, each tab I open I need to cd into the same directory. As of tmux 1.7, this should be unnecessary. Every tab and split will open in the working directory of the current pane, and the behavior can be changed with the `default-path` option.