![]() ![]() So you ssh into server1 and run tmux, then ssh into server2 from inside tmux. Thank you for any any direction, comments, questions. At that point I'd probably just do another C-S(get prompted for ssh servername) and join the window(which saying that isn't a bad idea as an alternative) The nested windows would then split and show another pane on that server. ![]() The closest way we have found is nesting and using a plugin to change which server tmux would respond to the prefix. nf and scripts all follow me to every server.Įach window has the server name set, though in the future we may try to get it to servername,task (example"srv001,htop") depends on how this works out :) What I would like to do is bind C-\ and C-"-" to split the current window and ssh into that same server instead of it opening a window for the main server. I spend just the right amount of debugging time figuring out that I need to give execution permissions to the johndoe.The way we use tmux is to ssh into a main server, we will then open tmux, and create a new window for each server we ssh into (C-S, prompts for a server and this will then create a new windows and ssh into the server). I create a bash/zsh alias to source this session configuration :Īlias tmuxjohndoe='.# (you might want to add "-t johndoe" here if you need several sessions running in parallel) # Attach the current terminal to the only session available Tmux send -t johndoe:'API run' 'dotnet run -no-build' Enter Tmux neww -t johndoe -n 'API run' -c ~/dev/own/johndoe/back-end/Api Tmux send -t pers:'UI run.1' 'npm run dev' Enter ![]() # Simulate user entering a command to the second pane in this window Tmux split-window -t pers:'UI run' -h -c ~/dev/own/johndoe/front-end Tmux send -t pers:'UI run.0' 'git status -short' Enter # Simulate user entering a command to the first pane Tmux neww -t pers -n 'UI run' -c ~/dev/own/johndoe/front-end # Create a new window in the target session, with the title 'UI run' Tmux send -t johndoe 'docker compose up -d' Enter # in the target session named (-t) johndoe # Simulate the user entering some docker command in the first window available Tmux new -d -s johndoe -n 'Main' -c ~/dev/own/johndoe # ignore the rest of the session definition Without -d, tmux would open the client right away and # The -d is for detached mode, which allows me to continue defining the rest of the session This file is simple to maintain because it does not have a myriad of \ everywhere like I saw in other answers: # Create a new session named johndoe, with a first window named Main I want being able to spawn this very quicklyįor my project named johndoe, I create a nf file which is essentially a bash script, somewhere in my configs ( ~/.config/tmux/tmux-sessions/nf).I want to focus the window I want at the end of the script.I want to run arbitrary commands in each of the panes, persisted in history.I want to have as many windows and panes as I want.I want to open titled windows at specific paths.I know my solution is quite similar to others, but I couldn't find any that had exactly what I was looking for : Which results in a session looking like that. It's also handy to pass with -p 75 a percentage size of the pane created by split-window to have more control over the size of the panes. Basicaly knowing your way around with split-window and select-pane is all you need. Now I tried to again sub-divide the bottom left pane, so switching either back using last-pane, or in more complex windows, with the select-pane -t 1 where 1 is the number of the pane in order created starting with 0. Send-keys 'tail -f /var/log/monitor.log' C-m \ \Īnd the resulting session should look like that. To run commands in that panes, just add them with the send-keys 'my-command' command and C-m which executes it: tmux new-session \ \ To split it horizontal or vertical use split-window -h or -v subsequently, like that: tmux new-session \ split-window -v \ split-window -h \ Here are my learnings: tmux new-session \ I was trying to create a complex grid of panes and had to deal with switching and splitting panes over and over again. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |