Last active
August 29, 2015 14:01
-
-
Save nnutter/57d4fe31bfb120b31cc6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| _tm_complete() { | |
| COMPREPLY=() | |
| local SESSIONS=$(tmux list-sessions | cut -f 1 -d :) | |
| if [ ${#COMP_WORDS[@]} -eq 2 ]; then | |
| local cur=${COMP_WORDS[COMP_CWORD]} | |
| COMPREPLY=($(compgen -W "$SESSIONS" -- $cur)) | |
| fi | |
| } | |
| complete -F _tm_complete tm | |
| function tm { | |
| session_name=$1 | |
| if [ -z "$session_name" ]; then | |
| echo "ERROR: Must provide session name as argument." | |
| return 1 | |
| fi | |
| if tmux has-session -t "$session_name"; then | |
| command tmux attach -t $session_name | |
| else | |
| command tmux new -s $session_name | |
| fi | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment