Update
This commit is contained in:
235
config/fish/completions/git-lfs.fish
Normal file
235
config/fish/completions/git-lfs.fish
Normal file
@@ -0,0 +1,235 @@
|
||||
# fish completion for git-lfs -*- shell-script -*-
|
||||
|
||||
function __git_lfs_debug
|
||||
set -l file "$BASH_COMP_DEBUG_FILE"
|
||||
if test -n "$file"
|
||||
echo "$argv" >> $file
|
||||
end
|
||||
end
|
||||
|
||||
function __git_lfs_perform_completion
|
||||
__git_lfs_debug "Starting __git_lfs_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))
|
||||
|
||||
__git_lfs_debug "args: $args"
|
||||
__git_lfs_debug "last arg: $lastArg"
|
||||
|
||||
# Disable ActiveHelp which is not supported for fish shell
|
||||
set -l requestComp "GIT_LFS_ACTIVE_HELP=0 $args[1] __completeNoDesc $args[2..-1] $lastArg"
|
||||
|
||||
__git_lfs_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")
|
||||
|
||||
__git_lfs_debug "Comps: $comps"
|
||||
__git_lfs_debug "DirectiveLine: $directiveLine"
|
||||
__git_lfs_debug "flagPrefix: $flagPrefix"
|
||||
|
||||
for comp in $comps
|
||||
printf "%s%s\n" "$flagPrefix" "$comp"
|
||||
end
|
||||
|
||||
printf "%s\n" "$directiveLine"
|
||||
end
|
||||
|
||||
# this function limits calls to __git_lfs_perform_completion, by caching the result behind $__git_lfs_perform_completion_once_result
|
||||
function __git_lfs_perform_completion_once
|
||||
__git_lfs_debug "Starting __git_lfs_perform_completion_once"
|
||||
|
||||
if test -n "$__git_lfs_perform_completion_once_result"
|
||||
__git_lfs_debug "Seems like a valid result already exists, skipping __git_lfs_perform_completion"
|
||||
return 0
|
||||
end
|
||||
|
||||
set --global __git_lfs_perform_completion_once_result (__git_lfs_perform_completion)
|
||||
if test -z "$__git_lfs_perform_completion_once_result"
|
||||
__git_lfs_debug "No completions, probably due to a failure"
|
||||
return 1
|
||||
end
|
||||
|
||||
__git_lfs_debug "Performed completions and set __git_lfs_perform_completion_once_result"
|
||||
return 0
|
||||
end
|
||||
|
||||
# this function is used to clear the $__git_lfs_perform_completion_once_result variable after completions are run
|
||||
function __git_lfs_clear_perform_completion_once_result
|
||||
__git_lfs_debug ""
|
||||
__git_lfs_debug "========= clearing previously set __git_lfs_perform_completion_once_result variable =========="
|
||||
set --erase __git_lfs_perform_completion_once_result
|
||||
__git_lfs_debug "Succesfully erased the variable __git_lfs_perform_completion_once_result"
|
||||
end
|
||||
|
||||
function __git_lfs_requires_order_preservation
|
||||
__git_lfs_debug ""
|
||||
__git_lfs_debug "========= checking if order preservation is required =========="
|
||||
|
||||
__git_lfs_perform_completion_once
|
||||
if test -z "$__git_lfs_perform_completion_once_result"
|
||||
__git_lfs_debug "Error determining if order preservation is required"
|
||||
return 1
|
||||
end
|
||||
|
||||
set -l directive (string sub --start 2 $__git_lfs_perform_completion_once_result[-1])
|
||||
__git_lfs_debug "Directive is: $directive"
|
||||
|
||||
set -l shellCompDirectiveKeepOrder 32
|
||||
set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2)
|
||||
__git_lfs_debug "Keeporder is: $keeporder"
|
||||
|
||||
if test $keeporder -ne 0
|
||||
__git_lfs_debug "This does require order preservation"
|
||||
return 0
|
||||
end
|
||||
|
||||
__git_lfs_debug "This doesn't require order preservation"
|
||||
return 1
|
||||
end
|
||||
|
||||
|
||||
# This function does two things:
|
||||
# - Obtain the completions and store them in the global __git_lfs_comp_results
|
||||
# - Return false if file completion should be performed
|
||||
function __git_lfs_prepare_completions
|
||||
__git_lfs_debug ""
|
||||
__git_lfs_debug "========= starting completion logic =========="
|
||||
|
||||
# Start fresh
|
||||
set --erase __git_lfs_comp_results
|
||||
|
||||
__git_lfs_perform_completion_once
|
||||
__git_lfs_debug "Completion results: $__git_lfs_perform_completion_once_result"
|
||||
|
||||
if test -z "$__git_lfs_perform_completion_once_result"
|
||||
__git_lfs_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 $__git_lfs_perform_completion_once_result[-1])
|
||||
set --global __git_lfs_comp_results $__git_lfs_perform_completion_once_result[1..-2]
|
||||
|
||||
__git_lfs_debug "Completions are: $__git_lfs_comp_results"
|
||||
__git_lfs_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
|
||||
__git_lfs_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
|
||||
__git_lfs_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)
|
||||
|
||||
__git_lfs_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)
|
||||
__git_lfs_debug "prefix: $prefix"
|
||||
|
||||
set -l completions (string match -r -- "^$prefix.*" $__git_lfs_comp_results)
|
||||
set --global __git_lfs_comp_results $completions
|
||||
__git_lfs_debug "Filtered completions are: $__git_lfs_comp_results"
|
||||
|
||||
# Important not to quote the variable for count to work
|
||||
set -l numComps (count $__git_lfs_comp_results)
|
||||
__git_lfs_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 $__git_lfs_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.
|
||||
__git_lfs_debug "Adding second completion to perform nospace directive"
|
||||
set --global __git_lfs_comp_results $split[1] $split[1].
|
||||
__git_lfs_debug "Completions are now: $__git_lfs_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
|
||||
__git_lfs_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 "git-lfs"
|
||||
# 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 "git-lfs " > /dev/null 2>&1
|
||||
end
|
||||
|
||||
# Remove any pre-existing completions for the program since we will be handling all of them.
|
||||
complete -c git-lfs -e
|
||||
|
||||
# this will get called after the two calls below and clear the $__git_lfs_perform_completion_once_result global
|
||||
complete -c git-lfs -n '__git_lfs_clear_perform_completion_once_result'
|
||||
# The call to __git_lfs_prepare_completions will setup __git_lfs_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 git-lfs -n 'not __git_lfs_requires_order_preservation && __git_lfs_prepare_completions' -f -a '$__git_lfs_comp_results'
|
||||
# otherwise we use the -k flag
|
||||
complete -k -c git-lfs -n '__git_lfs_requires_order_preservation && __git_lfs_prepare_completions' -f -a '$__git_lfs_comp_results'
|
||||
1
config/fish/completions/pio.fish
Normal file
1
config/fish/completions/pio.fish
Normal file
@@ -0,0 +1 @@
|
||||
eval (env _PIO_COMPLETE=fish_source pio)
|
||||
199
config/fish/completions/rustup.fish
Normal file
199
config/fish/completions/rustup.fish
Normal file
@@ -0,0 +1,199 @@
|
||||
complete -c rustup -n "__fish_use_subcommand" -s v -l verbose -d 'Enable verbose output'
|
||||
complete -c rustup -n "__fish_use_subcommand" -s q -l quiet -d 'Disable progress output'
|
||||
complete -c rustup -n "__fish_use_subcommand" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_use_subcommand" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_use_subcommand" -f -a "dump-testament" -d 'Dump information about the build'
|
||||
complete -c rustup -n "__fish_use_subcommand" -f -a "show" -d 'Show the active and installed toolchains or profiles'
|
||||
complete -c rustup -n "__fish_use_subcommand" -f -a "install" -d 'Update Rust toolchains'
|
||||
complete -c rustup -n "__fish_use_subcommand" -f -a "uninstall" -d 'Uninstall Rust toolchains'
|
||||
complete -c rustup -n "__fish_use_subcommand" -f -a "update" -d 'Update Rust toolchains and rustup'
|
||||
complete -c rustup -n "__fish_use_subcommand" -f -a "check" -d 'Check for updates to Rust toolchains and rustup'
|
||||
complete -c rustup -n "__fish_use_subcommand" -f -a "default" -d 'Set the default toolchain'
|
||||
complete -c rustup -n "__fish_use_subcommand" -f -a "toolchain" -d 'Modify or query the installed toolchains'
|
||||
complete -c rustup -n "__fish_use_subcommand" -f -a "target" -d 'Modify a toolchain\'s supported targets'
|
||||
complete -c rustup -n "__fish_use_subcommand" -f -a "component" -d 'Modify a toolchain\'s installed components'
|
||||
complete -c rustup -n "__fish_use_subcommand" -f -a "override" -d 'Modify directory toolchain overrides'
|
||||
complete -c rustup -n "__fish_use_subcommand" -f -a "run" -d 'Run a command with an environment configured for a given toolchain'
|
||||
complete -c rustup -n "__fish_use_subcommand" -f -a "which" -d 'Display which binary will be run for a given command'
|
||||
complete -c rustup -n "__fish_use_subcommand" -f -a "doc" -d 'Open the documentation for the current toolchain'
|
||||
complete -c rustup -n "__fish_use_subcommand" -f -a "man" -d 'View the man page for a given command'
|
||||
complete -c rustup -n "__fish_use_subcommand" -f -a "self" -d 'Modify the rustup installation'
|
||||
complete -c rustup -n "__fish_use_subcommand" -f -a "set" -d 'Alter rustup settings'
|
||||
complete -c rustup -n "__fish_use_subcommand" -f -a "completions" -d 'Generate tab-completion scripts for your shell'
|
||||
complete -c rustup -n "__fish_use_subcommand" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from dump-testament" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from dump-testament" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from show" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from show" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from show" -f -a "active-toolchain" -d 'Show the active toolchain'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from show" -f -a "home" -d 'Display the computed value of RUSTUP_HOME'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from show" -f -a "profile" -d 'Show the current profile'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from show" -f -a "keys" -d 'Display the known PGP keys'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from show" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from active-toolchain" -s v -l verbose -d 'Enable verbose output with rustc information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from active-toolchain" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from active-toolchain" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from home" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from home" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from profile" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from profile" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from keys" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from keys" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from help" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from help" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from install" -l profile -r -f -a "minimal default complete"
|
||||
complete -c rustup -n "__fish_seen_subcommand_from install" -l no-self-update -d 'Don\'t perform self-update when running the `rustup install` command'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from install" -l force -d 'Force an update, even if some components are missing'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from install" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from install" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from uninstall" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from uninstall" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from update" -l no-self-update -d 'Don\'t perform self update when running the `rustup update` command'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from update" -l force -d 'Force an update, even if some components are missing'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from update" -l force-non-host -d 'Install toolchains that require an emulator. See https://github.com/rust-lang/rustup/wiki/Non-host-toolchains'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from update" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from update" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from check" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from check" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from default" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from default" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from toolchain" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from toolchain" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from toolchain" -f -a "list" -d 'List installed toolchains'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from toolchain" -f -a "install" -d 'Install or update a given toolchain'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from toolchain" -f -a "uninstall" -d 'Uninstall a toolchain'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from toolchain" -f -a "link" -d 'Create a custom toolchain by symlinking to a directory'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from toolchain" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from list" -s v -l verbose -d 'Enable verbose output with toolchain information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from list" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from list" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from install" -l profile -r -f -a "minimal default complete"
|
||||
complete -c rustup -n "__fish_seen_subcommand_from install" -s c -l component -d 'Add specific components on installation'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from install" -s t -l target -d 'Add specific targets on installation'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from install" -l no-self-update -d 'Don\'t perform self update when running the`rustup toolchain install` command'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from install" -l force -d 'Force an update, even if some components are missing'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from install" -l allow-downgrade -d 'Allow rustup to downgrade the toolchain to satisfy your component choice'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from install" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from install" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from uninstall" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from uninstall" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from link" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from link" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from help" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from help" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from target" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from target" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from target" -f -a "list" -d 'List installed and available targets'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from target" -f -a "add" -d 'Add a target to a Rust toolchain'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from target" -f -a "remove" -d 'Remove a target from a Rust toolchain'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from target" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from list" -l toolchain -d 'Toolchain name, such as \'stable\', \'nightly\', or \'1.8.0\'. For more information see `rustup help toolchain`'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from list" -l installed -d 'List only installed targets'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from list" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from list" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from add" -l toolchain -d 'Toolchain name, such as \'stable\', \'nightly\', or \'1.8.0\'. For more information see `rustup help toolchain`'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from add" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from add" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from remove" -l toolchain -d 'Toolchain name, such as \'stable\', \'nightly\', or \'1.8.0\'. For more information see `rustup help toolchain`'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from remove" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from remove" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from help" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from help" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from component" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from component" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from component" -f -a "list" -d 'List installed and available components'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from component" -f -a "add" -d 'Add a component to a Rust toolchain'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from component" -f -a "remove" -d 'Remove a component from a Rust toolchain'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from component" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from list" -l toolchain -d 'Toolchain name, such as \'stable\', \'nightly\', or \'1.8.0\'. For more information see `rustup help toolchain`'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from list" -l installed -d 'List only installed components'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from list" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from list" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from add" -l toolchain -d 'Toolchain name, such as \'stable\', \'nightly\', or \'1.8.0\'. For more information see `rustup help toolchain`'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from add" -l target
|
||||
complete -c rustup -n "__fish_seen_subcommand_from add" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from add" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from remove" -l toolchain -d 'Toolchain name, such as \'stable\', \'nightly\', or \'1.8.0\'. For more information see `rustup help toolchain`'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from remove" -l target
|
||||
complete -c rustup -n "__fish_seen_subcommand_from remove" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from remove" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from help" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from help" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from override" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from override" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from override" -f -a "list" -d 'List directory toolchain overrides'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from override" -f -a "set" -d 'Set the override toolchain for a directory'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from override" -f -a "unset" -d 'Remove the override toolchain for a directory'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from override" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from list" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from list" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from set" -l path -d 'Path to the directory'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from set" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from set" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from unset" -l path -d 'Path to the directory'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from unset" -l nonexistent -d 'Remove override toolchain for all nonexistent directories'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from unset" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from unset" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from help" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from help" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from run" -l install -d 'Install the requested toolchain if needed'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from run" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from run" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from which" -l toolchain -d 'Toolchain name, such as \'stable\', \'nightly\', or \'1.8.0\'. For more information see `rustup help toolchain`'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from which" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from which" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from doc" -l toolchain -d 'Toolchain name, such as \'stable\', \'nightly\', or \'1.8.0\'. For more information see `rustup help toolchain`'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from doc" -l path -d 'Only print the path to the documentation'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from doc" -l alloc -d 'The Rust core allocation and collections library'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from doc" -l book -d 'The Rust Programming Language book'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from doc" -l cargo -d 'The Cargo Book'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from doc" -l core -d 'The Rust Core Library'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from doc" -l edition-guide -d 'The Rust Edition Guide'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from doc" -l nomicon -d 'The Dark Arts of Advanced and Unsafe Rust Programming'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from doc" -l proc_macro -d 'A support library for macro authors when defining new macros'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from doc" -l reference -d 'The Rust Reference'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from doc" -l rust-by-example -d 'A collection of runnable examples that illustrate various Rust concepts and standard libraries'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from doc" -l rustc -d 'The compiler for the Rust programming language'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from doc" -l rustdoc -d 'Generate documentation for Rust projects'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from doc" -l std -d 'Standard library API documentation'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from doc" -l test -d 'Support code for rustc\'s built in unit-test and micro-benchmarking framework'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from doc" -l unstable-book -d 'The Unstable Book'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from doc" -l embedded-book -d 'The Embedded Rust Book'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from doc" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from doc" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from man" -l toolchain -d 'Toolchain name, such as \'stable\', \'nightly\', or \'1.8.0\'. For more information see `rustup help toolchain`'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from man" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from man" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from self" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from self" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from self" -f -a "update" -d 'Download and install updates to rustup'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from self" -f -a "uninstall" -d 'Uninstall rustup.'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from self" -f -a "upgrade-data" -d 'Upgrade the internal data format.'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from self" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from update" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from update" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from uninstall" -s y
|
||||
complete -c rustup -n "__fish_seen_subcommand_from uninstall" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from uninstall" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from upgrade-data" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from upgrade-data" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from help" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from help" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from set" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from set" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from set" -f -a "default-host" -d 'The triple used to identify toolchains when not specified'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from set" -f -a "profile" -d 'The default components installed'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from set" -f -a "auto-self-update" -d 'The rustup auto self update mode'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from set" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from default-host" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from default-host" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from profile" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from profile" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from auto-self-update" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from auto-self-update" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from help" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from help" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from completions" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from completions" -s V -l version -d 'Prints version information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from help" -s h -l help -d 'Prints help information'
|
||||
complete -c rustup -n "__fish_seen_subcommand_from help" -s V -l version -d 'Prints version information'
|
||||
4
config/fish/completions/spark.fish
Normal file
4
config/fish/completions/spark.fish
Normal file
@@ -0,0 +1,4 @@
|
||||
complete --command spark --exclusive --long min --description "Minimum range"
|
||||
complete --command spark --exclusive --long max --description "Maximum range"
|
||||
complete --command spark --exclusive --long version --description "Print version"
|
||||
complete --command spark --exclusive --long help --description "Print this help message"
|
||||
5
config/fish/fish_plugins
Normal file
5
config/fish/fish_plugins
Normal file
@@ -0,0 +1,5 @@
|
||||
jorgebucaran/fisher
|
||||
jethrokuan/fzf
|
||||
jorgebucaran/spark.fish
|
||||
franciscolourenco/done
|
||||
edc/bass
|
||||
140
config/fish/functions/__bass.py
Normal file
140
config/fish/functions/__bass.py
Normal 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)
|
||||
29
config/fish/functions/bass.fish
Normal file
29
config/fish/functions/bass.fish
Normal 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
|
||||
3
config/fish/functions/bx.fish
Normal file
3
config/fish/functions/bx.fish
Normal file
@@ -0,0 +1,3 @@
|
||||
function bx
|
||||
command bundle exec $argv
|
||||
end
|
||||
16
config/fish/functions/load_nvm.fish
Normal file
16
config/fish/functions/load_nvm.fish
Normal file
@@ -0,0 +1,16 @@
|
||||
function load_nvm --on-variable="PWD"
|
||||
set -l default_node_version (nvm version default)
|
||||
set -l node_version (nvm version)
|
||||
set -l nvmrc_path (nvm_find_nvmrc)
|
||||
if test -n "$nvmrc_path"
|
||||
set -l nvmrc_node_version (nvm version (cat $nvmrc_path))
|
||||
if test "$nvmrc_node_version" = "N/A"
|
||||
nvm install (cat $nvmrc_path)
|
||||
else if test "$nvmrc_node_version" != "$node_version"
|
||||
nvm use $nvmrc_node_version
|
||||
end
|
||||
else if test "$node_version" != "$default_node_version"
|
||||
echo "Reverting to default Node version"
|
||||
nvm use default
|
||||
end
|
||||
end
|
||||
3
config/fish/functions/nvm.fish
Normal file
3
config/fish/functions/nvm.fish
Normal file
@@ -0,0 +1,3 @@
|
||||
function nvm
|
||||
bass source ~/.config/nvm/nvm.sh --no-use ';' nvm $argv
|
||||
end
|
||||
3
config/fish/functions/nvm_find_nvmrc.fish
Normal file
3
config/fish/functions/nvm_find_nvmrc.fish
Normal file
@@ -0,0 +1,3 @@
|
||||
function nvm_find_nvmrc
|
||||
bass source ~/.config/nvm/nvm.sh --no-use ';' nvm_find_nvmrc
|
||||
end
|
||||
Reference in New Issue
Block a user