4 ms·
I got sick of opening the same tmux/terminal format every time I had to restart, so I wrote this: #!/bin/bash function command() { CMD
by orthecreedence 6y ago
I got sick of opening the same tmux/terminal format every time I had to restart, so I wrote this:
#!/bin/bash
function command() {
CMD="$1"
xdotool type "$1"
xdotool key Return
}
function key() {
KEY="$1"
xdotool key $KEY
}
function clear() {
for n in {1..10}; do
key BackSpace
done
}
function name_panel() {
NAME="$1"
key ctrl+a
key comma
clear
command $NAME
}
name_panel 'cmd'
key ctrl+a
key c
name_panel 'srv'
key ctrl+a
key c
name_panel 'make'
key ctrl+a
key n
echo "Now type ssh-add to log in..."
ssh-agent bash
- yjftsjthsd-h 6y agoI feel like I should point out that tmux is quite happy to take commands directly on the command line: `tmux new-window -n srv` will make a new window named "srv", `tmux next-window` will move you forward one window, etc. Hit prefix-? to list the commands bound to each key when you're running.
- orthecreedence 6y agoThanks! I had this strange feeling someone was going to tell me something exactly like this after I posted. I'm glad I did though, it's good to learn new things.
- yjftsjthsd-h 6y ago:) Remember, just because someone tells you a better doesn't mean there was anything wrong with your way (if nothing else, sending actual keystrokes is a universal-ish API rather than having to learn each program's specific interface, if they even have one). But yeah, knowledge-sharing is a perk of these threads, too:)
- jacknews 6y agothere's a tmux plugin to restore a session you save; https://github.com/tmux-plugins/tmux-resurrect https://github.com/tmux-plugins/tmux-resurrect