File indexing completed on 2024-04-28 04:39:53
0001 # Bash completion script for KDevelop 0002 # 0003 # SPDX-FileCopyrightText: 2019 Kevin Funk <kfunk@kde.org> 0004 # 0005 # SPDX-License-Identifier: LGPL-2.0-or-later 0006 0007 0008 # Usage: 0009 # 0010 # Under Bash: 0011 # source kdevelop_completions.bash 0012 # 0013 # Under ZSH: 0014 # autoload bashcompinit 0015 # bashcompinit 0016 # source kdevelop_completions.bash 0017 # 0018 # (cf. https://stackoverflow.com/questions/3249432/can-a-bash-tab-completion-script-be-used-in-zsh) 0019 0020 _kdevelop_completions() 0021 { 0022 local cur prev 0023 0024 COMPREPLY=() 0025 cur="${COMP_WORDS[COMP_CWORD]}" 0026 prev="${COMP_WORDS[COMP_CWORD-1]}" 0027 case $prev in 0028 -s) 0029 local IFS=$'\n' 0030 CANDIDATES=( 0031 $(compgen -W \ 0032 "$(kdevelop --list-sessions 2>/dev/null | grep -E '^{' | cut -f2 | sed 's/\s*\[running\]//;s/\(.*\):.*/\1/;s/ /\\ /g')" \ 0033 -- "${cur}" 0034 ) 0035 ) 0036 0037 # Need to jump through hoops to properly handle spaces in results, cf. https://stackoverflow.com/a/11536437/592636 0038 # Correctly set our candidates to COMPREPLY 0039 if [ ${#CANDIDATES[*]} -eq 0 ]; then 0040 COMPREPLY=() 0041 else 0042 COMPREPLY=($(printf '%q\n' "${CANDIDATES[@]}")) 0043 fi 0044 ;; 0045 esac 0046 } 0047 0048 complete -F _kdevelop_completions kdevelop 0049 0050 # ex: filetype=sh