diff options
| author | Shulhan <ms@kilabit.info> | 2022-09-17 14:25:13 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2022-09-17 17:59:21 +0700 |
| commit | b2a4fb1351628323d9a16c74fc0771a7c451d89e (patch) | |
| tree | 7b67b7f8a496dd65ea790b7c9dd4dbd82182311d /etc/bash_completion.d | |
| download | bin.sh-b2a4fb1351628323d9a16c74fc0771a7c451d89e.tar.xz | |
bin.sh: a collection of shell scripts
In this first commit we have tmux-session.sh, a script to open tmux
session based on name and configuration in ~/.tmux.session.
Diffstat (limited to 'etc/bash_completion.d')
| -rw-r--r-- | etc/bash_completion.d/tmux-session | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/etc/bash_completion.d/tmux-session b/etc/bash_completion.d/tmux-session new file mode 100644 index 0000000..ee5ceab --- /dev/null +++ b/etc/bash_completion.d/tmux-session @@ -0,0 +1,23 @@ +#/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 + 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 |
