I'm written several zsh functions for tmux. I'm trying to add autocompletion to a few of these functions, but I'm running into trouble.
One of these functions is tk
, a shorthand for tmux kill-session
. This function takes the name of a session to kill and falls back to the current session if one isn't provided.
Here's what my function looks like:
function tk {
if [ $# -ne 0 ]; then
tmux kill-session -t $1
else
tmux kill-session
fi
}
I've also written an active_tmux_sessions
function that's used in a few other places:
function active_tmux_sessions {
tmux ls -F "#{session_name}" 2>/dev/null | cut -d: -f1
}
Here's what I did to glue them together.
function _tk() {
compadd $(active_tmux_sesions)
}
compdef _tk tk
When I type tk <tab>
, I get this error:
tk _tk:1: command not found: active_tmux_sesions
_tk:1: command not found: active_tmux_sesions
_tk:1: command not found: active_tmux_sesions