commit 1fb4d047872b3e388da74a2743acb16373a9ba6b Author: Zoey Date: Sun Apr 3 01:02:38 2022 +0200 Add files via upload diff --git a/configs/home/90-libinput.conf b/configs/home/90-libinput.conf new file mode 100644 index 0000000..819f995 --- /dev/null +++ b/configs/home/90-libinput.conf @@ -0,0 +1,6 @@ +Section "InputClass" + Identifier "Default Pointer (libinput)" + MatchDriver "libinput" + MatchIsPointer "on" + Option "AccelSpeed" "0" +EndSection diff --git a/scripts/Documents/Scripts/KVMStuff/w11mainkeyboard.xml b/scripts/Documents/Scripts/KVMStuff/w11mainkeyboard.xml new file mode 100644 index 0000000..2cea406 --- /dev/null +++ b/scripts/Documents/Scripts/KVMStuff/w11mainkeyboard.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/scripts/Documents/Scripts/KVMStuff/w11mainmouse.xml b/scripts/Documents/Scripts/KVMStuff/w11mainmouse.xml new file mode 100644 index 0000000..c39d7db --- /dev/null +++ b/scripts/Documents/Scripts/KVMStuff/w11mainmouse.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/scripts/Documents/Scripts/KVMStuff/w11secondarykeyboard.xml b/scripts/Documents/Scripts/KVMStuff/w11secondarykeyboard.xml new file mode 100644 index 0000000..0c4f53c --- /dev/null +++ b/scripts/Documents/Scripts/KVMStuff/w11secondarykeyboard.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/scripts/Documents/Scripts/KVMStuff/w11secondarymouse.xml b/scripts/Documents/Scripts/KVMStuff/w11secondarymouse.xml new file mode 100644 index 0000000..111b285 --- /dev/null +++ b/scripts/Documents/Scripts/KVMStuff/w11secondarymouse.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/scripts/Documents/Scripts/attachmain.sh b/scripts/Documents/Scripts/attachmain.sh new file mode 100644 index 0000000..f0b4e96 --- /dev/null +++ b/scripts/Documents/Scripts/attachmain.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +virsh attach-device Win10 /mnt/Usagichan/KVMstuff/w11mainkeyboard.xml +virsh attach-device Win10 /mnt/Usagichan/KVMstuff/w11mainmouse.xml + +virsh detach-device Win10 /mnt/Usagichan/KVMstuff/w11secondarykeyboard.xml +virsh detach-device Win10 /mnt/Usagichan/KVMstuff/w11secondarymouse.xml diff --git a/scripts/Documents/Scripts/attachsecondary.sh b/scripts/Documents/Scripts/attachsecondary.sh new file mode 100644 index 0000000..639431e --- /dev/null +++ b/scripts/Documents/Scripts/attachsecondary.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +virsh detach-device Win10 ./KVMStuff/w11mainkeyboard.xml +virsh detach-device Win10 ./KVMstuff/w11mainmouse.xml + +virsh attach-device Win10 ./KVMStuff/w11secondarykeyboard.xml +virsh attach-device Win10 ./KVMstuff/w11secondarymouse.xml diff --git a/scripts/Documents/Scripts/cmusrefresh.sh b/scripts/Documents/Scripts/cmusrefresh.sh new file mode 100644 index 0000000..2f45e41 --- /dev/null +++ b/scripts/Documents/Scripts/cmusrefresh.sh @@ -0,0 +1,4 @@ +#!/bin/bash +cmus-remote -C clear +cmus-remote -C "add /mnt/Pyon/Music" +cmus-remote -C "update-cache -f" diff --git a/scripts/Documents/Scripts/keyboardlayout.sh b/scripts/Documents/Scripts/keyboardlayout.sh new file mode 100644 index 0000000..12c6d9e --- /dev/null +++ b/scripts/Documents/Scripts/keyboardlayout.sh @@ -0,0 +1,15 @@ +#! /bin/bash + +CURRENT_LAYOUT=$(setxkbmap -query|awk -F : 'NR==3{print $2}'|sed 's/ //g') + +if [ "$CURRENT_LAYOUT" = "us" ]; then + setxkbmap "cz(rus)" +elif [ "$CURRENT_LAYOUT" = "cz(rus)" ]; then + setxkbmap "fr(us)" +elif [ "$CURRENT_LAYOUT" = "fr(us)" ]; then + setxkbmap "fi(nodeadkeys)" +elif [ "$CURRENT_LAYOUT" = "fi(nodeadkeys)" ]; then + setxkbmap "us" +fi + +setxkbmap -option caps:swapescape diff --git a/scripts/Documents/Scripts/perfgov.sh b/scripts/Documents/Scripts/perfgov.sh new file mode 100644 index 0000000..1019f18 --- /dev/null +++ b/scripts/Documents/Scripts/perfgov.sh @@ -0,0 +1,4 @@ +#!/bin/bash +cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor +for file in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do echo "performance" > $file; done +cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor diff --git a/scripts/Documents/Scripts/schedutilgov.sh b/scripts/Documents/Scripts/schedutilgov.sh new file mode 100644 index 0000000..bd39834 --- /dev/null +++ b/scripts/Documents/Scripts/schedutilgov.sh @@ -0,0 +1,4 @@ +#!/bin/bash +cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor +for file in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do echo "schedutil" > $file; done +cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor diff --git a/scripts/Documents/Scripts/screamloop.sh b/scripts/Documents/Scripts/screamloop.sh new file mode 100644 index 0000000..65c1a51 --- /dev/null +++ b/scripts/Documents/Scripts/screamloop.sh @@ -0,0 +1,19 @@ +#!/bin/dash + +killall -q scream +trap "exit" INT TERM +trap "kill 0" EXIT + +theloop() +{ +killall -q scream +scream -i virbr0 & +} + + +while true +do + theloop + sleep 300 + killall -q scream +done diff --git a/scripts/Documents/Scripts/zsh/zsh-autocomplete/LICENSE b/scripts/Documents/Scripts/zsh/zsh-autocomplete/LICENSE new file mode 100644 index 0000000..58c46b8 --- /dev/null +++ b/scripts/Documents/Scripts/zsh/zsh-autocomplete/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2020 Marlon Richert + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/scripts/Documents/Scripts/zsh/zsh-autocomplete/README.md b/scripts/Documents/Scripts/zsh/zsh-autocomplete/README.md new file mode 100644 index 0000000..1647b53 --- /dev/null +++ b/scripts/Documents/Scripts/zsh/zsh-autocomplete/README.md @@ -0,0 +1,148 @@ +# `zsh-autocomplete` +`zsh-autocomplete` adds **real-time type-ahead autocompletion** to Zsh. Find as you type, then +press Tab to insert the top completion, ShiftTab to insert the +bottom one, or /PgDn to select another completion. + +[![file-search](.img/file-search.gif)](https://asciinema.org/a/377611) + +> Enjoy using this software? [Become a sponsor!](https://github.com/sponsors/marlonrichert). + +## Other Features +Besides live autocompletion, `zsh-autocomplete` comes with many other useful completion features. + +### Optimized completion config +Zsh's completion system is powerful, but hard to configure. So, `zsh-autocomplete` [does it for +you](scripts/.autocomplete.config), while providing a manageable list of [configuration +settings](.zshrc) for changing the defaults. + +### Live history search +Press CtrlR or CtrlS to do live, multi-line history +search. + +[![history-search](.img/history-search.gif)](https://asciinema.org/a/379844) + +### History menu +Press (or Alt or PgUp) to open a menu with the last +16 history items. If the command line is not empty, then the contents of the command line are used +to perform a fuzzy history search. + +![history menu](.img/history-menu.png) + +### Multi-selection +Press CtrlSpace in the completion menu or the history menu to insert more +than one item. + +![multi-select](.img/multi-select.png) + +### Recent dirs completion +Works out of the box with zero configuration, but also supports `zsh-z`, `zoxide`, `z.lua`, +`rupa/z.sh`, `autojump` and `fasd`. + +![recent dirs](.img/recent-dirs.png) + +## Key Bindings + +On the command line: +| Key(s) | Action | [Widget](.zshrc) | +| ------ | ------ | --- | +| Tab | Accept top completion | `complete-word` | +| ShiftTab | Accept bottom completion | `complete-word` | +| CtrlSpace | Show additional completions | `list-expand` | +| | Cursor down (if able) or completion menu | `down-line-or-select` | +| PgDn / Alt | Completion menu (always) | `menu-select` | +| | Cursor up (if able) or [history menu](#history-menu) | `up-line-or-search` | +| PgUp / Alt | [History menu](#history-menu) (always) | `history-search` | +| CtrlR | [Live history search](#live-history-search), newest to oldest | `history-incremental-search-backward` | +| CtrlS | [Live history search](#live-history-search), oldest to newest | `history-incremental-search-forward` | + +In the completion menu: +| Key(s) | Action | +| ------ | ------ | +| / / / | Change selection | +| Alt | Backward one group | +| Alt | Forward one group | +| PgUp / PgDn | Page up/down | +| CtrlR | Full text search or previous search match | +| CtrlS | Full text search or next search match | +| CtrlSpace | Multi-select | +| Tab | Accept selection | +| ShiftTab | Accept bottom completion | +| Enter | Accept command line | +| most other keys | Accept selection, then perform usual action | + +In the history menu: +| Key(s) | Action | +| --- | --- | +| / | Change selection | +| CtrlSpace | Multi-select | +| Tab | Accept selection | +| Enter | Accept command line | +| most other keys | Accept selection, then perform usual action | + +## Requirements +Recommended: +* Tested to work with [Zsh](http://zsh.sourceforge.net) 5.7 or newer. + +Minimum: +* Should theoretically work with Zsh 5.4 or newer, but I'm unable to test that. + +## Installing & Updating +If you use [Znap](https://github.com/marlonrichert/zsh-snap), simply add the following to your +`.zshrc` file: +```zsh +znap source marlonrichert/zsh-autocomplete +``` +Then restart your shell. + +To update, do +```zsh +% znap pull +``` + +For configuration options, see the included [`.zshrc` file](.zshrc). + +To uninstall, remove `znap source marlonrichert/zsh-autocomplete` from your `.zshrc` file, then run +```zsh +% znap uninstall +``` + +### Manual installation + 1. Clone the repo: + ```zsh + % cd ~/Git # ...or wherever you keep your Git repos/Zsh plugins + % git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git + ``` + 1. Add at or near the top of your `.zshrc` file (_before_ any calls to `compdef`): + ```zsh + source ~/Git/zsh-autocomplete/zsh-autocomplete.plugin.zsh + ``` + 1. Remove any calls to `compinit` from your `.zshrc` file. + 1. If you're using Ubuntu, add to your `.zshenv` file: + ```zsh + skip_global_compinit=1 + ``` +Then restart your shell. + +To update, do: +```zsh +% git -C ~zsh-autocomplete pull +``` + +To uninstall, simply undo the installation steps above in reverse order: + 1. Restore the lines you deleted in step 3. + 1. Delete the line you added in step 2. + 1. Delete the repo you created in step 1. +Finally, restart your shell. + +### Other Frameworks/Plugin Managers +To install with another Zsh framework or plugin manager, please refer to your +framework's/plugin manager's documentation for instructions. + +## Troubleshooting +Try the steps in the [bug report template](.github/ISSUE_TEMPLATE/bug-report.md). + +## Author +© 2020-2021 [Marlon Richert](https://github.com/marlonrichert) + +## License +This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. diff --git a/scripts/Documents/Scripts/zsh/zsh-autocomplete/functions/completion/_autocomplete.all_matches b/scripts/Documents/Scripts/zsh/zsh-autocomplete/functions/completion/_autocomplete.all_matches new file mode 100644 index 0000000..36bbef7 --- /dev/null +++ b/scripts/Documents/Scripts/zsh/zsh-autocomplete/functions/completion/_autocomplete.all_matches @@ -0,0 +1,23 @@ +#autoload + +[[ -v _autocomplete__partial_list || $curcontext == *history* ]] && + return 1 + +(( CURRENT > 1 && compstate[nmatches] > 1 )) || + return + +if [[ $_completer == expand ]]; then + _autocomplete.is_glob || + return +else + [[ $words[1] != cd ]] || + return + [[ -n $_comp_tags ]] || + return + [[ -z ${${=_comp_tags}[@]:#((local-|)directories|((all|globbed)-|)files)} ]] || + return +fi + +local -a expl=() +_description all-matches expl 'all matches' +builtin compadd "$expl[@]" -C diff --git a/scripts/Documents/Scripts/zsh/zsh-autocomplete/functions/completion/_autocomplete.ancestor_dirs b/scripts/Documents/Scripts/zsh/zsh-autocomplete/functions/completion/_autocomplete.ancestor_dirs new file mode 100644 index 0000000..bac8cae --- /dev/null +++ b/scripts/Documents/Scripts/zsh/zsh-autocomplete/functions/completion/_autocomplete.ancestor_dirs @@ -0,0 +1,29 @@ +#autoload + +(( compstate[nmatches] )) && + return 1 + +[[ $_comp_tags != (|* )(|local-)directories(| *) ]] && + return 1 + +local displ= expl= +_description -V ancestor-directories expl 'ancestor directory' + +local -Pa ancestors=() +local -P parent=$PWD:h +while (( $#parent > 1 )); do + ancestors+=( $parent ) + parent=$parent:h +done + +local -Pi ret=1 +local -P a= +for a in ${(aO)ancestors[@]}; do + displ=( "$a" ) + [[ -z $PREFIX$SUFFIX ]] && + displ=( "$a:t" ) + compadd "$expl[@]" -d displ -P "${${(D)a:h}%/}/" -fW "${${a:h}%/}/" - "$a:t" && + ret=0 +done + +return ret diff --git a/scripts/Documents/Scripts/zsh/zsh-autocomplete/functions/completion/_autocomplete.command b/scripts/Documents/Scripts/zsh/zsh-autocomplete/functions/completion/_autocomplete.command new file mode 100644 index 0000000..77f1d91 --- /dev/null +++ b/scripts/Documents/Scripts/zsh/zsh-autocomplete/functions/completion/_autocomplete.command @@ -0,0 +1,7 @@ +#compdef -command- +local -P ret=1 +_expand_alias "$@" && + ret=0 +_autocd "$@" && + ret=0 +return ret diff --git a/scripts/Documents/Scripts/zsh/zsh-autocomplete/functions/completion/_autocomplete.compadd_opts_len b/scripts/Documents/Scripts/zsh/zsh-autocomplete/functions/completion/_autocomplete.compadd_opts_len new file mode 100644 index 0000000..a29c650 --- /dev/null +++ b/scripts/Documents/Scripts/zsh/zsh-autocomplete/functions/completion/_autocomplete.compadd_opts_len @@ -0,0 +1,10 @@ +#autoload + +local -Pi len=$(( ${@[(i)(-|--)]} - 1 )) +(( len < $# )) && + return len + +len=${@[(I)-*]} +[[ $@[len] == -*[PSpsiIdJVXxrRWFMOAD] ]] && + (( len++ )) +return len diff --git a/scripts/Documents/Scripts/zsh/zsh-autocomplete/functions/completion/_autocomplete.history_lines b/scripts/Documents/Scripts/zsh/zsh-autocomplete/functions/completion/_autocomplete.history_lines new file mode 100644 index 0000000..744b246 --- /dev/null +++ b/scripts/Documents/Scripts/zsh/zsh-autocomplete/functions/completion/_autocomplete.history_lines @@ -0,0 +1,144 @@ +#autoload + +_autocomplete.history_lines() { + local -P tag=history-lines + _tags $tag + _tags || + return 1 + _requested $tag || + return 1 + + local -PA events=() + local -Pi min_lines= max_lines= + builtin zstyle -s ":autocomplete:${curcontext}:" list-lines min_lines || + min_lines=16 + (( max_lines = min( min_lines, HISTNO - 1, LINES - BUFFERLINES ) )) + + if [[ -z $BUFFER ]]; then + if [[ $curcontext == *-forward:* ]]; then + local -Pi inc=1 histno=1 + else + local -Pi inc=-1 histno=$(( HISTNO - 1 )) + fi + if [[ -o histfindnodups ]]; then + while (( $#events[@] < max_lines && 0 < histno && histno < HISTNO )); do + # -v's arg is a literal string, so we need to quote all characters. + [[ -v history[$histno] && ! -v events[${(q)history[$histno]}] ]] && + events[$history[$histno]]=$histno + (( histno += inc )) + done + events=( "${(@Oa)${(@kv)events}}" ) + else + while (( $#events[@] < max_lines && 0 < histno && histno < HISTNO )); do + [[ -v history[$histno] ]] && + events[$histno]="$history[$histno]" + (( histno += inc )) + done + fi + _comp_colors=( '(history-lines)=[[:space:]]#(#b)(<->) *=0=2' "$_comp_colors[@]" ) + else + local -PaU queries=() err=( '(#ia'{0..$(( $#words[CURRENT] ))}')' ) + local -P query lbuffer= rbuffer= + if [[ $WIDGET == (|*-)search(|-*) ]]; then + queries=( \*$^err${(j:*:)${(0)words[CURRENT]}}\* ) + else + lbuffer="${(j.[[:blank:]]##.)${(@b)words[1,CURRENT-1]}}" + rbuffer="${(j.[[:blank:]]##.)${(@b)words[CURRENT+1,-1]}}" + [[ -n $lbuffer ]] && + lbuffer="${lbuffer}[[:blank:]]##" + [[ -n $rbuffer ]] && + rbuffer="[[:blank:]]##${rbuffer}" + lbuffer="$lbuffer${(b)QIPREFIX}" + rbuffer="${(b)QISUFFIX}$rbuffer" + queries=( $lbuffer\*\($^err${words[CURRENT]}\)\*$rbuffer ) + fi + if [[ -o histfindnodups ]]; then + local -Pa numbers=() + for query in $queries[@]; do + numbers=( "${(@k)history[(R)$~query]}" ) + (( $#numbers[@] > 1 )) && + break + done + local -Pa lines=( "${(@v)history[(I)(${(~j:|:)numbers})]}" ) + if [[ $curcontext != *-forward:* ]]; then + numbers=( "${(@Oa)numbers}" ) + lines=( "${(@Oa)lines}" ) + fi + events=( "${(@)lines:^numbers}" ) + events=( "${(@Oa)${(@kv)events}}" ) + else + for query in $queries[@]; do + events=( "${(@kv)history[(R)$~query]}" ) + (( $#events[@] > 1 )) && + break + done + fi + _comp_colors=( + "(history-lines)=[[:space:]]#(#b)(<->) *(${${query#$lbuffer\*}%\*$rbuffer})*=0=2=30;103" + "$_comp_colors[@]" + ) + fi + + (( $#events[@] )) || + return + + local -a displays=() + printf -v displays "%s:%s" "${(@kv)events}" + displays=( "$displays[@]" ) + + local -Pi diff=$(( $#displays[@] - max_lines )) + local -P suf= + if [[ $WIDGET == (|*-)search(|-*) ]]; then + displays=( ${(@n)displays} ) + (( diff > 0 )) && + shift "$diff" displays + suf=';' + else + if [[ $curcontext == *-forward:* ]]; then + displays=( ${(@n)displays} ) + else + displays=( ${(@On)displays} ) + fi + (( diff > 0 )) && + shift -p "$diff" displays + suf=' ' + fi + + local -a matches=( "${displays[@]##[[:blank:]]#<->:}" ) + [[ $WIDGET != (|*-)search(|-*) ]] && + matches=( "${(@)${(@)matches[@]##$~lbuffer}%%$~rbuffer}" ) + + local -Pa match=() mbegin=() mend=() + displays=( + "${(@r:COLUMNS-1:)displays[@]/%(#b)(<->):(*)/${(l:$#HISTNO:)match[1]} ${(V)${(Z+C+)match[2]}}}" + ) + + local -a expl=() + local _comp_no_ignore=1 + _description -2V "$tag" expl 'history line' + builtin compadd "$expl[@]" -S "$suf" -R _autocomplete.history_lines.suffix \ + -QU -ld displays -a matches +} +# functions -T _autocomplete.history_lines + +_autocomplete.history_lines.suffix() { + case $WIDGET in + ( (|.|*-)(hist(|ory)|search|delete|kill)(|-*) ) + ;; + ( (|.)(self-insert(|-*)|magic-space) ) + case $KEYS[-1] in + ( [$ZLE_SPACE_SUFFIX_CHARS$ZLE_REMOVE_SUFFIX_CHARS] ) + LBUFFER=$LBUFFER[1,-1-$1] + ;| + ( [$ZLE_SPACE_SUFFIX_CHARS] ) + LBUFFER+=' ' + ;; + esac + ;; + ( * ) + LBUFFER=$LBUFFER[1,-1-$1] + ;; + esac +} + +_autocomplete.history_lines "$@" diff --git a/scripts/Documents/Scripts/zsh/zsh-autocomplete/functions/completion/_autocomplete.is_glob b/scripts/Documents/Scripts/zsh/zsh-autocomplete/functions/completion/_autocomplete.is_glob new file mode 100644 index 0000000..d239525 --- /dev/null +++ b/scripts/Documents/Scripts/zsh/zsh-autocomplete/functions/completion/_autocomplete.is_glob @@ -0,0 +1,12 @@ +#autoload +zmodload -F zsh/parameter p:patchars + +local word=$PREFIX$SUFFIX +if [[ $word == ${~${(q)word}} && + $word == (*(${(~j:|:)patchars[@]:#\~}})*|?*(${(~j:|:)patchars})*) ]]; then + reply=( yes ) + true +else + reply=( no ) + false +fi diff --git a/scripts/Documents/Scripts/zsh/zsh-autocomplete/functions/completion/_autocomplete.recent_paths b/scripts/Documents/Scripts/zsh/zsh-autocomplete/functions/completion/_autocomplete.recent_paths new file mode 100644 index 0000000..1ffde00 --- /dev/null +++ b/scripts/Documents/Scripts/zsh/zsh-autocomplete/functions/completion/_autocomplete.recent_paths @@ -0,0 +1,56 @@ +#autoload +zmodload -F zsh/parameter p:functions + +_autocomplete.recent_paths() { + (( compstate[nmatches] )) && + return 1 + + local -PaU files=() + local -Pi ret=1 + local -P tag= + for tag in directories files; do + if [[ -v functions[_autocomplete.recent_$tag] && + $_comp_tags == (|* )(|(all|local)-)$tag(| *) ]] && + _autocomplete.recent_$tag "$PREFIX$SUFFIX"; then + files=( "$reply[@]" ) + _description -V recent-$tag expl 'recent directory' + .autocomplete.recent_paths.add $files[@] && + ret=0 + fi + done + + return ret +} + +.autocomplete.recent_paths.add() { + local -a displ=() matches=( "$@" ) + builtin compadd "$expl[@]" -D matches -- "$@:t" + displ=( "${(@D)matches}" ) + zformat -a displ '' $^displ':' + + .autocomplete.recent_paths.trim + + local -Pi ret=1 + + # Work around `setopt autonamedirs` by not assigning absolute paths to scalars. + while (( $#matches )); do + (( $#displ[1] > 1 )) && + compadd "$expl[@]" -d displ -P "${${(D)matches[1]:h}%/}/" -fW "${${matches[1]:h}%/}/" \ + -- "$matches[1]:t" && + ret=0 + shift -- displ matches + done + + return ret +} + +# Workaround to prevent the prompt from jumping +.autocomplete.recent_paths.trim() { + local -P total="${(j:/ :)displ}/ " + while (( $#total > COLUMNS )); do + shift -p -- displ matches + total="${(j:/ :)displ}/ " + done +} + +_autocomplete.recent_paths "$@" diff --git a/scripts/Documents/Scripts/zsh/zsh-autocomplete/functions/completion/_autocomplete.requoted b/scripts/Documents/Scripts/zsh/zsh-autocomplete/functions/completion/_autocomplete.requoted new file mode 100644 index 0000000..e17933e --- /dev/null +++ b/scripts/Documents/Scripts/zsh/zsh-autocomplete/functions/completion/_autocomplete.requoted @@ -0,0 +1,22 @@ +#autoload + +local -P tag=requoted +_tags $tag +_tags && _requested $tag || + return 1 + +(( compstate[nmatches] > 1 )) && + return 1 +_autocomplete.is_glob && + return 1 +[[ $_completer == expand ]] || + return 1 + +local -P match=${(Q)compstate[unambiguous]} + +[[ $match == ($words[CURRENT]|$compstate[unambiguous]) ]] && + return 1 + +local -a expl display=( "$match" ) +_description $tag expl 'human-readable' +compadd "$expl[@]" -qS ' ' -QU -d display - ${(q+)match} diff --git a/scripts/Documents/Scripts/zsh/zsh-autocomplete/functions/completion/_autocomplete.unambiguous b/scripts/Documents/Scripts/zsh/zsh-autocomplete/functions/completion/_autocomplete.unambiguous new file mode 100644 index 0000000..f258a39 --- /dev/null +++ b/scripts/Documents/Scripts/zsh/zsh-autocomplete/functions/completion/_autocomplete.unambiguous @@ -0,0 +1,35 @@ +#autoload +# setopt localoptions verbose xtrace + +[[ -v _autocomplete__partial_list ]] && + return 1 + +(( compstate[nmatches] > 1 )) || + return 1 +[[ $curcontext == history-*:* || + $IPREFIX$PREFIX$SUFFIX$ISUFFIX == *${compstate[unambiguous]:#?}* ]] && + return 1 + +local -P tag=unambiguous +_tags $tag +_tags || + return +_requested $tag || + return + +typeset -gH _autocomplete__unambiguous="$compstate[unambiguous]" + +if builtin zstyle -t :autocomplete:tab: insert-unambiguous; then + local -Pi nxt= prv=1 + local -P subs= cols= + for nxt in ${(s.:.)compstate[unambiguous_positions]}; do + subs+='('${(b)compstate[unambiguous][prv,nxt]}')*' + cols+='=30;103' # black foreground, bright yellow background + (( prv = ++nxt )) + done + ZLS_COLORS="=(#bi)*$subs=$cols:$ZLS_COLORS" + return 1 +fi + +builtin compadd -J "$tag" \ + -x $'%{\e[0;2m%}common substring:%b %F{0}%K{11}'"$compstate[unambiguous]%f%k" diff --git a/scripts/Documents/Scripts/zsh/zsh-autocomplete/run-tests.zsh b/scripts/Documents/Scripts/zsh/zsh-autocomplete/run-tests.zsh new file mode 100644 index 0000000..8a18ca4 --- /dev/null +++ b/scripts/Documents/Scripts/zsh/zsh-autocomplete/run-tests.zsh @@ -0,0 +1,3 @@ +#!/bin/zsh -f +print $VENDOR $OSTYPE =zsh $ZSH_VERSION $ZSH_PATCHLEVEL =clitest +FPATH=$FPATH zsh -f =clitest --list-run --progress dot --prompt '%' -- ${0:h}/.clitest/*.md diff --git a/scripts/Documents/Scripts/zsh/zsh-autocomplete/zsh-autocomplete.plugin.zsh b/scripts/Documents/Scripts/zsh/zsh-autocomplete/zsh-autocomplete.plugin.zsh new file mode 100644 index 0000000..d69f448 --- /dev/null +++ b/scripts/Documents/Scripts/zsh/zsh-autocomplete/zsh-autocomplete.plugin.zsh @@ -0,0 +1,19 @@ +#!/bin/zsh +zmodload -F zsh/parameter p:funcfiletrace p:functions + +# Workaround for https://github.com/zdharma/zinit/issues/366 +# NOTE: Needs to come before _everything_ else! +[[ -v functions[.zinit-shade-off] ]] && + .zinit-shade-off "${___mode:-load}" +[[ -v functions[.zinit-tmp-subst-off] ]] && + .zinit-tmp-subst-off "${___mode:-load}" + +zmodload zsh/param/private +setopt NO_flowcontrol NO_listbeep NO_singlelinezle +typeset -gHa _autocomplete__funcfiletrace=( $funcfiletrace[2,-2] ) +builtin autoload +X -Uz ${${(%):-%x}:P:h}/scripts/.autocomplete.__init__ +{ + .autocomplete.__init__ "$@" +} always { + unfunction .autocomplete.__init__ +}