This flag sets the session name to `<project>` where `<project>` is a git repository to make working with multiple worktrees more streamlined.
41 lines
978 B
Plaintext
41 lines
978 B
Plaintext
#compdef session
|
|
|
|
__session_sessions() {
|
|
list() {
|
|
for item in $HOME/.local/share/tmux/layouts/session-*; do
|
|
item=${item#$HOME/.local/share/tmux/layouts/}
|
|
# session-project is parameterized by -p, not a session of its own
|
|
[ "$item" = session-project ] && continue
|
|
echo ${item#session-}
|
|
done
|
|
}
|
|
local -a sessions
|
|
sessions=(${(fo)"$(list)"})
|
|
_describe 'session' sessions
|
|
}
|
|
|
|
__session_projects() {
|
|
_files -W $HOME/Projects -/
|
|
}
|
|
|
|
__session_hosts() {
|
|
list() {
|
|
declare -A hosts
|
|
if [ -f ~/.config/session ]; then
|
|
source ~/.config/session
|
|
for key val in "${(@kv)hosts}"; do
|
|
echo $key
|
|
done
|
|
fi
|
|
}
|
|
local -a hosts
|
|
hosts=(${(fo)"$(list)"})
|
|
_describe 'host' hosts
|
|
}
|
|
|
|
_arguments \
|
|
'(- *)'{-h,--help}'[Show usage information]' \
|
|
'(- *)'{-p,--project}'[Create or attach to a session for a project in ~/Projects]:project:__session_projects' \
|
|
':session:__session_sessions' \
|
|
':host:__session_hosts'
|