Stockholm syndrome is a proposed condition or theory that tries to explain why hostages sometimes develop a psychological bond with their captors. It is supposed to result from a rather specific set of circumstances, namely the power imbalances contained in hostage-taking, kidnapping, and abusive relationships. (Wikipedia)
Wait, what happened?
That's probably my first impression of Tmux, but where do I get to this situation, since it's not as common as Vim/Nvim where you are in the escape room situation.
so, this is a few weeks ago, I was working with a client with my buddies at Pukulenam(my buddy's startup) and I was asked to run a PyTorch program in Vast.ai which is a GPU server for rent thingy.
I picked the correct docker image, I SSH the thing then I met with a mysterious green bar.
Something's wrong
I was fine with the usual Linux activity, cd, ls, cat all that fine but when I trained the model I was thinking "Let me see if there's a file generated", I tried to open a new tab to my Konsole(KDE's terminal emulator) then SSH again because that's what I did to my buddy's laptop and it works when I login that's when I'm on the realization, that I was trapped in the same training print screen.
OH CRAP! It's Tmux!
I said audibly because I knew what it was but I always avoid it because I said to my self "I don't need it" but that's fine it can wait, then when I want to cat the file or log I forget, I use my scroll wheel to scroll then I get my second shocked moment, I can't scroll, WTF??
I'm confused as to why my usual workflow in Konsole didn't work here, I was also frustrated because it's midnight(yes my sleep cycle is broken I know) and I was frustrated, I was like "F*ck it, Imma head out, I sleep."
What's Tmux you might say??
Basically, it's a program in the terminal that allows having multiple windows, panes in the terminal, and Sessions(gonna talk about that after this), here is a Wikipedia article about it.
Fresh state of mind
In the morning or afternoon, I have a fresh mind, and because I need to work on another tab I open Tmux Cheatsheet I was doing keyboard dances just to open tabs/panes, I don't like it It's annoying.
But then I found the thing that opened my mind, a term in Tmux called Sessions
What's Sessions
I will oversimplify this, comment if I was wrong.
so session is a collection of terminal windows, and we can use/attach one session at a time, inside it can have as many windows/panes as you want.
sessions can be used to have presets of Windows layout, a terminal working setup, etc.
and why I think it's cool because I can detach the session, go to sleep, attach it again and I got the exact same stuff I left yesterday, which is neat.
It won't be the last time
I didn't touch Tmux again for a few days, and after that my ADHD kicked in and my conscience said "Bro, learn Tmux and Nvim, you will need it bro, Imagine SSH then write full Python code in nano like that time in the Coursera course. BOO! Indentation Error!"
"wait, you have a point, that is not gonna be my last, maybe I need to learn it fr," I replied my conscience's brilliant idea.
Wait I think this thing is cool
After that, I installed Tmux and tried a few tricks like making a new window and splitting horizontally and vertically, and then I learned about sessions.
then, when I watched an amazing quick tutorial from Dreams of Code I learned that Tmux has a plugin manager, say whaaaat?
I tried his tutorial, then I tried TPM(Tmux Plugin Manager), which is the plugin manager he used, and when I saw the potential of the customization and me being a sucker for something extensible(foreshadowing something) I was like.
This and Nvim together
I was hooked on panes, windows, and thingy, and the appearance customization that can match my riced Linux, and then fast forward I'm now on this stage.
A fully(maybe) customized Tmux, and what's crazier about this, is that this is possible only with one file.
So, this is my current .tmux.conf if you want to see
# Check if ~/.tmux directory exists, if not, clone TPM
if-shell "[ ! -d ~/.tmux ]" \
"run-shell 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm'"
# Check if xclip is installed when tmux starts
if-shell '! command -v xclip >/dev/null 2>&1'\
'display-message "Warning: xclip is not installed.\
Please install it for better copy-paste functionality in tmux.\
You can install xclip using your package manager. For example, on Debian/Ubuntu: sudo apt-get install xclip"'
# Set terminal to true colors
set -g default-terminal "tmux-256color"
set-option -sa terminal-overrides ".xterm*:Tc"
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'dracula/tmux'
set -g @plugin 'christoomey/vim-tmux-navigator'
# set -g @plugin 'tmux-plugins/tmux-yank'
# Dracula plugins setting
# available plugins: battery, cpu-usage, git, gpu-usage, ram-usage, tmux-ram-usage, network, network-bandwidth, network-ping, ssh-session, attached-clients, network-vpn, weather, time, mpc, spotify-tui, kubernetes-context, synchronize-panes
set -g @dracula-plugins "cpu-usage gpu-usage ram-usage time"
set -g @dracula-show-left-icon session
# Rebind prefix key to Ctrl+Space
unbind C-b
set-option -g prefix C-s
# Rebind the splits
unbind %
bind | split-window -h
unbind '"'
bind - split-window -v
# Add mouse support
set -g mouse on
# In order to enable tmux-yank
# set-option -g default-command "reattach-to-user-namespace -l $SHELL"
# Copy and Paste on Linux
bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -i -f -selection primary | xclip -i -selection clipboard"
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -selection clipboard -i"
set-option -s set-clipboard off
# set clipboard to on
# set -g set-clipboard on
# vi keymode
setw -g mode-keys vi
# start windows and panes from 1, not 0
set -g base-index 1
set -g pane-base-index 1
set-window-option -g pane-base-index 1
set-option -g renumber-windows on
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
It's crazy that in a few days I went from being frustrated with it to liking this program.
What I like about Tmux
There are a few things that I think are neat, especially in my situation where I need to SSH to a remote PC.
- It's terminal emulator agnostic, I can go from Konsole to Alacrity to idk, Putty? and my Tmux config, setup, and workflow are the same.
- one conf file to rule them all, and This includes Installing the plugin manager, custom keybinds, custom copy and paste functionality, etc. This is easy for me if I want to have my setup in a remote machine or someone's machine I can just curl it, and then We just go.
- Amazing integration with Neovim, I haven't talked about Nvim at all maybe later maybe never idk, but the point is the amazing integration mainly in the movement helps with a seamless experience.
Do you need one?
Simply no, depending on your job in the industry I don't think you need it but since I will use SSH to access a remote PC and after my initial encounter I need to learn it and...I like it
But I can tell that It's fun.
What's next
Now I currently learning about Neovim and vim motions in general but It's something else already. Maybe I'll talk about it in the future when im half decent at least.
If you like this writing make sure to tell me that you like it, if you want to ask something it's nice, there's a buymeacoffee page I just made if you want to..idk, buy me a coffee, hehe.
cheers
Top comments (0)