Improving Stow backward compatibility

This commit is contained in:
Fabio Scotto di Santolo
2024-11-29 16:17:59 +01:00
parent 272323c346
commit 3a93f11774
280 changed files with 11 additions and 1 deletions

View File

@@ -0,0 +1,235 @@
# fish completion for argocd -*- shell-script -*-
function __argocd_debug
set -l file "$BASH_COMP_DEBUG_FILE"
if test -n "$file"
echo "$argv" >> $file
end
end
function __argocd_perform_completion
__argocd_debug "Starting __argocd_perform_completion"
# Extract all args except the last one
set -l args (commandline -opc)
# Extract the last arg and escape it in case it is a space
set -l lastArg (string escape -- (commandline -ct))
__argocd_debug "args: $args"
__argocd_debug "last arg: $lastArg"
# Disable ActiveHelp which is not supported for fish shell
set -l requestComp "ARGOCD_ACTIVE_HELP=0 $args[1] __complete $args[2..-1] $lastArg"
__argocd_debug "Calling $requestComp"
set -l results (eval $requestComp 2> /dev/null)
# Some programs may output extra empty lines after the directive.
# Let's ignore them or else it will break completion.
# Ref: https://github.com/spf13/cobra/issues/1279
for line in $results[-1..1]
if test (string trim -- $line) = ""
# Found an empty line, remove it
set results $results[1..-2]
else
# Found non-empty line, we have our proper output
break
end
end
set -l comps $results[1..-2]
set -l directiveLine $results[-1]
# For Fish, when completing a flag with an = (e.g., <program> -n=<TAB>)
# completions must be prefixed with the flag
set -l flagPrefix (string match -r -- '-.*=' "$lastArg")
__argocd_debug "Comps: $comps"
__argocd_debug "DirectiveLine: $directiveLine"
__argocd_debug "flagPrefix: $flagPrefix"
for comp in $comps
printf "%s%s\n" "$flagPrefix" "$comp"
end
printf "%s\n" "$directiveLine"
end
# this function limits calls to __argocd_perform_completion, by caching the result behind $__argocd_perform_completion_once_result
function __argocd_perform_completion_once
__argocd_debug "Starting __argocd_perform_completion_once"
if test -n "$__argocd_perform_completion_once_result"
__argocd_debug "Seems like a valid result already exists, skipping __argocd_perform_completion"
return 0
end
set --global __argocd_perform_completion_once_result (__argocd_perform_completion)
if test -z "$__argocd_perform_completion_once_result"
__argocd_debug "No completions, probably due to a failure"
return 1
end
__argocd_debug "Performed completions and set __argocd_perform_completion_once_result"
return 0
end
# this function is used to clear the $__argocd_perform_completion_once_result variable after completions are run
function __argocd_clear_perform_completion_once_result
__argocd_debug ""
__argocd_debug "========= clearing previously set __argocd_perform_completion_once_result variable =========="
set --erase __argocd_perform_completion_once_result
__argocd_debug "Succesfully erased the variable __argocd_perform_completion_once_result"
end
function __argocd_requires_order_preservation
__argocd_debug ""
__argocd_debug "========= checking if order preservation is required =========="
__argocd_perform_completion_once
if test -z "$__argocd_perform_completion_once_result"
__argocd_debug "Error determining if order preservation is required"
return 1
end
set -l directive (string sub --start 2 $__argocd_perform_completion_once_result[-1])
__argocd_debug "Directive is: $directive"
set -l shellCompDirectiveKeepOrder 32
set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2)
__argocd_debug "Keeporder is: $keeporder"
if test $keeporder -ne 0
__argocd_debug "This does require order preservation"
return 0
end
__argocd_debug "This doesn't require order preservation"
return 1
end
# This function does two things:
# - Obtain the completions and store them in the global __argocd_comp_results
# - Return false if file completion should be performed
function __argocd_prepare_completions
__argocd_debug ""
__argocd_debug "========= starting completion logic =========="
# Start fresh
set --erase __argocd_comp_results
__argocd_perform_completion_once
__argocd_debug "Completion results: $__argocd_perform_completion_once_result"
if test -z "$__argocd_perform_completion_once_result"
__argocd_debug "No completion, probably due to a failure"
# Might as well do file completion, in case it helps
return 1
end
set -l directive (string sub --start 2 $__argocd_perform_completion_once_result[-1])
set --global __argocd_comp_results $__argocd_perform_completion_once_result[1..-2]
__argocd_debug "Completions are: $__argocd_comp_results"
__argocd_debug "Directive is: $directive"
set -l shellCompDirectiveError 1
set -l shellCompDirectiveNoSpace 2
set -l shellCompDirectiveNoFileComp 4
set -l shellCompDirectiveFilterFileExt 8
set -l shellCompDirectiveFilterDirs 16
if test -z "$directive"
set directive 0
end
set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)
if test $compErr -eq 1
__argocd_debug "Received error directive: aborting."
# Might as well do file completion, in case it helps
return 1
end
set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)
set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)
if test $filefilter -eq 1; or test $dirfilter -eq 1
__argocd_debug "File extension filtering or directory filtering not supported"
# Do full file completion instead
return 1
end
set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)
set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)
__argocd_debug "nospace: $nospace, nofiles: $nofiles"
# If we want to prevent a space, or if file completion is NOT disabled,
# we need to count the number of valid completions.
# To do so, we will filter on prefix as the completions we have received
# may not already be filtered so as to allow fish to match on different
# criteria than the prefix.
if test $nospace -ne 0; or test $nofiles -eq 0
set -l prefix (commandline -t | string escape --style=regex)
__argocd_debug "prefix: $prefix"
set -l completions (string match -r -- "^$prefix.*" $__argocd_comp_results)
set --global __argocd_comp_results $completions
__argocd_debug "Filtered completions are: $__argocd_comp_results"
# Important not to quote the variable for count to work
set -l numComps (count $__argocd_comp_results)
__argocd_debug "numComps: $numComps"
if test $numComps -eq 1; and test $nospace -ne 0
# We must first split on \t to get rid of the descriptions to be
# able to check what the actual completion will be.
# We don't need descriptions anyway since there is only a single
# real completion which the shell will expand immediately.
set -l split (string split --max 1 \t $__argocd_comp_results[1])
# Fish won't add a space if the completion ends with any
# of the following characters: @=/:.,
set -l lastChar (string sub -s -1 -- $split)
if not string match -r -q "[@=/:.,]" -- "$lastChar"
# In other cases, to support the "nospace" directive we trick the shell
# by outputting an extra, longer completion.
__argocd_debug "Adding second completion to perform nospace directive"
set --global __argocd_comp_results $split[1] $split[1].
__argocd_debug "Completions are now: $__argocd_comp_results"
end
end
if test $numComps -eq 0; and test $nofiles -eq 0
# To be consistent with bash and zsh, we only trigger file
# completion when there are no other completions
__argocd_debug "Requesting file completion"
return 1
end
end
return 0
end
# Since Fish completions are only loaded once the user triggers them, we trigger them ourselves
# so we can properly delete any completions provided by another script.
# Only do this if the program can be found, or else fish may print some errors; besides,
# the existing completions will only be loaded if the program can be found.
if type -q "argocd"
# The space after the program name is essential to trigger completion for the program
# and not completion of the program name itself.
# Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.
complete --do-complete "argocd " > /dev/null 2>&1
end
# Remove any pre-existing completions for the program since we will be handling all of them.
complete -c argocd -e
# this will get called after the two calls below and clear the $__argocd_perform_completion_once_result global
complete -c argocd -n '__argocd_clear_perform_completion_once_result'
# The call to __argocd_prepare_completions will setup __argocd_comp_results
# which provides the program's completion choices.
# If this doesn't require order preservation, we don't use the -k flag
complete -c argocd -n 'not __argocd_requires_order_preservation && __argocd_prepare_completions' -f -a '$__argocd_comp_results'
# otherwise we use the -k flag
complete -k -c argocd -n '__argocd_requires_order_preservation && __argocd_prepare_completions' -f -a '$__argocd_comp_results'

View File

@@ -0,0 +1,107 @@
complete -c delta -l blame-code-style -d 'Style string for the code section of a git blame line' -r
complete -c delta -l blame-format -d 'Format string for git blame commit metadata' -r
complete -c delta -l blame-palette -d 'Background colors used for git blame lines (space-separated string)' -r
complete -c delta -l blame-separator-format -d 'Separator between the blame format and the code section of a git blame line' -r
complete -c delta -l blame-separator-style -d 'Style string for the blame-separator-format' -r
complete -c delta -l blame-timestamp-format -d 'Format of `git blame` timestamp in raw git output received by delta' -r
complete -c delta -l blame-timestamp-output-format -d 'Format string for git blame timestamp output' -r
complete -c delta -l config -d 'Load the config file at PATH instead of ~/.gitconfig' -r -F
complete -c delta -l commit-decoration-style -d 'Style string for the commit hash decoration' -r
complete -c delta -l commit-regex -d 'Regular expression used to identify the commit line when parsing git output' -r
complete -c delta -l commit-style -d 'Style string for the commit hash line' -r
complete -c delta -l default-language -d 'Default language used for syntax highlighting' -r
complete -c delta -l detect-dark-light -d 'Detect whether or not the terminal is dark or light by querying for its colors' -r -f -a "{auto 'Only query the terminal for its colors if the output is not redirected',always 'Always query the terminal for its colors',never 'Never query the terminal for its colors'}"
complete -c delta -l diff-stat-align-width -d 'Width allocated for file paths in a diff stat section' -r
complete -c delta -l features -d 'Names of delta features to activate (space-separated)' -r
complete -c delta -l file-added-label -d 'Text to display before an added file path' -r
complete -c delta -l file-copied-label -d 'Text to display before a copied file path' -r
complete -c delta -l file-decoration-style -d 'Style string for the file decoration' -r
complete -c delta -l file-modified-label -d 'Text to display before a modified file path' -r
complete -c delta -l file-removed-label -d 'Text to display before a removed file path' -r
complete -c delta -l file-renamed-label -d 'Text to display before a renamed file path' -r
complete -c delta -l file-style -d 'Style string for the file section' -r
complete -c delta -l file-transformation -d 'Sed-style command transforming file paths for display' -r
complete -c delta -l generate-completion -d 'Print completion file for the given shell' -r -f -a "{bash '',elvish '',fish '',powershell '',zsh ''}"
complete -c delta -l grep-context-line-style -d 'Style string for non-matching lines of grep output' -r
complete -c delta -l grep-file-style -d 'Style string for file paths in grep output' -r
complete -c delta -l grep-header-decoration-style -d 'Style string for the header decoration in grep output' -r
complete -c delta -l grep-header-file-style -d 'Style string for the file path part of the header in grep output' -r
complete -c delta -l grep-line-number-style -d 'Style string for line numbers in grep output' -r
complete -c delta -l grep-output-type -d 'Grep output format. Possible values: "ripgrep" - file name printed once, followed by matching lines within that file, each preceded by a line number. "classic" - file name:line number, followed by matching line. Default is "ripgrep" if `rg --json` format is detected, otherwise "classic"' -r -f -a "{ripgrep '',classic ''}"
complete -c delta -l grep-match-line-style -d 'Style string for matching lines of grep output' -r
complete -c delta -l grep-match-word-style -d 'Style string for the matching substrings within a matching line of grep output' -r
complete -c delta -l grep-separator-symbol -d 'Separator symbol printed after the file path and line number in grep output' -r
complete -c delta -l hunk-header-decoration-style -d 'Style string for the hunk-header decoration' -r
complete -c delta -l hunk-header-file-style -d 'Style string for the file path part of the hunk-header' -r
complete -c delta -l hunk-header-line-number-style -d 'Style string for the line number part of the hunk-header' -r
complete -c delta -l hunk-header-style -d 'Style string for the hunk-header' -r
complete -c delta -l hunk-label -d 'Text to display before a hunk header' -r
complete -c delta -l hyperlinks-commit-link-format -d 'Format string for commit hyperlinks (requires --hyperlinks)' -r
complete -c delta -l hyperlinks-file-link-format -d 'Format string for file hyperlinks (requires --hyperlinks)' -r
complete -c delta -l inline-hint-style -d 'Style string for short inline hint text' -r
complete -c delta -l inspect-raw-lines -d 'Kill-switch for --color-moved support' -r -f -a "{true '',false ''}"
complete -c delta -l line-buffer-size -d 'Size of internal line buffer' -r
complete -c delta -l line-fill-method -d 'Line-fill method in side-by-side mode' -r -f -a "{ansi '',spaces ''}"
complete -c delta -l line-numbers-left-format -d 'Format string for the left column of line numbers' -r
complete -c delta -l line-numbers-left-style -d 'Style string for the left column of line numbers' -r
complete -c delta -l line-numbers-minus-style -d 'Style string for line numbers in the old (minus) version of the file' -r
complete -c delta -l line-numbers-plus-style -d 'Style string for line numbers in the new (plus) version of the file' -r
complete -c delta -l line-numbers-right-format -d 'Format string for the right column of line numbers' -r
complete -c delta -l line-numbers-right-style -d 'Style string for the right column of line numbers' -r
complete -c delta -l line-numbers-zero-style -d 'Style string for line numbers in unchanged (zero) lines' -r
complete -c delta -l map-styles -d 'Map styles encountered in raw input to desired output styles' -r
complete -c delta -l max-line-distance -d 'Maximum line pair distance parameter in within-line diff algorithm' -r
complete -c delta -l max-line-length -d 'Truncate lines longer than this' -r
complete -c delta -l merge-conflict-begin-symbol -d 'String marking the beginning of a merge conflict region' -r
complete -c delta -l merge-conflict-end-symbol -d 'String marking the end of a merge conflict region' -r
complete -c delta -l merge-conflict-ours-diff-header-decoration-style -d 'Style string for the decoration of the header above the \'ours\' merge conflict diff' -r
complete -c delta -l merge-conflict-ours-diff-header-style -d 'Style string for the header above the \'ours\' branch merge conflict diff' -r
complete -c delta -l merge-conflict-theirs-diff-header-decoration-style -d 'Style string for the decoration of the header above the \'theirs\' merge conflict diff' -r
complete -c delta -l merge-conflict-theirs-diff-header-style -d 'Style string for the header above the \'theirs\' branch merge conflict diff' -r
complete -c delta -l minus-empty-line-marker-style -d 'Style string for removed empty line marker' -r
complete -c delta -l minus-emph-style -d 'Style string for emphasized sections of removed lines' -r
complete -c delta -l minus-non-emph-style -d 'Style string for non-emphasized sections of removed lines that have an emphasized section' -r
complete -c delta -l minus-style -d 'Style string for removed lines' -r
complete -c delta -l navigate-regex -d 'Regular expression defining navigation stop points' -r
complete -c delta -l pager -d 'Which pager to use' -r
complete -c delta -l paging -d 'Whether to use a pager when displaying output' -r -f -a "{auto '',always '',never ''}"
complete -c delta -l plus-emph-style -d 'Style string for emphasized sections of added lines' -r
complete -c delta -l plus-empty-line-marker-style -d 'Style string for added empty line marker' -r
complete -c delta -l plus-non-emph-style -d 'Style string for non-emphasized sections of added lines that have an emphasized section' -r
complete -c delta -l plus-style -d 'Style string for added lines' -r
complete -c delta -l right-arrow -d 'Text to display with a changed file path' -r
complete -c delta -l syntax-theme -d 'The syntax-highlighting theme to use' -r
complete -c delta -l tabs -d 'The number of spaces to replace tab characters with' -r
complete -c delta -l true-color -d 'Whether to emit 24-bit ("true color") RGB color codes' -r -f -a "{auto '',always '',never ''}"
complete -c delta -l whitespace-error-style -d 'Style string for whitespace errors' -r
complete -c delta -s w -l width -d 'The width of underline/overline decorations' -r
complete -c delta -l word-diff-regex -d 'Regular expression defining a \'word\' in within-line diff algorithm' -r
complete -c delta -l wrap-left-symbol -d 'End-of-line wrapped content symbol (left-aligned)' -r
complete -c delta -l wrap-max-lines -d 'How often a line should be wrapped if it does not fit' -r
complete -c delta -l wrap-right-percent -d 'Threshold for right-aligning wrapped content' -r
complete -c delta -l wrap-right-prefix-symbol -d 'Pre-wrapped content symbol (right-aligned)' -r
complete -c delta -l wrap-right-symbol -d 'End-of-line wrapped content symbol (right-aligned)' -r
complete -c delta -l zero-style -d 'Style string for unchanged lines' -r
complete -c delta -l 24-bit-color -d 'Deprecated: use --true-color' -r -f -a "{auto '',always '',never ''}"
complete -c delta -l color-only -d 'Do not alter the input structurally in any way'
complete -c delta -l dark -d 'Use default colors appropriate for a dark terminal background'
complete -c delta -l diff-highlight -d 'Emulate diff-highlight'
complete -c delta -l diff-so-fancy -d 'Emulate diff-so-fancy'
complete -c delta -l hyperlinks -d 'Render commit hashes, file names, and line numbers as hyperlinks'
complete -c delta -l keep-plus-minus-markers -d 'Prefix added/removed lines with a +/- character, as git does'
complete -c delta -l light -d 'Use default colors appropriate for a light terminal background'
complete -c delta -s n -l line-numbers -d 'Display line numbers next to the diff'
complete -c delta -l list-languages -d 'List supported languages and associated file extensions'
complete -c delta -l list-syntax-themes -d 'List available syntax-highlighting color themes'
complete -c delta -l navigate -d 'Activate diff navigation'
complete -c delta -l no-gitconfig -d 'Do not read any settings from git config'
complete -c delta -l parse-ansi -d 'Display ANSI color escape sequences in human-readable form'
complete -c delta -l raw -d 'Do not alter the input in any way'
complete -c delta -l relative-paths -d 'Output all file paths relative to the current directory'
complete -c delta -l show-colors -d 'Show available named colors'
complete -c delta -l show-config -d 'Display the active values for all Delta options'
complete -c delta -l show-syntax-themes -d 'Show example diff for available syntax-highlighting themes'
complete -c delta -l show-themes -d 'Show example diff for available delta themes'
complete -c delta -s s -l side-by-side -d 'Display diffs in side-by-side layout'
complete -c delta -s h -l help -d 'Print help (see more with \'--help\')'
complete -c delta -s V -l version -d 'Print version'

View File

@@ -0,0 +1,54 @@
# Configure
complete -f -c exercism -n "__fish_use_subcommand" -a "configure" -d "Writes config values to a JSON file."
complete -f -c exercism -n "__fish_seen_subcommand_from configure" -s t -l token -d "Set token"
complete -f -c exercism -n "__fish_seen_subcommand_from configure" -s w -l workspace -d "Set workspace"
complete -f -c exercism -n "__fish_seen_subcommand_from configure" -s a -l api -d "set API base url"
complete -f -c exercism -n "__fish_seen_subcommand_from configure" -s s -l show -d "show settings"
# Download
complete -f -c exercism -n "__fish_use_subcommand" -a "download" -d "Downloads and saves a specified submission into the local system"
complete -f -c exercism -n "__fish_seen_subcommand_from download" -s e -l exercise -d "the exercise slug"
complete -f -c exercism -n "__fish_seen_subcommand_from download" -s h -l help -d "help for download"
complete -f -c exercism -n "__fish_seen_subcommand_from download" -s T -l team -d "the team slug"
complete -f -c exercism -n "__fish_seen_subcommand_from download" -s t -l track -d "the track ID"
complete -f -c exercism -n "__fish_seen_subcommand_from download" -s u -l uuid -d "the solution UUID"
# Help
complete -f -c exercism -n "__fish_use_subcommand" -a "help" -d "Shows a list of commands or help for one command"
complete -f -c exercism -n "__fish_seen_subcommand_from help" -a "configure download help open submit troubleshoot upgrade version workspace"
# Open
complete -f -c exercism -n "__fish_use_subcommand" -a "open" -d "Opens a browser to exercism.io for the specified submission."
complete -f -c exercism -n "__fish_seen_subcommand_from open" -s h -l help -d "help for open"
# Submit
complete -f -c exercism -n "__fish_use_subcommand" -a "submit" -d "Submits a new iteration to a problem on exercism.io."
complete -f -c exercism -n "__fish_seen_subcommand_from submit" -s h -l help -d "help for submit"
# Troubleshoot
complete -f -c exercism -n "__fish_use_subcommand" -a "troubleshoot" -d "Outputs useful debug information."
complete -f -c exercism -n "__fish_seen_subcommand_from troubleshoot" -s f -l full-api-key -d "display full API key (censored by default)"
complete -f -c exercism -n "__fish_seen_subcommand_from troubleshoot" -s h -l help -d "help for troubleshoot"
# Upgrade
complete -f -c exercism -n "__fish_use_subcommand" -a "upgrade" -d "Upgrades to the latest available version."
complete -f -c exercism -n "__fish_seen_subcommand_from help" -s h -l help -d "help for help"
# Version
complete -f -c exercism -n "__fish_use_subcommand" -a "version" -d "Outputs version information."
complete -f -c exercism -n "__fish_seen_subcommand_from version" -s l -l latest -d "check latest available version"
complete -f -c exercism -n "__fish_seen_subcommand_from version" -s h -l help -d "help for version"
# Workspace
complete -f -c exercism -n "__fish_use_subcommand" -a "workspace" -d "Outputs the root directory for Exercism exercises."
complete -f -c exercism -n "__fish_seen_subcommand_from workspace" -s h -l help -d "help for workspace"
# Options
complete -f -c exercism -s h -l help -d "show help"
complete -f -c exercism -l timeout -a "10" -d "10 seconds"
complete -f -c exercism -l timeout -a "30" -d "30 seconds"
complete -f -c exercism -l timeout -a "60" -d "1 minute"
complete -f -c exercism -l timeout -a "300" -d "5 minutes"
complete -f -c exercism -l timeout -a "600" -d "10 minutes"
complete -f -c exercism -l timeout -a "" -d "override default HTTP timeout"
complete -f -c exercism -s v -l verbose -d "turn on verbose logging"

View File

