41 lines
1.1 KiB
Plaintext
41 lines
1.1 KiB
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]' \
|
|
'(-H --host)'{-H,--host}'[Create or attach to the session on a remote host via ssh]:host:__session_hosts' \
|
|
'(-p --project :)'{-p,--project}'[Create or attach to a session for a project in ~/Projects]:project:__session_projects' \
|
|
'(-p --project)1:session:__session_sessions'
|