{
"$type": "site.standard.document",
"description": "The primary reason I use tmux and originally screen was so I don't lose my current working directories when I accidentally close my terminal window s",
"path": "/how-i-use-tmux/",
"publishedAt": "2024-08-13T09:12:00.000Z",
"site": "at://did:plc:bryys25pc2fnagnyxqgsglhd/site.standard.publication/3mn26bjkkmh23",
"tags": [
"Tools"
],
"textContent": "The primary reason I use tmux (and originally screen) was so I don't lose my current working directories when I accidentally close my terminal window(s). tmux attach and you are back where you fat fingered a cmd+w or cmd+q.\n\nThe second reason is because I have a number of projects (and their directories) I work on, so I have a little tmux configuration file called .tmuxdev that I run every time I reboot and start tmux by doing this:\n\ntmux #start tmux\nctrl-w-: source ~/.tmuxdev #source the script\n\n.tmuxdev looks like this:\n\nneww\nsend-keys 'cd ~/path-to-project1' Enter\nrenamew 'project1'\n\nkillw -t 0\n\nneww\nsend-keys 'cd ~/path-to-project2' Enter\nrenamew 'project2'\n\nneww\nsend-keys 'cd ~/path-to-project3' Enter\nrenamew 'project3'\n\n#2 panes\nneww\nsend-keys 'cd ~/path-to-project4/frontend' Enter\nrenamew 'project4'\nspl\nsend-keys 'cd ~/path-to-project4/backend' Enter\n\n#And so on\n\nThen in tmux, I can do ctrl-w and f to find a window by their names like project1.\n\nI also have a few more personalized keybindings that is more consistent with my workflow with vi:\n\nset -g prefix C-w\t#consistent with my vi bindings\nbind j select-pane -D\nbind k select-pane -U\nbind h select-pane -L\nbind l select-pane -R\nbind 9 select-pane -l\nbind 9 run-shell \"tmux select-window -t $(tmux list-windows | awk 'END{print NR-1}')\" #last window\n\n#Overrides default binding which does find-window too, but now case insensitive\nbind f command-prompt \"find-window -i '%%'\"\n\nbind -n C-h previous-window\nbind -n C-l next-window\nbind -n C-o last-window",
"title": "How I use tmux"
}