@@ -0,0 +1,7 @@
complete --command fisher --exclusive --long help --description "Print help"
complete --command fisher --exclusive --long version --description "Print version"
complete --command fisher --exclusive --condition __fish_use_subcommand --arguments install --description "Install plugins"
complete --command fisher --exclusive --condition __fish_use_subcommand --arguments update --description "Update installed plugins"
complete --command fisher --exclusive --condition __fish_use_subcommand --arguments remove --description "Remove installed plugins"
complete --command fisher --exclusive --condition __fish_use_subcommand --arguments list --description "List installed plugins matching regex"
complete --command fisher --exclusive --condition "__fish_seen_subcommand_from update remove" --arguments "(fisher list)"

View File

@@ -0,0 +1,8 @@
complete fzf_configure_bindings --no-files
complete fzf_configure_bindings --long help --short h --description "Print help" --condition "not __fish_seen_argument --help -h"
complete fzf_configure_bindings --long directory --description "Change the key binding for Search Directory" --condition "not __fish_seen_argument --directory"
complete fzf_configure_bindings --long git_log --description "Change the key binding for Search Git Log" --condition "not __fish_seen_argument --git_log"
complete fzf_configure_bindings --long git_status --description "Change the key binding for Search Git Status" --condition "not __fish_seen_argument --git_status"
complete fzf_configure_bindings --long history --description "Change the key binding for Search History" --condition "not __fish_seen_argument --history"
complete fzf_configure_bindings --long processes --description "Change the key binding for Search Processes" --condition "not __fish_seen_argument --processes"
complete fzf_configure_bindings --long variables --description "Change the key binding for Search Variables" --condition "not __fish_seen_argument --variables"

View File

@@ -0,0 +1,177 @@
# fish completion for glow -*- shell-script -*-
function __glow_debug
set -l file "$BASH_COMP_DEBUG_FILE"
if test -n "$file"
echo "$argv" >> $file
end
end
function __glow_perform_completion
__glow_debug "Starting __glow_perform_completion"
# Extract all args except the last one
set -l args (commandline -opc)
# Extract the last arg and escape it in case it is a space
set -l lastArg (string escape -- (commandline -ct))
__glow_debug "args: $args"
__glow_debug "last arg: $lastArg"
# Disable ActiveHelp which is not supported for fish shell
set -l requestComp "GLOW_ACTIVE_HELP=0 $args[1] __complete $args[2..-1] $lastArg"
__glow_debug "Calling $requestComp"
set -l results (eval $requestComp 2> /dev/null)
# Some programs may output extra empty lines after the directive.
# Let's ignore them or else it will break completion.
# Ref: https://github.com/spf13/cobra/issues/1279
for line in $results[-1..1]
if test (string trim -- $line) = ""
# Found an empty line, remove it
set results $results[1..-2]
else
# Found non-empty line, we have our proper output
break
end
end
set -l comps $results[1..-2]
set -l directiveLine $results[-1]
# For Fish, when completing a flag with an = (e.g., <program> -n=<TAB>)
# completions must be prefixed with the flag
set -l flagPrefix (string match -r -- '-.*=' "$lastArg")
__glow_debug "Comps: $comps"
__glow_debug "DirectiveLine: $directiveLine"
__glow_debug "flagPrefix: $flagPrefix"
for comp in $comps
printf "%s%s\n" "$flagPrefix" "$comp"
end
printf "%s\n" "$directiveLine"
end
# This function does two things:
# - Obtain the completions and store them in the global __glow_comp_results
# - Return false if file completion should be performed
function __glow_prepare_completions
__glow_debug ""
__glow_debug "========= starting completion logic =========="
# Start fresh
set --erase __glow_comp_results
set -l results (__glow_perform_completion)
__glow_debug "Completion results: $results"
if test -z "$results"
__glow_debug "No completion, probably due to a failure"
# Might as well do file completion, in case it helps
return 1
end
set -l directive (string sub --start 2 $results[-1])
set --global __glow_comp_results $results[1..-2]
__glow_debug "Completions are: $__glow_comp_results"
__glow_debug "Directive is: $directive"
set -l shellCompDirectiveError 1
set -l shellCompDirectiveNoSpace 2
set -l shellCompDirectiveNoFileComp 4
set -l shellCompDirectiveFilterFileExt 8
set -l shellCompDirectiveFilterDirs 16
if test -z "$directive"
set directive 0
end
set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)
if test $compErr -eq 1
__glow_debug "Received error directive: aborting."
# Might as well do file completion, in case it helps
return 1
end
set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)
set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)
if test $filefilter -eq 1; or test $dirfilter -eq 1
__glow_debug "File extension filtering or directory filtering not supported"
# Do full file completion instead
return 1
end
set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)
set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)
__glow_debug "nospace: $nospace, nofiles: $nofiles"
# If we want to prevent a space, or if file completion is NOT disabled,
# we need to count the number of valid completions.
# To do so, we will filter on prefix as the completions we have received
# may not already be filtered so as to allow fish to match on different
# criteria than the prefix.
if test $nospace -ne 0; or test $nofiles -eq 0
set -l prefix (commandline -t | string escape --style=regex)
__glow_debug "prefix: $prefix"
set -l completions (string match -r -- "^$prefix.*" $__glow_comp_results)
set --global __glow_comp_results $completions
__glow_debug "Filtered completions are: $__glow_comp_results"
# Important not to quote the variable for count to work
set -l numComps (count $__glow_comp_results)
__glow_debug "numComps: $numComps"
if test $numComps -eq 1; and test $nospace -ne 0
# We must first split on \t to get rid of the descriptions to be
# able to check what the actual completion will be.
# We don't need descriptions anyway since there is only a single
# real completion which the shell will expand immediately.
set -l split (string split --max 1 \t $__glow_comp_results[1])
# Fish won't add a space if the completion ends with any
# of the following characters: @=/:.,
set -l lastChar (string sub -s -1 -- $split)
if not string match -r -q "[@=/:.,]" -- "$lastChar"
# In other cases, to support the "nospace" directive we trick the shell
# by outputting an extra, longer completion.
__glow_debug "Adding second completion to perform nospace directive"
set --global __glow_comp_results $split[1] $split[1].
__glow_debug "Completions are now: $__glow_comp_results"
end
end
if test $numComps -eq 0; and test $nofiles -eq 0
# To be consistent with bash and zsh, we only trigger file
# completion when there are no other completions
__glow_debug "Requesting file completion"
return 1
end
end
return 0
end
# Since Fish completions are only loaded once the user triggers them, we trigger them ourselves
# so we can properly delete any completions provided by another script.
# Only do this if the program can be found, or else fish may print some errors; besides,
# the existing completions will only be loaded if the program can be found.
if type -q "glow"
# The space after the program name is essential to trigger completion for the program
# and not completion of the program name itself.
# Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.
complete --do-complete "glow " > /dev/null 2>&1
end
# Remove any pre-existing completions for the program since we will be handling all of them.
complete -c glow -e
# The call to __glow_prepare_completions will setup __glow_comp_results
# which provides the program's completion choices.
complete -c glow -n '__glow_prepare_completions' -f -a '$__glow_comp_results'

View File

@@ -0,0 +1,38 @@
set GO_TASK_PROGNAME task
function __task_get_tasks --description "Prints all available tasks with their description"
# Read the list of tasks (and potential errors)
$GO_TASK_PROGNAME --list-all 2>&1 | read -lz rawOutput
# Return on non-zero exit code (for cases when there is no Taskfile found or etc.)
if test $status -ne 0
return
end
# Grab names and descriptions (if any) of the tasks
set -l output (echo $rawOutput | sed -e '1d; s/\* \(.*\):\s*\(.*\)\s*(\(aliases.*\))/\1\t\2\t\3/' -e 's/\* \(.*\):\s*\(.*\)/\1\t\2/'| string split0)
if test $output
echo $output
end
end
complete -c $GO_TASK_PROGNAME -d 'Runs the specified task(s). Falls back to the "default" task if no task name was specified, or lists all tasks if an unknown task name was
specified.' -xa "(__task_get_tasks)"
complete -c $GO_TASK_PROGNAME -s c -l color -d 'colored output (default true)'
complete -c $GO_TASK_PROGNAME -s d -l dir -d 'sets directory of execution'
complete -c $GO_TASK_PROGNAME -l dry -d 'compiles and prints tasks in the order that they would be run, without executing them'
complete -c $GO_TASK_PROGNAME -s f -l force -d 'forces execution even when the task is up-to-date'
complete -c $GO_TASK_PROGNAME -s h -l help -d 'shows Task usage'
complete -c $GO_TASK_PROGNAME -s i -l init -d 'creates a new Taskfile.yml in the current folder'
complete -c $GO_TASK_PROGNAME -s l -l list -d 'lists tasks with description of current Taskfile'
complete -c $GO_TASK_PROGNAME -s o -l output -d 'sets output style: [interleaved|group|prefixed]' -xa "interleaved group prefixed"
complete -c $GO_TASK_PROGNAME -s p -l parallel -d 'executes tasks provided on command line in parallel'
complete -c $GO_TASK_PROGNAME -s s -l silent -d 'disables echoing'
complete -c $GO_TASK_PROGNAME -l status -d 'exits with non-zero exit code if any of the given tasks is not up-to-date'
complete -c $GO_TASK_PROGNAME -l summary -d 'show summary about a task'
complete -c $GO_TASK_PROGNAME -s t -l taskfile -d 'choose which Taskfile to run. Defaults to "Taskfile.yml"'
complete -c $GO_TASK_PROGNAME -s v -l verbose -d 'enables verbose mode'
complete -c $GO_TASK_PROGNAME -l version -d 'show Task version'
complete -c $GO_TASK_PROGNAME -s w -l watch -d 'enables watch of the given task'

View File

@@ -0,0 +1,235 @@
# fish completion for helm -*- shell-script -*-
function __helm_debug
set -l file "$BASH_COMP_DEBUG_FILE"
if test -n "$file"
echo "$argv" >> $file
end
end
function __helm_perform_completion
__helm_debug "Starting __helm_perform_completion"
# Extract all args except the last one
set -l args (commandline -opc)
# Extract the last arg and escape it in case it is a space
set -l lastArg (string escape -- (commandline -ct))
__helm_debug "args: $args"
__helm_debug "last arg: $lastArg"
# Disable ActiveHelp which is not supported for fish shell
set -l requestComp "HELM_ACTIVE_HELP=0 $args[1] __complete $args[2..-1] $lastArg"
__helm_debug "Calling $requestComp"
set -l results (eval $requestComp 2> /dev/null)
# Some programs may output extra empty lines after the directive.
# Let's ignore them or else it will break completion.
# Ref: https://github.com/spf13/cobra/issues/1279
for line in $results[-1..1]
if test (string trim -- $line) = ""
# Found an empty line, remove it
set results $results[1..-2]
else
# Found non-empty line, we have our proper output
break
end
end
set -l comps $results[1..-2]
set -l directiveLine $results[-1]
# For Fish, when completing a flag with an = (e.g., <program> -n=<TAB>)
# completions must be prefixed with the flag
set -l flagPrefix (string match -r -- '-.*=' "$lastArg")
__helm_debug "Comps: $comps"
__helm_debug "DirectiveLine: $directiveLine"
__helm_debug "flagPrefix: $flagPrefix"
for comp in $comps
printf "%s%s\n" "$flagPrefix" "$comp"
end
printf "%s\n" "$directiveLine"
end
# this function limits calls to __helm_perform_completion, by caching the result behind $__helm_perform_completion_once_result
function __helm_perform_completion_once
__helm_debug "Starting __helm_perform_completion_once"
if test -n "$__helm_perform_completion_once_result"
__helm_debug "Seems like a valid result already exists, skipping __helm_perform_completion"
return 0
end
set --global __helm_perform_completion_once_result (__helm_perform_completion)
if test -z "$__helm_perform_completion_once_result"
__helm_debug "No completions, probably due to a failure"
return 1
end
__helm_debug "Performed completions and set __helm_perform_completion_once_result"
return 0
end
# this function is used to clear the $__helm_perform_completion_once_result variable after completions are run
function __helm_clear_perform_completion_once_result
__helm_debug ""
__helm_debug "========= clearing previously set __helm_perform_completion_once_result variable =========="
set --erase __helm_perform_completion_once_result
__helm_debug "Successfully erased the variable __helm_perform_completion_once_result"
end
function __helm_requires_order_preservation
__helm_debug ""
__helm_debug "========= checking if order preservation is required =========="
__helm_perform_completion_once
if test -z "$__helm_perform_completion_once_result"
__helm_debug "Error determining if order preservation is required"
return 1
end
set -l directive (string sub --start 2 $__helm_perform_completion_once_result[-1])
__helm_debug "Directive is: $directive"
set -l shellCompDirectiveKeepOrder 32
set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2)
__helm_debug "Keeporder is: $keeporder"
if test $keeporder -ne 0
__helm_debug "This does require order preservation"
return 0
end
__helm_debug "This doesn't require order preservation"
return 1
end
# This function does two things:
# - Obtain the completions and store them in the global __helm_comp_results
# - Return false if file completion should be performed
function __helm_prepare_completions
__helm_debug ""
__helm_debug "========= starting completion logic =========="
# Start fresh
set --erase __helm_comp_results
__helm_perform_completion_once
__helm_debug "Completion results: $__helm_perform_completion_once_result"
if test -z "$__helm_perform_completion_once_result"
__helm_debug "No completion, probably due to a failure"
# Might as well do file completion, in case it helps
return 1
end
set -l directive (string sub --start 2 $__helm_perform_completion_once_result[-1])
set --global __helm_comp_results $__helm_perform_completion_once_result[1..-2]
__helm_debug "Completions are: $__helm_comp_results"
__helm_debug "Directive is: $directive"
set -l shellCompDirectiveError 1
set -l shellCompDirectiveNoSpace 2
set -l shellCompDirectiveNoFileComp 4
set -l shellCompDirectiveFilterFileExt 8
set -l shellCompDirectiveFilterDirs 16
if test -z "$directive"
set directive 0
end
set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)
if test $compErr -eq 1
__helm_debug "Received error directive: aborting."
# Might as well do file completion, in case it helps
return 1
end
set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)
set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)
if test $filefilter -eq 1; or test $dirfilter -eq 1
__helm_debug "File extension filtering or directory filtering not supported"
# Do full file completion instead
return 1
end
set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)
set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)
__helm_debug "nospace: $nospace, nofiles: $nofiles"
# If we want to prevent a space, or if file completion is NOT disabled,
# we need to count the number of valid completions.
# To do so, we will filter on prefix as the completions we have received
# may not already be filtered so as to allow fish to match on different
# criteria than the prefix.
if test $nospace -ne 0; or test $nofiles -eq 0
set -l prefix (commandline -t | string escape --style=regex)
__helm_debug "prefix: $prefix"
set -l completions (string match -r -- "^$prefix.*" $__helm_comp_results)
set --global __helm_comp_results $completions
__helm_debug "Filtered completions are: $__helm_comp_results"
# Important not to quote the variable for count to work
set -l numComps (count $__helm_comp_results)
__helm_debug "numComps: $numComps"
if test $numComps -eq 1; and test $nospace -ne 0
# We must first split on \t to get rid of the descriptions to be
# able to check what the actual completion will be.
# We don't need descriptions anyway since there is only a single
# real completion which the shell will expand immediately.
set -l split (string split --max 1 \t $__helm_comp_results[1])
# Fish won't add a space if the completion ends with any
# of the following characters: @=/:.,
set -l lastChar (string sub -s -1 -- $split)
if not string match -r -q "[@=/:.,]" -- "$lastChar"
# In other cases, to support the "nospace" directive we trick the shell
# by outputting an extra, longer completion.
__helm_debug "Adding second completion to perform nospace directive"
set --global __helm_comp_results $split[1] $split[1].
__helm_debug "Completions are now: $__helm_comp_results"
end
end
if test $numComps -eq 0; and test $nofiles -eq 0
# To be consistent with bash and zsh, we only trigger file
# completion when there are no other completions
__helm_debug "Requesting file completion"
return 1
end
end
return 0
end
# Since Fish completions are only loaded once the user triggers them, we trigger them ourselves
# so we can properly delete any completions provided by another script.
# Only do this if the program can be found, or else fish may print some errors; besides,
# the existing completions will only be loaded if the program can be found.
if type -q "helm"
# The space after the program name is essential to trigger completion for the program
# and not completion of the program name itself.
# Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.
complete --do-complete "helm " > /dev/null 2>&1
end
# Remove any pre-existing completions for the program since we will be handling all of them.
complete -c helm -e
# this will get called after the two calls below and clear the $__helm_perform_completion_once_result global
complete -c helm -n '__helm_clear_perform_completion_once_result'
# The call to __helm_prepare_completions will setup __helm_comp_results
# which provides the program's completion choices.
# If this doesn't require order preservation, we don't use the -k flag
complete -c helm -n 'not __helm_requires_order_preservation && __helm_prepare_completions' -f -a '$__helm_comp_results'
# otherwise we use the -k flag
complete -k -c helm -n '__helm_requires_order_preservation && __helm_prepare_completions' -f -a '$__helm_comp_results'

View File

@@ -0,0 +1,235 @@
# fish completion for k9s -*- shell-script -*-
function __k9s_debug
set -l file "$BASH_COMP_DEBUG_FILE"
if test -n "$file"
echo "$argv" >> $file
end
end
function __k9s_perform_completion
__k9s_debug "Starting __k9s_perform_completion"
# Extract all args except the last one
set -l args (commandline -opc)
# Extract the last arg and escape it in case it is a space
set -l lastArg (string escape -- (commandline -ct))
__k9s_debug "args: $args"
__k9s_debug "last arg: $lastArg"
# Disable ActiveHelp which is not supported for fish shell
set -l requestComp "K9S_ACTIVE_HELP=0 $args[1] __complete $args[2..-1] $lastArg"
__k9s_debug "Calling $requestComp"
set -l results (eval $requestComp 2> /dev/null)
# Some programs may output extra empty lines after the directive.
# Let's ignore them or else it will break completion.
# Ref: https://github.com/spf13/cobra/issues/1279
for line in $results[-1..1]
if test (string trim -- $line) = ""
# Found an empty line, remove it
set results $results[1..-2]
else
# Found non-empty line, we have our proper output
break
end
end
set -l comps $results[1..-2]
set -l directiveLine $results[-1]
# For Fish, when completing a flag with an = (e.g., <program> -n=<TAB>)
# completions must be prefixed with the flag
set -l flagPrefix (string match -r -- '-.*=' "$lastArg")
__k9s_debug "Comps: $comps"
__k9s_debug "DirectiveLine: $directiveLine"
__k9s_debug "flagPrefix: $flagPrefix"
for comp in $comps
printf "%s%s\n" "$flagPrefix" "$comp"
end
printf "%s\n" "$directiveLine"
end
# this function limits calls to __k9s_perform_completion, by caching the result behind $__k9s_perform_completion_once_result
function __k9s_perform_completion_once
__k9s_debug "Starting __k9s_perform_completion_once"
if test -n "$__k9s_perform_completion_once_result"
__k9s_debug "Seems like a valid result already exists, skipping __k9s_perform_completion"
return 0
end
set --global __k9s_perform_completion_once_result (__k9s_perform_completion)
if test -z "$__k9s_perform_completion_once_result"
__k9s_debug "No completions, probably due to a failure"
return 1
end
__k9s_debug "Performed completions and set __k9s_perform_completion_once_result"
return 0
end
# this function is used to clear the $__k9s_perform_completion_once_result variable after completions are run
function __k9s_clear_perform_completion_once_result
__k9s_debug ""
__k9s_debug "========= clearing previously set __k9s_perform_completion_once_result variable =========="
set --erase __k9s_perform_completion_once_result
__k9s_debug "Successfully erased the variable __k9s_perform_completion_once_result"
end
function __k9s_requires_order_preservation
__k9s_debug ""
__k9s_debug "========= checking if order preservation is required =========="
__k9s_perform_completion_once
if test -z "$__k9s_perform_completion_once_result"
__k9s_debug "Error determining if order preservation is required"
return 1
end
set -l directive (string sub --start 2 $__k9s_perform_completion_once_result[-1])
__k9s_debug "Directive is: $directive"
set -l shellCompDirectiveKeepOrder 32
set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2)
__k9s_debug "Keeporder is: $keeporder"
if test $keeporder -ne 0
__k9s_debug "This does require order preservation"
return 0
end
__k9s_debug "This doesn't require order preservation"
return 1
end
# This function does two things:
# - Obtain the completions and store them in the global __k9s_comp_results
# - Return false if file completion should be performed
function __k9s_prepare_completions
__k9s_debug ""
__k9s_debug "========= starting completion logic =========="
# Start fresh
set --erase __k9s_comp_results
__k9s_perform_completion_once
__k9s_debug "Completion results: $__k9s_perform_completion_once_result"
if test -z "$__k9s_perform_completion_once_result"
__k9s_debug "No completion, probably due to a failure"
# Might as well do file completion, in case it helps
return 1
end
set -l directive (string sub --start 2 $__k9s_perform_completion_once_result[-1])
set --global __k9s_comp_results $__k9s_perform_completion_once_result[1..-2]
__k9s_debug "Completions are: $__k9s_comp_results"
__k9s_debug "Directive is: $directive"
set -l shellCompDirectiveError 1
set -l shellCompDirectiveNoSpace 2
set -l shellCompDirectiveNoFileComp 4
set -l shellCompDirectiveFilterFileExt 8
set -l shellCompDirectiveFilterDirs 16
if test -z "$directive"
set directive 0
end
set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)
if test $compErr -eq 1
__k9s_debug "Received error directive: aborting."
# Might as well do file completion, in case it helps
return 1
end
set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)
set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)
if test $filefilter -eq 1; or test $dirfilter -eq 1
__k9s_debug "File extension filtering or directory filtering not supported"
# Do full file completion instead
return 1
end
set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)
set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)
__k9s_debug "nospace: $nospace, nofiles: $nofiles"
# If we want to prevent a space, or if file completion is NOT disabled,
# we need to count the number of valid completions.
# To do so, we will filter on prefix as the completions we have received
# may not already be filtered so as to allow fish to match on different
# criteria than the prefix.
if test $nospace -ne 0; or test $nofiles -eq 0
set -l prefix (commandline -t | string escape --style=regex)
__k9s_debug "prefix: $prefix"
set -l completions (string match -r -- "^$prefix.*" $__k9s_comp_results)
set --global __k9s_comp_results $completions
__k9s_debug "Filtered completions are: $__k9s_comp_results"
# Important not to quote the variable for count to work
set -l numComps (count $__k9s_comp_results)
__k9s_debug "numComps: $numComps"
if test $numComps -eq 1; and test $nospace -ne 0
# We must first split on \t to get rid of the descriptions to be
# able to check what the actual completion will be.
# We don't need descriptions anyway since there is only a single
# real completion which the shell will expand immediately.
set -l split (string split --max 1 \t $__k9s_comp_results[1])
# Fish won't add a space if the completion ends with any
# of the following characters: @=/:.,
set -l lastChar (string sub -s -1 -- $split)
if not string match -r -q "[@=/:.,]" -- "$lastChar"
# In other cases, to support the "nospace" directive we trick the shell
# by outputting an extra, longer completion.
__k9s_debug "Adding second completion to perform nospace directive"
set --global __k9s_comp_results $split[1] $split[1].
__k9s_debug "Completions are now: $__k9s_comp_results"
end
end
if test $numComps -eq 0; and test $nofiles -eq 0
# To be consistent with bash and zsh, we only trigger file
# completion when there are no other completions
__k9s_debug "Requesting file completion"
return 1
end
end
return 0
end
# Since Fish completions are only loaded once the user triggers them, we trigger them ourselves
# so we can properly delete any completions provided by another script.
# Only do this if the program can be found, or else fish may print some errors; besides,
# the existing completions will only be loaded if the program can be found.
if type -q "k9s"
# The space after the program name is essential to trigger completion for the program
# and not completion of the program name itself.
# Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.
complete --do-complete "k9s " > /dev/null 2>&1
end
# Remove any pre-existing completions for the program since we will be handling all of them.
complete -c k9s -e
# this will get called after the two calls below and clear the $__k9s_perform_completion_once_result global
complete -c k9s -n '__k9s_clear_perform_completion_once_result'
# The call to __k9s_prepare_completions will setup __k9s_comp_results
# which provides the program's completion choices.
# If this doesn't require order preservation, we don't use the -k flag
complete -c k9s -n 'not __k9s_requires_order_preservation && __k9s_prepare_completions' -f -a '$__k9s_comp_results'
# otherwise we use the -k flag
complete -k -c k9s -n '__k9s_requires_order_preservation && __k9s_prepare_completions' -f -a '$__k9s_comp_results'

View File

@@ -0,0 +1,176 @@
# fish completion for kind -*- shell-script -*-
function __kind_debug
set -l file "$BASH_COMP_DEBUG_FILE"
if test -n "$file"
echo "$argv" >> $file
end
end
function __kind_perform_completion
__kind_debug "Starting __kind_perform_completion"
# Extract all args except the last one
set -l args (commandline -opc)
# Extract the last arg and escape it in case it is a space
set -l lastArg (string escape -- (commandline -ct))
__kind_debug "args: $args"
__kind_debug "last arg: $lastArg"
set -l requestComp "$args[1] __complete $args[2..-1] $lastArg"
__kind_debug "Calling $requestComp"
set -l results (eval $requestComp 2> /dev/null)
# Some programs may output extra empty lines after the directive.
# Let's ignore them or else it will break completion.
# Ref: https://github.com/spf13/cobra/issues/1279
for line in $results[-1..1]
if test (string trim -- $line) = ""
# Found an empty line, remove it
set results $results[1..-2]
else
# Found non-empty line, we have our proper output
break
end
end
set -l comps $results[1..-2]
set -l directiveLine $results[-1]
# For Fish, when completing a flag with an = (e.g., <program> -n=<TAB>)
# completions must be prefixed with the flag
set -l flagPrefix (string match -r -- '-.*=' "$lastArg")
__kind_debug "Comps: $comps"
__kind_debug "DirectiveLine: $directiveLine"
__kind_debug "flagPrefix: $flagPrefix"
for comp in $comps
printf "%s%s\n" "$flagPrefix" "$comp"
end
printf "%s\n" "$directiveLine"
end
# This function does two things:
# - Obtain the completions and store them in the global __kind_comp_results
# - Return false if file completion should be performed
function __kind_prepare_completions
__kind_debug ""
__kind_debug "========= starting completion logic =========="
# Start fresh
set --erase __kind_comp_results
set -l results (__kind_perform_completion)
__kind_debug "Completion results: $results"
if test -z "$results"
__kind_debug "No completion, probably due to a failure"
# Might as well do file completion, in case it helps
return 1
end
set -l directive (string sub --start 2 $results[-1])
set --global __kind_comp_results $results[1..-2]
__kind_debug "Completions are: $__kind_comp_results"
__kind_debug "Directive is: $directive"
set -l shellCompDirectiveError 1
set -l shellCompDirectiveNoSpace 2
set -l shellCompDirectiveNoFileComp 4
set -l shellCompDirectiveFilterFileExt 8
set -l shellCompDirectiveFilterDirs 16
if test -z "$directive"
set directive 0
end
set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)
if test $compErr -eq 1
__kind_debug "Received error directive: aborting."
# Might as well do file completion, in case it helps
return 1
end
set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)
set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)
if test $filefilter -eq 1; or test $dirfilter -eq 1
__kind_debug "File extension filtering or directory filtering not supported"
# Do full file completion instead
return 1
end
set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)
set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)
__kind_debug "nospace: $nospace, nofiles: $nofiles"
# If we want to prevent a space, or if file completion is NOT disabled,
# we need to count the number of valid completions.
# To do so, we will filter on prefix as the completions we have received
# may not already be filtered so as to allow fish to match on different
# criteria than the prefix.
if test $nospace -ne 0; or test $nofiles -eq 0
set -l prefix (commandline -t | string escape --style=regex)
__kind_debug "prefix: $prefix"
set -l completions (string match -r -- "^$prefix.*" $__kind_comp_results)
set --global __kind_comp_results $completions
__kind_debug "Filtered completions are: $__kind_comp_results"
# Important not to quote the variable for count to work
set -l numComps (count $__kind_comp_results)
__kind_debug "numComps: $numComps"
if test $numComps -eq 1; and test $nospace -ne 0
# We must first split on \t to get rid of the descriptions to be
# able to check what the actual completion will be.
# We don't need descriptions anyway since there is only a single
# real completion which the shell will expand immediately.
set -l split (string split --max 1 \t $__kind_comp_results[1])
# Fish won't add a space if the completion ends with any
# of the following characters: @=/:.,
set -l lastChar (string sub -s -1 -- $split)
if not string match -r -q "[@=/:.,]" -- "$lastChar"
# In other cases, to support the "nospace" directive we trick the shell
# by outputting an extra, longer completion.
__kind_debug "Adding second completion to perform nospace directive"
set --global __kind_comp_results $split[1] $split[1].
__kind_debug "Completions are now: $__kind_comp_results"
end
end
if test $numComps -eq 0; and test $nofiles -eq 0
# To be consistent with bash and zsh, we only trigger file
# completion when there are no other completions
__kind_debug "Requesting file completion"
return 1
end
end
return 0
end
# Since Fish completions are only loaded once the user triggers them, we trigger them ourselves
# so we can properly delete any completions provided by another script.
# Only do this if the program can be found, or else fish may print some errors; besides,
# the existing completions will only be loaded if the program can be found.
if type -q "kind"
# The space after the program name is essential to trigger completion for the program
# and not completion of the program name itself.
# Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.
complete --do-complete "kind " > /dev/null 2>&1
end
# Remove any pre-existing completions for the program since we will be handling all of them.
complete -c kind -e
# The call to __kind_prepare_completions will setup __kind_comp_results
# which provides the program's completion choices.
complete -c kind -n '__kind_prepare_completions' -f -a '$__kind_comp_results'

View File

@@ -0,0 +1,235 @@
# fish completion for kubebuilder -*- shell-script -*-
function __kubebuilder_debug
set -l file "$BASH_COMP_DEBUG_FILE"
if test -n "$file"
echo "$argv" >> $file
end
end
function __kubebuilder_perform_completion
__kubebuilder_debug "Starting __kubebuilder_perform_completion"
# Extract all args except the last one
set -l args (commandline -opc)
# Extract the last arg and escape it in case it is a space
set -l lastArg (string escape -- (commandline -ct))
__kubebuilder_debug "args: $args"
__kubebuilder_debug "last arg: $lastArg"
# Disable ActiveHelp which is not supported for fish shell
set -l requestComp "KUBEBUILDER_ACTIVE_HELP=0 $args[1] __complete $args[2..-1] $lastArg"
__kubebuilder_debug "Calling $requestComp"
set -l results (eval $requestComp 2> /dev/null)
# Some programs may output extra empty lines after the directive.
# Let's ignore them or else it will break completion.
# Ref: https://github.com/spf13/cobra/issues/1279
for line in $results[-1..1]
if test (string trim -- $line) = ""
# Found an empty line, remove it
set results $results[1..-2]
else
# Found non-empty line, we have our proper output
break
end
end
set -l comps $results[1..-2]
set -l directiveLine $results[-1]
# For Fish, when completing a flag with an = (e.g., <program> -n=<TAB>)
# completions must be prefixed with the flag
set -l flagPrefix (string match -r -- '-.*=' "$lastArg")
__kubebuilder_debug "Comps: $comps"
__kubebuilder_debug "DirectiveLine: $directiveLine"
__kubebuilder_debug "flagPrefix: $flagPrefix"
for comp in $comps
printf "%s%s\n" "$flagPrefix" "$comp"
end
printf "%s\n" "$directiveLine"
end
# this function limits calls to __kubebuilder_perform_completion, by caching the result behind $__kubebuilder_perform_completion_once_result
function __kubebuilder_perform_completion_once
__kubebuilder_debug "Starting __kubebuilder_perform_completion_once"
if test -n "$__kubebuilder_perform_completion_once_result"
__kubebuilder_debug "Seems like a valid result already exists, skipping __kubebuilder_perform_completion"
return 0
end
set --global __kubebuilder_perform_completion_once_result (__kubebuilder_perform_completion)
if test -z "$__kubebuilder_perform_completion_once_result"
__kubebuilder_debug "No completions, probably due to a failure"
return 1
end
__kubebuilder_debug "Performed completions and set __kubebuilder_perform_completion_once_result"
return 0
end
# this function is used to clear the $__kubebuilder_perform_completion_once_result variable after completions are run
function __kubebuilder_clear_perform_completion_once_result
__kubebuilder_debug ""
__kubebuilder_debug "========= clearing previously set __kubebuilder_perform_completion_once_result variable =========="
set --erase __kubebuilder_perform_completion_once_result
__kubebuilder_debug "Successfully erased the variable __kubebuilder_perform_completion_once_result"
end
function __kubebuilder_requires_order_preservation
__kubebuilder_debug ""
__kubebuilder_debug "========= checking if order preservation is required =========="
__kubebuilder_perform_completion_once
if test -z "$__kubebuilder_perform_completion_once_result"
__kubebuilder_debug "Error determining if order preservation is required"
return 1
end
set -l directive (string sub --start 2 $__kubebuilder_perform_completion_once_result[-1])
__kubebuilder_debug "Directive is: $directive"
set -l shellCompDirectiveKeepOrder 32
set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2)
__kubebuilder_debug "Keeporder is: $keeporder"
if test $keeporder -ne 0
__kubebuilder_debug "This does require order preservation"
return 0
end
__kubebuilder_debug "This doesn't require order preservation"
return 1
end
# This function does two things:
# - Obtain the completions and store them in the global __kubebuilder_comp_results
# - Return false if file completion should be performed
function __kubebuilder_prepare_completions
__kubebuilder_debug ""
__kubebuilder_debug "========= starting completion logic =========="
# Start fresh
set --erase __kubebuilder_comp_results
__kubebuilder_perform_completion_once
__kubebuilder_debug "Completion results: $__kubebuilder_perform_completion_once_result"
if test -z "$__kubebuilder_perform_completion_once_result"
__kubebuilder_debug "No completion, probably due to a failure"
# Might as well do file completion, in case it helps
return 1
end
set -l directive (string sub --start 2 $__kubebuilder_perform_completion_once_result[-1])
set --global __kubebuilder_comp_results $__kubebuilder_perform_completion_once_result[1..-2]
__kubebuilder_debug "Completions are: $__kubebuilder_comp_results"
__kubebuilder_debug "Directive is: $directive"
set -l shellCompDirectiveError 1
set -l shellCompDirectiveNoSpace 2
set -l shellCompDirectiveNoFileComp 4
set -l shellCompDirectiveFilterFileExt 8
set -l shellCompDirectiveFilterDirs 16
if test -z "$directive"
set directive 0
end
set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)
if test $compErr -eq 1
__kubebuilder_debug "Received error directive: aborting."
# Might as well do file completion, in case it helps
return 1
end
set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)
set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)
if test $filefilter -eq 1; or test $dirfilter -eq 1
__kubebuilder_debug "File extension filtering or directory filtering not supported"
# Do full file completion instead
return 1
end
set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)
set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)
__kubebuilder_debug "nospace: $nospace, nofiles: $nofiles"
# If we want to prevent a space, or if file completion is NOT disabled,
# we need to count the number of valid completions.
# To do so, we will filter on prefix as the completions we have received
# may not already be filtered so as to allow fish to match on different
# criteria than the prefix.
if test $nospace -ne 0; or test $nofiles -eq 0
set -l prefix (commandline -t | string escape --style=regex)
__kubebuilder_debug "prefix: $prefix"
set -l completions (string match -r -- "^$prefix.*" $__kubebuilder_comp_results)
set --global __kubebuilder_comp_results $completions
__kubebuilder_debug "Filtered completions are: $__kubebuilder_comp_results"
# Important not to quote the variable for count to work
set -l numComps (count $__kubebuilder_comp_results)
__kubebuilder_debug "numComps: $numComps"
if test $numComps -eq 1; and test $nospace -ne 0
# We must first split on \t to get rid of the descriptions to be
# able to check what the actual completion will be.
# We don't need descriptions anyway since there is only a single
# real completion which the shell will expand immediately.
set -l split (string split --max 1 \t $__kubebuilder_comp_results[1])
# Fish won't add a space if the completion ends with any
# of the following characters: @=/:.,
set -l lastChar (string sub -s -1 -- $split)
if not string match -r -q "[@=/:.,]" -- "$lastChar"
# In other cases, to support the "nospace" directive we trick the shell
# by outputting an extra, longer completion.
__kubebuilder_debug "Adding second completion to perform nospace directive"
set --global __kubebuilder_comp_results $split[1] $split[1].
__kubebuilder_debug "Completions are now: $__kubebuilder_comp_results"
end
end
if test $numComps -eq 0; and test $nofiles -eq 0
# To be consistent with bash and zsh, we only trigger file
# completion when there are no other completions
__kubebuilder_debug "Requesting file completion"
return 1
end
end
return 0
end
# Since Fish completions are only loaded once the user triggers them, we trigger them ourselves
# so we can properly delete any completions provided by another script.
# Only do this if the program can be found, or else fish may print some errors; besides,
# the existing completions will only be loaded if the program can be found.
if type -q "kubebuilder"
# The space after the program name is essential to trigger completion for the program
# and not completion of the program name itself.
# Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.
complete --do-complete "kubebuilder " > /dev/null 2>&1
end
# Remove any pre-existing completions for the program since we will be handling all of them.
complete -c kubebuilder -e
# this will get called after the two calls below and clear the $__kubebuilder_perform_completion_once_result global
complete -c kubebuilder -n '__kubebuilder_clear_perform_completion_once_result'
# The call to __kubebuilder_prepare_completions will setup __kubebuilder_comp_results
# which provides the program's completion choices.
# If this doesn't require order preservation, we don't use the -k flag
complete -c kubebuilder -n 'not __kubebuilder_requires_order_preservation && __kubebuilder_prepare_completions' -f -a '$__kubebuilder_comp_results'
# otherwise we use the -k flag
complete -k -c kubebuilder -n '__kubebuilder_requires_order_preservation && __kubebuilder_prepare_completions' -f -a '$__kubebuilder_comp_results'

View File

@@ -0,0 +1,249 @@
# Copyright 2016 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# fish completion for kubectl -*- shell-script -*-
function __kubectl_debug
set -l file "$BASH_COMP_DEBUG_FILE"
if test -n "$file"
echo "$argv" >> $file
end
end
function __kubectl_perform_completion
__kubectl_debug "Starting __kubectl_perform_completion"
# Extract all args except the last one
set -l args (commandline -opc)
# Extract the last arg and escape it in case it is a space
set -l lastArg (string escape -- (commandline -ct))
__kubectl_debug "args: $args"
__kubectl_debug "last arg: $lastArg"
# Disable ActiveHelp which is not supported for fish shell
set -l requestComp "KUBECTL_ACTIVE_HELP=0 $args[1] __complete $args[2..-1] $lastArg"
__kubectl_debug "Calling $requestComp"
set -l results (eval $requestComp 2> /dev/null)
# Some programs may output extra empty lines after the directive.
# Let's ignore them or else it will break completion.
# Ref: https://github.com/spf13/cobra/issues/1279
for line in $results[-1..1]
if test (string trim -- $line) = ""
# Found an empty line, remove it
set results $results[1..-2]
else
# Found non-empty line, we have our proper output
break
end
end
set -l comps $results[1..-2]
set -l directiveLine $results[-1]
# For Fish, when completing a flag with an = (e.g., <program> -n=<TAB>)
# completions must be prefixed with the flag
set -l flagPrefix (string match -r -- '-.*=' "$lastArg")
__kubectl_debug "Comps: $comps"
__kubectl_debug "DirectiveLine: $directiveLine"
__kubectl_debug "flagPrefix: $flagPrefix"
for comp in $comps
printf "%s%s\n" "$flagPrefix" "$comp"
end
printf "%s\n" "$directiveLine"
end
# this function limits calls to __kubectl_perform_completion, by caching the result behind $__kubectl_perform_completion_once_result
function __kubectl_perform_completion_once
__kubectl_debug "Starting __kubectl_perform_completion_once"
if test -n "$__kubectl_perform_completion_once_result"
__kubectl_debug "Seems like a valid result already exists, skipping __kubectl_perform_completion"
return 0
end
set --global __kubectl_perform_completion_once_result (__kubectl_perform_completion)
if test -z "$__kubectl_perform_completion_once_result"
__kubectl_debug "No completions, probably due to a failure"
return 1
end
__kubectl_debug "Performed completions and set __kubectl_perform_completion_once_result"
return 0
end
# this function is used to clear the $__kubectl_perform_completion_once_result variable after completions are run
function __kubectl_clear_perform_completion_once_result
__kubectl_debug ""
__kubectl_debug "========= clearing previously set __kubectl_perform_completion_once_result variable =========="
set --erase __kubectl_perform_completion_once_result
__kubectl_debug "Successfully erased the variable __kubectl_perform_completion_once_result"
end
function __kubectl_requires_order_preservation
__kubectl_debug ""
__kubectl_debug "========= checking if order preservation is required =========="
__kubectl_perform_completion_once
if test -z "$__kubectl_perform_completion_once_result"
__kubectl_debug "Error determining if order preservation is required"
return 1
end
set -l directive (string sub --start 2 $__kubectl_perform_completion_once_result[-1])
__kubectl_debug "Directive is: $directive"
set -l shellCompDirectiveKeepOrder 32
set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2)
__kubectl_debug "Keeporder is: $keeporder"
if test $keeporder -ne 0
__kubectl_debug "This does require order preservation"
return 0
end
__kubectl_debug "This doesn't require order preservation"
return 1
end
# This function does two things:
# - Obtain the completions and store them in the global __kubectl_comp_results
# - Return false if file completion should be performed
function __kubectl_prepare_completions
__kubectl_debug ""
__kubectl_debug "========= starting completion logic =========="
# Start fresh
set --erase __kubectl_comp_results
__kubectl_perform_completion_once
__kubectl_debug "Completion results: $__kubectl_perform_completion_once_result"
if test -z "$__kubectl_perform_completion_once_result"
__kubectl_debug "No completion, probably due to a failure"
# Might as well do file completion, in case it helps
return 1
end
set -l directive (string sub --start 2 $__kubectl_perform_completion_once_result[-1])
set --global __kubectl_comp_results $__kubectl_perform_completion_once_result[1..-2]
__kubectl_debug "Completions are: $__kubectl_comp_results"
__kubectl_debug "Directive is: $directive"
set -l shellCompDirectiveError 1
set -l shellCompDirectiveNoSpace 2
set -l shellCompDirectiveNoFileComp 4
set -l shellCompDirectiveFilterFileExt 8
set -l shellCompDirectiveFilterDirs 16
if test -z "$directive"
set directive 0
end
set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)
if test $compErr -eq 1
__kubectl_debug "Received error directive: aborting."
# Might as well do file completion, in case it helps
return 1
end
set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)
set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)
if test $filefilter -eq 1; or test $dirfilter -eq 1
__kubectl_debug "File extension filtering or directory filtering not supported"
# Do full file completion instead
return 1
end
set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)
set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)
__kubectl_debug "nospace: $nospace, nofiles: $nofiles"
# If we want to prevent a space, or if file completion is NOT disabled,
# we need to count the number of valid completions.
# To do so, we will filter on prefix as the completions we have received
# may not already be filtered so as to allow fish to match on different
# criteria than the prefix.
if test $nospace -ne 0; or test $nofiles -eq 0
set -l prefix (commandline -t | string escape --style=regex)
__kubectl_debug "prefix: $prefix"
set -l completions (string match -r -- "^$prefix.*" $__kubectl_comp_results)
set --global __kubectl_comp_results $completions
__kubectl_debug "Filtered completions are: $__kubectl_comp_results"
# Important not to quote the variable for count to work
set -l numComps (count $__kubectl_comp_results)
__kubectl_debug "numComps: $numComps"
if test $numComps -eq 1; and test $nospace -ne 0
# We must first split on \t to get rid of the descriptions to be
# able to check what the actual completion will be.
# We don't need descriptions anyway since there is only a single
# real completion which the shell will expand immediately.
set -l split (string split --max 1 \t $__kubectl_comp_results[1])
# Fish won't add a space if the completion ends with any
# of the following characters: @=/:.,
set -l lastChar (string sub -s -1 -- $split)
if not string match -r -q "[@=/:.,]" -- "$lastChar"
# In other cases, to support the "nospace" directive we trick the shell
# by outputting an extra, longer completion.
__kubectl_debug "Adding second completion to perform nospace directive"
set --global __kubectl_comp_results $split[1] $split[1].
__kubectl_debug "Completions are now: $__kubectl_comp_results"
end
end
if test $numComps -eq 0; and test $nofiles -eq 0
# To be consistent with bash and zsh, we only trigger file
# completion when there are no other completions
__kubectl_debug "Requesting file completion"
return 1
end
end
return 0
end
# Since Fish completions are only loaded once the user triggers them, we trigger them ourselves
# so we can properly delete any completions provided by another script.
# Only do this if the program can be found, or else fish may print some errors; besides,
# the existing completions will only be loaded if the program can be found.
if type -q "kubectl"
# The space after the program name is essential to trigger completion for the program
# and not completion of the program name itself.
# Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.
complete --do-complete "kubectl " > /dev/null 2>&1
end
# Remove any pre-existing completions for the program since we will be handling all of them.
complete -c kubectl -e
# this will get called after the two calls below and clear the $__kubectl_perform_completion_once_result global
complete -c kubectl -n '__kubectl_clear_perform_completion_once_result'
# The call to __kubectl_prepare_completions will setup __kubectl_comp_results
# which provides the program's completion choices.
# If this doesn't require order preservation, we don't use the -k flag
complete -c kubectl -n 'not __kubectl_requires_order_preservation && __kubectl_prepare_completions' -f -a '$__kubectl_comp_results'
# otherwise we use the -k flag
complete -k -c kubectl -n '__kubectl_requires_order_preservation && __kubectl_prepare_completions' -f -a '$__kubectl_comp_results'

View File

@@ -0,0 +1,249 @@
# Copyright 2016 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# fish completion for minikube -*- shell-script -*-
function __minikube_debug
set -l file "$BASH_COMP_DEBUG_FILE"
if test -n "$file"
echo "$argv" >> $file
end
end
function __minikube_perform_completion
__minikube_debug "Starting __minikube_perform_completion"
# Extract all args except the last one
set -l args (commandline -opc)
# Extract the last arg and escape it in case it is a space
set -l lastArg (string escape -- (commandline -ct))
__minikube_debug "args: $args"
__minikube_debug "last arg: $lastArg"
# Disable ActiveHelp which is not supported for fish shell
set -l requestComp "MINIKUBE_ACTIVE_HELP=0 $args[1] __complete $args[2..-1] $lastArg"
__minikube_debug "Calling $requestComp"
set -l results (eval $requestComp 2> /dev/null)
# Some programs may output extra empty lines after the directive.
# Let's ignore them or else it will break completion.
# Ref: https://github.com/spf13/cobra/issues/1279
for line in $results[-1..1]
if test (string trim -- $line) = ""
# Found an empty line, remove it
set results $results[1..-2]
else
# Found non-empty line, we have our proper output
break
end
end
set -l comps $results[1..-2]
set -l directiveLine $results[-1]
# For Fish, when completing a flag with an = (e.g., <program> -n=<TAB>)
# completions must be prefixed with the flag
set -l flagPrefix (string match -r -- '-.*=' "$lastArg")
__minikube_debug "Comps: $comps"
__minikube_debug "DirectiveLine: $directiveLine"
__minikube_debug "flagPrefix: $flagPrefix"
for comp in $comps
printf "%s%s\n" "$flagPrefix" "$comp"
end
printf "%s\n" "$directiveLine"
end
# this function limits calls to __minikube_perform_completion, by caching the result behind $__minikube_perform_completion_once_result
function __minikube_perform_completion_once
__minikube_debug "Starting __minikube_perform_completion_once"
if test -n "$__minikube_perform_completion_once_result"
__minikube_debug "Seems like a valid result already exists, skipping __minikube_perform_completion"
return 0
end
set --global __minikube_perform_completion_once_result (__minikube_perform_completion)
if test -z "$__minikube_perform_completion_once_result"
__minikube_debug "No completions, probably due to a failure"
return 1
end
__minikube_debug "Performed completions and set __minikube_perform_completion_once_result"
return 0
end
# this function is used to clear the $__minikube_perform_completion_once_result variable after completions are run
function __minikube_clear_perform_completion_once_result
__minikube_debug ""
__minikube_debug "========= clearing previously set __minikube_perform_completion_once_result variable =========="
set --erase __minikube_perform_completion_once_result
__minikube_debug "Successfully erased the variable __minikube_perform_completion_once_result"
end
function __minikube_requires_order_preservation
__minikube_debug ""
__minikube_debug "========= checking if order preservation is required =========="
__minikube_perform_completion_once
if test -z "$__minikube_perform_completion_once_result"
__minikube_debug "Error determining if order preservation is required"
return 1
end
set -l directive (string sub --start 2 $__minikube_perform_completion_once_result[-1])
__minikube_debug "Directive is: $directive"
set -l shellCompDirectiveKeepOrder 32
set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2)
__minikube_debug "Keeporder is: $keeporder"
if test $keeporder -ne 0
__minikube_debug "This does require order preservation"
return 0
end
__minikube_debug "This doesn't require order preservation"
return 1
end
# This function does two things:
# - Obtain the completions and store them in the global __minikube_comp_results
# - Return false if file completion should be performed
function __minikube_prepare_completions
__minikube_debug ""
__minikube_debug "========= starting completion logic =========="
# Start fresh
set --erase __minikube_comp_results
__minikube_perform_completion_once
__minikube_debug "Completion results: $__minikube_perform_completion_once_result"
if test -z "$__minikube_perform_completion_once_result"
__minikube_debug "No completion, probably due to a failure"
# Might as well do file completion, in case it helps
return 1
end
set -l directive (string sub --start 2 $__minikube_perform_completion_once_result[-1])
set --global __minikube_comp_results $__minikube_perform_completion_once_result[1..-2]
__minikube_debug "Completions are: $__minikube_comp_results"
__minikube_debug "Directive is: $directive"
set -l shellCompDirectiveError 1
set -l shellCompDirectiveNoSpace 2
set -l shellCompDirectiveNoFileComp 4
set -l shellCompDirectiveFilterFileExt 8
set -l shellCompDirectiveFilterDirs 16
if test -z "$directive"
set directive 0
end
set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)
if test $compErr -eq 1
__minikube_debug "Received error directive: aborting."
# Might as well do file completion, in case it helps
return 1
end
set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)
set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)
if test $filefilter -eq 1; or test $dirfilter -eq 1
__minikube_debug "File extension filtering or directory filtering not supported"
# Do full file completion instead
return 1
end
set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)
set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)
__minikube_debug "nospace: $nospace, nofiles: $nofiles"
# If we want to prevent a space, or if file completion is NOT disabled,
# we need to count the number of valid completions.
# To do so, we will filter on prefix as the completions we have received
# may not already be filtered so as to allow fish to match on different
# criteria than the prefix.
if test $nospace -ne 0; or test $nofiles -eq 0
set -l prefix (commandline -t | string escape --style=regex)
__minikube_debug "prefix: $prefix"
set -l completions (string match -r -- "^$prefix.*" $__minikube_comp_results)
set --global __minikube_comp_results $completions
__minikube_debug "Filtered completions are: $__minikube_comp_results"
# Important not to quote the variable for count to work
set -l numComps (count $__minikube_comp_results)
__minikube_debug "numComps: $numComps"
if test $numComps -eq 1; and test $nospace -ne 0
# We must first split on \t to get rid of the descriptions to be
# able to check what the actual completion will be.
# We don't need descriptions anyway since there is only a single
# real completion which the shell will expand immediately.
set -l split (string split --max 1 \t $__minikube_comp_results[1])
# Fish won't add a space if the completion ends with any
# of the following characters: @=/:.,
set -l lastChar (string sub -s -1 -- $split)
if not string match -r -q "[@=/:.,]" -- "$lastChar"
# In other cases, to support the "nospace" directive we trick the shell
# by outputting an extra, longer completion.
__minikube_debug "Adding second completion to perform nospace directive"
set --global __minikube_comp_results $split[1] $split[1].
__minikube_debug "Completions are now: $__minikube_comp_results"
end
end
if test $numComps -eq 0; and test $nofiles -eq 0
# To be consistent with bash and zsh, we only trigger file
# completion when there are no other completions
__minikube_debug "Requesting file completion"
return 1
end
end
return 0
end
# Since Fish completions are only loaded once the user triggers them, we trigger them ourselves
# so we can properly delete any completions provided by another script.
# Only do this if the program can be found, or else fish may print some errors; besides,
# the existing completions will only be loaded if the program can be found.
if type -q "minikube"
# The space after the program name is essential to trigger completion for the program
# and not completion of the program name itself.
# Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.
complete --do-complete "minikube " > /dev/null 2>&1
end
# Remove any pre-existing completions for the program since we will be handling all of them.
complete -c minikube -e
# this will get called after the two calls below and clear the $__minikube_perform_completion_once_result global
complete -c minikube -n '__minikube_clear_perform_completion_once_result'
# The call to __minikube_prepare_completions will setup __minikube_comp_results
# which provides the program's completion choices.
# If this doesn't require order preservation, we don't use the -k flag
complete -c minikube -n 'not __minikube_requires_order_preservation && __minikube_prepare_completions' -f -a '$__minikube_comp_results'
# otherwise we use the -k flag
complete -k -c minikube -n '__minikube_requires_order_preservation && __minikube_prepare_completions' -f -a '$__minikube_comp_results'

View File

@@ -0,0 +1,236 @@
# fish completion for oc -*- shell-script -*-
function __oc_debug
set -l file "$BASH_COMP_DEBUG_FILE"
if test -n "$file"
echo "$argv" >> $file
end
end
function __oc_perform_completion
__oc_debug "Starting __oc_perform_completion"
# Extract all args except the last one
set -l args (commandline -opc)
# Extract the last arg and escape it in case it is a space
set -l lastArg (string escape -- (commandline -ct))
__oc_debug "args: $args"
__oc_debug "last arg: $lastArg"
# Disable ActiveHelp which is not supported for fish shell
set -l requestComp "OC_ACTIVE_HELP=0 $args[1] __complete $args[2..-1] $lastArg"
__oc_debug "Calling $requestComp"
set -l results (eval $requestComp 2> /dev/null)
# Some programs may output extra empty lines after the directive.
# Let's ignore them or else it will break completion.
# Ref: https://github.com/spf13/cobra/issues/1279
for line in $results[-1..1]
if test (string trim -- $line) = ""
# Found an empty line, remove it
set results $results[1..-2]
else
# Found non-empty line, we have our proper output
break
end
end
set -l comps $results[1..-2]
set -l directiveLine $results[-1]
# For Fish, when completing a flag with an = (e.g., <program> -n=<TAB>)
# completions must be prefixed with the flag
set -l flagPrefix (string match -r -- '-.*=' "$lastArg")
__oc_debug "Comps: $comps"
__oc_debug "DirectiveLine: $directiveLine"
__oc_debug "flagPrefix: $flagPrefix"
for comp in $comps
printf "%s%s\n" "$flagPrefix" "$comp"
end
printf "%s\n" "$directiveLine"
end
# this function limits calls to __oc_perform_completion, by caching the result behind $__oc_perform_completion_once_result
function __oc_perform_completion_once
__oc_debug "Starting __oc_perform_completion_once"
if test -n "$__oc_perform_completion_once_result"
__oc_debug "Seems like a valid result already exists, skipping __oc_perform_completion"
return 0
end
set --global __oc_perform_completion_once_result (__oc_perform_completion)
if test -z "$__oc_perform_completion_once_result"
__oc_debug "No completions, probably due to a failure"
return 1
end
__oc_debug "Performed completions and set __oc_perform_completion_once_result"
return 0
end
# this function is used to clear the $__oc_perform_completion_once_result variable after completions are run
function __oc_clear_perform_completion_once_result
__oc_debug ""
__oc_debug "========= clearing previously set __oc_perform_completion_once_result variable =========="
set --erase __oc_perform_completion_once_result
__oc_debug "Successfully erased the variable __oc_perform_completion_once_result"
end
function __oc_requires_order_preservation
__oc_debug ""
__oc_debug "========= checking if order preservation is required =========="
__oc_perform_completion_once
if test -z "$__oc_perform_completion_once_result"
__oc_debug "Error determining if order preservation is required"
return 1
end
set -l directive (string sub --start 2 $__oc_perform_completion_once_result[-1])
__oc_debug "Directive is: $directive"
set -l shellCompDirectiveKeepOrder 32
set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2)
__oc_debug "Keeporder is: $keeporder"
if test $keeporder -ne 0
__oc_debug "This does require order preservation"
return 0
end
__oc_debug "This doesn't require order preservation"
return 1
end
# This function does two things:
# - Obtain the completions and store them in the global __oc_comp_results
# - Return false if file completion should be performed
function __oc_prepare_completions
__oc_debug ""
__oc_debug "========= starting completion logic =========="
# Start fresh
set --erase __oc_comp_results
__oc_perform_completion_once
__oc_debug "Completion results: $__oc_perform_completion_once_result"
if test -z "$__oc_perform_completion_once_result"
__oc_debug "No completion, probably due to a failure"
# Might as well do file completion, in case it helps
return 1
end
set -l directive (string sub --start 2 $__oc_perform_completion_once_result[-1])
set --global __oc_comp_results $__oc_perform_completion_once_result[1..-2]
__oc_debug "Completions are: $__oc_comp_results"
__oc_debug "Directive is: $directive"
set -l shellCompDirectiveError 1
set -l shellCompDirectiveNoSpace 2
set -l shellCompDirectiveNoFileComp 4
set -l shellCompDirectiveFilterFileExt 8
set -l shellCompDirectiveFilterDirs 16
if test -z "$directive"
set directive 0
end
set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)
if test $compErr -eq 1
__oc_debug "Received error directive: aborting."
# Might as well do file completion, in case it helps
return 1
end
set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)
set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)
if test $filefilter -eq 1; or test $dirfilter -eq 1
__oc_debug "File extension filtering or directory filtering not supported"
# Do full file completion instead
return 1
end
set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)
set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)
__oc_debug "nospace: $nospace, nofiles: $nofiles"
# If we want to prevent a space, or if file completion is NOT disabled,
# we need to count the number of valid completions.
# To do so, we will filter on prefix as the completions we have received
# may not already be filtered so as to allow fish to match on different
# criteria than the prefix.
if test $nospace -ne 0; or test $nofiles -eq 0
set -l prefix (commandline -t | string escape --style=regex)
__oc_debug "prefix: $prefix"
set -l completions (string match -r -- "^$prefix.*" $__oc_comp_results)
set --global __oc_comp_results $completions
__oc_debug "Filtered completions are: $__oc_comp_results"
# Important not to quote the variable for count to work
set -l numComps (count $__oc_comp_results)
__oc_debug "numComps: $numComps"
if test $numComps -eq 1; and test $nospace -ne 0
# We must first split on \t to get rid of the descriptions to be
# able to check what the actual completion will be.
# We don't need descriptions anyway since there is only a single
# real completion which the shell will expand immediately.
set -l split (string split --max 1 \t $__oc_comp_results[1])
# Fish won't add a space if the completion ends with any
# of the following characters: @=/:.,
set -l lastChar (string sub -s -1 -- $split)
if not string match -r -q "[@=/:.,]" -- "$lastChar"
# In other cases, to support the "nospace" directive we trick the shell
# by outputting an extra, longer completion.
__oc_debug "Adding second completion to perform nospace directive"
set --global __oc_comp_results $split[1] $split[1].
__oc_debug "Completions are now: $__oc_comp_results"
end
end
if test $numComps -eq 0; and test $nofiles -eq 0
# To be consistent with bash and zsh, we only trigger file
# completion when there are no other completions
__oc_debug "Requesting file completion"
return 1
end
end
return 0
end
# Since Fish completions are only loaded once the user triggers them, we trigger them ourselves
# so we can properly delete any completions provided by another script.
# Only do this if the program can be found, or else fish may print some errors; besides,
# the existing completions will only be loaded if the program can be found.
if type -q "oc"
# The space after the program name is essential to trigger completion for the program
# and not completion of the program name itself.
# Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.
complete --do-complete "oc " > /dev/null 2>&1
end
# Remove any pre-existing completions for the program since we will be handling all of them.
complete -c oc -e
# this will get called after the two calls below and clear the $__oc_perform_completion_once_result global
complete -c oc -n '__oc_clear_perform_completion_once_result'
# The call to __oc_prepare_completions will setup __oc_comp_results
# which provides the program's completion choices.
# If this doesn't require order preservation, we don't use the -k flag
complete -c oc -n 'not __oc_requires_order_preservation && __oc_prepare_completions' -f -a '$__oc_comp_results'
# otherwise we use the -k flag
complete -k -c oc -n '__oc_requires_order_preservation && __oc_prepare_completions' -f -a '$__oc_comp_results'

View File

@@ -0,0 +1,235 @@
# fish completion for operator-sdk -*- shell-script -*-
function __operator_sdk_debug
set -l file "$BASH_COMP_DEBUG_FILE"
if test -n "$file"
echo "$argv" >> $file
end
end
function __operator_sdk_perform_completion
__operator_sdk_debug "Starting __operator_sdk_perform_completion"
# Extract all args except the last one
set -l args (commandline -opc)
# Extract the last arg and escape it in case it is a space
set -l lastArg (string escape -- (commandline -ct))
__operator_sdk_debug "args: $args"
__operator_sdk_debug "last arg: $lastArg"
# Disable ActiveHelp which is not supported for fish shell
set -l requestComp "OPERATOR_SDK_ACTIVE_HELP=0 $args[1] __complete $args[2..-1] $lastArg"
__operator_sdk_debug "Calling $requestComp"
set -l results (eval $requestComp 2> /dev/null)
# Some programs may output extra empty lines after the directive.
# Let's ignore them or else it will break completion.
# Ref: https://github.com/spf13/cobra/issues/1279
for line in $results[-1..1]
if test (string trim -- $line) = ""
# Found an empty line, remove it
set results $results[1..-2]
else
# Found non-empty line, we have our proper output
break
end
end
set -l comps $results[1..-2]
set -l directiveLine $results[-1]
# For Fish, when completing a flag with an = (e.g., <program> -n=<TAB>)
# completions must be prefixed with the flag
set -l flagPrefix (string match -r -- '-.*=' "$lastArg")
__operator_sdk_debug "Comps: $comps"
__operator_sdk_debug "DirectiveLine: $directiveLine"
__operator_sdk_debug "flagPrefix: $flagPrefix"
for comp in $comps
printf "%s%s\n" "$flagPrefix" "$comp"
end
printf "%s\n" "$directiveLine"
end
# this function limits calls to __operator_sdk_perform_completion, by caching the result behind $__operator_sdk_perform_completion_once_result
function __operator_sdk_perform_completion_once
__operator_sdk_debug "Starting __operator_sdk_perform_completion_once"
if test -n "$__operator_sdk_perform_completion_once_result"
__operator_sdk_debug "Seems like a valid result already exists, skipping __operator_sdk_perform_completion"
return 0
end
set --global __operator_sdk_perform_completion_once_result (__operator_sdk_perform_completion)
if test -z "$__operator_sdk_perform_completion_once_result"
__operator_sdk_debug "No completions, probably due to a failure"
return 1
end
__operator_sdk_debug "Performed completions and set __operator_sdk_perform_completion_once_result"
return 0
end
# this function is used to clear the $__operator_sdk_perform_completion_once_result variable after completions are run
function __operator_sdk_clear_perform_completion_once_result
__operator_sdk_debug ""
__operator_sdk_debug "========= clearing previously set __operator_sdk_perform_completion_once_result variable =========="
set --erase __operator_sdk_perform_completion_once_result
__operator_sdk_debug "Successfully erased the variable __operator_sdk_perform_completion_once_result"
end
function __operator_sdk_requires_order_preservation
__operator_sdk_debug ""
__operator_sdk_debug "========= checking if order preservation is required =========="
__operator_sdk_perform_completion_once
if test -z "$__operator_sdk_perform_completion_once_result"
__operator_sdk_debug "Error determining if order preservation is required"
return 1
end
set -l directive (string sub --start 2 $__operator_sdk_perform_completion_once_result[-1])
__operator_sdk_debug "Directive is: $directive"
set -l shellCompDirectiveKeepOrder 32
set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2)
__operator_sdk_debug "Keeporder is: $keeporder"
if test $keeporder -ne 0
__operator_sdk_debug "This does require order preservation"
return 0
end
__operator_sdk_debug "This doesn't require order preservation"
return 1
end
# This function does two things:
# - Obtain the completions and store them in the global __operator_sdk_comp_results
# - Return false if file completion should be performed
function __operator_sdk_prepare_completions
__operator_sdk_debug ""
__operator_sdk_debug "========= starting completion logic =========="
# Start fresh
set --erase __operator_sdk_comp_results
__operator_sdk_perform_completion_once
__operator_sdk_debug "Completion results: $__operator_sdk_perform_completion_once_result"
if test -z "$__operator_sdk_perform_completion_once_result"
__operator_sdk_debug "No completion, probably due to a failure"
# Might as well do file completion, in case it helps
return 1
end
set -l directive (string sub --start 2 $__operator_sdk_perform_completion_once_result[-1])
set --global __operator_sdk_comp_results $__operator_sdk_perform_completion_once_result[1..-2]
__operator_sdk_debug "Completions are: $__operator_sdk_comp_results"
__operator_sdk_debug "Directive is: $directive"
set -l shellCompDirectiveError 1
set -l shellCompDirectiveNoSpace 2
set -l shellCompDirectiveNoFileComp 4
set -l shellCompDirectiveFilterFileExt 8
set -l shellCompDirectiveFilterDirs 16
if test -z "$directive"
set directive 0
end
set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)
if test $compErr -eq 1
__operator_sdk_debug "Received error directive: aborting."
# Might as well do file completion, in case it helps
return 1
end
set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)
set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)
if test $filefilter -eq 1; or test $dirfilter -eq 1
__operator_sdk_debug "File extension filtering or directory filtering not supported"
# Do full file completion instead
return 1
end
set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)
set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)
__operator_sdk_debug "nospace: $nospace, nofiles: $nofiles"
# If we want to prevent a space, or if file completion is NOT disabled,
# we need to count the number of valid completions.
# To do so, we will filter on prefix as the completions we have received
# may not already be filtered so as to allow fish to match on different
# criteria than the prefix.
if test $nospace -ne 0; or test $nofiles -eq 0
set -l prefix (commandline -t | string escape --style=regex)
__operator_sdk_debug "prefix: $prefix"
set -l completions (string match -r -- "^$prefix.*" $__operator_sdk_comp_results)
set --global __operator_sdk_comp_results $completions
__operator_sdk_debug "Filtered completions are: $__operator_sdk_comp_results"
# Important not to quote the variable for count to work
set -l numComps (count $__operator_sdk_comp_results)
__operator_sdk_debug "numComps: $numComps"
if test $numComps -eq 1; and test $nospace -ne 0
# We must first split on \t to get rid of the descriptions to be
# able to check what the actual completion will be.
# We don't need descriptions anyway since there is only a single
# real completion which the shell will expand immediately.
set -l split (string split --max 1 \t $__operator_sdk_comp_results[1])
# Fish won't add a space if the completion ends with any
# of the following characters: @=/:.,
set -l lastChar (string sub -s -1 -- $split)
if not string match -r -q "[@=/:.,]" -- "$lastChar"
# In other cases, to support the "nospace" directive we trick the shell
# by outputting an extra, longer completion.
__operator_sdk_debug "Adding second completion to perform nospace directive"
set --global __operator_sdk_comp_results $split[1] $split[1].
__operator_sdk_debug "Completions are now: $__operator_sdk_comp_results"
end
end
if test $numComps -eq 0; and test $nofiles -eq 0
# To be consistent with bash and zsh, we only trigger file
# completion when there are no other completions
__operator_sdk_debug "Requesting file completion"
return 1
end
end
return 0
end
# Since Fish completions are only loaded once the user triggers them, we trigger them ourselves
# so we can properly delete any completions provided by another script.
# Only do this if the program can be found, or else fish may print some errors; besides,
# the existing completions will only be loaded if the program can be found.
if type -q "operator-sdk"
# The space after the program name is essential to trigger completion for the program
# and not completion of the program name itself.
# Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.
complete --do-complete "operator-sdk " > /dev/null 2>&1
end
# Remove any pre-existing completions for the program since we will be handling all of them.
complete -c operator-sdk -e
# this will get called after the two calls below and clear the $__operator_sdk_perform_completion_once_result global
complete -c operator-sdk -n '__operator_sdk_clear_perform_completion_once_result'
# The call to __operator_sdk_prepare_completions will setup __operator_sdk_comp_results
# which provides the program's completion choices.
# If this doesn't require order preservation, we don't use the -k flag
complete -c operator-sdk -n 'not __operator_sdk_requires_order_preservation && __operator_sdk_prepare_completions' -f -a '$__operator_sdk_comp_results'
# otherwise we use the -k flag
complete -k -c operator-sdk -n '__operator_sdk_requires_order_preservation && __operator_sdk_prepare_completions' -f -a '$__operator_sdk_comp_results'

