X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;f=bash%2F.bash_aliases;h=d5cc9d5ca933872062bbcccab5a85f84f5a0cfe1;hb=faf51df9805fc8401924cb4d27029262cf4af074;hp=952029c6af8df02214836da349205b8f7d54534f;hpb=931f09be7e7d09db5c26616096d285e9964b6c5e;p=max%2Fdotfiles.git diff --git a/bash/.bash_aliases b/bash/.bash_aliases index 952029c..d5cc9d5 100644 --- a/bash/.bash_aliases +++ b/bash/.bash_aliases @@ -27,7 +27,26 @@ fi function ssh_in() { + control_file="$TMPDIR/${1}_ssh_in" + if [[ -e $control_file ]]; then + echo "Session is already open" + exit + fi + + cat ~/.tmux.conf | ssh \ + -M \ + -S "$control_file" \ + -o ControlPersist=yes \ + "${1}" \ + 'cat - > ~/.tmux_ssh.conf' + + i3-sensible-terminal -e \ - ssh -o RemoteCommand="/bin/sh -c 'tmux has-session && exec tmux attach || exec tmux'" \ - -t "$@" + sh -c \ + "ssh \ + -o RemoteCommand=\"/bin/sh -c 'exec tmux -f ~/.tmux_ssh.conf new -As remote'\" \ + -S \"$control_file\" \ + -t \ + \"$@\" + ssh -O exit -S \"$control_file\" \"$1\"" }