From 65ad7f77eeb93b3d27c997f42b949153a4cf1ef1 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Tue, 4 Feb 2020 10:00:05 +0100 Subject: [PATCH] Add tmux_attach_start script zsh completions Will autocomplete with currently open tmux sessions. --- tmux/.config/zsh/completions/_tmux_attach_start | 12 ++++++++++++ tmux/.local/bin/tmux_attach_start | 1 + 2 files changed, 13 insertions(+) create mode 100755 tmux/.config/zsh/completions/_tmux_attach_start diff --git a/tmux/.config/zsh/completions/_tmux_attach_start b/tmux/.config/zsh/completions/_tmux_attach_start new file mode 100755 index 0000000..da73e36 --- /dev/null +++ b/tmux/.config/zsh/completions/_tmux_attach_start @@ -0,0 +1,12 @@ +#compdef _tmux_attach_start +# +# Requires tmux_attach_start script in path +# +# Enables completion for zsh of tmux_attach_start function +# with currently open sessions, or tmux options. + +_tmux_attach_start() { + _alternative \ + "sessions:user sessions:($(tmux list-sessions -F'#{session_name}' 2>/dev/null))" +} + diff --git a/tmux/.local/bin/tmux_attach_start b/tmux/.local/bin/tmux_attach_start index afdeea8..e6ffc26 100755 --- a/tmux/.local/bin/tmux_attach_start +++ b/tmux/.local/bin/tmux_attach_start @@ -120,6 +120,7 @@ _attach_or_create() { if ! _session_exists; then _create_detached_session # look for .tmux.session file if no file has been explicitly passed in + # session files always take precedence over environment files when specifically passed in if ! _file_exists "$session_file"; then _load_env_session_file fi