View File

@@ -0,0 +1,257 @@
function __fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand
for i in (commandline -opc)
if contains -- $i about add build cache check config debug env export help init install list lock new publish remove run search self shell show source update version
return 1
end
end
return 0
end
# global options
complete -c poetry -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -l ansi -d 'Force ANSI output.'
complete -c poetry -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -l directory -d 'The working directory for the Poetry command (defaults to the current working directory).'
complete -c poetry -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -l help -d 'Display help for the given command. When no command is given display help for the list command.'
complete -c poetry -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -l no-ansi -d 'Disable ANSI output.'
complete -c poetry -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -l no-cache -d 'Disables Poetry source caches.'
complete -c poetry -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -l no-interaction -d 'Do not ask any interactive question.'
complete -c poetry -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -l no-plugins -d 'Disables plugins.'
complete -c poetry -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -l quiet -d 'Do not output any message.'
complete -c poetry -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -l verbose -d 'Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug.'
complete -c poetry -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -l version -d 'Display this application version.'
# commands
complete -c poetry -f -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -a about -d 'Shows information about Poetry.'
complete -c poetry -f -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -a add -d 'Adds a new dependency to pyproject.toml and installs it.'
complete -c poetry -f -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -a build -d 'Builds a package, as a tarball and a wheel by default.'
complete -c poetry -f -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -a cache
complete -c poetry -f -n '__fish_seen_subcommand_from cache; and not __fish_seen_subcommand_from clear list' -a clear -d 'Clears a Poetry cache by name.'
complete -c poetry -f -n '__fish_seen_subcommand_from cache; and not __fish_seen_subcommand_from clear list' -a list -d 'List Poetry\'s caches.'
complete -c poetry -f -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -a check -d 'Validates the content of the pyproject.toml file and its consistency with the poetry.lock file.'
complete -c poetry -f -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -a config -d 'Manages configuration settings.'
complete -c poetry -f -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -a debug
complete -c poetry -f -n '__fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from info resolve' -a info -d 'Shows debug information.'
complete -c poetry -f -n '__fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from info resolve' -a resolve -d 'Debugs dependency resolution.'
complete -c poetry -f -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -a env
complete -c poetry -f -n '__fish_seen_subcommand_from env; and not __fish_seen_subcommand_from info list remove use' -a info -d 'Displays information about the current environment.'
complete -c poetry -f -n '__fish_seen_subcommand_from env; and not __fish_seen_subcommand_from info list remove use' -a list -d 'Lists all virtualenvs associated with the current project.'
complete -c poetry -f -n '__fish_seen_subcommand_from env; and not __fish_seen_subcommand_from info list remove use' -a remove -d 'Remove virtual environments associated with the project.'
complete -c poetry -f -n '__fish_seen_subcommand_from env; and not __fish_seen_subcommand_from info list remove use' -a use -d 'Activates or creates a new virtualenv for the current project.'
complete -c poetry -f -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -a export -d 'Exports the lock file to alternative formats.'
complete -c poetry -f -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -a help -d 'Displays help for a command.'
complete -c poetry -f -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -a init -d 'Creates a basic pyproject.toml file in the current directory.'
complete -c poetry -f -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -a install -d 'Installs the project dependencies.'
complete -c poetry -f -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -a list -d 'Lists commands.'
complete -c poetry -f -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -a lock -d 'Locks the project dependencies.'
complete -c poetry -f -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -a new -d 'Creates a new Python project at <path>.'
complete -c poetry -f -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -a publish -d 'Publishes a package to a remote repository.'
complete -c poetry -f -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -a remove -d 'Removes a package from the project dependencies.'
complete -c poetry -f -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -a run -d 'Runs a command in the appropriate environment.'
complete -c poetry -f -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -a search -d 'Searches for packages on remote repositories.'
complete -c poetry -f -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -a self
complete -c poetry -f -n '__fish_seen_subcommand_from self; and not __fish_seen_subcommand_from add install lock remove update show' -a add -d 'Add additional packages to Poetry\'s runtime environment.'
complete -c poetry -f -n '__fish_seen_subcommand_from self; and not __fish_seen_subcommand_from add install lock remove update show' -a install -d 'Install locked packages (incl. addons) required by this Poetry installation.'
complete -c poetry -f -n '__fish_seen_subcommand_from self; and not __fish_seen_subcommand_from add install lock remove update show' -a lock -d 'Lock the Poetry installation\'s system requirements.'
complete -c poetry -f -n '__fish_seen_subcommand_from self; and not __fish_seen_subcommand_from add install lock remove update show' -a remove -d 'Remove additional packages from Poetry\'s runtime environment.'
complete -c poetry -f -n '__fish_seen_subcommand_from self; and not __fish_seen_subcommand_from add install lock remove update show' -a show -d 'Show packages from Poetry\'s runtime environment.'
complete -c poetry -f -n '__fish_seen_subcommand_from self; and not __fish_seen_subcommand_from add install lock remove update show' -a plugins -d 'Shows information about the currently installed plugins.'
complete -c poetry -f -n '__fish_seen_subcommand_from self; and not __fish_seen_subcommand_from add install lock remove update show' -a update -d 'Updates Poetry to the latest version.'
complete -c poetry -f -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -a shell -d 'Spawns a shell within the virtual environment.'
complete -c poetry -f -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -a show -d 'Shows information about packages.'
complete -c poetry -f -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -a source
complete -c poetry -f -n '__fish_seen_subcommand_from source; and not __fish_seen_subcommand_from add remove show' -a add -d 'Add source configuration for project.'
complete -c poetry -f -n '__fish_seen_subcommand_from source; and not __fish_seen_subcommand_from add remove show' -a remove -d 'Remove source configured for the project.'
complete -c poetry -f -n '__fish_seen_subcommand_from source; and not __fish_seen_subcommand_from add remove show' -a show -d 'Show information about sources configured for the project.'
complete -c poetry -f -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -a update -d 'Update the dependencies as according to the pyproject.toml file.'
complete -c poetry -f -n '__fish_poetry_b04eeefc2dfbdfae_complete_no_subcommand' -a version -d 'Shows the version of the project or bumps it when a valid bump rule is provided.'
# command options
# about
# add
complete -c poetry -n '__fish_seen_subcommand_from add' -l allow-prereleases -d 'Accept prereleases.'
complete -c poetry -n '__fish_seen_subcommand_from add' -l dev -d 'Add as a development dependency. (Deprecated) Use --group=dev instead.'
complete -c poetry -n '__fish_seen_subcommand_from add' -l dry-run -d 'Output the operations but do not execute anything (implicitly enables --verbose).'
complete -c poetry -n '__fish_seen_subcommand_from add' -l editable -d 'Add vcs/path dependencies as editable.'
complete -c poetry -n '__fish_seen_subcommand_from add' -l extras -d 'Extras to activate for the dependency.'
complete -c poetry -n '__fish_seen_subcommand_from add' -l group -d 'The group to add the dependency to.'
complete -c poetry -n '__fish_seen_subcommand_from add' -l lock -d 'Do not perform operations (only update the lockfile).'
complete -c poetry -n '__fish_seen_subcommand_from add' -l optional -d 'Add as an optional dependency.'
complete -c poetry -n '__fish_seen_subcommand_from add' -l platform -d 'Platforms for which the dependency must be installed.'
complete -c poetry -n '__fish_seen_subcommand_from add' -l python -d 'Python version for which the dependency must be installed.'
complete -c poetry -n '__fish_seen_subcommand_from add' -l source -d 'Name of the source to use to install the package.'
# build
complete -c poetry -n '__fish_seen_subcommand_from build' -l format -d 'Limit the format to either sdist or wheel.'
complete -c poetry -n '__fish_seen_subcommand_from build' -l output -d 'Set output directory for build artifacts. Default is `dist`.'
# cache clear
complete -c poetry -n '__fish_seen_subcommand_from cache; and __fish_seen_subcommand_from clear' -l all -d 'Clear all entries in the cache.'
# cache list
# check
complete -c poetry -n '__fish_seen_subcommand_from check' -l lock -d 'Checks that poetry.lock exists for the current version of pyproject.toml.'
# config
complete -c poetry -n '__fish_seen_subcommand_from config' -l list -d 'List configuration settings.'
complete -c poetry -n '__fish_seen_subcommand_from config' -l local -d 'Set/Get from the project\'s local configuration.'
complete -c poetry -n '__fish_seen_subcommand_from config' -l unset -d 'Unset configuration setting.'
# debug info
# debug resolve
complete -c poetry -n '__fish_seen_subcommand_from debug; and __fish_seen_subcommand_from resolve' -l extras -d 'Extras to activate for the dependency.'
complete -c poetry -n '__fish_seen_subcommand_from debug; and __fish_seen_subcommand_from resolve' -l install -d 'Show what would be installed for the current system.'
complete -c poetry -n '__fish_seen_subcommand_from debug; and __fish_seen_subcommand_from resolve' -l python -d 'Python version(s) to use for resolution.'
complete -c poetry -n '__fish_seen_subcommand_from debug; and __fish_seen_subcommand_from resolve' -l tree -d 'Display the dependency tree.'
# env info
complete -c poetry -n '__fish_seen_subcommand_from env; and __fish_seen_subcommand_from info' -l executable -d 'Only display the environment\'s python executable path.'
complete -c poetry -n '__fish_seen_subcommand_from env; and __fish_seen_subcommand_from info' -l path -d 'Only display the environment\'s path.'
# env list
complete -c poetry -n '__fish_seen_subcommand_from env; and __fish_seen_subcommand_from list' -l full-path -d 'Output the full paths of the virtualenvs.'
# env remove
complete -c poetry -n '__fish_seen_subcommand_from env; and __fish_seen_subcommand_from remove' -l all -d 'Remove all managed virtual environments associated with the project.'
# env use
# export
complete -c poetry -n '__fish_seen_subcommand_from export' -l all-extras -d 'Include all sets of extra dependencies.'
complete -c poetry -n '__fish_seen_subcommand_from export' -l dev -d 'Include development dependencies. (Deprecated)'
complete -c poetry -n '__fish_seen_subcommand_from export' -l extras -d 'Extra sets of dependencies to include.'
complete -c poetry -n '__fish_seen_subcommand_from export' -l format -d 'Format to export to. Currently, only constraints.txt and requirements.txt are supported.'
complete -c poetry -n '__fish_seen_subcommand_from export' -l only -d 'The only dependency groups to include.'
complete -c poetry -n '__fish_seen_subcommand_from export' -l output -d 'The name of the output file.'
complete -c poetry -n '__fish_seen_subcommand_from export' -l with -d 'The optional dependency groups to include.'
complete -c poetry -n '__fish_seen_subcommand_from export' -l with-credentials -d 'Include credentials for extra indices.'
complete -c poetry -n '__fish_seen_subcommand_from export' -l without -d 'The dependency groups to ignore.'
complete -c poetry -n '__fish_seen_subcommand_from export' -l without-hashes -d 'Exclude hashes from the exported file.'
complete -c poetry -n '__fish_seen_subcommand_from export' -l without-urls -d 'Exclude source repository urls from the exported file.'
# help
# init
complete -c poetry -n '__fish_seen_subcommand_from init' -l author -d 'Author name of the package.'
complete -c poetry -n '__fish_seen_subcommand_from init' -l dependency -d 'Package to require, with an optional version constraint, e.g. requests:^2.10.0 or requests=2.11.1.'
complete -c poetry -n '__fish_seen_subcommand_from init' -l description -d 'Description of the package.'
complete -c poetry -n '__fish_seen_subcommand_from init' -l dev-dependency -d 'Package to require for development, with an optional version constraint, e.g. requests:^2.10.0 or requests=2.11.1.'
complete -c poetry -n '__fish_seen_subcommand_from init' -l license -d 'License of the package.'
complete -c poetry -n '__fish_seen_subcommand_from init' -l name -d 'Name of the package.'
complete -c poetry -n '__fish_seen_subcommand_from init' -l python -d 'Compatible Python versions.'
# install
complete -c poetry -n '__fish_seen_subcommand_from install' -l all-extras -d 'Install all extra dependencies.'
complete -c poetry -n '__fish_seen_subcommand_from install' -l compile -d 'Compile Python source files to bytecode. (This option has no effect if modern-installation is disabled because the old installer always compiles.)'
complete -c poetry -n '__fish_seen_subcommand_from install' -l dry-run -d 'Output the operations but do not execute anything (implicitly enables --verbose).'
complete -c poetry -n '__fish_seen_subcommand_from install' -l extras -d 'Extra sets of dependencies to install.'
complete -c poetry -n '__fish_seen_subcommand_from install' -l no-dev -d 'Do not install the development dependencies. (Deprecated)'
complete -c poetry -n '__fish_seen_subcommand_from install' -l no-directory -d 'Do not install any directory path dependencies; useful to install dependencies without source code, e.g. for caching of Docker layers)'
complete -c poetry -n '__fish_seen_subcommand_from install' -l no-root -d 'Do not install the root package (the current project).'
complete -c poetry -n '__fish_seen_subcommand_from install' -l only -d 'The only dependency groups to include.'
complete -c poetry -n '__fish_seen_subcommand_from install' -l only-root -d 'Exclude all dependencies.'
complete -c poetry -n '__fish_seen_subcommand_from install' -l remove-untracked -d 'Removes packages not present in the lock file. (Deprecated)'
complete -c poetry -n '__fish_seen_subcommand_from install' -l sync -d 'Synchronize the environment with the locked packages and the specified groups.'
complete -c poetry -n '__fish_seen_subcommand_from install' -l with -d 'The optional dependency groups to include.'
complete -c poetry -n '__fish_seen_subcommand_from install' -l without -d 'The dependency groups to ignore.'
# list
# lock
complete -c poetry -n '__fish_seen_subcommand_from lock' -l check -d 'Check that the poetry.lock file corresponds to the current version of pyproject.toml. (Deprecated) Use poetry check --lock instead.'
complete -c poetry -n '__fish_seen_subcommand_from lock' -l no-update -d 'Do not update locked versions, only refresh lock file.'
# new
complete -c poetry -n '__fish_seen_subcommand_from new' -l name -d 'Set the resulting package name.'
complete -c poetry -n '__fish_seen_subcommand_from new' -l readme -d 'Specify the readme file format. Default is md.'
complete -c poetry -n '__fish_seen_subcommand_from new' -l src -d 'Use the src layout for the project.'
# publish
complete -c poetry -n '__fish_seen_subcommand_from publish' -l build -d 'Build the package before publishing.'
complete -c poetry -n '__fish_seen_subcommand_from publish' -l cert -d 'Certificate authority to access the repository.'
complete -c poetry -n '__fish_seen_subcommand_from publish' -l client-cert -d 'Client certificate to access the repository.'
complete -c poetry -n '__fish_seen_subcommand_from publish' -l dist-dir -d 'Dist directory where built artifact are stored. Default is `dist`.'
complete -c poetry -n '__fish_seen_subcommand_from publish' -l dry-run -d 'Perform all actions except upload the package.'
complete -c poetry -n '__fish_seen_subcommand_from publish' -l password -d 'The password to access the repository.'
complete -c poetry -n '__fish_seen_subcommand_from publish' -l repository -d 'The repository to publish the package to.'
complete -c poetry -n '__fish_seen_subcommand_from publish' -l skip-existing -d 'Ignore errors from files already existing in the repository.'
complete -c poetry -n '__fish_seen_subcommand_from publish' -l username -d 'The username to access the repository.'
# remove
complete -c poetry -n '__fish_seen_subcommand_from remove' -l dev -d 'Remove a package from the development dependencies. (Deprecated) Use --group=dev instead.'
complete -c poetry -n '__fish_seen_subcommand_from remove' -l dry-run -d 'Output the operations but do not execute anything (implicitly enables --verbose).'
complete -c poetry -n '__fish_seen_subcommand_from remove' -l group -d 'The group to remove the dependency from.'
complete -c poetry -n '__fish_seen_subcommand_from remove' -l lock -d 'Do not perform operations (only update the lockfile).'
# run
# search
# self add
complete -c poetry -n '__fish_seen_subcommand_from self; and __fish_seen_subcommand_from add' -l allow-prereleases -d 'Accept prereleases.'
complete -c poetry -n '__fish_seen_subcommand_from self; and __fish_seen_subcommand_from add' -l dry-run -d 'Output the operations but do not execute anything (implicitly enables --verbose).'
complete -c poetry -n '__fish_seen_subcommand_from self; and __fish_seen_subcommand_from add' -l editable -d 'Add vcs/path dependencies as editable.'
complete -c poetry -n '__fish_seen_subcommand_from self; and __fish_seen_subcommand_from add' -l extras -d 'Extras to activate for the dependency.'
complete -c poetry -n '__fish_seen_subcommand_from self; and __fish_seen_subcommand_from add' -l source -d 'Name of the source to use to install the package.'
# self install
complete -c poetry -n '__fish_seen_subcommand_from self; and __fish_seen_subcommand_from install' -l dry-run -d 'Output the operations but do not execute anything (implicitly enables --verbose).'
complete -c poetry -n '__fish_seen_subcommand_from self; and __fish_seen_subcommand_from install' -l sync -d 'Synchronize the environment with the locked packages and the specified groups.'
# self lock
complete -c poetry -n '__fish_seen_subcommand_from self; and __fish_seen_subcommand_from lock' -l check -d 'Check that the poetry.lock file corresponds to the current version of pyproject.toml. (Deprecated) Use poetry check --lock instead.'
complete -c poetry -n '__fish_seen_subcommand_from self; and __fish_seen_subcommand_from lock' -l no-update -d 'Do not update locked versions, only refresh lock file.'
# self remove
complete -c poetry -n '__fish_seen_subcommand_from self; and __fish_seen_subcommand_from remove' -l dry-run -d 'Output the operations but do not execute anything (implicitly enables --verbose).'
# self show
complete -c poetry -n '__fish_seen_subcommand_from self; and __fish_seen_subcommand_from show' -l addons -d 'List only add-on packages installed.'
complete -c poetry -n '__fish_seen_subcommand_from self; and __fish_seen_subcommand_from show' -l latest -d 'Show the latest version.'
complete -c poetry -n '__fish_seen_subcommand_from self; and __fish_seen_subcommand_from show' -l outdated -d 'Show the latest version but only for packages that are outdated.'
complete -c poetry -n '__fish_seen_subcommand_from self; and __fish_seen_subcommand_from show' -l tree -d 'List the dependencies as a tree.'
# self show plugins
# self update
complete -c poetry -n '__fish_seen_subcommand_from self; and __fish_seen_subcommand_from update' -l dry-run -d 'Output the operations but do not execute anything (implicitly enables --verbose).'
complete -c poetry -n '__fish_seen_subcommand_from self; and __fish_seen_subcommand_from update' -l preview -d 'Allow the installation of pre-release versions.'
# shell
# show
complete -c poetry -n '__fish_seen_subcommand_from show' -l all -d 'Show all packages (even those not compatible with current system).'
complete -c poetry -n '__fish_seen_subcommand_from show' -l latest -d 'Show the latest version.'
complete -c poetry -n '__fish_seen_subcommand_from show' -l no-dev -d 'Do not list the development dependencies. (Deprecated)'
complete -c poetry -n '__fish_seen_subcommand_from show' -l only -d 'The only dependency groups to include.'
complete -c poetry -n '__fish_seen_subcommand_from show' -l outdated -d 'Show the latest version but only for packages that are outdated.'
complete -c poetry -n '__fish_seen_subcommand_from show' -l top-level -d 'Show only top-level dependencies.'
complete -c poetry -n '__fish_seen_subcommand_from show' -l tree -d 'List the dependencies as a tree.'
complete -c poetry -n '__fish_seen_subcommand_from show' -l why -d 'When showing the full list, or a --tree for a single package, display whether they are a direct dependency or required by other packages'
complete -c poetry -n '__fish_seen_subcommand_from show' -l with -d 'The optional dependency groups to include.'
complete -c poetry -n '__fish_seen_subcommand_from show' -l without -d 'The dependency groups to ignore.'
# source add
complete -c poetry -n '__fish_seen_subcommand_from source; and __fish_seen_subcommand_from add' -l default -d 'Set this source as the default (disable PyPI). A default source will also be the fallback source if you add other sources. (Deprecated, use --priority)'
complete -c poetry -n '__fish_seen_subcommand_from source; and __fish_seen_subcommand_from add' -l priority -d 'Set the priority of this source. One of: default, primary, secondary, supplemental, explicit. Defaults to primary.'
complete -c poetry -n '__fish_seen_subcommand_from source; and __fish_seen_subcommand_from add' -l secondary -d 'Set this source as secondary. (Deprecated, use --priority)'
# source remove
# source show
# update
complete -c poetry -n '__fish_seen_subcommand_from update' -l dry-run -d 'Output the operations but do not execute anything (implicitly enables --verbose).'
complete -c poetry -n '__fish_seen_subcommand_from update' -l lock -d 'Do not perform operations (only update the lockfile).'
complete -c poetry -n '__fish_seen_subcommand_from update' -l no-dev -d 'Do not update the development dependencies. (Deprecated)'
complete -c poetry -n '__fish_seen_subcommand_from update' -l only -d 'The only dependency groups to include.'
complete -c poetry -n '__fish_seen_subcommand_from update' -l sync -d 'Synchronize the environment with the locked packages and the specified groups.'
complete -c poetry -n '__fish_seen_subcommand_from update' -l with -d 'The optional dependency groups to include.'
complete -c poetry -n '__fish_seen_subcommand_from update' -l without -d 'The dependency groups to ignore.'
# version
complete -c poetry -n '__fish_seen_subcommand_from version' -l dry-run -d 'Do not update pyproject.toml file'
complete -c poetry -n '__fish_seen_subcommand_from version' -l next-phase -d 'Increment the phase of the current version'
complete -c poetry -n '__fish_seen_subcommand_from version' -l short -d 'Output the version number only'

