From b6c5f55079d946e4f1f6cbc39cd6526c4965baef Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Mon, 15 Feb 2016 11:20:51 -0500 Subject: [PATCH] Auto-start tmux when on a remote connection --- .aliases/command-specific/todo.sh | 3 +++ .aliases/general | 2 +- .zshrc | 34 +++++++++++++++---------------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/.aliases/command-specific/todo.sh b/.aliases/command-specific/todo.sh index 388b43c..76dff73 100644 --- a/.aliases/command-specific/todo.sh +++ b/.aliases/command-specific/todo.sh @@ -1,5 +1,8 @@ ## todo.sh alias taz='todo.sh add "(Z)"' +tap() { + todo.sh add "($1) $2" +} alias t='todo.sh' alias hw='t hw' alias hwr="hw rel" diff --git a/.aliases/general b/.aliases/general index 201e544..debe1f6 100644 --- a/.aliases/general +++ b/.aliases/general @@ -14,4 +14,4 @@ mcd() { mkdir -p "$1" && cd "$1"; } alias irc='ssh ag tmux a -t irc' #quick alias for enabling bluetooth -alias ebluetooth="sudo modprobe btusb;blueman-manager" +alias ebluetooth="sudo modprobe btusb;ssy start bluetooth;blueman-manager" diff --git a/.zshrc b/.zshrc index 839de08..4c7f5e4 100644 --- a/.zshrc +++ b/.zshrc @@ -21,24 +21,6 @@ source $HOME/.aliases/general # Various Options CORRECT_IGNORE="_*" stty -ixon #disable XON/XOFF, which breaks C-s - -# Keybindings -my-backward-kill-word () { - local WORDCHARS=${WORDCHARS/\//} - zle backward-kill-word -} -zle -N my-backward-kill-word -bindkey '^H' my-backward-kill-word - -# Inserts 'sudo ' at the beginning of the line. -function prepend-sudo() { - if [[ "$BUFFER" != su(do|)\ * ]]; then - BUFFER="sudo $BUFFER" - (( CURSOR += 5 )) - fi -} -zle -N prepend-sudo -bindkey "^X^S" prepend-sudo setopt no_share_history #load fasd if it exists @@ -48,3 +30,19 @@ hash fasd 2>/dev/null && eval "$(fasd --init auto)" unalias run-help autoload run-help +# Auto start tmux if a remote connection +if [[ -z "$TMUX" && -z "$EMACS" && -z "$VIM" ]] && [[ -n "$SSH_TTY" ]] +then + tmux_session='zim' + tmux start-server + # Create a 'prezto' session if no session has been defined in tmux.conf. + if ! tmux has-session 2> /dev/null; then + tmux \ + new-session -d -s "$tmux_session" \; \ + set-option -t "$tmux_session" destroy-unattached off &> /dev/null + fi + + # Attach only to the prezto session + exec tmux new-session -A -s $tmux_session +fi +