![]() I use the Fish shell, so I can just create a ~/.config/fish/conf.d/tmux-trap. last pane of the last window of the current session), switch to the default session before this one dies tmux new-session -d -s 'visited' bash -ic 'visited -server' Following one is a simplified command of what Id like to do. check how many panes and windows the current session have, if it is more than 1, do nothing.check if the shell is not interactive, if it isn’t, we do nothing.It scrolls by 5 rows, which feels like a big jump. Another tmux’s default I would prefer to change is the mouse wheel scroll. Read my previous part of tmux in practice series for more details: tmux in practice: iTerm2 and tmux integration. Traps allow you to listen and to POSIX signals and do things when they happen. So pressed in iTerm just sends M-Up keystroke to tmux session. After spending way too much time thinking how I could override CTRL+d in tmux, I thought of a simpler alternative: a shell trap! Shell traps When that happens, I sight and reconnect.Įventually, I had enough and decided to look for a way to fix it. The issue with my workflow is that, when I’m in the last pane of the last window of the current session, if I exit that shell, it also exits tmux (because my SSH command is tmux), and, as expected, it also kills my SSH connection. I have been closing terminals with CTRL+d for as long as I can remember, so that’s burned in my “muscle memory” forever. To be precise, Ctrld does not exit tmux, but rather a shell. I normally exit the shell by hitting Ctrl+D, so I programmed tmux to exit and switch sessions when hitting PREFIX Ctrl+D. I also always get the most used projects first, so that prevents some keypresses, which is always nice. The closest I got was a tmux function I wrote. I don’t even know how many sessions I have open, nor what session has what running… all I know is that I create one session for each project I work on and that I always have a default session to work on random things. ![]() ![]() The main advantage to this: it is predictable. find $PROJECTS/* -type d -maxdepth 0 | while read -r p do # get the projects in each namespace with their zoxide scores zoxide query -l -s " $p /" done | sort -rnk1 | # sort by zoxide score (first column) fzf -no-sort | # pipe to fzf without its sorting awk '' # use the path as selected (second column) ) Selected = $( # get my project's namespaces # I have it organized in namespaces per organization, so I have # my personal org (caarlos0), one for work, one for goreleaser, and so on. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |