aboutsummaryrefslogtreecommitdiffhomepage
path: root/hyprpm
diff options
context:
space:
mode:
authorloseardes77 <[email protected]>2024-08-18 22:25:23 +0200
committerMihai Fufezan <[email protected]>2024-08-19 00:21:59 +0300
commit83d88fa56467a2b749fb2320e1595281107bd326 (patch)
treeb38a6b045db6e25c8da7ace36d0cde0d5efc9783 /hyprpm
parent11dfb8397becca85cad078dd31bf043d1c40ceac (diff)
downloadHyprland-83d88fa56467a2b749fb2320e1595281107bd326.tar.gz
Hyprland-83d88fa56467a2b749fb2320e1595281107bd326.zip
hyprpm, hyprctl: update shell completions
Diffstat (limited to 'hyprpm')
-rw-r--r--hyprpm/hyprpm.bash58
-rw-r--r--hyprpm/hyprpm.fish91
-rw-r--r--hyprpm/hyprpm.usage4
-rw-r--r--hyprpm/hyprpm.zsh46
4 files changed, 108 insertions, 91 deletions
diff --git a/hyprpm/hyprpm.bash b/hyprpm/hyprpm.bash
index ffc33e19..3c2bc90b 100644
--- a/hyprpm/hyprpm.bash
+++ b/hyprpm/hyprpm.bash
@@ -2,6 +2,10 @@ _hyprpm_cmd_0 () {
hyprpm list | awk '/Plugin/{print $4}'
}
+_hyprpm_cmd_1 () {
+ hyprpm list | awk '/Repository/{print $4}' | sed 's/:$//'
+}
+
_hyprpm () {
if [[ $(type -t _get_comp_words_by_ref) != function ]]; then
echo _get_comp_words_by_ref: function not defined. Make sure the bash-completions system package is installed
@@ -11,16 +15,13 @@ _hyprpm () {
local words cword
_get_comp_words_by_ref -n "$COMP_WORDBREAKS" words cword
- local -a literals=("-n" "::=" "list" "disable" "--help" "update" "add" "--verbose" "-v" "--force" "remove" "enable" "--notify" "-h" "reload" "-f")
-
+ declare -a literals=(--no-shallow -n ::= disable list --help update add --verbose -v --force -s remove enable --notify -h reload -f)
declare -A literal_transitions
- literal_transitions[0]="([9]=6 [2]=2 [7]=6 [8]=6 [4]=6 [10]=2 [11]=3 [5]=2 [13]=6 [3]=3 [14]=2 [15]=6 [6]=2)"
- literal_transitions[1]="([10]=2 [11]=3 [3]=3 [2]=2 [14]=2 [5]=2 [6]=2)"
- literal_transitions[4]="([1]=5)"
- literal_transitions[5]="([0]=6 [12]=6)"
-
- declare -A match_anything_transitions
- match_anything_transitions=([3]=2 [2]=4 [0]=1 [1]=1)
+ literal_transitions[0]="([0]=7 [3]=3 [4]=4 [8]=7 [9]=7 [6]=4 [7]=4 [11]=7 [5]=7 [10]=7 [12]=2 [13]=3 [15]=7 [16]=4 [17]=7)"
+ literal_transitions[1]="([12]=2 [13]=3 [3]=3 [4]=4 [16]=4 [6]=4 [7]=4)"
+ literal_transitions[5]="([2]=6)"
+ literal_transitions[6]="([1]=7 [14]=7)"
+ declare -A match_anything_transitions=([1]=1 [4]=5 [3]=4 [2]=4 [0]=1)
declare -A subword_transitions
local state=0
@@ -58,21 +59,9 @@ _hyprpm () {
done
- local prefix="${words[$cword]}"
-
- local shortest_suffix="$word"
- for ((i=0; i < ${#COMP_WORDBREAKS}; i++)); do
- local char="${COMP_WORDBREAKS:$i:1}"
- local candidate="${word##*$char}"
- if [[ ${#candidate} -lt ${#shortest_suffix} ]]; then
- shortest_suffix=$candidate
- fi
- done
- local superfluous_prefix=""
- if [[ "$shortest_suffix" != "$word" ]]; then
- local superfluous_prefix=${word%$shortest_suffix}
- fi
+ local -a matches=()
+ local prefix="${words[$cword]}"
if [[ -v "literal_transitions[$state]" ]]; then
local state_transitions_initializer=${literal_transitions[$state]}
declare -A state_transitions
@@ -81,25 +70,38 @@ _hyprpm () {
for literal_id in "${!state_transitions[@]}"; do
local literal="${literals[$literal_id]}"
if [[ $literal = "${prefix}"* ]]; then
- local completion=${literal#"$superfluous_prefix"}
- COMPREPLY+=("$completion ")
+ matches+=("$literal ")
fi
done
fi
declare -A commands
- commands=([3]=0)
+ commands=([3]=0 [2]=1)
if [[ -v "commands[$state]" ]]; then
local command_id=${commands[$state]}
local completions=()
- mapfile -t completions < <(_hyprpm_cmd_${command_id} "$prefix" | cut -f1)
+ readarray -t completions < <(_hyprpm_cmd_${command_id} "$prefix" | cut -f1)
for item in "${completions[@]}"; do
if [[ $item = "${prefix}"* ]]; then
- COMPREPLY+=("$item")
+ matches+=("$item")
fi
done
fi
+ local shortest_suffix="$prefix"
+ for ((i=0; i < ${#COMP_WORDBREAKS}; i++)); do
+ local char="${COMP_WORDBREAKS:$i:1}"
+ local candidate=${prefix##*$char}
+ if [[ ${#candidate} -lt ${#shortest_suffix} ]]; then
+ shortest_suffix=$candidate
+ fi
+ done
+ local superfluous_prefix=""
+ if [[ "$shortest_suffix" != "$prefix" ]]; then
+ local superfluous_prefix=${prefix%$shortest_suffix}
+ fi
+ COMPREPLY=("${matches[@]#$superfluous_prefix}")
+
return 0
}
diff --git a/hyprpm/hyprpm.fish b/hyprpm/hyprpm.fish
index 7be4f224..82561bd8 100644
--- a/hyprpm/hyprpm.fish
+++ b/hyprpm/hyprpm.fish
@@ -3,6 +3,11 @@ function _hyprpm_1
hyprpm list | awk '/Plugin/{print $4}'
end
+function _hyprpm_2
+ set 1 $argv[1]
+ hyprpm list | awk '/Repository/{print $4}' | sed 's/:$//'
+end
+
function _hyprpm
set COMP_LINE (commandline --cut-at-cursor)
@@ -14,49 +19,51 @@ function _hyprpm
set COMP_CWORD (count $COMP_WORDS)
end
- set --local literals "-n" "::=" "list" "disable" "--help" "update" "add" "--verbose" "-v" "--force" "remove" "enable" "--notify" "-h" "reload" "-f"
+ set literals "--no-shallow" "-n" "::=" "disable" "list" "--help" "update" "add" "--verbose" "-v" "--force" "-s" "remove" "enable" "--notify" "-h" "reload" "-f"
- set --local descriptions
- set descriptions[1] "Send a hyprland notification for important events (e.g. load fail)"
- set descriptions[3] "List all installed plugins"
+ set descriptions
+ set descriptions[1] "Disable shallow cloning of Hyprland sources"
+ set descriptions[2] "Send a hyprland notification for important events (e.g. load fail)"
set descriptions[4] "Unload a plugin"
- set descriptions[5] "Show help menu"
- set descriptions[6] "Check and update all plugins if needed"
- set descriptions[7] "Install a new plugin repository from git"
- set descriptions[8] "Enable too much loggin"
+ set descriptions[5] "List all installed plugins"
+ set descriptions[6] "Show help menu"
+ set descriptions[7] "Check and update all plugins if needed"
+ set descriptions[8] "Install a new plugin repository from git"
set descriptions[9] "Enable too much loggin"
- set descriptions[10] "Force an operation ignoring checks (e.g. update -f)"
- set descriptions[11] "Remove a plugin repository"
- set descriptions[12] "Load a plugin"
- set descriptions[13] "Send a hyprland notification for important events (e.g. load fail)"
- set descriptions[14] "Show help menu"
- set descriptions[15] "Reload all plugins"
- set descriptions[16] "Force an operation ignoring checks (e.g. update -f)"
-
- set --local literal_transitions
- set literal_transitions[1] "set inputs 10 3 8 9 5 11 12 6 14 4 15 16 7; set tos 7 3 7 7 7 3 4 3 7 4 3 7 3"
- set literal_transitions[2] "set inputs 11 12 4 3 15 6 7; set tos 3 4 4 3 3 3 3"
- set literal_transitions[5] "set inputs 2; set tos 6"
- set literal_transitions[6] "set inputs 1 13; set tos 7 7"
-
- set --local match_anything_transitions_from 4 3 1 2
- set --local match_anything_transitions_to 3 5 2 2
-
- set --local state 1
- set --local word_index 2
+ set descriptions[10] "Enable too much loggin"
+ set descriptions[11] "Force an operation ignoring checks (e.g. update -f)"
+ set descriptions[12] "Disable shallow cloning of Hyprland sources"
+ set descriptions[13] "Remove a plugin repository"
+ set descriptions[14] "Load a plugin"
+ set descriptions[15] "Send a hyprland notification for important events (e.g. load fail)"
+ set descriptions[16] "Show help menu"
+ set descriptions[17] "Reload all plugins"
+ set descriptions[18] "Force an operation ignoring checks (e.g. update -f)"
+
+ set literal_transitions
+ set literal_transitions[1] "set inputs 1 4 5 9 10 7 8 12 6 11 13 14 16 17 18; set tos 8 4 5 8 8 5 5 8 8 8 3 4 8 5 8"
+ set literal_transitions[2] "set inputs 13 14 4 5 17 7 8; set tos 3 4 4 5 5 5 5"
+ set literal_transitions[6] "set inputs 3; set tos 7"
+ set literal_transitions[7] "set inputs 2 15; set tos 8 8"
+
+ set match_anything_transitions_from 2 5 4 3 1
+ set match_anything_transitions_to 2 6 5 5 2
+
+ set state 1
+ set word_index 2
while test $word_index -lt $COMP_CWORD
- set --local -- word $COMP_WORDS[$word_index]
+ set -- word $COMP_WORDS[$word_index]
if set --query literal_transitions[$state] && test -n $literal_transitions[$state]
- set --local --erase inputs
- set --local --erase tos
+ set --erase inputs
+ set --erase tos
eval $literal_transitions[$state]
if contains -- $word $literals
- set --local literal_matched 0
+ set literal_matched 0
for literal_id in (seq 1 (count $literals))
if test $literals[$literal_id] = $word
- set --local index (contains --index -- $literal_id $inputs)
+ set index (contains --index -- $literal_id $inputs)
set state $tos[$index]
set word_index (math $word_index + 1)
set literal_matched 1
@@ -70,7 +77,7 @@ function _hyprpm
end
if set --query match_anything_transitions_from[$state] && test -n $match_anything_transitions_from[$state]
- set --local index (contains --index -- $state $match_anything_transitions_from)
+ set index (contains --index -- $state $match_anything_transitions_from)
set state $match_anything_transitions_to[$index]
set word_index (math $word_index + 1)
continue
@@ -80,8 +87,8 @@ function _hyprpm
end
if set --query literal_transitions[$state] && test -n $literal_transitions[$state]
- set --local --erase inputs
- set --local --erase tos
+ set --erase inputs
+ set --erase tos
eval $literal_transitions[$state]
for literal_id in $inputs
if test -n $descriptions[$literal_id]
@@ -92,14 +99,14 @@ function _hyprpm
end
end
- set command_states 4
- set command_ids 1
+ set command_states 4 3
+ set command_ids 1 2
if contains $state $command_states
- set --local index (contains --index $state $command_states)
- set --local function_id $command_ids[$index]
- set --local function_name _hyprpm_$function_id
- set --local --erase inputs
- set --local --erase tos
+ set index (contains --index $state $command_states)
+ set function_id $command_ids[$index]
+ set function_name _hyprpm_$function_id
+ set --erase inputs
+ set --erase tos
$function_name "$COMP_WORDS[$COMP_CWORD]"
end
diff --git a/hyprpm/hyprpm.usage b/hyprpm/hyprpm.usage
index 369c9d2b..24e631c5 100644
--- a/hyprpm/hyprpm.usage
+++ b/hyprpm/hyprpm.usage
@@ -5,10 +5,11 @@ hyprpm [<FLAGS>]... <ARGUMENT>
| (--help | -h) "Show help menu"
| (--verbose | -v) "Enable too much loggin"
| (--force | -f) "Force an operation ignoring checks (e.g. update -f)"
+ | (--no-shallow | -s) "Disable shallow cloning of Hyprland sources"
;
<ARGUMENT> ::= (add) "Install a new plugin repository from git"
- | (remove) "Remove a plugin repository"
+ | (remove <PLUGIN_REPOS>) "Remove a plugin repository"
| (update) "Check and update all plugins if needed"
| (list) "List all installed plugins"
| (enable <PLUGINS>) "Load a plugin"
@@ -17,3 +18,4 @@ hyprpm [<FLAGS>]... <ARGUMENT>
;
<PLUGINS> ::= {{{ hyprpm list | awk '/Plugin/{print $4}' }}};
+<PLUGIN_REPOS> ::= {{{ hyprpm list | awk '/Repository/{print $4}' | sed 's/:$//' }}};
diff --git a/hyprpm/hyprpm.zsh b/hyprpm/hyprpm.zsh
index 854e8426..859c5313 100644
--- a/hyprpm/hyprpm.zsh
+++ b/hyprpm/hyprpm.zsh
@@ -4,34 +4,40 @@ _hyprpm_cmd_0 () {
hyprpm list | awk '/Plugin/{print $4}'
}
+_hyprpm_cmd_1 () {
+ hyprpm list | awk '/Repository/{print $4}' | sed 's/:$//'
+}
+
_hyprpm () {
- local -a literals=("-n" "::=" "list" "disable" "--help" "update" "add" "--verbose" "-v" "--force" "remove" "enable" "--notify" "-h" "reload" "-f")
+ local -a literals=("--no-shallow" "-n" "::=" "disable" "list" "--help" "update" "add" "--verbose" "-v" "--force" "-s" "remove" "enable" "--notify" "-h" "reload" "-f")
local -A descriptions
- descriptions[1]="Send a hyprland notification for important events (e.g. load fail)"
- descriptions[3]="List all installed plugins"
+ descriptions[1]="Disable shallow cloning of Hyprland sources"
+ descriptions[2]="Send a hyprland notification for important events (e.g. load fail)"
descriptions[4]="Unload a plugin"
- descriptions[5]="Show help menu"
- descriptions[6]="Check and update all plugins if needed"
- descriptions[7]="Install a new plugin repository from git"
- descriptions[8]="Enable too much loggin"
+ descriptions[5]="List all installed plugins"
+ descriptions[6]="Show help menu"
+ descriptions[7]="Check and update all plugins if needed"
+ descriptions[8]="Install a new plugin repository from git"
descriptions[9]="Enable too much loggin"
- descriptions[10]="Force an operation ignoring checks (e.g. update -f)"
- descriptions[11]="Remove a plugin repository"
- descriptions[12]="Load a plugin"
- descriptions[13]="Send a hyprland notification for important events (e.g. load fail)"
- descriptions[14]="Show help menu"
- descriptions[15]="Reload all plugins"
- descriptions[16]="Force an operation ignoring checks (e.g. update -f)"
+ descriptions[10]="Enable too much loggin"
+ descriptions[11]="Force an operation ignoring checks (e.g. update -f)"
+ descriptions[12]="Disable shallow cloning of Hyprland sources"
+ descriptions[13]="Remove a plugin repository"
+ descriptions[14]="Load a plugin"
+ descriptions[15]="Send a hyprland notification for important events (e.g. load fail)"
+ descriptions[16]="Show help menu"
+ descriptions[17]="Reload all plugins"
+ descriptions[18]="Force an operation ignoring checks (e.g. update -f)"
local -A literal_transitions
- literal_transitions[1]="([10]=7 [3]=3 [8]=7 [9]=7 [5]=7 [11]=3 [12]=4 [6]=3 [14]=7 [4]=4 [15]=3 [16]=7 [7]=3)"
- literal_transitions[2]="([11]=3 [12]=4 [4]=4 [3]=3 [15]=3 [6]=3 [7]=3)"
- literal_transitions[5]="([2]=6)"
- literal_transitions[6]="([1]=7 [13]=7)"
+ literal_transitions[1]="([1]=8 [4]=4 [5]=5 [9]=8 [10]=8 [7]=5 [8]=5 [12]=8 [6]=8 [11]=8 [13]=3 [14]=4 [16]=8 [17]=5 [18]=8)"
+ literal_transitions[2]="([13]=3 [14]=4 [4]=4 [5]=5 [17]=5 [7]=5 [8]=5)"
+ literal_transitions[6]="([3]=7)"
+ literal_transitions[7]="([2]=8 [15]=8)"
local -A match_anything_transitions
- match_anything_transitions=([4]=3 [3]=5 [1]=2 [2]=2)
+ match_anything_transitions=([2]=2 [5]=6 [4]=5 [3]=5 [1]=2)
declare -A subword_transitions
@@ -91,7 +97,7 @@ _hyprpm () {
fi
done
fi
- local -A commands=([4]=0)
+ local -A commands=([4]=0 [3]=1)
if [[ -v "commands[$state]" ]]; then
local command_id=${commands[$state]}