These scripts have been created by myself (using as reference tmux-sessionizer by the The Primeagen).
These scripts help me a lot in my tmux workflow.
I a senior Network engineer, I currently work as a mix of an Architect and Project Delivery engineer. I AM NOT A PROGRAMMER, I am self tought in programming so most likely you will find bugs, or not the best code to achieve my goals, but it usually does the job I want.
- OS: Gentoo
- Window Manager: I3-WM
- Terminal: ST
- Shell: zsh
I use a lot terminal based applications, so I spend a lot of time in my terminal and these scripts help me a lot with my workflow. One of the main reason I use TMUX, is that even though I have 3 monitors in my setup, I like the ability of having all in one terminal window and be able to organise it and jump into folders and projects quick.
Name | Purpose |
---|---|
tmux-keys | Shows key bindings for either nvim or tmux from a user populated list |
tmux-sipcalc | CLI subnet calculator |
tmux-wiki | Easy way to search through wiki files and open them in neovim |
tmux-ssh-session | SSH to a server from a user populated list in a new tmux session |
tmux-ssh-split | SSH to a server from a user populated list in existing tmux window in split pane mode |
tmux-lxexplorer | opens nvim with Lexplore in a remote server user selected folder |
tmux-sessionizer-session | Creates new tmux session on a folder selected by the user |
tmux-sessionizer-split | Creates a new split pane in existing tmux window on a folder selected by the user |
tmux-docker-net | Opens dvmfa90/net-tools docker container |
tmux-ssh | SSH to a server from a user populated list in a new tmux session or split pane in existing window |
tmux-sessionizer | Open folder selected by the user on a new tmux session or split pane in existing window, it also gives the option to search for files in the selected folder and open a pop up with nvim editing the selected file |
I am always in tmux, when I start my terminal, I have some code in my zsh config where it checks if there is an existing tmux session and if doesn't, it starts a tmux session called "diogo". So everytime I open a terminal I will be already attached to a tmux session.
- Enviroment variable called TMUXSCRIPTSDIR pointing to the path where these scripts will be located. EX: export TMUXSCRIPTSDIR=~/github/tmux-scripts
- sipcalc installed for the sipcalc script
- FZF installed
- RIPGREP installed
- Two text files, one for tmux key bindings and another one with nvim key bindings. For these scripts to work they need to be called tmux.txt and nvim.txt, but of course you can change the code in the scripts if you want to use different names.
bind -r K run-shell "tmux display-popup -w 40% -h 90% -E "$TMUXSCRIPTSDIR/tmux-keys""
So when I am in my terminal, if I press my tmux prefix + K, a pop up shows up with a menu(Cats the file options/options_keys.txt) where I have the option to chose Tmux keys or Nvim keys.
No matter what option I chose, this will open tmux-keys script, if I chose tmux it opens in fzf tmux.txt file, if I chose nvim it opens nvim.txt. This open the files using fzf, which means you can search on it for strings.
tmux-keys.mp4
- sipcalc installed
bind -r M-c display-popup -w 70% -h 70% -E "tmux new-session -A -s test ~/scripts/tmux/tmux-sipcalc"
So when I am in my terminal, if I press my tmux prefix + ALT + c, a pop up shows up asking for subnet. Once you type in the subnet and press enter, it will then run sipcalc + subnet entered and show the result. This is now been added to a loop, so it asks again for user input to calculate a new subnet, if you press q or ctrl+c it will than exit the script. This means you can now "call" the script once, and calculate multiple subnets and exist when you done.
tmux-sipcalc.mp4
- Text file, with list of servers you usually log on to via ssh. This works priv/pub key authentication for the servers
bind -r M-s run-shell "tmux display-popup -w 70% -h 40% -E "$TMUXSCRIPTSDIR/tmux-ssh-session""
==== HOME ====
diogo@192.168.100.11 - gns3client
diogo@192.168.100.10 - gns3server
diogo@192.168.100.12 - ubuntu-dev
diogo@192.168.100.13 - ubuntu-secure
So when I am in my terminal, if I press my tmux prefix + ALT + s, this runs tmux-ssh-session script. The script cats the ssh list text file with fzf, and once you chose the server, it saves the first bit of the line, using awk to a variable. It then creates a new tmux session where it ssh to the save variable.
So for example, if from the list I chose diogo@192.168.100.11 - gns3client, this will save diogo@192.168.100.11, then when it starts the new tmux session it does ssh -Y diogo@192.168.100.11.
tmux-ssh-session.mp4
- Text file, with list of servers you usually log on to via ssh. This works priv/pub key authentication for the servers
bind -r M-S run-shell "tmux display-popup -w 70% -h 40% -E "$TMUXSCRIPTSDIR/tmux-ssh-split""
==== HOME ====
diogo@192.168.100.11 - gns3client
diogo@192.168.100.10 - gns3server
diogo@192.168.100.12 - ubuntu-dev
diogo@192.168.100.13 - ubuntu-secure
So when I am in my terminal, if I press my tmux prefix + ALT + S, this runs tmux-ssh-split script. The script cats the ssh list text file with fzf, and once you chose the server, it saves the first bit of the line, using awk to a variable. It then creates a new tmux pane in split mode on the current tmux session, where it ssh to the saved variable.
So for example, if from the list I chose diogo@192.168.100.11 - gns3client, this will save diogo@192.168.100.11, then when it starts the new tmux pane in splt mode and it does ssh -Y diogo@192.168.100.11.
tmux-ssh-split.mp4
bind -r M-w run-shell "tmux display-popup -w 70% -h 70% -E "$TMUXSCRIPTSDIR/tmux-wiki""
So when I am in my terminal, if I press my tmux prefix + ALT + w, this runs tmux-wiki script. This will then open a pop up with fzf listing all files within ~/vimwiki folder. I can than search for keyworks and when I press enter on the one I want open, it opens a pop up with nvim with the select file open.
tmux-wiki.mp4
bind -r M-n run-shell "tmux display-popup -w 80% -h 80% -E "$TMUXSCRIPTSDIR/tmux-docker-net""
So when I am in my terminal, if I press my tmux prefix + ALT + n, this runs tmux-docker-net script. This will open a pop up where I am on the docker container shell. This docker container is a public one I created dvmfa90/net-tools.
tmux-docker-net.mp4
- nvim with lexplore
- Text file, with list of servers you usually log on to via ssh. This works priv/pub key authentication for the servers
bind -r M-l run-shell "tmux display-popup -w 70% -h 70% -E "$TMUXSCRIPTSDIR/tmux-lxexplorer""
So when I am in my terminal, if I press my tmux prefix + ALT + l, this runs tmux-lxexplorer script. This will open a pop up where I chose form a text file list a remote server. Once chosen, it uses fzf and lists folders and subfolders of the remote host where I can serach for specific folders Once I chose a folder it will ask if you want to open the folder in a new session, in split or pop up and will open nvim with lexplore on the remote host selected folder, from here I can then browse and open a file and edit it.
tmux-lexplorer.mp4
bind -r f run-shell "tmux display-popup -w 70% -h 80% -E "$TMUXSCRIPTSDIR/tmux-sessionizer-session""
So when I am in my terminal, if I press my tmux prefix + f , this runs tmux-sessionizer-session script. A pop up will list subfolders within a set of folders. Once a folder is chosen, it lists all files within the selected folder.
- You chose a file: This will open the file using nvim in a pop up.
- You did not chose file, it will create a new session with the folder you selected.
The one video will show both exmaples.
tmux-sessionizer-session.mp4
bind -r F run-shell "tmux display-popup -w 70% -h 80% -E "$TMUXSCRIPTSDIR/tmux-sessionizer-split""
So when I am in my terminal, if I press my tmux prefix + F , this runs tmux-sessionizer-split script. A pop up will list subfolders within a set of folders. Once a folder is chosen, it lists all files within the selected folder.
- You chose a file: This will open the file using nvim in a pop up.
- You did not chose file, it will create a pane in split mode in your existing tmux window with the folder you selected.
The one video will show both exmaples.
tmux-sessionizer-split.mp4
- Text file, with list of servers you usually log on to via ssh. This works priv/pub key authentication for the servers
- Enviroment variable called SSHLISTDIR with the folder path that contains the list of servers, example: export SSHLISTDIR=~/.config/ssh
bind -r M-s run-shell "tmux display-popup -w 70% -h 40% -E "$TMUXSCRIPTSDIR/tmux-ssh""
==== HOME ====
diogo@192.168.100.11 - gns3client
diogo@192.168.100.10 - gns3server
diogo@192.168.100.12 - ubuntu-dev
diogo@192.168.100.13 - ubuntu-secure
So when I am in my terminal, if I press my tmux prefix + ALT + s, this runs tmux-ssh script. The script cats the ssh list text file with fzf, and once you chose the server, it saves the first bit of the line, using awk to a variable. It then asks if you want to ssh to the selected server in a new tmux session or in a split pane in existing window.
So for example, if from the list I chose diogo@192.168.100.11 - gns3client, this will save diogo@192.168.100.11, it will then ask if you want to ssh to the selected server in a new tmux session or in a split pane, and according to the chosen opion it does ssh -Y diogo@192.168.100.11.
tmux-ssh.mp4
bind -r f run-shell "tmux display-popup -w 70% -h 80% -E "$TMUXSCRIPTSDIR/tmux-sessionizer""
So when I am in my terminal, if I press my tmux prefix + f , this runs tmux-sessionizer script. A pop up will list subfolders within a set of folders. Once a folder is chosen, it will ask if you want to search for files in the selected folder
If you press y, it will open fzf in the folder and list a;; the files in that folder, once you chose a file it will open a pop up with nvim $selectedfile
If you press n, it will ask if you want to open the selected folder in a new session or in a split pane in existing window.
tmux-sessionizer.mp4
- Create instalation script