4 ms·
I used to have a bunch of scripts, but I compulsively "clean" my backups too often to keep old stuff around. Here's my "newterm" script, which I use for launchi
by t-3 4y ago
I used to have a bunch of scripts, but I compulsively "clean" my backups too often to keep old stuff around. Here's my "newterm" script, which I use for launching xterm with tmux:
#!/bin/sh
if [ $(tmux has-session 2>/dev/null; echo $?) -eq 0 ]; then
if [ $(tmux list-windows -f '#{window_active_clients}') ]; then
if [ $(tmux ls | head -n 1 | awk '{print $2}') -le 2 ]; then
xterm -e "tmux new-session -f active-pane,ignore-size -t "0" \; new-window"
else
xterm -e "tmux new-session -f active-pane,ignore-size -t "0" \; select-window -t +2"
fi
else
xterm -e "tmux attach -f active-pane,ignore-size -t "0""
fi
else
xterm -e tmux new-session -f active-pane,ignore-size
fi
if [ $(tmux ls | wc -l) -gt 1 ]; then
for i in $(tmux ls -F '#S' -f '#{?session_attached,,#S}' ); do
tmux kill-session -t ${i}
done
fi
- t-3 4y agoErr... Maybe next time I'll remember to test before posting! (I fixed an obvious but easy to ignore bug that was in since the beginning to make it "presentable", but didn't test/trace to make sure the new version actually worked correctly!) --- newterm Mon Aug 15 18:09:51 2022 +++ .local/bin/newterm Mon Aug 15 18:07:51 2022 @@ -1,8 +1,8 @@ #!/bin/sh if [ $(tmux has-session 2>/dev/null; echo $?) -eq 0 ]; then - if [ $(tmux list-windows -f '#{window_active_clients}') ]; then - if [ $(tmux ls | head -n 1 | awk '{print $2}') -le 2 ]; then + if [ $(tmux list-windows -F '#I' -f '#{window_active_clients}' | wc -l) -gt 0 ]; then + if [ $(tmux ls -F '#{session_windows}' | head -n 1) -le 2 ]; then xterm -e "tmux new-session -f active-pane,ignore-size -t "0" \; new-window" else xterm -e "tmux new-session -f active-pane,ignore-size -t "0" \; select-window -t +2"