From 18b7b45f179a83ada3486f03b6c37f322f343e59 Mon Sep 17 00:00:00 2001 From: Marcel Schoengens Date: Thu, 1 Nov 2018 14:41:45 +0100 Subject: [PATCH] Add zsh alias / function for ssh + tmux --- zsh/zshrc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/zsh/zshrc b/zsh/zshrc index 0a5f742..0891179 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -153,6 +153,26 @@ function sortimages () { esac } + +read -r -d '' REMOTE_CMD << EOF +if [ \$(command -v module 2> /dev/null | wc -l) -gt 0 ]; then + module load tmux +fi + +if [ \$(lsof -U 2> /dev/null | grep ^tmux | wc -l) -gt 0 ]; then + tmux a +else + tmux +fi +EOF + +function st () { + ssh -t $@ ${REMOTE_CMD} +} + +compdef st=ssh + + ### Alias configuration if [[ $(uname) = "Linux" ]]; then