aboutsummaryrefslogtreecommitdiff
path: root/usr/share/bash-completion/completions/tmux-session.sh
diff options
context:
space:
mode:
Diffstat (limited to 'usr/share/bash-completion/completions/tmux-session.sh')
-rw-r--r--usr/share/bash-completion/completions/tmux-session.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/usr/share/bash-completion/completions/tmux-session.sh b/usr/share/bash-completion/completions/tmux-session.sh
new file mode 100644
index 0000000..71a2c28
--- /dev/null
+++ b/usr/share/bash-completion/completions/tmux-session.sh
@@ -0,0 +1,26 @@
+#/usr/bin/env bash
+## SPDX-FileCopyrightText: 2022 M. Shulhan <ms@kilabit.info>
+## SPDX-License-Identifier: GPL-3.0-or-later
+
+_tmux-session_completions()
+{
+ local names=()
+ {
+ while read name _; do
+ if [[ "$name" =~ ^"#" ]]; then
+ continue
+ fi
+ names+=($name)
+ done
+ } < ~/.tmux.session
+
+ if [[ "${COMP_WORDS[1]}" == "" ]]; then
+ COMPREPLY=("${names[@]}")
+ return
+ fi
+
+ words="${names[@]}"
+ COMPREPLY=($(compgen -W "$words" -- "${COMP_WORDS[1]}"))
+}
+
+complete -F _tmux-session_completions tmux-session.sh