diff options
author | jakob.stendahl <jakob.stendahl@infomedia.dk> | 2022-05-03 08:41:57 +0200 |
---|---|---|
committer | jakobst1n <jakob.stendahl@outlook.com> | 2022-05-03 08:41:57 +0200 |
commit | 12102c365247329f4d6964d6b48e12fa2bf67208 (patch) | |
tree | 0275ffef4d603a5f19dd161f79d6f80ebc9ab770 /Common/zshrc | |
parent | 8c8ea3760651c226e585a67b3800e676a2cc86c0 (diff) | |
download | dotfiles-12102c365247329f4d6964d6b48e12fa2bf67208.tar.gz dotfiles-12102c365247329f4d6964d6b48e12fa2bf67208.zip |
Some changes
Diffstat (limited to 'Common/zshrc')
-rw-r--r-- | Common/zshrc | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Common/zshrc b/Common/zshrc index 356f69c..bba6b7f 100644 --- a/Common/zshrc +++ b/Common/zshrc @@ -64,6 +64,43 @@ man() { command man "$@" } +# Make tmux window title show the ssh hostname +# Make short hostname only if its not an IP address +__tm_get_hostname(){ + local HOST="$(echo $* | rev | cut -d ' ' -f 1 | rev)" + if echo $HOST | grep -P "^([0-9]+\.){3}[0-9]+" -q; then + echo $HOST + else + echo $HOST| cut -d . -f 1 + fi +} + +__tm_get_current_window(){ + tmux list-windows| awk -F : '/\(active\)$/{print $1}' +} + +# Rename window according to __tm_get_hostname and then restore it after the command +__tm_command() { + if [ "$(ps -p $(ps -p $$ -o ppid=) -o comm=| cut -d : -f 1)" = "tmux" ]; then + __tm_window=$(__tm_get_current_window) + # Use current window to change back the setting. If not it will be applied to the active window + trap "tmux set-window-option -t $__tm_window automatic-rename on 1>/dev/null" EXIT HUP INT QUIT PIPE TERM + tmux rename-window "$(__tm_get_hostname $*)" + command "$@" + tmux set-window-option -t $__tm_window automatic-rename on 1>/dev/null + else + command "$@" + fi +} + +ssh() { + __tm_command ssh "$@" +} + +ec2ssh() { + __tm_command ec2ssh "$@" +} + [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh case "$OSTYPE" in @@ -85,3 +122,8 @@ case "$OSTYPE" in alias pbpaste='xsel --clipboard --output' ;; esac + +export EDITOR="vim" +export GIT_AUTHOR_NAME="jakob.stendahl" +export GIT_AUTHOR_EMAIL="jakob.stendahl@infomedia.dk" + |