File indexing completed on 2024-04-28 05:50:33
0001 #compdef konsole konsoleprofile 0002 0003 # SPDX-FileCopyrightText: 2022 ivan tkachenko <me@ratijas.tk> 0004 # 0005 # SPDX-License-Identifier: GPL-2.0-or-later 0006 0007 function _konsole_profiles() { 0008 local -a profiles profiles_descr profiles_comp 0009 0010 # Technically, built-in profile's "path" is `FALLBACK/`. Let's suggest it just for completeness. 0011 profiles=( ${(f)"$(_call_program konsole-profiles konsole --list-profiles)"} ) 0012 profiles_descr=( $profiles Built-in ) 0013 profiles_comp=( $profiles FALLBACK/ ) 0014 0015 _describe -t profile 'profile' profiles_descr profiles_comp -o nosort 0016 } 0017 0018 function _konsole_profile_properties() { 0019 local -A properties 0020 local -a prop_names prop_types 0021 local property prop_type ret=1 0022 0023 # first split by lines, then split in `key : type` pairs, and stuff that into an associative array 0024 properties=( ${(@s. : .)${(f)"$(_call_program konsole-properties-list konsole --list-profile-properties)"}} ) 0025 prop_names=( ${(@k)properties} ) 0026 prop_types=( ${(@v)properties} ) 0027 0028 # skip all property=value pair up to the last one 0029 while compset -P 1 '*=*;' ; do done 0030 0031 if compset -P 1 '*='; then 0032 property=${${IPREFIX%=}##*;} 0033 prop_type=${properties[$property]} 0034 0035 case "$prop_type" in 0036 (bool) 0037 _describe -t bool bool '(true false 1 0)' && ret=0 0038 ;; 0039 (int) 0040 _numbers && ret=0 0041 ;; 0042 *) 0043 # XXX: what about other types? QString, QStringList, QColor, QFont 0044 _describe -t property-value "$prop_type" '()' && ret=0 0045 ;; 0046 esac 0047 else 0048 _describe -t property-name 'property=value' prop_names -S '=' && ret=0 0049 fi 0050 return $ret 0051 } 0052 0053 # Note: '-' denotes mutually exclusive sets of options. '-e' trick was copied from _xterm completions. 0054 0055 case "$service" in 0056 (konsoleprofile) 0057 _arguments \ 0058 '1:properties:_konsole_profile_properties' 0059 ;; 0060 (konsole) 0061 _arguments -s \ 0062 '(- *)'{-h,--help}'[Displays help on commandline options]' \ 0063 '(- *)'{-v,--version}'[Displays version information]' \ 0064 \ 0065 - list-profiles \ 0066 '--list-profiles[List the available profiles]' \ 0067 \ 0068 - list-profile-properties \ 0069 '--list-profile-properties[List all the profile properties names and their type (for use with -p)]' \ 0070 \ 0071 - main \ 0072 '(--profile --builtin-profile)--profile=[Name of profile to use for new Konsole instance]:profile:_konsole_profiles' \ 0073 '(--profile --builtin-profile)--builtin-profile[Use the built-in profile instead of the default profile]' \ 0074 '*-p[Change the value of a profile property.]:property=value:_konsole_profile_properties' \ 0075 \ 0076 '--layout=[json layoutfile to be loaded to use for new Konsole instance]:file:_files -g "*.json"' \ 0077 '--workdir=[Set the initial working directory of the new tab or window]:dir:_files -/' \ 0078 '--tabs-from-file=[Create tabs as specified in given tabs configuration file]:file:_files' \ 0079 '(--hold --noclose)'{--hold,--noclose}'[Do not close the initial session automatically when it ends.]' \ 0080 '--new-tab[Create a new tab in an existing window rather than creating a new window]' \ 0081 '--background-mode[Start Konsole in the background and bring to the front when Ctrl+Shift+F12 (by default) is pressed]' \ 0082 '(--separate --nofork)'{--separate,--nofork}'[Run in a separate process]' \ 0083 '--fullscreen[Start Konsole in fullscreen mode]' \ 0084 '--notransparency[Disable transparent backgrounds, even if the system supports them.]' \ 0085 '--force-reuse[Force re-using the existing instance even if it breaks functionality.]' \ 0086 \ 0087 '(--show-menubar --hide-menubar)'--{show,hide}-menubar'[Toggle the menubar, overriding the default setting]' \ 0088 '(--show-tabbar --hide-tabbar)'--{show,hide}-tabbar'[Toggle the tabbar, overriding the default setting]' \ 0089 \ 0090 '-e[Command to execute. This option will catch all following arguments, so use it as the last option.]:program: _command_names -e:*::program arguments: _normal' 0091 ;; 0092 esac