iconBjarne Verschorre

../my-servers-tmux-config.md

The Vision

I wanted to start a clean tmux session every time I ssh into my server. I want to only have one session running, and I want to be able to create a new window in the directory I’m currently in.

The Config

# ~/.bashrc.conf
if [ -z "$TMUX" ]; then
  tmux new-session -s phoenix\; set-option destroy-unattach on;
  exit
fi

This creates a new tmux session called phoenix if there isn’t one already running. It also sets the destroy-unattach option to on. This means that when I detach from the session, it will be destroyed. This is needed for when I force close my terminal, I don’t want to have to clean up the session later.

# ~/.tmux.conf
bind-key c new-window -c "#{pane_current_path}"
bind-key '"' split-window -v -c "#{pane_current_path}"
bind-key '%' split-window -h -c "#{pane_current_path}"

The make it so that the new windows and splits are created in the current directory. This is very handy since I don’t have to always cd into the directory I’m working in.

Final Thoughts

I’m gonna keep playing around with the configs and see what I like best, but for now, this is what I’m using. I might just keep the tmux configs but revert the bashrc changes. I’m not sure yet.

← Encryption What Types of Encryption to Use →