Avishay Guttman Posted September 6, 2020 Share Posted September 6, 2020 Hi, I'm trying to do something that maybe a bit excessive, but I'll try my luck here. In my day to day work I need to open several SSH connections to 5-7 different servers, and navigate in each server to the same place usually. This task takes a lot of time, I need to go one by one and open each server. I wonder if there is an option to do it all at once using Alfred workflow. I want to write one keyword and to have this open: Note that all panes already broadcast input to each other, so I will only need to type the password once. Is there any way to do that? Thanks on advance, Avishay Link to comment
deanishe Posted September 6, 2020 Share Posted September 6, 2020 Hi @Avishay Guttman, welcome to the forum. Your question doesn't really have much to do with Alfred, tbh. What you need is an iTerm script. When you've written that, Alfred can run it for you. Link to comment
Avishay Guttman Posted September 13, 2020 Author Share Posted September 13, 2020 iTerm script or shell script? Do you have any getting started etc? (I know this is not related directly to Alfred, but if we are already talking about this and you may have done or saw something similar) Link to comment
deanishe Posted September 14, 2020 Share Posted September 14, 2020 On 9/13/2020 at 9:17 AM, Avishay Guttman said: iTerm script or shell script? I presume you will need an iTerm script to open the splits (unless you're using tmux). On 9/13/2020 at 9:17 AM, Avishay Guttman said: Do you have any getting started etc? (I know this is not related directly to Alfred, but if we are already talking about this and you may have done or saw something similar) Me, no. I don't do any iTerm scripting. Link to comment
Toontje Posted December 29, 2021 Share Posted December 29, 2021 set hostnames to {"pi@host1.local", "pi@host2.local", "pi@host3.local", "pi@host4.local", "pi@host5.local", "-p 12345 gregorio@host12"} if application "iTerm" is running then tell application "iTerm" create window with default profile tell current tab of current window select tell current session -- make the window fullscreen tell application "System Events" to key code 36 using command down split horizontally with default profile set num_hosts to count of hostnames repeat with n from 1 to num_hosts if n - 1 is (round (num_hosts / 2)) then -- move to lower split tell application "System Events" to keystroke "]" using command down else if n > 1 then -- split vertically tell application "System Events" to keystroke "d" using command down end if delay 1 write text "ssh " & (item n of hostnames) end repeat end tell end tell end tell else activate application "iTerm" end if deanishe 1 Link to comment
blgentry Posted January 1, 2022 Share Posted January 1, 2022 If you use SSH all the time, tmux will change your life. I keep between 4 and 10 SSH sessions going all the time. But my computer isn't always connected to them. I run tmux on an internal server at work. I SSH or MOSH to the internal server. Then run "tmux attach" to access my tmux session. Then I can see all of my SSH sessions, exactly like I left them. Tmux supports splits as well, so you can have your stacked layout if that's what you really like. I find it easier to navigate from session to session with tmux commands, but you could do either, or a combination. The key point here is you don't need to keep opening many sessions. Tmux will keep them open for you. ...and it will keep you exactly where you were when you last saw them. Even if you were running an interactive program like top or vim, or a compile or a shell script. Tmux keeps every session alive. When you get back to work and attach, you see the current state. This is also great for working remotely or changing work sites. All of your stuff is always in the same place, all ready to go. Brian. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now