Compare commits
5 Commits
96be2560c3
...
a655f68d6e
Author | SHA1 | Date | |
---|---|---|---|
a655f68d6e | |||
1306eaad33 | |||
ae9e4adf8b | |||
756dd74776 | |||
2d5c70b3c0 |
@ -1,21 +0,0 @@
|
||||
complete --command nvm --exclusive
|
||||
complete --command nvm --exclusive --long version --description "Print version"
|
||||
complete --command nvm --exclusive --long help --description "Print help"
|
||||
complete --command nvm --long silent --description "Suppress standard output"
|
||||
|
||||
complete --command nvm --exclusive --condition __fish_use_subcommand --arguments install --description "Download and activate the specified Node version"
|
||||
complete --command nvm --exclusive --condition __fish_use_subcommand --arguments use --description "Activate the specified Node version in the current shell"
|
||||
complete --command nvm --exclusive --condition __fish_use_subcommand --arguments list --description "List installed Node versions"
|
||||
complete --command nvm --exclusive --condition __fish_use_subcommand --arguments list-remote --description "List available Node versions to install"
|
||||
complete --command nvm --exclusive --condition __fish_use_subcommand --arguments current --description "Print the currently-active Node version"
|
||||
complete --command nvm --exclusive --condition "__fish_seen_subcommand_from install" --arguments "(
|
||||
test -e $nvm_data && string split ' ' <$nvm_data/.index
|
||||
)"
|
||||
complete --command nvm --exclusive --condition "__fish_seen_subcommand_from use" --arguments "(_nvm_list | string split ' ')"
|
||||
complete --command nvm --exclusive --condition __fish_use_subcommand --arguments uninstall --description "Uninstall the specified Node version"
|
||||
complete --command nvm --exclusive --condition "__fish_seen_subcommand_from uninstall" --arguments "(
|
||||
_nvm_list | string split ' ' | string replace system ''
|
||||
)"
|
||||
complete --command nvm --exclusive --condition "__fish_seen_subcommand_from use uninstall" --arguments "(
|
||||
set --query nvm_default_version && echo default
|
||||
)"
|
@ -1,3 +0,0 @@
|
||||
complete --command replay --no-files
|
||||
complete --command replay --exclusive --long version --description "Print version"
|
||||
complete --command replay --exclusive --long help --description "Print help"
|
@ -24,3 +24,5 @@ abbr -a gr 'git restore'
|
||||
abbr -a gs 'git status'
|
||||
abbr -a gst 'git stash'
|
||||
abbr -a gsw 'git switch'
|
||||
abbr -a --command git rbi 'rebase --interactive'
|
||||
abbr -a --command git wipe 'restore --staged --worktree'
|
||||
|
@ -1,28 +0,0 @@
|
||||
set --query nvm_mirror || set --global nvm_mirror https://nodejs.org/dist
|
||||
set --query XDG_DATA_HOME || set --local XDG_DATA_HOME ~/.local/share
|
||||
set --global nvm_data $XDG_DATA_HOME/nvm
|
||||
|
||||
function _nvm_install --on-event nvm_install
|
||||
test ! -d $nvm_data && command mkdir -p $nvm_data
|
||||
echo "Downloading the Node distribution index..." 2>/dev/null
|
||||
_nvm_index_update
|
||||
end
|
||||
|
||||
function _nvm_update --on-event nvm_update
|
||||
set --query --universal nvm_data && set --erase --universal nvm_data
|
||||
set --query --universal nvm_mirror && set --erase --universal nvm_mirror
|
||||
set --query nvm_mirror || set --global nvm_mirror https://nodejs.org/dist
|
||||
end
|
||||
|
||||
function _nvm_uninstall --on-event nvm_uninstall
|
||||
command rm -rf $nvm_data
|
||||
|
||||
set --query nvm_current_version && _nvm_version_deactivate $nvm_current_version
|
||||
|
||||
set --names | string replace --filter --regex -- "^nvm" "set --erase nvm" | source
|
||||
functions --erase (functions --all | string match --entire --regex -- "^_nvm_")
|
||||
end
|
||||
|
||||
if status is-interactive && set --query nvm_default_version && ! set --query nvm_current_version
|
||||
nvm use --silent $nvm_default_version
|
||||
end
|
@ -32,10 +32,12 @@ if status --is-interactive
|
||||
set -g __fish_git_prompt_color_upstream yellow
|
||||
|
||||
# Bindings
|
||||
bind \cb battery
|
||||
bind \cq fkill
|
||||
bind \cp __fzf_files
|
||||
bind \cg __fzf_git_log
|
||||
bind ctrl-q fkill
|
||||
bind ctrl-p __fzf_files
|
||||
bind ctrl-g __fzf_git_log
|
||||
|
||||
# You can get the cancelled command with ctrl-z now
|
||||
#bind ctrl-c __fish_cancel_commandline
|
||||
|
||||
# Shell history
|
||||
if command -q atuin
|
||||
|
@ -1,5 +1,3 @@
|
||||
jorgebucaran/fisher
|
||||
jorgebucaran/nvm.fish
|
||||
jorgebucaran/replay.fish
|
||||
lilyball/nix-env.fish
|
||||
reitzig/sdkman-for-fish@v2.1.0
|
||||
|
@ -1,20 +0,0 @@
|
||||
function _nvm_index_update
|
||||
test ! -d $nvm_data && command mkdir -p $nvm_data
|
||||
|
||||
set --local index $nvm_data/.index
|
||||
|
||||
if not command curl -q --location --silent $nvm_mirror/index.tab >$index.temp
|
||||
command rm -f $index.temp
|
||||
echo "nvm: Can't update index, host unavailable: \"$nvm_mirror\"" >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
command awk -v OFS=\t '
|
||||
/v0.9.12/ { exit } # Unsupported
|
||||
NR > 1 {
|
||||
print $1 (NR == 2 ? " latest" : $10 != "-" ? " lts/" tolower($10) : "")
|
||||
}
|
||||
' $index.temp >$index
|
||||
|
||||
command rm -f $index.temp
|
||||
end
|
@ -1,14 +0,0 @@
|
||||
function _nvm_list
|
||||
set --local versions $nvm_data/*
|
||||
|
||||
set --query versions[1] &&
|
||||
string match --entire --regex -- (
|
||||
string replace --all -- $nvm_data/ "" $versions |
|
||||
string match --regex -- "v\d.+" |
|
||||
string escape --style=regex |
|
||||
string join "|"
|
||||
) <$nvm_data/.index
|
||||
|
||||
command --all node |
|
||||
string match --quiet --invert --regex -- "^$nvm_data" && echo system
|
||||
end
|
@ -1,4 +0,0 @@
|
||||
function _nvm_version_activate --argument-names ver
|
||||
set --global --export nvm_current_version $ver
|
||||
set --prepend PATH $nvm_data/$ver/bin
|
||||
end
|
@ -1,5 +0,0 @@
|
||||
function _nvm_version_deactivate --argument-names ver
|
||||
test "$nvm_current_version" = "$ver" && set --erase nvm_current_version
|
||||
set --local index (contains --index -- $nvm_data/$ver/bin $PATH) &&
|
||||
set --erase PATH[$index]
|
||||
end
|
@ -1,234 +0,0 @@
|
||||
function nvm --description "Node version manager"
|
||||
for silent in --silent -s
|
||||
if set --local index (contains --index -- $silent $argv)
|
||||
set --erase argv[$index] && break
|
||||
end
|
||||
set --erase silent
|
||||
end
|
||||
|
||||
set --local cmd $argv[1]
|
||||
set --local ver $argv[2]
|
||||
|
||||
if set --query silent && ! set --query cmd[1]
|
||||
echo "nvm: Version number not specified (see nvm -h for usage)" >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
if ! set --query ver[1] && contains -- "$cmd" install use
|
||||
for file in .nvmrc .node-version
|
||||
set file (_nvm_find_up $PWD $file) && read ver <$file && break
|
||||
end
|
||||
|
||||
if ! set --query ver[1]
|
||||
echo "nvm: Invalid version or missing \".nvmrc\" file" >&2
|
||||
return 1
|
||||
end
|
||||
end
|
||||
|
||||
set --local their_version $ver
|
||||
|
||||
switch "$cmd"
|
||||
case -v --version
|
||||
echo "nvm, version 2.2.16"
|
||||
case "" -h --help
|
||||
echo "Usage: nvm install <version> Download and activate the specified Node version"
|
||||
echo " nvm install Install the version specified in the nearest .nvmrc file"
|
||||
echo " nvm use <version> Activate the specified Node version in the current shell"
|
||||
echo " nvm use Activate the version specified in the nearest .nvmrc file"
|
||||
echo " nvm list List installed Node versions"
|
||||
echo " nvm list-remote List available Node versions to install"
|
||||
echo " nvm list-remote <regex> List Node versions matching a given regex pattern"
|
||||
echo " nvm current Print the currently-active Node version"
|
||||
echo " nvm uninstall <version> Uninstall the specified Node version"
|
||||
echo "Options:"
|
||||
echo " -s, --silent Suppress standard output"
|
||||
echo " -v, --version Print the version of nvm"
|
||||
echo " -h, --help Print this help message"
|
||||
echo "Variables:"
|
||||
echo " nvm_arch Override architecture, e.g. x64-musl"
|
||||
echo " nvm_mirror Use a mirror for downloading Node binaries"
|
||||
echo " nvm_default_version Set the default version for new shells"
|
||||
echo " nvm_default_packages Install a list of packages every time a Node version is installed"
|
||||
echo "Examples:"
|
||||
echo " nvm install latest Install the latest version of Node"
|
||||
echo " nvm use 14.15.1 Use Node version 14.15.1"
|
||||
echo " nvm use system Activate the system's Node version"
|
||||
|
||||
case install
|
||||
_nvm_index_update
|
||||
|
||||
string match --entire --regex -- (_nvm_version_match $ver) <$nvm_data/.index | read ver alias
|
||||
|
||||
if ! set --query ver[1]
|
||||
echo "nvm: Invalid version number or alias: \"$their_version\"" >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
if test ! -e $nvm_data/$ver
|
||||
set --local os (command uname -s | string lower)
|
||||
set --local ext tar.gz
|
||||
set --local arch (command uname -m)
|
||||
|
||||
switch $os
|
||||
case aix
|
||||
set arch ppc64
|
||||
case sunos
|
||||
case linux
|
||||
case darwin
|
||||
case {MSYS_NT,MINGW\*_NT}\*
|
||||
set os win
|
||||
set ext zip
|
||||
case \*
|
||||
echo "nvm: Unsupported operating system: \"$os\"" >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
switch $arch
|
||||
case i\*86
|
||||
set arch x86
|
||||
case x86_64
|
||||
set arch x64
|
||||
case arm64
|
||||
string match --regex --quiet "v(?<major>\d+)" $ver
|
||||
if test "$os" = darwin -a $major -lt 16
|
||||
set arch x64
|
||||
end
|
||||
case armv6 armv6l
|
||||
set arch armv6l
|
||||
case armv7 armv7l
|
||||
set arch armv7l
|
||||
case armv8 armv8l aarch64
|
||||
set arch arm64
|
||||
end
|
||||
|
||||
set --query nvm_arch && set arch $nvm_arch
|
||||
|
||||
set --local dir "node-$ver-$os-$arch"
|
||||
set --local url $nvm_mirror/$ver/$dir.$ext
|
||||
|
||||
command mkdir -p $nvm_data/$ver
|
||||
|
||||
if ! set --query silent
|
||||
echo -e "Installing Node \x1b[1m$ver\x1b[22m $alias"
|
||||
echo -e "Fetching \x1b[4m$url\x1b[24m\x1b[7m"
|
||||
end
|
||||
|
||||
if ! command curl -q $silent --progress-bar --location $url |
|
||||
command tar --extract --gzip --directory $nvm_data/$ver 2>/dev/null
|
||||
command rm -rf $nvm_data/$ver
|
||||
echo -e "\033[F\33[2K\x1b[0mnvm: Invalid mirror or host unavailable: \"$url\"" >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
set --query silent || echo -en "\033[F\33[2K\x1b[0m"
|
||||
|
||||
if test "$os" = win
|
||||
command mv $nvm_data/$ver/$dir $nvm_data/$ver/bin
|
||||
else
|
||||
command mv $nvm_data/$ver/$dir/* $nvm_data/$ver
|
||||
command rm -rf $nvm_data/$ver/$dir
|
||||
end
|
||||
end
|
||||
|
||||
if test $ver != "$nvm_current_version"
|
||||
set --query nvm_current_version && _nvm_version_deactivate $nvm_current_version
|
||||
_nvm_version_activate $ver
|
||||
|
||||
set --query nvm_default_packages[1] && npm install --global $silent $nvm_default_packages
|
||||
end
|
||||
|
||||
set --query silent || printf "Now using Node %s (npm %s) %s\n" (_nvm_node_info)
|
||||
case use
|
||||
test $ver = default && set ver $nvm_default_version
|
||||
_nvm_list | string match --entire --regex -- (_nvm_version_match $ver) | read ver __
|
||||
|
||||
if ! set --query ver[1]
|
||||
echo "nvm: Can't use Node \"$their_version\", version must be installed first" >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
if test $ver != "$nvm_current_version"
|
||||
set --query nvm_current_version && _nvm_version_deactivate $nvm_current_version
|
||||
test $ver != system && _nvm_version_activate $ver
|
||||
end
|
||||
|
||||
set --query silent || printf "Now using Node %s (npm %s) %s\n" (_nvm_node_info)
|
||||
case uninstall
|
||||
if test -z "$ver"
|
||||
echo "nvm: Not enough arguments for command: \"$cmd\"" >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
test $ver = default && test ! -z "$nvm_default_version" && set ver $nvm_default_version
|
||||
|
||||
_nvm_list | string match --entire --regex -- (_nvm_version_match $ver) | read ver __
|
||||
|
||||
if ! set -q ver[1]
|
||||
echo "nvm: Node version not installed or invalid: \"$their_version\"" >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
set --query silent || printf "Uninstalling Node %s %s\n" $ver (string replace ~ \~ "$nvm_data/$ver/bin/node")
|
||||
|
||||
_nvm_version_deactivate $ver
|
||||
|
||||
command rm -rf $nvm_data/$ver
|
||||
case current
|
||||
_nvm_current
|
||||
case ls list
|
||||
_nvm_list | _nvm_list_format (_nvm_current) $argv[2]
|
||||
case lsr {ls,list}-remote
|
||||
_nvm_index_update || return
|
||||
_nvm_list | command awk '
|
||||
FILENAME == "-" && (is_local[$1] = FNR == NR) { next } {
|
||||
print $0 (is_local[$1] ? " ✓" : "")
|
||||
}
|
||||
' - $nvm_data/.index | _nvm_list_format (_nvm_current) $argv[2]
|
||||
case \*
|
||||
echo "nvm: Unknown command or option: \"$cmd\" (see nvm -h for usage)" >&2
|
||||
return 1
|
||||
end
|
||||
end
|
||||
|
||||
function _nvm_find_up --argument-names path file
|
||||
test -e "$path/$file" && echo $path/$file || begin
|
||||
test ! -z "$path" || return
|
||||
_nvm_find_up (string replace --regex -- '/[^/]*$' "" $path) $file
|
||||
end
|
||||
end
|
||||
|
||||
function _nvm_version_match --argument-names ver
|
||||
string replace --regex -- '^v?(\d+|\d+\.\d+)$' 'v$1.' $ver |
|
||||
string replace --filter --regex -- '^v?(\d+)' 'v$1' |
|
||||
string escape --style=regex || string lower '\b'$ver'(?:/\w+)?$'
|
||||
end
|
||||
|
||||
function _nvm_list_format --argument-names current regex
|
||||
command awk -v current="$current" -v regex="$regex" '
|
||||
$0 ~ regex {
|
||||
aliases[versions[i++] = $1] = $2 " " $3
|
||||
pad = (n = length($1)) > pad ? n : pad
|
||||
}
|
||||
END {
|
||||
if (!i) exit 1
|
||||
while (i--)
|
||||
printf((current == versions[i] ? " ▶ " : " ") "%"pad"s %s\n",
|
||||
versions[i], aliases[versions[i]])
|
||||
}
|
||||
'
|
||||
end
|
||||
|
||||
function _nvm_current
|
||||
command --search --quiet node || return
|
||||
set --query nvm_current_version && echo $nvm_current_version || echo system
|
||||
end
|
||||
|
||||
function _nvm_node_info
|
||||
set --local npm_path (string replace bin/npm-cli.js "" (realpath (command --search npm)))
|
||||
test -f $npm_path/package.json || set --local npm_version_default (command npm --version)
|
||||
command node --eval "
|
||||
console.log(process.version)
|
||||
console.log('$npm_version_default' ? '$npm_version_default': require('$npm_path/package.json').version)
|
||||
console.log(process.execPath)
|
||||
" | string replace -- ~ \~
|
||||
end
|
@ -1,48 +0,0 @@
|
||||
function replay --description "Run Bash commands replaying changes in Fish"
|
||||
switch "$argv"
|
||||
case -v --version
|
||||
echo "replay, version 1.2.1"
|
||||
case "" -h --help
|
||||
echo "Usage: replay <commands> Run Bash commands replaying changes in Fish"
|
||||
echo "Options:"
|
||||
echo " -v or --version Print version"
|
||||
echo " -h or --help Print this help message"
|
||||
case \*
|
||||
set --local env
|
||||
set --local sep @$fish_pid(random)(command date +%s)
|
||||
set --local argv $argv[1] (string escape -- $argv[2..-1])
|
||||
set --local out (command bash -c "
|
||||
$argv
|
||||
status=\$?
|
||||
[ \$status -gt 0 ] && exit \$status
|
||||
|
||||
command compgen -e | command awk -v sep=$sep '{
|
||||
gsub(/\n/, \"\\\n\", ENVIRON[\$0])
|
||||
print \$0 sep ENVIRON[\$0]
|
||||
}' && alias
|
||||
") || return
|
||||
|
||||
string replace --all -- \\n \n (
|
||||
for line in $out
|
||||
if string split -- $sep $line | read --local --line name value
|
||||
set --append env $name
|
||||
|
||||
contains -- $name SHLVL PS1 BASH_FUNC || test "$$name" = "$value" && continue
|
||||
|
||||
if test "$name" = PATH
|
||||
echo set PATH (string split -- : $value | string replace --regex --all -- '(^.*$)' '"$1"')
|
||||
else if test "$name" = PWD
|
||||
echo builtin cd "\"$value\""
|
||||
else
|
||||
echo "set --global --export $name "(string escape -- $value)
|
||||
end
|
||||
else
|
||||
set --query env[1] && string match --entire --regex -- "^alias" $line || echo "echo \"$line\""
|
||||
end
|
||||
end | string replace --all -- \$ \\\$
|
||||
for name in (set --export --names)
|
||||
contains -- $name $env || echo "set --erase $name"
|
||||
end
|
||||
) | source
|
||||
end
|
||||
end
|
@ -2,8 +2,6 @@
|
||||
aliases = config --get-regexp --includes alias
|
||||
branchsort = branch --sort='-committerdate' --format='%(HEAD) %(color:blue)%(committerdate:short)%(color:reset) %(if)%(worktreepath)%(then)%(color:reverse yellow)%(refname:short)%(color:reset)%(else)%(color:yellow)%(refname:short)%(color:reset)%(end) %(color:green)%(upstream:short)%(color:reset)'
|
||||
logsearch = log --color=always --pretty=tformat:'%C(blue)%cs %C(auto)%h%d %s%C(reset)'
|
||||
rbi = rebase --interactive
|
||||
wipe = restore --staged --worktree
|
||||
[color "status"]
|
||||
added = yellow
|
||||
changed = green
|
||||
|
@ -4,11 +4,14 @@ echo "***** INSTALL SHELL *****"
|
||||
|
||||
if [ -x "/usr/local/bin/fish" ]; then
|
||||
SHELL_PATH="/usr/local/bin/fish"
|
||||
elif [ -x "/opt/homebrew/bin/fish" ]; then
|
||||
SHELL_PATH="/opt/homebrew/bin/fish"
|
||||
elif [ -x "$HOME/.nix-profile/bin/fish" ]; then
|
||||
SHELL_PATH="$HOME/.nix-profile/bin/fish"
|
||||
else
|
||||
echo "Cannot set login shell! Tried the following paths:"
|
||||
echo " - /usr/local/bin/fish"
|
||||
echo " - /opt/homebrew/bin/fish"
|
||||
echo " - $HOME/.nix-profile/bin/fish"
|
||||
exit 1
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user