View File

@@ -0,0 +1,52 @@
# Print an optspec for argparse to handle cmd's options that are independent of any subcommand.
function __fish_ya_global_optspecs
string join \n V/version h/help
end
function __fish_ya_needs_command
# Figure out if the current invocation already has a command.
set -l cmd (commandline -opc)
set -e cmd[1]
argparse -s (__fish_ya_global_optspecs) -- $cmd 2>/dev/null
or return
if set -q argv[1]
# Also print the command, so this can be used to figure out what it is.
echo $argv[1]
return 1
end
return 0
end
function __fish_ya_using_subcommand
set -l cmd (__fish_ya_needs_command)
test -z "$cmd"
and return 1
contains -- $cmd[1] $argv
end
complete -c ya -n "__fish_ya_needs_command" -s V -l version -d 'Print version'
complete -c ya -n "__fish_ya_needs_command" -s h -l help -d 'Print help'
complete -c ya -n "__fish_ya_needs_command" -f -a "pub" -d 'Publish a message to the current instance'
complete -c ya -n "__fish_ya_needs_command" -f -a "pub-to" -d 'Publish a message to the specified instance'
complete -c ya -n "__fish_ya_needs_command" -f -a "sub" -d 'Subscribe to messages from all remote instances'
complete -c ya -n "__fish_ya_needs_command" -f -a "pack" -d 'Manage packages'
complete -c ya -n "__fish_ya_needs_command" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
complete -c ya -n "__fish_ya_using_subcommand pub" -l str -d 'Send the message with a string body' -r
complete -c ya -n "__fish_ya_using_subcommand pub" -l json -d 'Send the message with a JSON body' -r
complete -c ya -n "__fish_ya_using_subcommand pub" -l list -d 'Send the message as string of list' -r
complete -c ya -n "__fish_ya_using_subcommand pub" -s h -l help -d 'Print help'
complete -c ya -n "__fish_ya_using_subcommand pub-to" -l str -d 'Send the message with a string body' -r
complete -c ya -n "__fish_ya_using_subcommand pub-to" -l json -d 'Send the message with a JSON body' -r
complete -c ya -n "__fish_ya_using_subcommand pub-to" -l list -d 'Send the message as string of list' -r
complete -c ya -n "__fish_ya_using_subcommand pub-to" -s h -l help -d 'Print help'
complete -c ya -n "__fish_ya_using_subcommand sub" -s h -l help -d 'Print help'
complete -c ya -n "__fish_ya_using_subcommand pack" -s a -l add -d 'Add a package' -r
complete -c ya -n "__fish_ya_using_subcommand pack" -s i -l install -d 'Install all packages'
complete -c ya -n "__fish_ya_using_subcommand pack" -s l -l list -d 'List all packages'
complete -c ya -n "__fish_ya_using_subcommand pack" -s u -l upgrade -d 'Upgrade all packages'
complete -c ya -n "__fish_ya_using_subcommand pack" -s h -l help -d 'Print help'
complete -c ya -n "__fish_ya_using_subcommand help; and not __fish_seen_subcommand_from pub pub-to sub pack help" -f -a "pub" -d 'Publish a message to the current instance'
complete -c ya -n "__fish_ya_using_subcommand help; and not __fish_seen_subcommand_from pub pub-to sub pack help" -f -a "pub-to" -d 'Publish a message to the specified instance'
complete -c ya -n "__fish_ya_using_subcommand help; and not __fish_seen_subcommand_from pub pub-to sub pack help" -f -a "sub" -d 'Subscribe to messages from all remote instances'
complete -c ya -n "__fish_ya_using_subcommand help; and not __fish_seen_subcommand_from pub pub-to sub pack help" -f -a "pack" -d 'Manage packages'
complete -c ya -n "__fish_ya_using_subcommand help; and not __fish_seen_subcommand_from pub pub-to sub pack help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'

View File

@@ -0,0 +1,9 @@
complete -c yazi -l cwd-file -d 'Write the cwd on exit to this file' -r -F
complete -c yazi -l chooser-file -d 'Write the selected files to this file on open fired' -r -F
complete -c yazi -l client-id -d 'Use the specified client ID, must be a globally unique number' -r
complete -c yazi -l local-events -d 'Report the specified local events to stdout' -r
complete -c yazi -l remote-events -d 'Report the specified remote events to stdout' -r
complete -c yazi -l clear-cache -d 'Clear the cache directory'
complete -c yazi -l debug -d 'Print debug information'
complete -c yazi -s V -l version -d 'Print version'
complete -c yazi -s h -l help -d 'Print help'

View File

@@ -0,0 +1,335 @@
# MIT License
# Copyright (c) 2016 Francisco Lourenço & Daniel Wehner
# 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.
if not status is-interactive
exit
end
set -g __done_version 1.19.2
function __done_run_powershell_script
set -l powershell_exe (command --search "powershell.exe")
if test $status -ne 0
and command --search wslvar
set -l powershell_exe (wslpath (wslvar windir)/System32/WindowsPowerShell/v1.0/powershell.exe)
end
if string length --quiet "$powershell_exe"
and test -x "$powershell_exe"
set cmd (string escape $argv)
eval "$powershell_exe -Command $cmd"
end
end
function __done_windows_notification -a title -a message
if test "$__done_notify_sound" -eq 1
set soundopt "<audio silent=\"false\" src=\"ms-winsoundevent:Notification.Default\" />"
else
set soundopt "<audio silent=\"true\" />"
end
__done_run_powershell_script "
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null
[Windows.UI.Notifications.ToastNotification, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
\$toast_xml_source = @\"
<toast>
$soundopt
<visual>
<binding template=\"ToastText02\">
<text id=\"1\">$title</text>
<text id=\"2\">$message</text>
</binding>
</visual>
</toast>
\"@
\$toast_xml = New-Object Windows.Data.Xml.Dom.XmlDocument
\$toast_xml.loadXml(\$toast_xml_source)
\$toast = New-Object Windows.UI.Notifications.ToastNotification \$toast_xml
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier(\"fish\").Show(\$toast)
"
end
function __done_get_focused_window_id
if type -q lsappinfo
lsappinfo info -only bundleID (lsappinfo front | string replace 'ASN:0x0-' '0x') | cut -d '"' -f4
else if test -n "$SWAYSOCK"
and type -q jq
swaymsg --type get_tree | jq '.. | objects | select(.focused == true) | .id'
else if test -n "$HYPRLAND_INSTANCE_SIGNATURE"
hyprctl activewindow | awk 'NR==1 {print $2}'
else if begin
test "$XDG_SESSION_DESKTOP" = gnome; and type -q gdbus
end
gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval 'global.display.focus_window.get_id()'
else if type -q xprop
and test -n "$DISPLAY"
# Test that the X server at $DISPLAY is running
and xprop -grammar >/dev/null 2>&1
xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2
else if uname -a | string match --quiet --ignore-case --regex microsoft
__done_run_powershell_script '
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class WindowsCompat {
[DllImport("user32.dll")]
public static extern IntPtr GetForegroundWindow();
}
"@
[WindowsCompat]::GetForegroundWindow()
'
else if set -q __done_allow_nongraphical
echo 12345 # dummy value
end
end
function __done_is_tmux_window_active
set -q fish_pid; or set -l fish_pid %self
# find the outermost process within tmux
# ppid != "tmux" -> pid = ppid
# ppid == "tmux" -> break
set tmux_fish_pid $fish_pid
while set tmux_fish_ppid (ps -o ppid= -p $tmux_fish_pid | string trim)
# remove leading hyphen so that basename does not treat it as an argument (e.g. -fish), and return only
# the actual command and not its arguments so that basename finds the correct command name.
# (e.g. '/usr/bin/tmux' from command '/usr/bin/tmux new-session -c /some/start/dir')
and ! string match -q "tmux*" (basename (ps -o command= -p $tmux_fish_ppid | string replace -r '^-' '' | string split ' ')[1])
set tmux_fish_pid $tmux_fish_ppid
end
# tmux session attached and window is active -> no notification
# all other combinations -> send notification
tmux list-panes -a -F "#{session_attached} #{window_active} #{pane_pid}" | string match -q "1 1 $tmux_fish_pid"
end
function __done_is_screen_window_active
string match --quiet --regex "$STY\s+\(Attached" (screen -ls)
end
function __done_is_process_window_focused
# Return false if the window is not focused
if set -q __done_allow_nongraphical
return 1
end
if set -q __done_kitty_remote_control
kitty @ --password="$__done_kitty_remote_control_password" ls | jq -e ".[].tabs[] | select(any(.windows[]; .is_self)) | .is_focused" >/dev/null
return $status
end
set __done_focused_window_id (__done_get_focused_window_id)
if test "$__done_sway_ignore_visible" -eq 1
and test -n "$SWAYSOCK"
string match --quiet --regex "^true" (swaymsg -t get_tree | jq ".. | objects | select(.id == "$__done_initial_window_id") | .visible")
return $status
else if test -n "$HYPRLAND_INSTANCE_SIGNATURE"
and test $__done_initial_window_id = (hyprctl activewindow | awk 'NR==1 {print $2}')
return $status
else if test "$__done_initial_window_id" != "$__done_focused_window_id"
return 1
end
# If inside a tmux session, check if the tmux window is focused
if type -q tmux
and test -n "$TMUX"
__done_is_tmux_window_active
return $status
end
# If inside a screen session, check if the screen window is focused
if type -q screen
and test -n "$STY"
__done_is_screen_window_active
return $status
end
return 0
end
function __done_humanize_duration -a milliseconds
set -l seconds (math --scale=0 "$milliseconds/1000" % 60)
set -l minutes (math --scale=0 "$milliseconds/60000" % 60)
set -l hours (math --scale=0 "$milliseconds/3600000")
if test $hours -gt 0
printf '%s' $hours'h '
end
if test $minutes -gt 0
printf '%s' $minutes'm '
end
if test $seconds -gt 0
printf '%s' $seconds's'
end
end
# verify that the system has graphical capabilities before initializing
if test -z "$SSH_CLIENT" # not over ssh
and count (__done_get_focused_window_id) >/dev/null # is able to get window id
set __done_enabled
end
if set -q __done_allow_nongraphical
and set -q __done_notification_command
set __done_enabled
end
if set -q __done_enabled
set -g __done_initial_window_id ''
set -q __done_min_cmd_duration; or set -g __done_min_cmd_duration 5000
set -q __done_exclude; or set -g __done_exclude '^git (?!push|pull|fetch)'
set -q __done_notify_sound; or set -g __done_notify_sound 0
set -q __done_sway_ignore_visible; or set -g __done_sway_ignore_visible 0
set -q __done_tmux_pane_format; or set -g __done_tmux_pane_format '[#{window_index}]'
set -q __done_notification_duration; or set -g __done_notification_duration 3000
function __done_started --on-event fish_preexec
set __done_initial_window_id (__done_get_focused_window_id)
end
function __done_ended --on-event fish_postexec
set -l exit_status $status
# backwards compatibility for fish < v3.0
set -q cmd_duration; or set -l cmd_duration $CMD_DURATION
if test $cmd_duration
and test $cmd_duration -gt $__done_min_cmd_duration # longer than notify_duration
and not __done_is_process_window_focused # process pane or window not focused
# don't notify if command matches exclude list
for pattern in $__done_exclude
if string match -qr $pattern $argv[1]
return
end
end
# Store duration of last command
set -l humanized_duration (__done_humanize_duration "$cmd_duration")
set -l title "Done in $humanized_duration"
set -l wd (string replace --regex "^$HOME" "~" (pwd))
set -l message "$wd/ $argv[1]"
set -l sender $__done_initial_window_id
if test $exit_status -ne 0
set title "Failed ($exit_status) after $humanized_duration"
end
if test -n "$TMUX_PANE"
set message (tmux lsw -F"$__done_tmux_pane_format" -f '#{==:#{pane_id},'$TMUX_PANE'}')" $message"
end
if set -q __done_notification_command
eval $__done_notification_command
if test "$__done_notify_sound" -eq 1
echo -e "\a" # bell sound
end
else if set -q KITTY_WINDOW_ID
printf "\x1b]99;i=done:d=0;$title\x1b\\"
printf "\x1b]99;i=done:d=1:p=body;$message\x1b\\"
else if type -q terminal-notifier # https://github.com/julienXX/terminal-notifier
if test "$__done_notify_sound" -eq 1
# pipe message into terminal-notifier to avoid escaping issues (https://github.com/julienXX/terminal-notifier/issues/134). fixes #140
echo "$message" | terminal-notifier -title "$title" -sender "$__done_initial_window_id" -sound default
else
echo "$message" | terminal-notifier -title "$title" -sender "$__done_initial_window_id"
end
else if type -q osascript # AppleScript
# escape double quotes that might exist in the message and break osascript. fixes #133
set -l message (string replace --all '"' '\"' "$message")
set -l title (string replace --all '"' '\"' "$title")
osascript -e "display notification \"$message\" with title \"$title\""
if test "$__done_notify_sound" -eq 1
osascript -e "display notification \"$message\" with title \"$title\" sound name \"Glass\""
else
osascript -e "display notification \"$message\" with title \"$title\""
end
else if type -q notify-send # Linux notify-send
# set urgency to normal
set -l urgency normal
# use user-defined urgency if set
if set -q __done_notification_urgency_level
set urgency "$__done_notification_urgency_level"
end
# override user-defined urgency level if non-zero exitstatus
if test $exit_status -ne 0
set urgency critical
if set -q __done_notification_urgency_level_failure
set urgency "$__done_notification_urgency_level_failure"
end
end
notify-send --hint=int:transient:1 --urgency=$urgency --icon=utilities-terminal --app-name=fish --expire-time=$__done_notification_duration "$title" "$message"
if test "$__done_notify_sound" -eq 1
echo -e "\a" # bell sound
end
else if type -q notify-desktop # Linux notify-desktop
set -l urgency
if test $exit_status -ne 0
set urgency "--urgency=critical"
end
notify-desktop $urgency --icon=utilities-terminal --app-name=fish "$title" "$message"
if test "$__done_notify_sound" -eq 1
echo -e "\a" # bell sound
end
else if uname -a | string match --quiet --ignore-case --regex microsoft
__done_windows_notification "$title" "$message"
else # anything else
echo -e "\a" # bell sound
end
end
end
end
function __done_uninstall -e done_uninstall
# Erase all __done_* functions
functions -e __done_ended
functions -e __done_started
functions -e __done_get_focused_window_id
functions -e __done_is_tmux_window_active
functions -e __done_is_screen_window_active
functions -e __done_is_process_window_focused
functions -e __done_windows_notification
functions -e __done_run_powershell_script
functions -e __done_humanize_duration
# Erase __done variables
set -e __done_version
end

View File

@@ -0,0 +1,28 @@
# fzf.fish is only meant to be used in interactive mode. If not in interactive mode and not in CI, skip the config to speed up shell startup
if not status is-interactive && test "$CI" != true
exit
end
# Because of scoping rules, to capture the shell variables exactly as they are, we must read
# them before even executing _fzf_search_variables. We use psub to store the
# variables' info in temporary files and pass in the filenames as arguments.
# This variable is global so that it can be referenced by fzf_configure_bindings and in tests
set --global _fzf_search_vars_command '_fzf_search_variables (set --show | psub) (set --names | psub)'
# Install the default bindings, which are mnemonic and minimally conflict with fish's preset bindings
fzf_configure_bindings
# Doesn't erase autoloaded _fzf_* functions because they are not easily accessible once key bindings are erased
function _fzf_uninstall --on-event fzf_uninstall
_fzf_uninstall_bindings
set --erase _fzf_search_vars_command
functions --erase _fzf_uninstall _fzf_migration_message _fzf_uninstall_bindings fzf_configure_bindings
complete --erase fzf_configure_bindings
set_color cyan
echo "fzf.fish uninstalled."
echo "You may need to manually remove fzf_configure_bindings from your config.fish if you were using custom key bindings."
set_color normal
end

View File

@@ -0,0 +1,9 @@
set -q GHCUP_INSTALL_BASE_PREFIX[1]; or set GHCUP_INSTALL_BASE_PREFIX $HOME
if not contains $HOME/.cabal/bin $PATH
set -x PATH $HOME/.cabal/bin $PATH
end
if not contains $HOME/.ghcup/bin $PATH
set -x PATH $HOME/.ghcup/bin
end

View File

@@ -0,0 +1,3 @@
if not contains $GOBIN $PATH
set -x PATH $GOBIN $PATH
end

View File

@@ -0,0 +1,3 @@
if test (uname -s) = "Linux"
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
end

View File

@@ -0,0 +1 @@
/usr/bin/mise activate fish | source

View File

@@ -0,0 +1 @@
source "$HOME/.cargo/env.fish"

View File

@@ -0,0 +1 @@
zoxide init fish | source

178
fish/.config/fish/config.fish Executable file
View File

@@ -0,0 +1,178 @@
## Set values
# Hide welcome message & ensure we are reporting fish as shell
set fish_greeting
set VIRTUAL_ENV_DISABLE_PROMPT 1
set -xU MANPAGER "sh -c 'col -bx | bat -l man -p'"
set -xU MANROFFOPT -c
set -x SHELL /usr/bin/fish
set -x GOPATH $HOME/.local/share/go
set -x GOBIN $GOPATH/bin
## Export variable need for qt-theme
if type qtile >>/dev/null 2>&1
set -x QT_QPA_PLATFORMTHEME qt5ct
end
# Set settings for https://github.com/franciscolourenco/done
set -U __done_min_cmd_duration 10000
set -U __done_notification_urgency_level low
## Environment setup
# Apply .profile: use this to put fish compatible .profile stuff in
if test -f ~/.fish_profile
source ~/.fish_profile
end
# Add ~/.local/bin to PATH
if test -d ~/.local/bin
if not contains -- ~/.local/bin $PATH
set -p PATH ~/.local/bin
end
end
## Starship prompt
if status --is-interactive
set -l starship_path (which starship)
source ($starship_path init fish --print-full-init | psub)
end
## Advanced command-not-found hook
#source /usr/share/doc/find-the-command/ftc.fish
set -l xdg_data_home $XDG_DATA_HOME ~/.local/share
set -gx --path XDG_DATA_DIRS $xdg_data_home[1]/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share
for flatpakdir in ~/.local/share/flatpak/exports/bin /var/lib/flatpak/exports/bin
if test -d $flatpakdir
contains $flatpakdir $PATH; or set -a PATH $flatpakdir
end
end
## Functions
# Functions needed for !! and !$ https://github.com/oh-my-fish/plugin-bang-bang
function __history_previous_command
switch (commandline -t)
case "!"
commandline -t $history[1]
commandline -f repaint
case "*"
commandline -i !
end
end
function __history_previous_command_arguments
switch (commandline -t)
case "!"
commandline -t ""
commandline -f history-token-search-backward
case "*"
commandline -i '$'
end
end
if [ "$fish_key_bindings" = fish_vi_key_bindings ]
bind -Minsert ! __history_previous_command
bind -Minsert '$' __history_previous_command_arguments
else
bind ! __history_previous_command
bind '$' __history_previous_command_arguments
end
# Fish command history
function history
builtin history --show-time='%F %T '
end
function backup --argument filename
cp $filename $filename.bak
end
# Copy DIR1 DIR2
function copy
set count (count $argv | tr -d \n)
if test "$count" = 2; and test -d "$argv[1]"
set from (echo $argv[1] | string trim --right --chars=/)
set to (echo $argv[2])
command cp -r $from $to
else
command cp $argv
end
end
function fish_greeting
# echo -e "\n"
# fastfetch
end
function tmux-session --argument session_name
tmux has-session -t=$session_name 2>/dev/null
if test $status -ne 0
TMUX='' tmux new-session -d -s $session_name
end
if test -z $TMUX
tmux attach -t $session_name
else
tmux switch-client -t $session_name
end
end
function yy
set tmp (mktemp -t "yazi-cwd.XXXXXX")
yazi $argv --cwd-file="$tmp"
if set cwd (cat -- "$tmp"); and [ -n "$cwd" ]; and [ "$cwd" != "$PWD" ]
cd -- "$cwd"
end
rm -f -- "$tmp"
end
function paths
for p in $PATH
echo -e "$p"
end
end
function system-upgrade
sudo dnf upgrade && flatpak upgrade && mise upgrade && rustup upgrade
end
## Useful aliases
# Replace ls with eza
alias ls 'eza --color=always --group-directories-first --icons' # preferred listing
alias la 'eza -a --color=always --group-directories-first --icons' # all files and dirs
alias ll 'eza -l --color=always --group-directories-first --icons' # long format
alias lt 'eza -aT --color=always --group-directories-first --icons' # tree listing
alias l. 'eza -ald --color=always --group-directories-first --icons .*' # show only dotfiles
# Replace some more things with better alternatives
alias cat 'bat --style header --style snip --style changes --style header --pager never'
# Replace df command tool
alias df='duf'
# Common use
alias .. 'cd ..'
alias ... 'cd ../..'
alias .... 'cd ../../..'
alias ..... 'cd ../../../..'
alias ...... 'cd ../../../../..'
alias dir 'dir --color=auto'
alias grep 'ugrep --color=auto'
alias egrep 'ugrep -E --color=auto'
alias fgrep 'ugrep -F --color=auto'
alias hw 'hwinfo --short' # Hardware Info
alias ip 'ip -color'
alias psmem 'ps auxf | sort -nr -k 4'
alias psmem10 'ps auxf | sort -nr -k 4 | head -10'
alias tarnow 'tar -acf '
alias untar 'tar -zxvf '
alias vdir 'vdir --color=auto'
alias wget 'wget -c '
alias stow 'stow --dotfiles -d ~/.dotfiles '
alias openport 'netstat -nape --inet'
alias kssh 'kitty +kitten ssh'
alias lzg lazygit
alias lzd lazydocker

6
fish/.config/fish/fish_plugins Executable file
View File

@@ -0,0 +1,6 @@
jorgebucaran/fisher
reitzig/sdkman-for-fish@v2.1.0
edc/bass
patrickf1/fzf.fish
justinmayer/virtualfish
catppuccin/fish

View File

@@ -0,0 +1,55 @@
# This file contains fish universal variable definitions.
# VERSION: 3.0
SETUVAR --export BAT_PAGER:moar
SETUVAR --export EDITOR:nvim
SETUVAR --export FZF_DEFAULT_COMMAND:fd\x20\x2d\x2dtype\x20f
SETUVAR --export FZF_DEFAULT_OPTS:\x2d\x2dcolor\x3dbg\x2b\x3a\x23414559\x2cbg\x3a\x23303446\x2cspinner\x3a\x23f2d5cf\x2chl\x3a\x23e78284\x20\x2d\x2dcolor\x3dfg\x3a\x23c6d0f5\x2cheader\x3a\x23e78284\x2cinfo\x3a\x23ca9ee6\x2cpointer\x3a\x23f2d5cf\x20\x2d\x2dcolor\x3dmarker\x3a\x23f2d5cf\x2cfg\x2b\x3a\x23c6d0f5\x2cprompt\x3a\x23ca9ee6\x2chl\x2b\x3a\x23e78284
SETUVAR --export HOMEBREW_NO_ENV_HINTS:1
SETUVAR --export MANPAGER:sh\x20\x2dc\x20\x27col\x20\x2dbx\x20\x7c\x20bat\x20\x2dl\x20man\x20\x2dp\x27
SETUVAR --export MANROFFOPT:\x2dc
SETUVAR __done_min_cmd_duration:10000
SETUVAR __done_notification_urgency_level:low
SETUVAR __fish_initialized:3400
SETUVAR _fisher_catppuccin_2F_fish_files:\x7e/\x2econfig/fish/themes/Catppuccin\x20Frappe\x2etheme\x1e\x7e/\x2econfig/fish/themes/Catppuccin\x20Latte\x2etheme\x1e\x7e/\x2econfig/fish/themes/Catppuccin\x20Macchiato\x2etheme\x1e\x7e/\x2econfig/fish/themes/Catppuccin\x20Mocha\x2etheme
SETUVAR _fisher_edc_2F_bass_files:\x7e/\x2econfig/fish/functions/__bass\x2epy\x1e\x7e/\x2econfig/fish/functions/bass\x2efish
SETUVAR _fisher_jorgebucaran_2F_fisher_files:\x7e/\x2econfig/fish/functions/fisher\x2efish\x1e\x7e/\x2econfig/fish/completions/fisher\x2efish
SETUVAR _fisher_patrickf1_2F_fzf_2E_fish_files:\x7e/\x2econfig/fish/functions/_fzf_configure_bindings_help\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_extract_var_info\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_preview_changed_file\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_preview_file\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_report_diff_type\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_report_file_type\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_directory\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_git_log\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_git_status\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_history\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_processes\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_variables\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_wrapper\x2efish\x1e\x7e/\x2econfig/fish/functions/fzf_configure_bindings\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/fzf\x2efish\x1e\x7e/\x2econfig/fish/completions/fzf_configure_bindings\x2efish
SETUVAR _fisher_plugins:jorgebucaran/fisher\x1ereitzig/sdkman\x2dfor\x2dfish\x40v2\x2e1\x2e0\x1eedc/bass\x1epatrickf1/fzf\x2efish\x1ejustinmayer/virtualfish\x1ecatppuccin/fish
SETUVAR _fisher_reitzig_2F_sdkman_2D_for_2D_fish_40_v2_2E_31_2E_30__files:\x7e/\x2econfig/fish/functions/sdk\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/sdk\x2efish\x1e\x7e/\x2econfig/fish/completions/sdk\x2efish
SETUVAR _fisher_upgraded_to_4_4:\x1d
SETUVAR fish_color_autosuggestion:737994
SETUVAR fish_color_cancel:e78284
SETUVAR fish_color_command:8caaee
SETUVAR fish_color_comment:838ba7
SETUVAR fish_color_cwd:e5c890
SETUVAR fish_color_end:ef9f76
SETUVAR fish_color_error:e78284
SETUVAR fish_color_escape:ea999c
SETUVAR fish_color_gray:737994
SETUVAR fish_color_host:8caaee
SETUVAR fish_color_host_remote:a6d189
SETUVAR fish_color_keyword:e78284
SETUVAR fish_color_normal:c6d0f5
SETUVAR fish_color_operator:f4b8e4
SETUVAR fish_color_option:a6d189
SETUVAR fish_color_param:eebebe
SETUVAR fish_color_quote:a6d189
SETUVAR fish_color_redirection:f4b8e4
SETUVAR fish_color_search_match:\x2d\x2dbackground\x3d414559
SETUVAR fish_color_selection:\x2d\x2dbackground\x3d414559
SETUVAR fish_color_status:e78284
SETUVAR fish_color_user:81c8be
SETUVAR fish_key_bindings:fish_default_key_bindings
SETUVAR fish_pager_color_background:\x1d
SETUVAR fish_pager_color_completion:c6d0f5
SETUVAR fish_pager_color_description:737994
SETUVAR fish_pager_color_prefix:f4b8e4
SETUVAR fish_pager_color_progress:737994
SETUVAR fish_pager_color_secondary_background:\x1d
SETUVAR fish_pager_color_secondary_completion:\x1d
SETUVAR fish_pager_color_secondary_description:\x1d
SETUVAR fish_pager_color_secondary_prefix:\x1d
SETUVAR fish_pager_color_selected_background:\x1d
SETUVAR fish_pager_color_selected_completion:\x1d
SETUVAR fish_pager_color_selected_description:\x1d
SETUVAR fish_pager_color_selected_prefix:\x1d

View File

@@ -0,0 +1,140 @@
"""
To be used with a companion fish function like this:
function refish
set -l _x (python /tmp/bass.py source ~/.nvm/nvim.sh ';' nvm use iojs); source $_x; and rm -f $_x
end
"""
from __future__ import print_function
import json
import os
import signal
import subprocess
import sys
import traceback
BASH = 'bash'
FISH_READONLY = [
'PWD', 'SHLVL', 'history', 'pipestatus', 'status', 'version',
'FISH_VERSION', 'fish_pid', 'hostname', '_', 'fish_private_mode'
]
IGNORED = [
'PS1', 'XPC_SERVICE_NAME'
]
def ignored(name):
if name == 'PWD': # this is read only, but has special handling
return False
# ignore other read only variables
if name in FISH_READONLY:
return True
if name in IGNORED or name.startswith("BASH_FUNC"):
return True
if name.startswith('%'):
return True
return False
def escape(string):
# use json.dumps to reliably escape quotes and backslashes
return json.dumps(string).replace(r'$', r'\$')
def escape_identifier(word):
return escape(word.replace('?', '\\?'))
def comment(string):
return '\n'.join(['# ' + line for line in string.split('\n')])
def gen_script():
# Use the following instead of /usr/bin/env to read environment so we can
# deal with multi-line environment variables (and other odd cases).
env_reader = "%s -c 'import os,json; print(json.dumps({k:v for k,v in os.environ.items()}))'" % (sys.executable)
args = [BASH, '-c', env_reader]
output = subprocess.check_output(args, universal_newlines=True)
old_env = output.strip()
pipe_r, pipe_w = os.pipe()
if sys.version_info >= (3, 4):
os.set_inheritable(pipe_w, True)
command = 'eval $1 && ({}; alias) >&{}'.format(
env_reader,
pipe_w
)
args = [BASH, '-c', command, 'bass', ' '.join(sys.argv[1:])]
p = subprocess.Popen(args, universal_newlines=True, close_fds=False)
os.close(pipe_w)
with os.fdopen(pipe_r) as f:
new_env = f.readline()
alias_str = f.read()
if p.wait() != 0:
raise subprocess.CalledProcessError(
returncode=p.returncode,
cmd=' '.join(sys.argv[1:]),
output=new_env + alias_str
)
new_env = new_env.strip()
old_env = json.loads(old_env)
new_env = json.loads(new_env)
script_lines = []
for k, v in new_env.items():
if ignored(k):
continue
v1 = old_env.get(k)
if not v1:
script_lines.append(comment('adding %s=%s' % (k, v)))
elif v1 != v:
script_lines.append(comment('updating %s=%s -> %s' % (k, v1, v)))
# process special variables
if k == 'PWD':
script_lines.append('cd %s' % escape(v))
continue
else:
continue
if k == 'PATH':
value = ' '.join([escape(directory)
for directory in v.split(':')])
else:
value = escape(v)
script_lines.append('set -g -x %s %s' % (k, value))
for var in set(old_env.keys()) - set(new_env.keys()):
script_lines.append(comment('removing %s' % var))
script_lines.append('set -e %s' % var)
script = '\n'.join(script_lines)
alias_lines = []
for line in alias_str.splitlines():
_, rest = line.split(None, 1)
k, v = rest.split("=", 1)
alias_lines.append("alias " + escape_identifier(k) + "=" + v)
alias = '\n'.join(alias_lines)
return script + '\n' + alias
script_file = os.fdopen(3, 'w')
if not sys.argv[1:]:
print('__bass_usage', file=script_file, end='')
sys.exit(0)
try:
script = gen_script()
except subprocess.CalledProcessError as e:
sys.exit(e.returncode)
except Exception:
print('Bass internal error!', file=sys.stderr)
raise # traceback will output to stderr
except KeyboardInterrupt:
signal.signal(signal.SIGINT, signal.SIG_DFL)
os.kill(os.getpid(), signal.SIGINT)
else:
script_file.write(script)

View File

@@ -0,0 +1,43 @@
function _fzf_configure_bindings_help --description "Prints the help message for fzf_configure_bindings."
echo "\
USAGE:
fzf_configure_bindings [--COMMAND=[KEY_SEQUENCE]...]
DESCRIPTION
fzf_configure_bindings installs key bindings for fzf.fish's commands and erases any bindings it
previously installed. It installs bindings for both default and insert modes. fzf.fish executes
it without options on fish startup to install the out-of-the-box key bindings.
By default, commands are bound to a mnemonic key sequence, shown below. Each command's binding
can be configured using a namesake corresponding option:
COMMAND | DEFAULT KEY SEQUENCE | CORRESPONDING OPTION
Search Directory | Ctrl+Alt+F (F for file) | --directory
Search Git Log | Ctrl+Alt+L (L for log) | --git_log
Search Git Status | Ctrl+Alt+S (S for status) | --git_status
Search History | Ctrl+R (R for reverse) | --history
Search Processes | Ctrl+Alt+P (P for process) | --processes
Search Variables | Ctrl+V (V for variable) | --variables
Override a command's binding by specifying its corresponding option with the desired key
sequence. Disable a command's binding by specifying its corresponding option with no value.
Because fzf_configure_bindings erases bindings it previously installed, it can be cleanly
executed multiple times. Once the desired fzf_configure_bindings command has been found, add it
to your config.fish in order to persist the customized bindings.
In terms of validation, fzf_configure_bindings fails if passed unknown options. It expects an
equals sign between an option's name and value. However, it does not validate key sequences.
Pass -h or --help to print this help message and exit.
EXAMPLES
Default bindings but bind Search Directory to Ctrl+F and Search Variables to Ctrl+Alt+V
\$ fzf_configure_bindings --directory=\cf --variables=\e\cv
Default bindings but disable Search History
\$ fzf_configure_bindings --history=
An agglomeration of different options
\$ fzf_configure_bindings --git_status=\cg --history=\ch --variables= --processes=
SEE Also
To learn more about fish key bindings, see bind(1) and fish_key_reader(1).
"
end

View File

@@ -0,0 +1,15 @@
# helper function for _fzf_search_variables
function _fzf_extract_var_info --argument-names variable_name set_show_output --description "Extract and reformat lines pertaining to \$variable_name from \$set_show_output."
# Extract only the lines about the variable, all of which begin with either
# $variable_name: ...or... $variable_name[
string match --regex "^\\\$$variable_name(?::|\[).*" <$set_show_output |
# Strip the variable name prefix, including ": " for scope info lines
string replace --regex "^\\\$$variable_name(?:: )?" '' |
# Distill the lines of values, replacing...
# [1]: |value|
# ...with...
# [1] value
string replace --regex ": \|(.*)\|" ' $1'
end

View File

@@ -0,0 +1,49 @@
# helper for _fzf_search_git_status
# arg should be a line from git status --short, e.g.
# MM functions/_fzf_preview_changed_file.fish
# D README.md
# R LICENSE -> "New License"
function _fzf_preview_changed_file --argument-names path_status --description "Show the git diff of the given file."
# remove quotes because they'll be interpreted literally by git diff
# no need to requote when referencing $path because fish does not perform word splitting
# https://fishshell.com/docs/current/fish_for_bash_users.html
set -f path (string unescape (string sub --start 4 $path_status))
# first letter of short format shows index, second letter shows working tree
# https://git-scm.com/docs/git-status/2.35.0#_short_format
set -f index_status (string sub --length 1 $path_status)
set -f working_tree_status (string sub --start 2 --length 1 $path_status)
set -f diff_opts --color=always
if test $index_status = '?'
_fzf_report_diff_type Untracked
_fzf_preview_file $path
else if contains {$index_status}$working_tree_status DD AU UD UA DU AA UU
# Unmerged statuses taken directly from git status help's short format table
# Unmerged statuses are mutually exclusive with other statuses, so if we see
# these, then safe to assume the path is unmerged
_fzf_report_diff_type Unmerged
git diff $diff_opts -- $path
else
if test $index_status != ' '
_fzf_report_diff_type Staged
# renames are only detected in the index, never working tree, so only need to test for it here
# https://stackoverflow.com/questions/73954214
if test $index_status = R
# diff the post-rename path with the original path, otherwise the diff will show the entire file as being added
set -f orig_and_new_path (string split --max 1 -- ' -> ' $path)
git diff --staged $diff_opts -- $orig_and_new_path[1] $orig_and_new_path[2]
# path currently has the form of "original -> current", so we need to correct it before it's used below
set path $orig_and_new_path[2]
else
git diff --staged $diff_opts -- $path
end
end
if test $working_tree_status != ' '
_fzf_report_diff_type Unstaged
git diff $diff_opts -- $path
end
end
end

View File

@@ -0,0 +1,43 @@
# helper function for _fzf_search_directory and _fzf_search_git_status
function _fzf_preview_file --description "Print a preview for the given file based on its file type."
# because there's no way to guarantee that _fzf_search_directory passes the path to _fzf_preview_file
# as one argument, we collect all the arguments into one single variable and treat that as the path
set -f file_path $argv
if test -L "$file_path" # symlink
# notify user and recurse on the target of the symlink, which can be any of these file types
set -l target_path (realpath "$file_path")
set_color yellow
echo "'$file_path' is a symlink to '$target_path'."
set_color normal
_fzf_preview_file "$target_path"
else if test -f "$file_path" # regular file
if set --query fzf_preview_file_cmd
# need to escape quotes to make sure eval receives file_path as a single arg
eval "$fzf_preview_file_cmd '$file_path'"
else
bat --style=numbers --color=always "$file_path"
end
else if test -d "$file_path" # directory
if set --query fzf_preview_dir_cmd
# see above
eval "$fzf_preview_dir_cmd '$file_path'"
else
# -A list hidden files as well, except for . and ..
# -F helps classify files by appending symbols after the file name
command ls -A -F "$file_path"
end
else if test -c "$file_path"
_fzf_report_file_type "$file_path" "character device file"
else if test -b "$file_path"
_fzf_report_file_type "$file_path" "block device file"
else if test -S "$file_path"
_fzf_report_file_type "$file_path" socket
else if test -p "$file_path"
_fzf_report_file_type "$file_path" "named pipe"
else
echo "$file_path doesn't exist." >&2
end
end

View File

@@ -0,0 +1,18 @@
# helper for _fzf_preview_changed_file
# prints out something like
# ╭────────╮
# │ Staged │
# ╰────────╯
function _fzf_report_diff_type --argument-names diff_type --description "Print a distinct colored header meant to preface a git patch."
# number of "-" to draw is the length of the string to box + 2 for padding
set -f repeat_count (math 2 + (string length $diff_type))
set -f line (string repeat --count $repeat_count)
set -f top_border$line
set -f btm_border$line
set_color yellow
echo $top_border
echo "$diff_type"
echo $btm_border
set_color normal
end

View File

@@ -0,0 +1,6 @@
# helper function for _fzf_preview_file
function _fzf_report_file_type --argument-names file_path file_type --description "Explain the file type for a file."
set_color red
echo "Cannot preview '$file_path': it is a $file_type."
set_color normal
end

View File

@@ -0,0 +1,33 @@
function _fzf_search_directory --description "Search the current directory. Replace the current token with the selected file paths."
# Directly use fd binary to avoid output buffering delay caused by a fd alias, if any.
# Debian-based distros install fd as fdfind and the fd package is something else, so
# check for fdfind first. Fall back to "fd" for a clear error message.
set -f fd_cmd (command -v fdfind || command -v fd || echo "fd")
set -f --append fd_cmd --color=always $fzf_fd_opts
set -f fzf_arguments --multi --ansi $fzf_directory_opts
set -f token (commandline --current-token)
# expand any variables or leading tilde (~) in the token
set -f expanded_token (eval echo -- $token)
# unescape token because it's already quoted so backslashes will mess up the path
set -f unescaped_exp_token (string unescape -- $expanded_token)
# If the current token is a directory and has a trailing slash,
# then use it as fd's base directory.
if string match --quiet -- "*/" $unescaped_exp_token && test -d "$unescaped_exp_token"
set --append fd_cmd --base-directory=$unescaped_exp_token
# use the directory name as fzf's prompt to indicate the search is limited to that directory
set --prepend fzf_arguments --prompt="Directory $unescaped_exp_token> " --preview="_fzf_preview_file $expanded_token{}"
set -f file_paths_selected $unescaped_exp_token($fd_cmd 2>/dev/null | _fzf_wrapper $fzf_arguments)
else
set --prepend fzf_arguments --prompt="Directory> " --query="$unescaped_exp_token" --preview='_fzf_preview_file {}'
set -f file_paths_selected ($fd_cmd 2>/dev/null | _fzf_wrapper $fzf_arguments)
end
if test $status -eq 0
commandline --current-token --replace -- (string escape -- $file_paths_selected | string join ' ')
end
commandline --function repaint
end

View File

@@ -0,0 +1,36 @@
function _fzf_search_git_log --description "Search the output of git log and preview commits. Replace the current token with the selected commit hash."
if not git rev-parse --git-dir >/dev/null 2>&1
echo '_fzf_search_git_log: Not in a git repository.' >&2
else
if not set --query fzf_git_log_format
# %h gives you the abbreviated commit hash, which is useful for saving screen space, but we will have to expand it later below
set -f fzf_git_log_format '%C(bold blue)%h%C(reset) - %C(cyan)%ad%C(reset) %C(yellow)%d%C(reset) %C(normal)%s%C(reset) %C(dim normal)[%an]%C(reset)'
end
set -f preview_cmd 'git show --color=always --stat --patch {1}'
if set --query fzf_diff_highlighter
set preview_cmd "$preview_cmd | $fzf_diff_highlighter"
end
set -f selected_log_lines (
git log --no-show-signature --color=always --format=format:$fzf_git_log_format --date=short | \
_fzf_wrapper --ansi \
--multi \
--scheme=history \
--prompt="Git Log> " \
--preview=$preview_cmd \
--query=(commandline --current-token) \
$fzf_git_log_opts
)
if test $status -eq 0
for line in $selected_log_lines
set -f abbreviated_commit_hash (string split --field 1 " " $line)
set -f full_commit_hash (git rev-parse $abbreviated_commit_hash)
set -f --append commit_hashes $full_commit_hash
end
commandline --current-token --replace (string join ' ' $commit_hashes)
end
end
commandline --function repaint
end

View File

@@ -0,0 +1,41 @@
function _fzf_search_git_status --description "Search the output of git status. Replace the current token with the selected file paths."
if not git rev-parse --git-dir >/dev/null 2>&1
echo '_fzf_search_git_status: Not in a git repository.' >&2
else
set -f preview_cmd '_fzf_preview_changed_file {}'
if set --query fzf_diff_highlighter
set preview_cmd "$preview_cmd | $fzf_diff_highlighter"
end
set -f selected_paths (
# Pass configuration color.status=always to force status to use colors even though output is sent to a pipe
git -c color.status=always status --short |
_fzf_wrapper --ansi \
--multi \
--prompt="Git Status> " \
--query=(commandline --current-token) \
--preview=$preview_cmd \
--nth="2.." \
$fzf_git_status_opts
)
if test $status -eq 0
# git status --short automatically escapes the paths of most files for us so not going to bother trying to handle
# the few edges cases of weird file names that should be extremely rare (e.g. "this;needs;escaping")
set -f cleaned_paths
for path in $selected_paths
if test (string sub --length 1 $path) = R
# path has been renamed and looks like "R LICENSE -> LICENSE.md"
# extract the path to use from after the arrow
set --append cleaned_paths (string split -- "-> " $path)[-1]
else
set --append cleaned_paths (string sub --start=4 $path)
end
end
commandline --current-token --replace -- (string join ' ' $cleaned_paths)
end
end
commandline --function repaint
end

View File

@@ -0,0 +1,39 @@
function _fzf_search_history --description "Search command history. Replace the command line with the selected command."
# history merge incorporates history changes from other fish sessions
# it errors out if called in private mode
if test -z "$fish_private_mode"
builtin history merge
end
if not set --query fzf_history_time_format
# Reference https://devhints.io/strftime to understand strftime format symbols
set -f fzf_history_time_format "%m-%d %H:%M:%S"
end
# Delinate time from command in history entries using the vertical box drawing char (U+2502).
# Then, to get raw command from history entries, delete everything up to it. The ? on regex is
# necessary to make regex non-greedy so it won't match into commands containing the char.
set -f time_prefix_regex '^.*? │ '
# Delinate commands throughout pipeline using null rather than newlines because commands can be multi-line
set -f commands_selected (
builtin history --null --show-time="$fzf_history_time_format" |
_fzf_wrapper --read0 \
--print0 \
--multi \
--scheme=history \
--prompt="History> " \
--query=(commandline) \
--preview="string replace --regex '$time_prefix_regex' '' -- {} | fish_indent --ansi" \
--preview-window="bottom:3:wrap" \
$fzf_history_opts |
string split0 |
# remove timestamps from commands selected
string replace --regex $time_prefix_regex ''
)
if test $status -eq 0
commandline --replace -- $commands_selected
end
commandline --function repaint
end

View File

@@ -0,0 +1,32 @@
function _fzf_search_processes --description "Search all running processes. Replace the current token with the pid of the selected process."
# Directly use ps command because it is often aliased to a different command entirely
# or with options that dirty the search results and preview output
set -f ps_cmd (command -v ps || echo "ps")
# use all caps to be consistent with ps default format
# snake_case because ps doesn't seem to allow spaces in the field names
set -f ps_preview_fmt (string join ',' 'pid' 'ppid=PARENT' 'user' '%cpu' 'rss=RSS_IN_KB' 'start=START_TIME' 'command')
set -f processes_selected (
$ps_cmd -A -opid,command | \
_fzf_wrapper --multi \
--prompt="Processes> " \
--query (commandline --current-token) \
--ansi \
# first line outputted by ps is a header, so we need to mark it as so
--header-lines=1 \
# ps uses exit code 1 if the process was not found, in which case show an message explaining so
--preview="$ps_cmd -o '$ps_preview_fmt' -p {1} || echo 'Cannot preview {1} because it exited.'" \
--preview-window="bottom:4:wrap" \
$fzf_processes_opts
)
if test $status -eq 0
for process in $processes_selected
set -f --append pids_selected (string split --no-empty --field=1 -- " " $process)
end
# string join to replace the newlines outputted by string split with spaces
commandline --current-token --replace -- (string join ' ' $pids_selected)
end
commandline --function repaint
end

View File

@@ -0,0 +1,47 @@
# This function expects the following two arguments:
# argument 1 = output of (set --show | psub), i.e. a file with the scope info and values of all variables
# argument 2 = output of (set --names | psub), i.e. a file with all variable names
function _fzf_search_variables --argument-names set_show_output set_names_output --description "Search and preview shell variables. Replace the current token with the selected variable."
if test -z "$set_names_output"
printf '%s\n' '_fzf_search_variables requires 2 arguments.' >&2
commandline --function repaint
return 22 # 22 means invalid argument in POSIX
end
# Exclude the history variable from being piped into fzf because
# 1. it's not included in $set_names_output
# 2. it tends to be a very large value => increases computation time
# 3._fzf_search_history is a much better way to examine history anyway
set -f all_variable_names (string match --invert history <$set_names_output)
set -f current_token (commandline --current-token)
# Use the current token to pre-populate fzf's query. If the current token begins
# with a $, remove it from the query so that it will better match the variable names
set -f cleaned_curr_token (string replace -- '$' '' $current_token)
set -f variable_names_selected (
printf '%s\n' $all_variable_names |
_fzf_wrapper --preview "_fzf_extract_var_info {} $set_show_output" \
--prompt="Variables> " \
--preview-window="wrap" \
--multi \
--query=$cleaned_curr_token \
$fzf_variables_opts
)
if test $status -eq 0
# If the current token begins with a $, do not overwrite the $ when
# replacing the current token with the selected variable.
# Uses brace expansion to prepend $ to each variable name.
commandline --current-token --replace (
if string match --quiet -- '$*' $current_token
string join " " \${$variable_names_selected}
else
string join " " $variable_names_selected
end
)
end
commandline --function repaint
end

View File

@@ -0,0 +1,21 @@
function _fzf_wrapper --description "Prepares some environment variables before executing fzf."
# Make sure fzf uses fish to execute preview commands, some of which
# are autoloaded fish functions so don't exist in other shells.
# Use --function so that it doesn't clobber SHELL outside this function.
set -f --export SHELL (command --search fish)
# If neither FZF_DEFAULT_OPTS nor FZF_DEFAULT_OPTS_FILE are set, then set some sane defaults.
# See https://github.com/junegunn/fzf#environment-variables
set --query FZF_DEFAULT_OPTS FZF_DEFAULT_OPTS_FILE
if test $status -eq 2
# cycle allows jumping between the first and last results, making scrolling faster
# layout=reverse lists results top to bottom, mimicking the familiar layouts of git log, history, and env
# border shows where the fzf window begins and ends
# height=90% leaves space to see the current command and some scrollback, maintaining context of work
# preview-window=wrap wraps long lines in the preview window, making reading easier
# marker=* makes the multi-select marker more distinguishable from the pointer (since both default to >)
set --export FZF_DEFAULT_OPTS '--cycle --layout=reverse --border --height=90% --preview-window=wrap --marker="*"'
end
fzf $argv
end

View File

@@ -0,0 +1,29 @@
function bass
set -l bash_args $argv
set -l bass_debug
if test "$bash_args[1]_" = '-d_'
set bass_debug true
set -e bash_args[1]
end
set -l script_file (mktemp)
if command -v python3 >/dev/null 2>&1
command python3 -sS (dirname (status -f))/__bass.py $bash_args 3>$script_file
else
command python -sS (dirname (status -f))/__bass.py $bash_args 3>$script_file
end
set -l bass_status $status
if test $bass_status -ne 0
return $bass_status
end
if test -n "$bass_debug"
cat $script_file
end
source $script_file
command rm $script_file
end
function __bass_usage
echo "Usage: bass [-d] <bash-command>"
end

View File

@@ -0,0 +1,240 @@
function fisher --argument-names cmd --description "A plugin manager for Fish"
set --query fisher_path || set --local fisher_path $__fish_config_dir
set --local fisher_version 4.4.4
set --local fish_plugins $__fish_config_dir/fish_plugins
switch "$cmd"
case -v --version
echo "fisher, version $fisher_version"
case "" -h --help
echo "Usage: fisher install <plugins...> Install plugins"
echo " fisher remove <plugins...> Remove installed plugins"
echo " fisher update <plugins...> Update installed plugins"
echo " fisher update Update all installed plugins"
echo " fisher list [<regex>] List installed plugins matching regex"
echo "Options:"
echo " -v, --version Print version"
echo " -h, --help Print this help message"
echo "Variables:"
echo " \$fisher_path Plugin installation path. Default: $__fish_config_dir" | string replace --regex -- $HOME \~
case ls list
string match --entire --regex -- "$argv[2]" $_fisher_plugins
case install update remove
isatty || read --local --null --array stdin && set --append argv $stdin
set --local install_plugins
set --local update_plugins
set --local remove_plugins
set --local arg_plugins $argv[2..-1]
set --local old_plugins $_fisher_plugins
set --local new_plugins
test -e $fish_plugins && set --local file_plugins (string match --regex -- '^[^\s]+$' <$fish_plugins)
if ! set --query argv[2]
if test "$cmd" != update
echo "fisher: Not enough arguments for command: \"$cmd\"" >&2 && return 1
else if ! set --query file_plugins
echo "fisher: \"$fish_plugins\" file not found: \"$cmd\"" >&2 && return 1
end
set arg_plugins $file_plugins
end
for plugin in $arg_plugins
set plugin (test -e "$plugin" && realpath $plugin || string lower -- $plugin)
contains -- "$plugin" $new_plugins || set --append new_plugins $plugin
end
if set --query argv[2]
for plugin in $new_plugins
if contains -- "$plugin" $old_plugins
test "$cmd" = remove &&
set --append remove_plugins $plugin ||
set --append update_plugins $plugin
else if test "$cmd" = install
set --append install_plugins $plugin
else
echo "fisher: Plugin not installed: \"$plugin\"" >&2 && return 1
end
end
else
for plugin in $new_plugins
contains -- "$plugin" $old_plugins &&
set --append update_plugins $plugin ||
set --append install_plugins $plugin
end
for plugin in $old_plugins
contains -- "$plugin" $new_plugins || set --append remove_plugins $plugin
end
end
set --local pid_list
set --local source_plugins
set --local fetch_plugins $update_plugins $install_plugins
set --local fish_path (status fish-path)
echo (set_color --bold)fisher $cmd version $fisher_version(set_color normal)
for plugin in $fetch_plugins
set --local source (command mktemp -d)
set --append source_plugins $source
command mkdir -p $source/{completions,conf.d,themes,functions}
$fish_path --command "
if test -e $plugin
command cp -Rf $plugin/* $source
else
set temp (command mktemp -d)
set repo (string split -- \@ $plugin) || set repo[2] HEAD
if set path (string replace --regex -- '^(https://)?gitlab.com/' '' \$repo[1])
set name (string split -- / \$path)[-1]
set url https://gitlab.com/\$path/-/archive/\$repo[2]/\$name-\$repo[2].tar.gz
else
set url https://api.github.com/repos/\$repo[1]/tarball/\$repo[2]
end
echo Fetching (set_color --underline)\$url(set_color normal)
if command curl -q --silent -L \$url | command tar -xzC \$temp -f - 2>/dev/null
command cp -Rf \$temp/*/* $source
else
echo fisher: Invalid plugin name or host unavailable: \\\"$plugin\\\" >&2
command rm -rf $source
end
command rm -rf \$temp
end
set files $source/* && string match --quiet --regex -- .+\.fish\\\$ \$files
" &
set --append pid_list (jobs --last --pid)
end
wait $pid_list 2>/dev/null
for plugin in $fetch_plugins
if set --local source $source_plugins[(contains --index -- "$plugin" $fetch_plugins)] && test ! -e $source
if set --local index (contains --index -- "$plugin" $install_plugins)
set --erase install_plugins[$index]
else
set --erase update_plugins[(contains --index -- "$plugin" $update_plugins)]
end
end
end
for plugin in $update_plugins $remove_plugins
if set --local index (contains --index -- "$plugin" $_fisher_plugins)
set --local plugin_files_var _fisher_(string escape --style=var -- $plugin)_files
if contains -- "$plugin" $remove_plugins
for name in (string replace --filter --regex -- '.+/conf\.d/([^/]+)\.fish$' '$1' $$plugin_files_var)
emit {$name}_uninstall
end
printf "%s\n" Removing\ (set_color red --bold)$plugin(set_color normal) " "$$plugin_files_var | string replace -- \~ ~
set --erase _fisher_plugins[$index]
end
command rm -rf (string replace -- \~ ~ $$plugin_files_var)
functions --erase (string replace --filter --regex -- '.+/functions/([^/]+)\.fish$' '$1' $$plugin_files_var)
for name in (string replace --filter --regex -- '.+/completions/([^/]+)\.fish$' '$1' $$plugin_files_var)
complete --erase --command $name
end
set --erase $plugin_files_var
end
end
if set --query update_plugins[1] || set --query install_plugins[1]
command mkdir -p $fisher_path/{functions,themes,conf.d,completions}
end
for plugin in $update_plugins $install_plugins
set --local source $source_plugins[(contains --index -- "$plugin" $fetch_plugins)]
set --local files $source/{functions,themes,conf.d,completions}/*
if set --local index (contains --index -- $plugin $install_plugins)
set --local user_files $fisher_path/{functions,themes,conf.d,completions}/*
set --local conflict_files
for file in (string replace -- $source/ $fisher_path/ $files)
contains -- $file $user_files && set --append conflict_files $file
end
if set --query conflict_files[1] && set --erase install_plugins[$index]
echo -s "fisher: Cannot install \"$plugin\": please remove or move conflicting files first:" \n" "$conflict_files >&2
continue
end
end
for file in (string replace -- $source/ "" $files)
command cp -RLf $source/$file $fisher_path/$file
end
set --local plugin_files_var _fisher_(string escape --style=var -- $plugin)_files
set --query files[1] && set --universal $plugin_files_var (string replace -- $source $fisher_path $files | string replace -- ~ \~)
contains -- $plugin $_fisher_plugins || set --universal --append _fisher_plugins $plugin
contains -- $plugin $install_plugins && set --local event install || set --local event update
printf "%s\n" Installing\ (set_color --bold)$plugin(set_color normal) " "$$plugin_files_var | string replace -- \~ ~
for file in (string match --regex -- '.+/[^/]+\.fish$' $$plugin_files_var | string replace -- \~ ~)
source $file
if set --local name (string replace --regex -- '.+conf\.d/([^/]+)\.fish$' '$1' $file)
emit {$name}_$event
end
end
end
command rm -rf $source_plugins
if set --query _fisher_plugins[1]
set --local commit_plugins
for plugin in $file_plugins
contains -- (string lower -- $plugin) (string lower -- $_fisher_plugins) && set --append commit_plugins $plugin
end
for plugin in $_fisher_plugins
contains -- (string lower -- $plugin) (string lower -- $commit_plugins) || set --append commit_plugins $plugin
end
printf "%s\n" $commit_plugins >$fish_plugins
else
set --erase _fisher_plugins
command rm -f $fish_plugins
end
set --local total (count $install_plugins) (count $update_plugins) (count $remove_plugins)
test "$total" != "0 0 0" && echo (string join ", " (
test $total[1] = 0 || echo "Installed $total[1]") (
test $total[2] = 0 || echo "Updated $total[2]") (
test $total[3] = 0 || echo "Removed $total[3]")
) plugin/s
case \*
echo "fisher: Unknown command: \"$cmd\"" >&2 && return 1
end
end
if ! set --query _fisher_upgraded_to_4_4
set --universal _fisher_upgraded_to_4_4
if functions --query _fisher_list
set --query XDG_DATA_HOME[1] || set --local XDG_DATA_HOME ~/.local/share
command rm -rf $XDG_DATA_HOME/fisher
functions --erase _fisher_{list,plugin_parse}
fisher update >/dev/null 2>/dev/null
else
for var in (set --names | string match --entire --regex '^_fisher_.+_files$')
set $var (string replace -- ~ \~ $$var)
end
functions --erase _fisher_fish_postexec
end
end

View File

@@ -0,0 +1,46 @@
# Always installs bindings for insert and default mode for simplicity and b/c it has almost no side-effect
# https://gitter.im/fish-shell/fish-shell?at=60a55915ee77a74d685fa6b1
function fzf_configure_bindings --description "Installs the default key bindings for fzf.fish with user overrides passed as options."
# no need to install bindings if not in interactive mode or running tests
status is-interactive || test "$CI" = true; or return
set -f options_spec h/help 'directory=?' 'git_log=?' 'git_status=?' 'history=?' 'processes=?' 'variables=?'
argparse --max-args=0 --ignore-unknown $options_spec -- $argv 2>/dev/null
if test $status -ne 0
echo "Invalid option or a positional argument was provided." >&2
_fzf_configure_bindings_help
return 22
else if set --query _flag_help
_fzf_configure_bindings_help
return
else
# Initialize with default key sequences and then override or disable them based on flags
# index 1 = directory, 2 = git_log, 3 = git_status, 4 = history, 5 = processes, 6 = variables
set -f key_sequences \e\cf \e\cl \e\cs \cr \e\cp \cv # \c = control, \e = escape
set --query _flag_directory && set key_sequences[1] "$_flag_directory"
set --query _flag_git_log && set key_sequences[2] "$_flag_git_log"
set --query _flag_git_status && set key_sequences[3] "$_flag_git_status"
set --query _flag_history && set key_sequences[4] "$_flag_history"
set --query _flag_processes && set key_sequences[5] "$_flag_processes"
set --query _flag_variables && set key_sequences[6] "$_flag_variables"
# If fzf bindings already exists, uninstall it first for a clean slate
if functions --query _fzf_uninstall_bindings
_fzf_uninstall_bindings
end
for mode in default insert
test -n $key_sequences[1] && bind --mode $mode $key_sequences[1] _fzf_search_directory
test -n $key_sequences[2] && bind --mode $mode $key_sequences[2] _fzf_search_git_log
test -n $key_sequences[3] && bind --mode $mode $key_sequences[3] _fzf_search_git_status
test -n $key_sequences[4] && bind --mode $mode $key_sequences[4] _fzf_search_history
test -n $key_sequences[5] && bind --mode $mode $key_sequences[5] _fzf_search_processes
test -n $key_sequences[6] && bind --mode $mode $key_sequences[6] "$_fzf_search_vars_command"
end
function _fzf_uninstall_bindings --inherit-variable key_sequences
bind --erase -- $key_sequences
bind --erase --mode insert -- $key_sequences
end
end
end

View File

@@ -0,0 +1,30 @@
# name: 'Catppuccin Frappé'
# url: 'https://github.com/catppuccin/fish'
# preferred_background: 303446
fish_color_normal c6d0f5
fish_color_command 8caaee
fish_color_param eebebe
fish_color_keyword e78284
fish_color_quote a6d189
fish_color_redirection f4b8e4
fish_color_end ef9f76
fish_color_comment 838ba7
fish_color_error e78284
fish_color_gray 737994
fish_color_selection --background=414559
fish_color_search_match --background=414559
fish_color_option a6d189
fish_color_operator f4b8e4
fish_color_escape ea999c
fish_color_autosuggestion 737994
fish_color_cancel e78284
fish_color_cwd e5c890
fish_color_user 81c8be
fish_color_host 8caaee
fish_color_host_remote a6d189
fish_color_status e78284
fish_pager_color_progress 737994
fish_pager_color_prefix f4b8e4
fish_pager_color_completion c6d0f5
fish_pager_color_description 737994

View File

@@ -0,0 +1,30 @@
# name: 'Catppuccin Latte'
# url: 'https://github.com/catppuccin/fish'
# preferred_background: eff1f5
fish_color_normal 4c4f69
fish_color_command 1e66f5
fish_color_param dd7878
fish_color_keyword d20f39
fish_color_quote 40a02b
fish_color_redirection ea76cb
fish_color_end fe640b
fish_color_comment 8c8fa1
fish_color_error d20f39
fish_color_gray 9ca0b0
fish_color_selection --background=ccd0da
fish_color_search_match --background=ccd0da
fish_color_option 40a02b
fish_color_operator ea76cb
fish_color_escape e64553
fish_color_autosuggestion 9ca0b0
fish_color_cancel d20f39
fish_color_cwd df8e1d
fish_color_user 179299
fish_color_host 1e66f5
fish_color_host_remote 40a02b
fish_color_status d20f39
fish_pager_color_progress 9ca0b0
fish_pager_color_prefix ea76cb
fish_pager_color_completion 4c4f69
fish_pager_color_description 9ca0b0

View File

@@ -0,0 +1,30 @@
# name: 'Catppuccin Macchiato'
# url: 'https://github.com/catppuccin/fish'
# preferred_background: 24273a
fish_color_normal cad3f5
fish_color_command 8aadf4
fish_color_param f0c6c6
fish_color_keyword ed8796
fish_color_quote a6da95
fish_color_redirection f5bde6
fish_color_end f5a97f
fish_color_comment 8087a2
fish_color_error ed8796
fish_color_gray 6e738d
fish_color_selection --background=363a4f
fish_color_search_match --background=363a4f
fish_color_option a6da95
fish_color_operator f5bde6
fish_color_escape ee99a0
fish_color_autosuggestion 6e738d
fish_color_cancel ed8796
fish_color_cwd eed49f
fish_color_user 8bd5ca
fish_color_host 8aadf4
fish_color_host_remote a6da95
fish_color_status ed8796
fish_pager_color_progress 6e738d
fish_pager_color_prefix f5bde6
fish_pager_color_completion cad3f5
fish_pager_color_description 6e738d

View File

@@ -0,0 +1,30 @@
# name: 'Catppuccin Mocha'
# url: 'https://github.com/catppuccin/fish'
# preferred_background: 1e1e2e
fish_color_normal cdd6f4
fish_color_command 89b4fa
fish_color_param f2cdcd
fish_color_keyword f38ba8
fish_color_quote a6e3a1
fish_color_redirection f5c2e7
fish_color_end fab387
fish_color_comment 7f849c
fish_color_error f38ba8
fish_color_gray 6c7086
fish_color_selection --background=313244
fish_color_search_match --background=313244
fish_color_option a6e3a1
fish_color_operator f5c2e7
fish_color_escape eba0ac
fish_color_autosuggestion 6c7086
fish_color_cancel f38ba8
fish_color_cwd f9e2af
fish_color_user 94e2d5
fish_color_host 89b4fa
fish_color_host_remote a6e3a1
fish_color_status f38ba8
fish_pager_color_progress 6c7086
fish_pager_color_prefix f5c2e7
fish_pager_color_completion cdd6f4
fish_pager_color_description 6c7086