mirror of
https://github.com/cupcakearmy/dotfiles.git
synced 2024-12-23 00:36:31 +00:00
fish
This commit is contained in:
parent
e4a32cb394
commit
ceb8419b44
164
files/fish/completions/autorestic.fish
Normal file
164
files/fish/completions/autorestic.fish
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
# fish completion for autorestic -*- shell-script -*-
|
||||||
|
|
||||||
|
function __autorestic_debug
|
||||||
|
set file "$BASH_COMP_DEBUG_FILE"
|
||||||
|
if test -n "$file"
|
||||||
|
echo "$argv" >> $file
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function __autorestic_perform_completion
|
||||||
|
__autorestic_debug "Starting __autorestic_perform_completion with: $argv"
|
||||||
|
|
||||||
|
set args (string split -- " " "$argv")
|
||||||
|
set lastArg "$args[-1]"
|
||||||
|
|
||||||
|
__autorestic_debug "args: $args"
|
||||||
|
__autorestic_debug "last arg: $lastArg"
|
||||||
|
|
||||||
|
set emptyArg ""
|
||||||
|
if test -z "$lastArg"
|
||||||
|
__autorestic_debug "Setting emptyArg"
|
||||||
|
set emptyArg \"\"
|
||||||
|
end
|
||||||
|
__autorestic_debug "emptyArg: $emptyArg"
|
||||||
|
|
||||||
|
if not type -q "$args[1]"
|
||||||
|
# This can happen when "complete --do-complete autorestic" is called when running this script.
|
||||||
|
__autorestic_debug "Cannot find $args[1]. No completions."
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
set requestComp "$args[1] __complete $args[2..-1] $emptyArg"
|
||||||
|
__autorestic_debug "Calling $requestComp"
|
||||||
|
|
||||||
|
set results (eval $requestComp 2> /dev/null)
|
||||||
|
set comps $results[1..-2]
|
||||||
|
set directiveLine $results[-1]
|
||||||
|
|
||||||
|
# For Fish, when completing a flag with an = (e.g., <program> -n=<TAB>)
|
||||||
|
# completions must be prefixed with the flag
|
||||||
|
set flagPrefix (string match -r -- '-.*=' "$lastArg")
|
||||||
|
|
||||||
|
__autorestic_debug "Comps: $comps"
|
||||||
|
__autorestic_debug "DirectiveLine: $directiveLine"
|
||||||
|
__autorestic_debug "flagPrefix: $flagPrefix"
|
||||||
|
|
||||||
|
for comp in $comps
|
||||||
|
printf "%s%s\n" "$flagPrefix" "$comp"
|
||||||
|
end
|
||||||
|
|
||||||
|
printf "%s\n" "$directiveLine"
|
||||||
|
end
|
||||||
|
|
||||||
|
# This function does three things:
|
||||||
|
# 1- Obtain the completions and store them in the global __autorestic_comp_results
|
||||||
|
# 2- Set the __autorestic_comp_do_file_comp flag if file completion should be performed
|
||||||
|
# and unset it otherwise
|
||||||
|
# 3- Return true if the completion results are not empty
|
||||||
|
function __autorestic_prepare_completions
|
||||||
|
# Start fresh
|
||||||
|
set --erase __autorestic_comp_do_file_comp
|
||||||
|
set --erase __autorestic_comp_results
|
||||||
|
|
||||||
|
# Check if the command-line is already provided. This is useful for testing.
|
||||||
|
if not set --query __autorestic_comp_commandLine
|
||||||
|
# Use the -c flag to allow for completion in the middle of the line
|
||||||
|
set __autorestic_comp_commandLine (commandline -c)
|
||||||
|
end
|
||||||
|
__autorestic_debug "commandLine is: $__autorestic_comp_commandLine"
|
||||||
|
|
||||||
|
set results (__autorestic_perform_completion "$__autorestic_comp_commandLine")
|
||||||
|
set --erase __autorestic_comp_commandLine
|
||||||
|
__autorestic_debug "Completion results: $results"
|
||||||
|
|
||||||
|
if test -z "$results"
|
||||||
|
__autorestic_debug "No completion, probably due to a failure"
|
||||||
|
# Might as well do file completion, in case it helps
|
||||||
|
set --global __autorestic_comp_do_file_comp 1
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
|
||||||
|
set directive (string sub --start 2 $results[-1])
|
||||||
|
set --global __autorestic_comp_results $results[1..-2]
|
||||||
|
|
||||||
|
__autorestic_debug "Completions are: $__autorestic_comp_results"
|
||||||
|
__autorestic_debug "Directive is: $directive"
|
||||||
|
|
||||||
|
set shellCompDirectiveError 1
|
||||||
|
set shellCompDirectiveNoSpace 2
|
||||||
|
set shellCompDirectiveNoFileComp 4
|
||||||
|
set shellCompDirectiveFilterFileExt 8
|
||||||
|
set shellCompDirectiveFilterDirs 16
|
||||||
|
|
||||||
|
if test -z "$directive"
|
||||||
|
set directive 0
|
||||||
|
end
|
||||||
|
|
||||||
|
set compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)
|
||||||
|
if test $compErr -eq 1
|
||||||
|
__autorestic_debug "Received error directive: aborting."
|
||||||
|
# Might as well do file completion, in case it helps
|
||||||
|
set --global __autorestic_comp_do_file_comp 1
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
|
||||||
|
set filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)
|
||||||
|
set dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)
|
||||||
|
if test $filefilter -eq 1; or test $dirfilter -eq 1
|
||||||
|
__autorestic_debug "File extension filtering or directory filtering not supported"
|
||||||
|
# Do full file completion instead
|
||||||
|
set --global __autorestic_comp_do_file_comp 1
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
|
||||||
|
set nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)
|
||||||
|
set nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)
|
||||||
|
|
||||||
|
__autorestic_debug "nospace: $nospace, nofiles: $nofiles"
|
||||||
|
|
||||||
|
# Important not to quote the variable for count to work
|
||||||
|
set numComps (count $__autorestic_comp_results)
|
||||||
|
__autorestic_debug "numComps: $numComps"
|
||||||
|
|
||||||
|
if test $numComps -eq 1; and test $nospace -ne 0
|
||||||
|
# To support the "nospace" directive we trick the shell
|
||||||
|
# by outputting an extra, longer completion.
|
||||||
|
__autorestic_debug "Adding second completion to perform nospace directive"
|
||||||
|
set --append __autorestic_comp_results $__autorestic_comp_results[1].
|
||||||
|
end
|
||||||
|
|
||||||
|
if test $numComps -eq 0; and test $nofiles -eq 0
|
||||||
|
__autorestic_debug "Requesting file completion"
|
||||||
|
set --global __autorestic_comp_do_file_comp 1
|
||||||
|
end
|
||||||
|
|
||||||
|
# If we don't want file completion, we must return true even if there
|
||||||
|
# are no completions found. This is because fish will perform the last
|
||||||
|
# completion command, even if its condition is false, if no other
|
||||||
|
# completion command was triggered
|
||||||
|
return (not set --query __autorestic_comp_do_file_comp)
|
||||||
|
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.
|
||||||
|
# The space after the the program name is essential to trigger completion for the program
|
||||||
|
# and not completion of the program name itself.
|
||||||
|
complete --do-complete "autorestic " > /dev/null 2>&1
|
||||||
|
# Using '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.
|
||||||
|
|
||||||
|
# Remove any pre-existing completions for the program since we will be handling all of them.
|
||||||
|
complete -c autorestic -e
|
||||||
|
|
||||||
|
# The order in which the below two lines are defined is very important so that __autorestic_prepare_completions
|
||||||
|
# is called first. It is __autorestic_prepare_completions that sets up the __autorestic_comp_do_file_comp variable.
|
||||||
|
#
|
||||||
|
# This completion will be run second as complete commands are added FILO.
|
||||||
|
# It triggers file completion choices when __autorestic_comp_do_file_comp is set.
|
||||||
|
complete -c autorestic -n 'set --query __autorestic_comp_do_file_comp'
|
||||||
|
|
||||||
|
# This completion will be run first as complete commands are added FILO.
|
||||||
|
# The call to __autorestic_prepare_completions will setup both __autorestic_comp_results and __autorestic_comp_do_file_comp.
|
||||||
|
# It provides the program's completion choices.
|
||||||
|
complete -c autorestic -n '__autorestic_prepare_completions' -f -a '$__autorestic_comp_results'
|
||||||
|
|
1
files/fish/completions/fisher.fish
Normal file
1
files/fish/completions/fisher.fish
Normal file
@ -0,0 +1 @@
|
|||||||
|
fisher complete
|
7
files/fish/conf.d/omf.fish
Normal file
7
files/fish/conf.d/omf.fish
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Path to Oh My Fish install.
|
||||||
|
set -q XDG_DATA_HOME
|
||||||
|
and set -gx OMF_PATH "$XDG_DATA_HOME/omf"
|
||||||
|
or set -gx OMF_PATH "$HOME/.local/share/omf"
|
||||||
|
|
||||||
|
# Load Oh My Fish configuration.
|
||||||
|
source $OMF_PATH/init.fish
|
10
files/fish/config.fish
Normal file
10
files/fish/config.fish
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
set -g fish_user_paths "/usr/local/sbin" $fish_user_paths
|
||||||
|
|
||||||
|
set -x PIPENV_VENV_IN_PROJECT true
|
||||||
|
|
||||||
|
export GOPATH="$HOME/.go"
|
||||||
|
export GOROOT=(brew --prefix go)"/libexec"
|
||||||
|
export PATH="$PATH:$GOPATH/bin:$GOROOT/bin:$HOME/.cargo/bin"
|
||||||
|
|
||||||
|
# The next line updates PATH for the Google Cloud SDK.
|
||||||
|
if [ -f '$HOME/Desktop/google-cloud-sdk/path.fish.inc' ]; . '$HOME/Desktop/google-cloud-sdk/path.fish.inc'; end
|
33
files/fish/fish_variables
Normal file
33
files/fish/fish_variables
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# This file contains fish universal variable definitions.
|
||||||
|
# VERSION: 3.0
|
||||||
|
|
||||||
|
SETUVAR __fish_initialized:3100
|
||||||
|
SETUVAR fish_color_autosuggestion:555\x1ebrblack
|
||||||
|
SETUVAR fish_color_cancel:\x2dr
|
||||||
|
SETUVAR fish_color_command:005fd7
|
||||||
|
SETUVAR fish_color_comment:990000
|
||||||
|
SETUVAR fish_color_cwd:green
|
||||||
|
SETUVAR fish_color_cwd_root:red
|
||||||
|
SETUVAR fish_color_end:009900
|
||||||
|
SETUVAR fish_color_error:ff0000
|
||||||
|
SETUVAR fish_color_escape:00a6b2
|
||||||
|
SETUVAR fish_color_history_current:\x2d\x2dbold
|
||||||
|
SETUVAR fish_color_host:normal
|
||||||
|
SETUVAR fish_color_host_remote:yellow
|
||||||
|
SETUVAR fish_color_match:\x2d\x2dbackground\x3dbrblue
|
||||||
|
SETUVAR fish_color_normal:normal
|
||||||
|
SETUVAR fish_color_operator:00a6b2
|
||||||
|
SETUVAR fish_color_param:00afff
|
||||||
|
SETUVAR fish_color_quote:999900
|
||||||
|
SETUVAR fish_color_redirection:00afff
|
||||||
|
SETUVAR fish_color_search_match:bryellow\x1e\x2d\x2dbackground\x3dbrblack
|
||||||
|
SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack
|
||||||
|
SETUVAR fish_color_status:red
|
||||||
|
SETUVAR fish_color_user:brgreen
|
||||||
|
SETUVAR fish_color_valid_path:\x2d\x2dunderline
|
||||||
|
SETUVAR fish_greeting:Welcome\x20to\x20fish\x2c\x20the\x20friendly\x20interactive\x20shell\x0aType\x20\x60help\x60\x20for\x20instructions\x20on\x20how\x20to\x20use\x20fish
|
||||||
|
SETUVAR fish_key_bindings:fish_default_key_bindings
|
||||||
|
SETUVAR fish_pager_color_completion:\x1d
|
||||||
|
SETUVAR fish_pager_color_description:B3A06D\x1eyellow
|
||||||
|
SETUVAR fish_pager_color_prefix:white\x1e\x2d\x2dbold\x1e\x2d\x2dunderline
|
||||||
|
SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan
|
1
files/fish/fishfile
Normal file
1
files/fish/fishfile
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
4
files/fish/functions/dc.fish
Normal file
4
files/fish/functions/dc.fish
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Defined in - @ line 1
|
||||||
|
function dc --wraps=docker-compose --description 'alias dc=docker-compose'
|
||||||
|
docker compose $argv;
|
||||||
|
end
|
4
files/fish/functions/dpa.fish
Normal file
4
files/fish/functions/dpa.fish
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Defined in - @ line 1
|
||||||
|
function dpa --wraps='docker system prune -af --volumes' --description 'alias dpa docker system prune -af --volumes'
|
||||||
|
docker system prune -af --volumes $argv;
|
||||||
|
end
|
1104
files/fish/functions/fish_prompt.fish
Normal file
1104
files/fish/functions/fish_prompt.fish
Normal file
File diff suppressed because it is too large
Load Diff
435
files/fish/functions/fisher.fish
Normal file
435
files/fish/functions/fisher.fish
Normal file
@ -0,0 +1,435 @@
|
|||||||
|
set -g fisher_version 3.2.10
|
||||||
|
|
||||||
|
function fisher -a cmd -d "fish package manager"
|
||||||
|
set -q XDG_CACHE_HOME; or set XDG_CACHE_HOME ~/.cache
|
||||||
|
set -q XDG_CONFIG_HOME; or set XDG_CONFIG_HOME ~/.config
|
||||||
|
|
||||||
|
set -g fish_config $XDG_CONFIG_HOME/fish
|
||||||
|
set -g fisher_cache $XDG_CACHE_HOME/fisher
|
||||||
|
set -g fisher_config $XDG_CONFIG_HOME/fisher
|
||||||
|
|
||||||
|
set -q fisher_path; or set -g fisher_path $fish_config
|
||||||
|
set -g fishfile $fish_config/fishfile
|
||||||
|
|
||||||
|
for path in {$fish_config,$fisher_path}/{functions,completions,conf.d} $fisher_cache
|
||||||
|
if test ! -d $path
|
||||||
|
command mkdir -p $path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if test ! -e $fisher_path/completions/fisher.fish
|
||||||
|
echo "fisher complete" >$fisher_path/completions/fisher.fish
|
||||||
|
_fisher_complete
|
||||||
|
end
|
||||||
|
|
||||||
|
if test -e $fisher_path/conf.d/fisher.fish
|
||||||
|
switch "$version"
|
||||||
|
case \*-\*
|
||||||
|
command rm -f $fisher_path/conf.d/fisher.fish
|
||||||
|
case 2\*
|
||||||
|
case \*
|
||||||
|
command rm -f $fisher_path/conf.d/fisher.fish
|
||||||
|
end
|
||||||
|
else
|
||||||
|
switch "$version"
|
||||||
|
case \*-\*
|
||||||
|
case 2\*
|
||||||
|
echo "fisher copy-user-key-bindings" >$fisher_path/conf.d/fisher.fish
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# 2019-10-22: temp code, migrates fishfile from old path back to $fish_config
|
||||||
|
if test -e "$fisher_path/fishfile"; and test ! -e "$fishfile"
|
||||||
|
command mv -f "$fisher_path/fishfile" "$fishfile"
|
||||||
|
end
|
||||||
|
|
||||||
|
switch "$cmd"
|
||||||
|
case {,self-}complete
|
||||||
|
_fisher_complete
|
||||||
|
case copy-user-key-bindings
|
||||||
|
_fisher_copy_user_key_bindings
|
||||||
|
case ls
|
||||||
|
set -e argv[1]
|
||||||
|
if test -s "$fishfile"
|
||||||
|
set -l file (_fisher_fmt <$fishfile | _fisher_parse -R | command sed "s|@.*||")
|
||||||
|
_fisher_ls | _fisher_fmt | command awk -v FILE="$file" "
|
||||||
|
BEGIN { for (n = split(FILE, f); ++i <= n;) file[f[i]] } \$0 in file && /$argv[1]/
|
||||||
|
" | command sed "s|^$HOME|~|"
|
||||||
|
end
|
||||||
|
case self-update
|
||||||
|
_fisher_self_update (status -f)
|
||||||
|
case self-uninstall
|
||||||
|
_fisher_self_uninstall
|
||||||
|
case {,-}-v{ersion,}
|
||||||
|
echo "fisher version $fisher_version" (status -f | command sed "s|^$HOME|~|")
|
||||||
|
case {,-}-h{elp,}
|
||||||
|
_fisher_help
|
||||||
|
case ""
|
||||||
|
_fisher_commit --
|
||||||
|
case add rm
|
||||||
|
if not isatty
|
||||||
|
while read -l arg
|
||||||
|
set argv $argv $arg
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if test (count $argv) = 1
|
||||||
|
echo "fisher: invalid number of arguments" >&2
|
||||||
|
_fisher_help >&2
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
|
||||||
|
_fisher_commit $argv
|
||||||
|
case \*
|
||||||
|
echo "fisher: unknown flag or command \"$cmd\"" >&2
|
||||||
|
_fisher_help >&2
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function _fisher_complete
|
||||||
|
complete -ec fisher
|
||||||
|
complete -xc fisher -n __fish_use_subcommand -a add -d "Add packages"
|
||||||
|
complete -xc fisher -n __fish_use_subcommand -a rm -d "Remove packages"
|
||||||
|
complete -xc fisher -n __fish_use_subcommand -a ls -d "List installed packages matching REGEX"
|
||||||
|
complete -xc fisher -n __fish_use_subcommand -a --help -d "Show usage help"
|
||||||
|
complete -xc fisher -n __fish_use_subcommand -a --version -d "$fisher_version"
|
||||||
|
complete -xc fisher -n __fish_use_subcommand -a self-update -d "Update to the latest version"
|
||||||
|
for pkg in (fisher ls)
|
||||||
|
complete -xc fisher -n "__fish_seen_subcommand_from rm" -a $pkg
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function _fisher_copy_user_key_bindings
|
||||||
|
if functions -q fish_user_key_bindings
|
||||||
|
functions -c fish_user_key_bindings fish_user_key_bindings_copy
|
||||||
|
end
|
||||||
|
function fish_user_key_bindings
|
||||||
|
for file in $fisher_path/conf.d/*_key_bindings.fish
|
||||||
|
source $file >/dev/null 2>/dev/null
|
||||||
|
end
|
||||||
|
if functions -q fish_user_key_bindings_copy
|
||||||
|
fish_user_key_bindings_copy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function _fisher_ls
|
||||||
|
for pkg in $fisher_config/*/*/*
|
||||||
|
command readlink $pkg; or echo $pkg
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function _fisher_fmt
|
||||||
|
command sed "s|^[[:space:]]*||;s|^$fisher_config/||;s|^~|$HOME|;s|^\.\/*|$PWD/|;s|^https*:/*||;s|^github\.com/||;s|/*\$||"
|
||||||
|
end
|
||||||
|
|
||||||
|
function _fisher_help
|
||||||
|
echo "usage: fisher add <package...> Add packages"
|
||||||
|
echo " fisher rm <package...> Remove packages"
|
||||||
|
echo " fisher Update all packages"
|
||||||
|
echo " fisher ls [<regex>] List installed packages matching <regex>"
|
||||||
|
echo " fisher --help Show this help"
|
||||||
|
echo " fisher --version Show the current version"
|
||||||
|
echo " fisher self-update Update to the latest version"
|
||||||
|
echo " fisher self-uninstall Uninstall from your system"
|
||||||
|
echo "examples:"
|
||||||
|
echo " fisher add jethrokuan/z rafaelrinaldi/pure"
|
||||||
|
echo " fisher add gitlab.com/foo/bar@v2"
|
||||||
|
echo " fisher add ~/path/to/local/pkg"
|
||||||
|
echo " fisher add <file"
|
||||||
|
echo " fisher rm rafaelrinaldi/pure"
|
||||||
|
echo " fisher ls | fisher rm"
|
||||||
|
echo " fisher ls fish-\*"
|
||||||
|
end
|
||||||
|
|
||||||
|
function _fisher_self_update -a file
|
||||||
|
set -l url "https://raw.githubusercontent.com/jorgebucaran/fisher/master/fisher.fish"
|
||||||
|
echo "fetching $url" >&2
|
||||||
|
command curl -s "$url?nocache" >$file.
|
||||||
|
|
||||||
|
set -l next_version (command awk '{ print $4 } { exit }' <$file.)
|
||||||
|
switch "$next_version"
|
||||||
|
case "" $fisher_version
|
||||||
|
command rm -f $file.
|
||||||
|
if test -z "$next_version"
|
||||||
|
echo "fisher: cannot update fisher -- are you offline?" >&2
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
echo "fisher is already up-to-date" >&2
|
||||||
|
case \*
|
||||||
|
echo "linking $file" | command sed "s|$HOME|~|" >&2
|
||||||
|
command mv -f $file. $file
|
||||||
|
source $file
|
||||||
|
echo "updated to fisher $fisher_version -- hooray!" >&2
|
||||||
|
_fisher_complete
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function _fisher_self_uninstall
|
||||||
|
for pkg in (_fisher_ls)
|
||||||
|
_fisher_rm $pkg
|
||||||
|
end
|
||||||
|
|
||||||
|
for file in $fisher_cache $fisher_config $fisher_path/{functions,completions,conf.d}/fisher.fish $fishfile
|
||||||
|
echo "removing $file"
|
||||||
|
command rm -Rf $file 2>/dev/null
|
||||||
|
end | command sed "s|$HOME|~|" >&2
|
||||||
|
|
||||||
|
for name in (set -n | command awk '/^fisher_/')
|
||||||
|
set -e "$name"
|
||||||
|
end
|
||||||
|
|
||||||
|
functions -e (functions -a | command awk '/^_fisher/') fisher
|
||||||
|
complete -c fisher --erase
|
||||||
|
end
|
||||||
|
|
||||||
|
function _fisher_commit -a cmd
|
||||||
|
set -e argv[1]
|
||||||
|
set -l elapsed (_fisher_now)
|
||||||
|
|
||||||
|
if test ! -e "$fishfile"
|
||||||
|
command touch $fishfile
|
||||||
|
echo "created new fishfile in $fishfile" | command sed "s|$HOME|~|" >&2
|
||||||
|
end
|
||||||
|
|
||||||
|
set -l old_pkgs (_fisher_ls | _fisher_fmt)
|
||||||
|
for pkg in (_fisher_ls)
|
||||||
|
_fisher_rm $pkg
|
||||||
|
end
|
||||||
|
command rm -Rf $fisher_config
|
||||||
|
command mkdir -p $fisher_config
|
||||||
|
|
||||||
|
set -l next_pkgs (_fisher_fmt <$fishfile | _fisher_parse -R $cmd (printf "%s\n" $argv | _fisher_fmt))
|
||||||
|
set -l actual_pkgs (_fisher_fetch $next_pkgs)
|
||||||
|
set -l updated_pkgs
|
||||||
|
for pkg in $old_pkgs
|
||||||
|
if contains -- $pkg $actual_pkgs
|
||||||
|
set updated_pkgs $updated_pkgs $pkg
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if test -z "$actual_pkgs$updated_pkgs$old_pkgs$next_pkgs"
|
||||||
|
echo "fisher: nothing to commit -- try adding some packages" >&2
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
|
||||||
|
set -l out_pkgs
|
||||||
|
if test "$cmd" = "rm"
|
||||||
|
set out_pkgs $next_pkgs
|
||||||
|
else
|
||||||
|
for pkg in $next_pkgs
|
||||||
|
if contains -- (echo $pkg | command sed "s|@.*||") $actual_pkgs
|
||||||
|
set out_pkgs $out_pkgs $pkg
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
printf "%s\n" (_fisher_fmt <$fishfile | _fisher_parse -W $cmd $out_pkgs | command sed "s|^$HOME|~|") >$fishfile
|
||||||
|
|
||||||
|
_fisher_complete
|
||||||
|
|
||||||
|
command awk -v A=(count $actual_pkgs) -v U=(count $updated_pkgs) -v O=(count $old_pkgs) -v E=(_fisher_now $elapsed) '
|
||||||
|
BEGIN {
|
||||||
|
res = fmt("removed", O - U, fmt("updated", U, fmt("added", A - U)))
|
||||||
|
printf((res ? res : "done") " in %.2fs\n", E / 1000)
|
||||||
|
}
|
||||||
|
function fmt(action, n, s) {
|
||||||
|
return n ? (s ? s ", " : s) action " " n " package" (n > 1 ? "s" : "") : s
|
||||||
|
}
|
||||||
|
' >&2
|
||||||
|
end
|
||||||
|
|
||||||
|
function _fisher_parse -a mode cmd
|
||||||
|
set -e argv[1..2]
|
||||||
|
command awk -v FS="[[:space:]]*#+" -v MODE="$mode" -v CMD="$cmd" -v ARGSTR="$argv" '
|
||||||
|
BEGIN {
|
||||||
|
for (n = split(ARGSTR, a, " "); i++ < n;) pkgs[getkey(a[i])] = a[i]
|
||||||
|
}
|
||||||
|
!NF { next } { k = getkey($1) }
|
||||||
|
MODE == "-R" && !(k in pkgs) && $0 = $1
|
||||||
|
MODE == "-W" && (/^#/ || k in pkgs || CMD != "rm") { print pkgs[k] (sub($1, "") ? $0 : "") }
|
||||||
|
MODE == "-W" || CMD == "rm" { delete pkgs[k] }
|
||||||
|
END {
|
||||||
|
for (k in pkgs) {
|
||||||
|
if (CMD != "rm" || MODE == "-W") print pkgs[k]
|
||||||
|
else print "fisher: cannot remove \""k"\" -- package is not in fishfile" > "/dev/stderr"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function getkey(s, a) {
|
||||||
|
return (split(s, a, /@+|:/) > 2) ? a[2]"/"a[1]"/"a[3] : a[1]
|
||||||
|
}
|
||||||
|
'
|
||||||
|
end
|
||||||
|
|
||||||
|
function _fisher_fetch
|
||||||
|
set -l pkg_jobs
|
||||||
|
set -l out_pkgs
|
||||||
|
set -l next_pkgs
|
||||||
|
set -l local_pkgs
|
||||||
|
set -q fisher_user_api_token; and set -l curl_opts -u $fisher_user_api_token
|
||||||
|
|
||||||
|
for pkg in $argv
|
||||||
|
switch $pkg
|
||||||
|
case \~\* /\*
|
||||||
|
set -l path (echo "$pkg" | command sed "s|^~|$HOME|")
|
||||||
|
if test -e "$path"
|
||||||
|
set local_pkgs $local_pkgs $path
|
||||||
|
else
|
||||||
|
echo "fisher: cannot add \"$pkg\" -- is this a valid file?" >&2
|
||||||
|
end
|
||||||
|
continue
|
||||||
|
end
|
||||||
|
|
||||||
|
command awk -v PKG="$pkg" -v FS=/ '
|
||||||
|
BEGIN {
|
||||||
|
if (split(PKG, tmp, /@+|:/) > 2) {
|
||||||
|
if (tmp[4]) sub("@"tmp[4], "", PKG)
|
||||||
|
print PKG "\t" tmp[2]"/"tmp[1]"/"tmp[3] "\t" (tmp[4] ? tmp[4] : "master")
|
||||||
|
} else {
|
||||||
|
pkg = split(PKG, _, "/") <= 2 ? "github.com/"tmp[1] : tmp[1]
|
||||||
|
tag = tmp[2] ? tmp[2] : "master"
|
||||||
|
print (\
|
||||||
|
pkg ~ /^github/ ? "https://codeload."pkg"/tar.gz/"tag : \
|
||||||
|
pkg ~ /^gitlab/ ? "https://"pkg"/-/archive/"tag"/"tmp[split(pkg, tmp, "/")]"-"tag".tar.gz" : \
|
||||||
|
pkg ~ /^bitbucket/ ? "https://"pkg"/get/"tag".tar.gz" : pkg \
|
||||||
|
) "\t" pkg
|
||||||
|
}
|
||||||
|
}
|
||||||
|
' | read -l url pkg branch
|
||||||
|
|
||||||
|
if test ! -d "$fisher_config/$pkg"
|
||||||
|
fish -c "
|
||||||
|
echo fetching $url >&2
|
||||||
|
command mkdir -p $fisher_config/$pkg $fisher_cache/(command dirname $pkg)
|
||||||
|
if test ! -z \"$branch\"
|
||||||
|
command git clone $url $fisher_config/$pkg --branch $branch --depth 1 2>/dev/null
|
||||||
|
or echo fisher: cannot clone \"$url\" -- is this a valid url\? >&2
|
||||||
|
else if command curl $curl_opts -Ss -w \"\" $url 2>&1 | command tar -xzf- -C $fisher_config/$pkg 2>/dev/null
|
||||||
|
command rm -Rf $fisher_cache/$pkg
|
||||||
|
command mv -f $fisher_config/$pkg/* $fisher_cache/$pkg
|
||||||
|
command rm -Rf $fisher_config/$pkg
|
||||||
|
command cp -Rf {$fisher_cache,$fisher_config}/$pkg
|
||||||
|
else if test -d \"$fisher_cache/$pkg\"
|
||||||
|
echo fisher: cannot connect to server -- looking in \"$fisher_cache/$pkg\" | command sed 's|$HOME|~|' >&2
|
||||||
|
command cp -Rf $fisher_cache/$pkg $fisher_config/$pkg/..
|
||||||
|
else
|
||||||
|
command rm -Rf $fisher_config/$pkg
|
||||||
|
echo fisher: cannot add \"$pkg\" -- is this a valid package\? >&2
|
||||||
|
end
|
||||||
|
" >/dev/null &
|
||||||
|
set pkg_jobs $pkg_jobs (_fisher_jobs --last)
|
||||||
|
set next_pkgs $next_pkgs "$fisher_config/$pkg"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if set -q pkg_jobs[1]
|
||||||
|
while for job in $pkg_jobs
|
||||||
|
contains -- $job (_fisher_jobs); and break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for pkg in $next_pkgs
|
||||||
|
if test -d "$pkg"
|
||||||
|
set out_pkgs $out_pkgs $pkg
|
||||||
|
_fisher_add $pkg
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
set -l local_prefix $fisher_config/local/$USER
|
||||||
|
if test ! -d "$local_prefix"
|
||||||
|
command mkdir -p $local_prefix
|
||||||
|
end
|
||||||
|
for pkg in $local_pkgs
|
||||||
|
set -l target $local_prefix/(command basename $pkg)
|
||||||
|
if test ! -L "$target"
|
||||||
|
command ln -sf $pkg $target
|
||||||
|
set out_pkgs $out_pkgs $pkg
|
||||||
|
_fisher_add $pkg --link
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if set -q out_pkgs[1]
|
||||||
|
_fisher_fetch (
|
||||||
|
for pkg in $out_pkgs
|
||||||
|
if test -s "$pkg/fishfile"
|
||||||
|
_fisher_fmt <$pkg/fishfile | _fisher_parse -R
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
printf "%s\n" $out_pkgs | _fisher_fmt
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function _fisher_add -a pkg opts
|
||||||
|
for src in $pkg/{functions,completions,conf.d}/**.* $pkg/*.fish
|
||||||
|
set -l target (command basename $src)
|
||||||
|
switch $src
|
||||||
|
case $pkg/conf.d\*
|
||||||
|
set target $fisher_path/conf.d/$target
|
||||||
|
case $pkg/completions\*
|
||||||
|
set target $fisher_path/completions/$target
|
||||||
|
case $pkg/{functions,}\*
|
||||||
|
switch $target
|
||||||
|
case uninstall.fish
|
||||||
|
continue
|
||||||
|
case {init,key_bindings}.fish
|
||||||
|
set target $fisher_path/conf.d/(command basename $pkg)\_$target
|
||||||
|
case \*
|
||||||
|
set target $fisher_path/functions/$target
|
||||||
|
end
|
||||||
|
end
|
||||||
|
echo "linking $target" | command sed "s|$HOME|~|" >&2
|
||||||
|
if set -q opts[1]
|
||||||
|
command ln -sf $src $target
|
||||||
|
else
|
||||||
|
command cp -f $src $target
|
||||||
|
end
|
||||||
|
switch $target
|
||||||
|
case \*.fish
|
||||||
|
source $target >/dev/null 2>/dev/null
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function _fisher_rm -a pkg
|
||||||
|
for src in $pkg/{conf.d,completions,functions}/**.* $pkg/*.fish
|
||||||
|
set -l target (command basename $src)
|
||||||
|
set -l filename (command basename $target .fish)
|
||||||
|
switch $src
|
||||||
|
case $pkg/conf.d\*
|
||||||
|
test "$filename.fish" = "$target"; and emit "$filename"_uninstall
|
||||||
|
set target conf.d/$target
|
||||||
|
case $pkg/completions\*
|
||||||
|
test "$filename.fish" = "$target"; and complete -ec $filename
|
||||||
|
set target completions/$target
|
||||||
|
case $pkg/{,functions}\*
|
||||||
|
test "$filename.fish" = "$target"; and functions -e $filename
|
||||||
|
switch $target
|
||||||
|
case uninstall.fish
|
||||||
|
source $src
|
||||||
|
continue
|
||||||
|
case {init,key_bindings}.fish
|
||||||
|
set target conf.d/(command basename $pkg)\_$target
|
||||||
|
case \*
|
||||||
|
set target functions/$target
|
||||||
|
end
|
||||||
|
end
|
||||||
|
command rm -f $fisher_path/$target
|
||||||
|
end
|
||||||
|
if not functions -q fish_prompt
|
||||||
|
source "$__fish_datadir$__fish_data_dir/functions/fish_prompt.fish"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function _fisher_jobs
|
||||||
|
jobs $argv | command awk '/^[0-9]+\t/ { print $1 }'
|
||||||
|
end
|
||||||
|
|
||||||
|
function _fisher_now -a elapsed
|
||||||
|
switch (command uname)
|
||||||
|
case Darwin \*BSD
|
||||||
|
command perl -MTime::HiRes -e 'printf("%.0f\n", (Time::HiRes::time() * 1000) - $ARGV[0])' $elapsed
|
||||||
|
case \*
|
||||||
|
math (command date "+%s%3N") - "0$elapsed"
|
||||||
|
end
|
||||||
|
end
|
4
files/fish/functions/l.fish
Normal file
4
files/fish/functions/l.fish
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Defined in - @ line 1
|
||||||
|
function l --wraps=la --description 'alias l la'
|
||||||
|
la $argv;
|
||||||
|
end
|
4
files/fish/functions/p.fish
Normal file
4
files/fish/functions/p.fish
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Defined via `source`
|
||||||
|
function p --wraps=pnpm --description 'alias p pnpm'
|
||||||
|
pnpm $argv;
|
||||||
|
end
|
3
files/fish/functions/px.fish
Normal file
3
files/fish/functions/px.fish
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
function px --wraps=pnpx --description 'alias px pnpx'
|
||||||
|
pnpx $argv;
|
||||||
|
end
|
2
files/omf/bundle
Normal file
2
files/omf/bundle
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
theme bobthefish
|
||||||
|
theme default
|
1
files/omf/channel
Normal file
1
files/omf/channel
Normal file
@ -0,0 +1 @@
|
|||||||
|
stable
|
1
files/omf/theme
Normal file
1
files/omf/theme
Normal file
@ -0,0 +1 @@
|
|||||||
|
bobthefish
|
@ -1,15 +1,17 @@
|
|||||||
- defaults:
|
- defaults:
|
||||||
link:
|
link:
|
||||||
create: true
|
create: true
|
||||||
relink: true
|
relink: true
|
||||||
force: true
|
force: true
|
||||||
|
|
||||||
- clean: ["~"]
|
- clean: ["~"]
|
||||||
|
|
||||||
- link:
|
- link:
|
||||||
~/.gitconfig: files/gitconfig
|
~/.gitconfig: files/gitconfig
|
||||||
~/.vim: files/vim
|
~/.vim: files/vim
|
||||||
~/.vimrc: files/vimrc
|
~/.vimrc: files/vimrc
|
||||||
|
~/.config/fish: files/fish
|
||||||
|
~/.config/omf: files/omf
|
||||||
|
|
||||||
- shell:
|
- shell:
|
||||||
- [git submodule update --init --recursive, Installing submodules]
|
- [git submodule update --init --recursive, Installing submodules]
|
||||||
|
Loading…
Reference in New Issue
Block a user