├── .gitignore ├── README.MD ├── keys ├── keys.txt ├── nvim.txt └── tmux.txt ├── options ├── option ├── options_keys.txt └── options_tmux.txt ├── ssh └── list.txt ├── tmux-docker-net ├── tmux-keys ├── tmux-lxexplorer ├── tmux-sessionizer ├── tmux-sessionizer-session ├── tmux-sessionizer-split ├── tmux-sipcalc ├── tmux-ssh ├── tmux-ssh-session ├── tmux-ssh-split ├── tmux-test └── tmux-wiki /.gitignore: -------------------------------------------------------------------------------- 1 | V2/ 2 | -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | These scripts have been created by myself (using as reference tmux-sessionizer by the The Primeagen). 2 | 3 | These scripts help me a lot in my tmux workflow. 4 | 5 | # About myself: 6 | 7 | I a senior Network engineer, I currently work as a mix of an Architect and Project Delivery engineer. 8 | I AM NOT A PROGRAMMER, I am self tought in programming so most likely you will find bugs, or not the best code to 9 | achieve my goals, but it usually does the job I want. 10 | 11 | # My system 12 | 13 | - OS: Gentoo 14 | - Window Manager: I3-WM 15 | - Terminal: ST 16 | - Shell: zsh 17 | 18 | 19 | # Purpose of these scripts 20 | 21 | 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 22 | 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 23 | having all in one terminal window and be able to organise it and jump into folders and projects quick. 24 | 25 | # Scripts 26 | 27 | 28 | | Name | Purpose | 29 | |--------------------------|--------------------------------------------------------------| 30 | | tmux-keys | Shows key bindings for either nvim or tmux from a user populated list | 31 | | tmux-sipcalc | CLI subnet calculator | 32 | | tmux-wiki | Easy way to search through wiki files and open them in neovim | 33 | | tmux-ssh-session | SSH to a server from a user populated list in a new tmux session | 34 | | tmux-ssh-split | SSH to a server from a user populated list in existing tmux window in split pane mode | 35 | | tmux-lxexplorer | opens nvim with Lexplore in a remote server user selected folder | 36 | | tmux-sessionizer-session | Creates new tmux session on a folder selected by the user | 37 | | tmux-sessionizer-split | Creates a new split pane in existing tmux window on a folder selected by the user | 38 | | tmux-docker-net | Opens dvmfa90/net-tools docker container | 39 | | tmux-ssh | SSH to a server from a user populated list in a new tmux session or split pane in existing window | 40 | | 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 | 41 | 42 | # Important notes 43 | 44 | 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 45 | session and if doesn't, it starts a tmux session called "diogo". So everytime I open a terminal I will be already 46 | attached to a tmux session. 47 | 48 | # Overall requirements for these scripts to work: 49 | 50 | - Enviroment variable called TMUXSCRIPTSDIR pointing to the path where these scripts will be located. EX: export TMUXSCRIPTSDIR=~/github/tmux-scripts 51 | - sipcalc installed for the sipcalc script 52 | - FZF installed 53 | - RIPGREP installed 54 | 55 | # Instructions of each script + Demo video 56 | 57 | ## tmux-keys: 58 | 59 | ### Requirements: 60 | 61 | - Two text files, one for tmux key bindings and another one with nvim key bindings. For these scripts to work they need 62 | 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 63 | names. 64 | 65 | 66 | ### Tmux Keybinding example(to be added to your .tmux.conf): 67 | 68 | bind -r K run-shell "tmux display-popup -w 40% -h 90% -E "$TMUXSCRIPTSDIR/tmux-keys"" 69 | 70 | ### Usage: 71 | 72 | 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 73 | options/options_keys.txt) where I have the option to chose Tmux keys or Nvim keys. 74 | 75 | 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 76 | chose nvim it opens nvim.txt. This open the files using fzf, which means you can search on it for strings. 77 | 78 | 79 | 80 | https://github.com/dvmfa90/tmux-scripts/assets/51400932/ddef6389-d9c4-41da-bec7-94e64a662fa1 81 | 82 | 83 | 84 | ## tmux-sipcalc: 85 | 86 | ### Requirements: 87 | 88 | - sipcalc installed 89 | 90 | ### Tmux Keybinding example(to be added to your .tmux.conf): 91 | 92 | bind -r M-c display-popup -w 70% -h 70% -E "tmux new-session -A -s test ~/scripts/tmux/tmux-sipcalc" 93 | 94 | 95 | ### Usage: 96 | 97 | So when I am in my terminal, if I press my tmux prefix + ALT + c, a pop up shows up asking for subnet. 98 | Once you type in the subnet and press enter, it will then run sipcalc + subnet entered and show the result. This is now 99 | 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 100 | exit the script. 101 | This means you can now "call" the script once, and calculate multiple subnets and exist when you done. 102 | 103 | 104 | https://github.com/dvmfa90/tmux-scripts/assets/51400932/1bd2eab5-7f4f-46c6-a9f7-341c49b8a7b9 105 | 106 | 107 | ## tmux-ssh-session: 108 | 109 | ### Requirements: 110 | 111 | 112 | - Text file, with list of servers you usually log on to via ssh. This works priv/pub key authentication for the servers 113 | 114 | ### Tmux Keybinding example(to be added to your .tmux.conf): 115 | 116 | bind -r M-s run-shell "tmux display-popup -w 70% -h 40% -E "$TMUXSCRIPTSDIR/tmux-ssh-session"" 117 | 118 | ### SSH text file list example: 119 | 120 | ==== HOME ==== 121 | 122 | diogo@192.168.100.11 - gns3client 123 | 124 | diogo@192.168.100.10 - gns3server 125 | 126 | diogo@192.168.100.12 - ubuntu-dev 127 | 128 | diogo@192.168.100.13 - ubuntu-secure 129 | 130 | ### Usage: 131 | 132 | So when I am in my terminal, if I press my tmux prefix + ALT + s, this runs tmux-ssh-session script. 133 | The script cats the ssh list text file with fzf, and once you chose the server, it saves the first bit of the line, 134 | using awk to a variable. It then creates a new tmux session where it ssh to the save variable. 135 | 136 | So for example, if from the list I chose diogo@192.168.100.11 - gns3client, this will save diogo@192.168.100.11, then 137 | when it starts the new tmux session it does ssh -Y diogo@192.168.100.11. 138 | 139 | https://github.com/dvmfa90/tmux-scripts/assets/51400932/67300db7-2161-4bab-82b0-5cc10f628d5b 140 | 141 | 142 | ## tmux-ssh-split: 143 | 144 | ### Requirements: 145 | 146 | 147 | - Text file, with list of servers you usually log on to via ssh. This works priv/pub key authentication for the servers 148 | 149 | ### Tmux Keybinding example(to be added to your .tmux.conf): 150 | 151 | bind -r M-S run-shell "tmux display-popup -w 70% -h 40% -E "$TMUXSCRIPTSDIR/tmux-ssh-split"" 152 | 153 | ### SSH text file list example: 154 | 155 | ==== HOME ==== 156 | 157 | diogo@192.168.100.11 - gns3client 158 | 159 | diogo@192.168.100.10 - gns3server 160 | 161 | diogo@192.168.100.12 - ubuntu-dev 162 | 163 | diogo@192.168.100.13 - ubuntu-secure 164 | 165 | 166 | ### Usage: 167 | 168 | So when I am in my terminal, if I press my tmux prefix + ALT + S, this runs tmux-ssh-split script. 169 | The script cats the ssh list text file with fzf, and once you chose the server, it saves the first bit of the line, 170 | 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 171 | saved variable. 172 | 173 | So for example, if from the list I chose diogo@192.168.100.11 - gns3client, this will save diogo@192.168.100.11, then 174 | when it starts the new tmux pane in splt mode and it does ssh -Y diogo@192.168.100.11. 175 | 176 | 177 | https://github.com/dvmfa90/tmux-scripts/assets/51400932/10a72b96-e350-4464-a64a-b108db659417 178 | 179 | 180 | ## tmux-wiki: 181 | 182 | 183 | ### Tmux Keybinding example(to be added to your .tmux.conf): 184 | 185 | bind -r M-w run-shell "tmux display-popup -w 70% -h 70% -E "$TMUXSCRIPTSDIR/tmux-wiki"" 186 | 187 | ### Usage: 188 | 189 | So when I am in my terminal, if I press my tmux prefix + ALT + w, this runs tmux-wiki script. 190 | This will then open a pop up with fzf listing all files within ~/vimwiki folder. 191 | 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 192 | select file open. 193 | 194 | https://github.com/dvmfa90/tmux-scripts/assets/51400932/c0ff49bb-2f3d-4618-a671-ee3d7c4e4189 195 | 196 | ## tmux-docker-net: 197 | 198 | 199 | ### Tmux Keybinding example(to be added to your .tmux.conf): 200 | 201 | bind -r M-n run-shell "tmux display-popup -w 80% -h 80% -E "$TMUXSCRIPTSDIR/tmux-docker-net"" 202 | 203 | ### Usage: 204 | 205 | So when I am in my terminal, if I press my tmux prefix + ALT + n, this runs tmux-docker-net script. 206 | This will open a pop up where I am on the docker container shell. 207 | This docker container is a public one I created dvmfa90/net-tools. 208 | 209 | https://github.com/dvmfa90/tmux-scripts/assets/51400932/9f59ad1f-8596-4c84-a9ee-6bca7fa72ad9 210 | 211 | 212 | ## tmux-lxexplorer: 213 | 214 | ### Requirements: 215 | 216 | - nvim with lexplore 217 | - Text file, with list of servers you usually log on to via ssh. This works priv/pub key authentication for the servers 218 | 219 | 220 | ### Tmux Keybinding example(to be added to your .tmux.conf): 221 | 222 | bind -r M-l run-shell "tmux display-popup -w 70% -h 70% -E "$TMUXSCRIPTSDIR/tmux-lxexplorer"" 223 | 224 | 225 | ### Usage: 226 | 227 | So when I am in my terminal, if I press my tmux prefix + ALT + l, this runs tmux-lxexplorer script. 228 | This will open a pop up where I chose form a text file list a remote server. 229 | Once chosen, it uses fzf and lists folders and subfolders of the remote host where I can serach for specific folders 230 | 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 231 | file and edit it. 232 | 233 | 234 | https://github.com/dvmfa90/tmux-scripts/assets/51400932/665b28d2-7db9-4104-860a-763dff02bb5e 235 | 236 | ## tmux-sessionizer-session: 237 | 238 | ### Tmux Keybinding example(to be added to your .tmux.conf): 239 | 240 | bind -r f run-shell "tmux display-popup -w 70% -h 80% -E "$TMUXSCRIPTSDIR/tmux-sessionizer-session"" 241 | 242 | ### Usage: 243 | 244 | So when I am in my terminal, if I press my tmux prefix + f , this runs tmux-sessionizer-session script. 245 | A pop up will list subfolders within a set of folders. 246 | Once a folder is chosen, it lists all files within the selected folder. 247 | 248 | 1. You chose a file: This will open the file using nvim in a pop up. 249 | 2. You did not chose file, it will create a new session with the folder you selected. 250 | 251 | The one video will show both exmaples. 252 | 253 | 254 | 255 | https://github.com/dvmfa90/tmux-scripts/assets/51400932/eac466b5-5ac3-45a7-b37c-a151eebf07ce 256 | 257 | 258 | 259 | ## tmux-sessionizer-split: 260 | 261 | ### Tmux Keybinding example(to be added to your .tmux.conf): 262 | 263 | bind -r F run-shell "tmux display-popup -w 70% -h 80% -E "$TMUXSCRIPTSDIR/tmux-sessionizer-split"" 264 | 265 | ### Usage: 266 | 267 | So when I am in my terminal, if I press my tmux prefix + F , this runs tmux-sessionizer-split script. 268 | A pop up will list subfolders within a set of folders. 269 | Once a folder is chosen, it lists all files within the selected folder. 270 | 271 | 1. You chose a file: This will open the file using nvim in a pop up. 272 | 2. You did not chose file, it will create a pane in split mode in your existing tmux window with the folder you selected. 273 | 274 | The one video will show both exmaples. 275 | 276 | 277 | 278 | https://github.com/dvmfa90/tmux-scripts/assets/51400932/831ca5d8-2cb9-4afe-b7de-39d0e2196c05 279 | 280 | 281 | ## tmux-ssh: 282 | 283 | ### Requirements: 284 | 285 | 286 | - Text file, with list of servers you usually log on to via ssh. This works priv/pub key authentication for the servers 287 | - Enviroment variable called SSHLISTDIR with the folder path that contains the list of servers, example: export SSHLISTDIR=~/.config/ssh 288 | 289 | ### Tmux Keybinding example(to be added to your .tmux.conf): 290 | 291 | bind -r M-s run-shell "tmux display-popup -w 70% -h 40% -E "$TMUXSCRIPTSDIR/tmux-ssh"" 292 | 293 | ### SSH text file list example: 294 | 295 | ==== HOME ==== 296 | 297 | diogo@192.168.100.11 - gns3client 298 | 299 | diogo@192.168.100.10 - gns3server 300 | 301 | diogo@192.168.100.12 - ubuntu-dev 302 | 303 | diogo@192.168.100.13 - ubuntu-secure 304 | 305 | ### Usage: 306 | 307 | So when I am in my terminal, if I press my tmux prefix + ALT + s, this runs tmux-ssh script. 308 | The script cats the ssh list text file with fzf, and once you chose the server, it saves the first bit of the line, 309 | 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 310 | in existing window. 311 | 312 | 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 313 | 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 314 | opion it does ssh -Y diogo@192.168.100.11. 315 | 316 | https://github.com/dvmfa90/tmux-scripts/assets/51400932/12425bb8-8580-4d45-974a-c759d10373d3 317 | 318 | ## tmux-sessionizer: 319 | 320 | ### Tmux Keybinding example(to be added to your .tmux.conf): 321 | 322 | bind -r f run-shell "tmux display-popup -w 70% -h 80% -E "$TMUXSCRIPTSDIR/tmux-sessionizer"" 323 | 324 | ### Usage: 325 | 326 | So when I am in my terminal, if I press my tmux prefix + f , this runs tmux-sessionizer script. 327 | A pop up will list subfolders within a set of folders. 328 | Once a folder is chosen, it will ask if you want to search for files in the selected folder 329 | 330 | 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 331 | a pop up with nvim $selectedfile 332 | 333 | 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 334 | window. 335 | 336 | https://github.com/dvmfa90/tmux-scripts/assets/51400932/e80d1e60-eb47-4077-b60d-48e42c396895 337 | # TO DO: 338 | 339 | - Create instalation script 340 | -------------------------------------------------------------------------------- /keys/keys.txt: -------------------------------------------------------------------------------- 1 | CTRl + W = www 2 | -------------------------------------------------------------------------------- /keys/nvim.txt: -------------------------------------------------------------------------------- 1 | ====================================== 2 | = = 3 | = NVIM KEYS = 4 | = = 5 | ===================================== 6 | 7 | ************************************* 8 | * USEFUL * 9 | ************************************* 10 | 11 | Delete blanck lines -> + rs 12 | 13 | ************************************* 14 | * Telescope * 15 | ************************************* 16 | 17 | Search recent files -> + ? 18 | 19 | List buffers -> + space 20 | 21 | Fuzzy within current buffer aka search lines-> + / 22 | 23 | Search Files in current directory -> + sf 24 | 25 | Search Nvim help -> + sh 26 | 27 | Search word in current buffer -> + sw 28 | 29 | Search by grep -> + sg 30 | 31 | Search Diagnostics -> + sd 32 | 33 | ************************************* 34 | * Telescope Navigation * 35 | ************************************* 36 | 37 | Scroll down/up in the results -> CTRL + (j/k) 38 | 39 | Scroll down/up in the preview pane -> CTRL + (d/u) 40 | 41 | Open result in Vertical/horizontal -> CTRL + SHIFT + (v/h) 42 | 43 | ************************************* 44 | * LSP * 45 | ************************************* 46 | 47 | [ NORMAL MODE ] 48 | 49 | Go to Declaration -> gD 50 | 51 | Go to Definition -> gd 52 | 53 | Hover command explanation -> K 54 | 55 | Go to implementation -> gi 56 | 57 | rename variable you are on it -> + rn 58 | 59 | Show refences in horizontal buffer for the code you are -> gr 60 | 61 | Go to next/previous warning/error from diagnostics-> + (l/h) 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /keys/tmux.txt: -------------------------------------------------------------------------------- 1 | ====================================== 2 | = = 3 | = TMUX KEYS = 4 | = = 5 | ===================================== 6 | 7 | ************************************* 8 | * TMUX scripts * 9 | ************************************* 10 | 11 | Open net-tools docker -> CTRL + x + ALT + n 12 | 13 | Search folder and open in new session -> CTRL + x + f 14 | 15 | Search folder and open in split pane -> CTRL + x + F 16 | 17 | SSH to server in new session -> CTRL + x + ALT + s 18 | 19 | SSH to server in split pane -> CTRL + x + ALT + S 20 | 21 | Display Tmux Options -> CTRL + x + O 22 | 23 | Search wiki and open in pop up window -> CTRL + x + ALT + w 24 | 25 | Create and go to session for Home folder -> CTRL + x + H 26 | 27 | Create and go to session for Github folder -> CTRL + x + G 28 | 29 | Create and go to session for .Config folder -> CTRL + x + C 30 | 31 | Search for SSH server and select directory to open using nvim Lexpore -> CTRL + x + ALT + l 32 | 33 | ************************************* 34 | * TMUX basics * 35 | ************************************* 36 | 37 | Cycle TMUX layouts -> CTRL + x + space 38 | 39 | Increase or Decrease Pane left/right -> CTRL + x + () 40 | 41 | Increase or Decrease Pane up/down -> CTRL + x + (]/[) 42 | -------------------------------------------------------------------------------- /options/option: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | options=$(cat $TMUXOPTIONS/options_tmux.txt | fzf) 3 | echo $options 4 | 5 | option=$(echo $options | awk '{print $1}') 6 | echo $option 7 | 8 | 9 | 10 | if [[ $option -lt 1 || $option -gt 6 ]]; then 11 | echo wrong option 12 | else 13 | if [[ $option -eq 5 ]]; then 14 | # export OPTION=$option 15 | ~/scripts/tmux/tmux-wiki 16 | fi 17 | if [[ $option -eq 3 ]]; then 18 | # export OPTION=$option 19 | ~/scripts/tmux/tmux-ssh-session 20 | fi 21 | if [[ $option -eq 4 ]]; then 22 | # export OPTION=$option 23 | ~/scripts/tmux/tmux-ssh-split 24 | fi 25 | if [[ $option -eq 1 ]]; then 26 | # export OPTION=$option 27 | ~/scripts/tmux/tmux-sessionizer-session 28 | fi 29 | if [[ $option -eq 2 ]]; then 30 | # export OPTION=$option 31 | ~/scripts/tmux/tmux-sessionizer-split 32 | fi 33 | if [[ $option -eq 6 ]]; then 34 | # export OPTION=$option 35 | ~/scripts/tmux/tmux-test 36 | fi 37 | fi 38 | -------------------------------------------------------------------------------- /options/options_keys.txt: -------------------------------------------------------------------------------- 1 | 1 - TMUX Keys 2 | 3 | 2 - NVIM Keys 4 | -------------------------------------------------------------------------------- /options/options_tmux.txt: -------------------------------------------------------------------------------- 1 | 1 - Search and open folder in new session 2 | 3 | 2 - Search and open folder in split pane 4 | 5 | 3 - SSH to a box in new session 6 | 7 | 4 - SSH to a box in split pane 8 | 9 | 5 - Search in wiki 10 | 11 | 6 - test 12 | -------------------------------------------------------------------------------- /ssh/list.txt: -------------------------------------------------------------------------------- 1 | ==== SERVERS ==== 2 | user@ip/domain - description 3 | user@ip/domain - description 4 | user@ip/domain - description 5 | user@ip/domain - description 6 | user@ip/domain - description 7 | -------------------------------------------------------------------------------- /tmux-docker-net: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | tmux -c "tmux new-session -As docker_net_tools ssh -t 10.0.20.107 docker run --rm -it dvmfa90/nettools fish" 4 | -------------------------------------------------------------------------------- /tmux-keys: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | options=$(cat $TMUXSCRIPTSDIR/options/options_keys.txt | fzf) 4 | 5 | option=$(echo $options | awk '{print $1}') 6 | 7 | 8 | 9 | if [[ $option -lt 1 || $option -gt 2 ]]; then 10 | echo wrong option 11 | else 12 | if [[ $option -eq 1 ]]; then 13 | cat $TMUXSCRIPTSDIR/keys/tmux.txt | fzf 14 | fi 15 | if [[ $option -eq 2 ]]; then 16 | cat $TMUXSCRIPTSDIR/keys/nvim.txt | fzf 17 | fi 18 | if [[ -z $option ]]; then 19 | exit 0 20 | fi 21 | fi 22 | 23 | 24 | -------------------------------------------------------------------------------- /tmux-lxexplorer: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | chose=$(cat $TMUXSCRIPTSDIR/ssh/list.txt| fzf) 4 | selected=$(echo $chose | awk '{print $1}') 5 | name=$(echo $chose | awk '{print $3}') 6 | selected_name=$(basename "$name" | tr . _) 7 | # 8 | # If nothing is selected from FZF pop up, exit 9 | if [[ -z $selected ]]; then 10 | exit 0 11 | fi 12 | 13 | 14 | dir_selected=$(ssh $selected find ~/ -mindepth 0 -maxdepth 4 -type d | fzf) 15 | 16 | # If nothing is selected from FZF pop up, exit 17 | if [[ -z $dir_selected ]]; then 18 | exit 0 19 | fi 20 | 21 | 22 | 23 | while : 24 | do 25 | echo "Press 'q' to exit" 26 | read -p "Open in split,new session or pop up? [sp/s/p] " answer2 27 | 28 | case $answer2 in 29 | sp) 30 | tmux split-window "nvim -c \":Lexplore scp://$selected/$dir_selected/\"" 31 | exit 0 32 | ;; 33 | 34 | s) 35 | tmux new-session -ds lexplore_$selected_name "nvim -c \":Lexplore scp://$selected/$dir_selected/\"" 36 | tmux switch-client -t lexplore_$selected_name 37 | exit 0 38 | ;; 39 | q) 40 | echo "quiting" 41 | exit 0 42 | ;; 43 | 44 | p) 45 | tmux -c "tmux new-session -As lexplore_$selected_name nvim -c \":Lexplore scp://$selected/$dir_selected/\"" 46 | exit 0 47 | ;; 48 | *) 49 | echo "quiting" 50 | exit 0 51 | ;; 52 | esac 53 | 54 | done 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /tmux-sessionizer: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # this checks if we passed a directory in the command to open this script 4 | if [[ $# -eq 1 ]]; then 5 | dir_selected=$1 6 | dir_selected_name=$(basename "$dir_selected" | tr . _) 7 | tmux new-session -ds $dir_selected_name -c $dir_selected 8 | tmux switch-client -t $dir_selected_name 9 | exit 0 10 | 11 | else 12 | dir_selected=$(find ~/vimwiki ~/.config $GITHUBDIR /mnt/onedrive ~/scripts -mindepth 0 -maxdepth 4 -type d | fzf) 13 | fi 14 | 15 | if [[ -z $dir_selected ]]; then 16 | exit 0 17 | fi 18 | 19 | dir_selected_name=$(basename "$dir_selected" | tr . _) 20 | 21 | while : 22 | do 23 | echo "Press 'q' to exit" 24 | read -p "Search files in folder? [y/n] " answer 25 | case $answer in 26 | y) 27 | echo "search files in folder" 28 | file_selected=$(rg --files --hidden $dir_selected | fzf) 29 | file_selected_name=$(basename "$file_selected" | tr . _) 30 | if [[ -z $file_selected ]]; then 31 | exit 0 32 | else 33 | tmux -c "tmux new-session -As $file_selected_name nvim \"$file_selected\"" 34 | exit 0 35 | fi 36 | ;; 37 | 38 | n) 39 | read -p "Open folder in split or new session? [sp/s] " answer2 40 | 41 | case $answer2 in 42 | sp) 43 | tmux split-window -c $dir_selected 44 | exit 0 45 | ;; 46 | 47 | s) 48 | tmux new-session -ds $dir_selected_name -c $dir_selected 49 | tmux switch-client -t $dir_selected_name 50 | exit 0 51 | ;; 52 | esac 53 | ;; 54 | 55 | q) 56 | echo "quiting" 57 | exit 0 58 | ;; 59 | 60 | *) 61 | echo "quiting" 62 | exit 0 63 | ;; 64 | esac 65 | 66 | done 67 | 68 | -------------------------------------------------------------------------------- /tmux-sessionizer-session: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # this checks if we passed a directory in the command to open this script 4 | if [[ $# -eq 1 ]]; then 5 | dir_selected=$1 6 | else 7 | dir_selected=$(find ~/vimwiki ~/.config ~/github /mnt/onedrive ~/scripts -mindepth 0 -maxdepth 4 -type d | fzf) 8 | fi 9 | 10 | if [[ -z $dir_selected ]]; then 11 | exit 0 12 | fi 13 | 14 | dir_selected_name=$(basename "$dir_selected" | tr . _) 15 | file_selected=$(rg --files --hidden $dir_selected | fzf) 16 | file_selected_name=$(basename "$file_selected" | tr . _) 17 | 18 | 19 | if [[ -z $file_selected ]]; then 20 | tmux new-session -ds $dir_selected_name -c $dir_selected 21 | tmux switch-client -t $dir_selected_name 22 | exit 0 23 | else 24 | tmux -c "tmux new-session -As $file_selected_name nvim \"$file_selected\"" 25 | fi 26 | 27 | -------------------------------------------------------------------------------- /tmux-sessionizer-split: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | dir_selected=$(find ~/vimwiki ~/.config ~/github /mnt/onedrive ~/scripts -mindepth 0 -maxdepth 4 -type d | fzf) 4 | 5 | if [[ -z $dir_selected ]]; then 6 | exit 0 7 | fi 8 | 9 | dir_selected_name=$(basename "$dir_selected" | tr . _) 10 | 11 | file_selected=$(rg --files --hidden $dir_selected | fzf) 12 | file_selected_name=$(basename "$file_selected" | tr . _) 13 | 14 | 15 | if [[ -z $file_selected ]]; then 16 | tmux split-window -c $dir_selected 17 | exit 0 18 | else 19 | tmux -c "tmux new-session -As $file_selected_name nvim \"$file_selected\"" 20 | fi 21 | -------------------------------------------------------------------------------- /tmux-sipcalc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | while : 4 | do 5 | echo "Press 'q' to exit" 6 | read -p "Type subnet to calc: " answer 7 | case $answer in 8 | q) 9 | echo "quiting" 10 | exit 0 11 | ;; 12 | 13 | *) 14 | sipcalc $answer 15 | ;; 16 | esac 17 | 18 | done 19 | 20 | -------------------------------------------------------------------------------- /tmux-ssh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | 4 | chose=$(cat $TMUXSCRIPTSDIR/ssh/list.txt| fzf) 5 | selected=$(echo $chose | awk '{print $1}') 6 | name=$(echo $chose | awk '{print $3}') 7 | selected_name=$(basename "$name" | tr . _) 8 | # 9 | # If nothing is select from FZF pop up, exit 10 | if [[ -z $selected ]]; then 11 | exit 0 12 | fi 13 | 14 | 15 | while : 16 | do 17 | echo "Press 'q' to exit" 18 | read -p "SSH to server in split or new session? [sp/s] " answer2 19 | 20 | case $answer2 in 21 | sp) 22 | tmux split-window ssh -Y $selected 23 | exit 0 24 | ;; 25 | 26 | s) 27 | tmux new-session -ds $selected_name -c $selected ssh -Y $selected 28 | tmux switch-client -t $selected_name 29 | exit 0 30 | ;; 31 | q) 32 | echo "quiting" 33 | exit 0 34 | ;; 35 | 36 | *) 37 | echo "quiting" 38 | exit 0 39 | ;; 40 | esac 41 | 42 | done 43 | 44 | 45 | -------------------------------------------------------------------------------- /tmux-ssh-session: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | chose=$(cat $TMUXSCRIPTSDIR/ssh/list.txt| fzf) 4 | selected=$(echo $chose | awk '{print $1}') 5 | name=$(echo $chose | awk '{print $3}') 6 | selected_name=$(basename "$name" | tr . _) 7 | # 8 | # If nothing is select from FZF pop up, exit 9 | if [[ -z $selected ]]; then 10 | exit 0 11 | fi 12 | tmux new-session -ds $selected_name -c $selected ssh -Y $selected 13 | tmux switch-client -t $selected_name 14 | -------------------------------------------------------------------------------- /tmux-ssh-split: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | chose=$(cat $TMUXSCRIPTSDIR/ssh/list.txt| fzf) 3 | selected=$(echo $chose | awk '{print $1}') 4 | name=$(echo $chose | awk '{print $3}') 5 | selected_name=$(basename "$name" | tr . _) 6 | # 7 | # If nothing is select from FZF pop up, exit 8 | 9 | if [[ -z $selected ]]; then 10 | exit 0 11 | fi 12 | tmux split-window ssh -Y $selected 13 | -------------------------------------------------------------------------------- /tmux-test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | 4 | -------------------------------------------------------------------------------- /tmux-wiki: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | selected=$(find ~/vimwiki -mindepth 0 -maxdepth 4 -type f | fzf) 4 | 5 | if [[ -z $selected ]]; then 6 | exit 0 7 | fi 8 | tmux -c "tmux new-session -As wiki nvim \"$selected\"" 9 | 10 | 11 | --------------------------------------------------------------------------------