On Sun, Sep 4, 2022 at 7:38 AM, Alex Holst <a...@mongers.org> wrote: > This is my ~/bin/bootstrap-tmux script. > > Maybe it can inspire you to share some of your tmux config snippets or > tricks? I'd also be interested if you have suggestions for improvements > to my script. > > #!/bin/sh > # > # Bootstraps tmux to 80%; saves a bit of typing and thinking right after > # reboots when I just want to get back to work. > > set -e > > # If I specify ~/work it messes up the tmux config, so cd to home first > cd $HOME > WORKDIR="projects/* business/. work wrk 3rdparty/*" > > # Build tmux sessions and windows based on the my project directories. These > # almost always reflect what I am working on anyway. > for wpath in $WORKDIR; do > if [ -d $wpath ]; then > session_name=$(dirname $wpath | sed 's/\./_/g') > wname=$(basename $wpath) > if $(tmux has-session -t $session_name); then > tmux new-window -d -t $session_name -c $wpath -n $wname > else > tmux new-session -P -d -s $session_name -c $wpath -n $wname > fi > # Populate the session with windows, etc per project > if [ -f $wpath/.tmux.conf.local ]; then > tmux source-file $wpath/.tmux.conf.local > fi > fi > done > > if [ -d ~/Business/Mail -o -d ~/Personal/Mail ]; then > tmux new-session -P -d -s email -n neomutt neomutt > fi > > WORKDIR="/usr/src /usr/ports /usr/ports/mystuff /usr/xenocara" > > for wpath in $WORKDIR; do > # Are there signs of a usable OpenBSD src checkout? > if [ -w $wpath/Makefile ]; then > wname=$(basename $wpath) > if $(tmux has-session -t openbsd); then > tmux new-window -P -d -t openbsd -c $wpath -n $wname > else > tmux new-session -P -d -s openbsd -c $wpath -n $wname > fi > # Populate the session with windows, etc per project > if [ -f $wpath/.tmux.conf.local ]; then > tmux source-file $wpath/.tmux.conf.local > fi > fi > done
That’s pretty good Alex! tmuxis a huge help to me. My only customization is to rebind the prefix key. $ cat .tmux.conf # started 06-30-21 # By default, tmux uses Ctrl-b as prefix. Emacs, Mg, and other apps # also use C-b. To pass C-b through tmux to the app, it needs to be # typed twice as C-b C-b. I want to use C-b in the app without having # to type it twice. # https://www.reddit.com/r/emacs/comments/dv7sxo/using_tmux_terminal_emacs # Backtick ` is easier to type than C-b and is much easier to pass # through tmux to the app using `` rather than C-b C-b. # The below tmux configuration block changes the default prefix key # from Ctrl-b to backtick ` (above tab key). # https://gist.github.com/JikkuJose/7509315 # https://wiki.archlinux.org/title/Tmux unbind-key C-b set-option -g prefix ` bind-key ` send-prefix