add new tmux function for default sessions
This commit is contained in:
parent
e0881154db
commit
1345a7f9d5
1 changed files with 30 additions and 0 deletions
30
home/private_dot_config/zsh/functions/tn-ws
Normal file
30
home/private_dot_config/zsh/functions/tn-ws
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#!/usr/bin/env zsh
|
||||||
|
##? create a new tmux session
|
||||||
|
##? use current directory name as a fallback
|
||||||
|
##? create neovim and shell windows
|
||||||
|
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
SESSION="${PWD:A:t2}"
|
||||||
|
else
|
||||||
|
SESSION="$1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# sanitize name
|
||||||
|
SESSION="${SESSION:gs/\./_}"
|
||||||
|
|
||||||
|
if ! tmux list-sessions | grep $SESSION 2>/dev/null; then
|
||||||
|
tmux new-session -d -s $SESSION
|
||||||
|
|
||||||
|
tmux rename-window -t $SESSION:0 'neovim'
|
||||||
|
tmux send-keys -t 'neovim' 'nvim' Enter
|
||||||
|
|
||||||
|
tmux new-window -t $SESSION:1 -n 'shell'
|
||||||
|
tmux send-keys -t 'shell'
|
||||||
|
|
||||||
|
#TODO: open as many windows as defined by '$2'
|
||||||
|
fi
|
||||||
|
|
||||||
|
tmux attach -t $SESSION
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue