[READ-ONLY] Mirror of https://github.com/shuuji3/dotfiles. ⚙ dotfiles managed by chezmoi
0

Configure Feed

Select the types of activity you want to include in your feed.

feat(fish): install nvm.fish fisher plugin

+299 -1
+21
dot_config/private_fish/completions/nvm.fish
··· 1 + complete --command nvm --exclusive 2 + complete --command nvm --exclusive --long version --description "Print version" 3 + complete --command nvm --exclusive --long help --description "Print help" 4 + complete --command nvm --long silent --description "Suppress standard output" 5 + 6 + complete --command nvm --exclusive --condition __fish_use_subcommand --arguments install --description "Download and activate the specified Node version" 7 + complete --command nvm --exclusive --condition __fish_use_subcommand --arguments use --description "Activate the specified Node version in the current shell" 8 + complete --command nvm --exclusive --condition __fish_use_subcommand --arguments list --description "List installed Node versions" 9 + complete --command nvm --exclusive --condition __fish_use_subcommand --arguments list-remote --description "List available Node versions to install" 10 + complete --command nvm --exclusive --condition __fish_use_subcommand --arguments current --description "Print the currently-active Node version" 11 + complete --command nvm --exclusive --condition "__fish_seen_subcommand_from install" --arguments "( 12 + test -e $nvm_data && string split ' ' <$nvm_data/.index 13 + )" 14 + complete --command nvm --exclusive --condition "__fish_seen_subcommand_from use" --arguments "(_nvm_list | string split ' ')" 15 + complete --command nvm --exclusive --condition __fish_use_subcommand --arguments uninstall --description "Uninstall the specified Node version" 16 + complete --command nvm --exclusive --condition "__fish_seen_subcommand_from uninstall" --arguments "( 17 + _nvm_list | string split ' ' | string replace system '' 18 + )" 19 + complete --command nvm --exclusive --condition "__fish_seen_subcommand_from use uninstall" --arguments "( 20 + set --query nvm_default_version && echo default 21 + )"
+2
dot_config/private_fish/fish_plugins
··· 1 + jorgebucaran/fisher 2 + jorgebucaran/nvm.fish
+2 -1
dot_config/private_fish/fish_variables
··· 3 3 SETUVAR --export PYENV_ROOT:/home/shuuji3/\x2epyenv 4 4 SETUVAR __fish_initialized:3100 5 5 SETUVAR _fisher_jorgebucaran_2F_fisher_files:\x7e/\x2econfig/fish/functions/fisher\x2efish\x1e\x7e/\x2econfig/fish/completions/fisher\x2efish 6 - SETUVAR _fisher_plugins:jorgebucaran/fisher 6 + SETUVAR _fisher_jorgebucaran_2F_nvm_2E_fish_files:\x7e/\x2econfig/fish/functions/_nvm_index_update\x2efish\x1e\x7e/\x2econfig/fish/functions/_nvm_list\x2efish\x1e\x7e/\x2econfig/fish/functions/_nvm_version_activate\x2efish\x1e\x7e/\x2econfig/fish/functions/_nvm_version_deactivate\x2efish\x1e\x7e/\x2econfig/fish/functions/nvm\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/nvm\x2efish\x1e\x7e/\x2econfig/fish/completions/nvm\x2efish 7 + SETUVAR _fisher_plugins:jorgebucaran/fisher\x1ejorgebucaran/nvm\x2efish 7 8 SETUVAR _fisher_upgraded_to_4_4:\x1d 8 9 SETUVAR fish_color_autosuggestion:555\x1ebrblack 9 10 SETUVAR fish_color_cancel:\x2dr
+20
dot_config/private_fish/functions/_nvm_index_update.fish
··· 1 + function _nvm_index_update 2 + test ! -d $nvm_data && command mkdir -p $nvm_data 3 + 4 + set --local index $nvm_data/.index 5 + 6 + if not command curl --location --silent $nvm_mirror/index.tab >$index.temp 7 + command rm -f $index.temp 8 + echo "nvm: Can't update index, host unavailable: \"$nvm_mirror\"" >&2 9 + return 1 10 + end 11 + 12 + command awk -v OFS=\t ' 13 + /v0.9.12/ { exit } # Unsupported 14 + NR > 1 { 15 + print $1 (NR == 2 ? " latest" : $10 != "-" ? " lts/" tolower($10) : "") 16 + } 17 + ' $index.temp >$index 18 + 19 + command rm -f $index.temp 20 + end
+11
dot_config/private_fish/functions/_nvm_list.fish
··· 1 + function _nvm_list 2 + set --local versions $nvm_data/* 3 + set --query versions[1] && 4 + string match --entire --regex -- (string match --regex -- "v\d.+" $versions | 5 + string escape --style=regex | 6 + string join "|" 7 + ) <$nvm_data/.index 8 + 9 + command --all node | 10 + string match --quiet --invert --regex -- "^$nvm_data" && echo system 11 + end
+4
dot_config/private_fish/functions/_nvm_version_activate.fish
··· 1 + function _nvm_version_activate --argument-names ver 2 + set --global --export nvm_current_version $ver 3 + set --prepend PATH $nvm_data/$ver/bin 4 + end
+5
dot_config/private_fish/functions/_nvm_version_deactivate.fish
··· 1 + function _nvm_version_deactivate --argument-names ver 2 + test "$nvm_current_version" = "$ver" && set --erase nvm_current_version 3 + set --local index (contains --index -- $nvm_data/$ver/bin $PATH) && 4 + set --erase PATH[$index] 5 + end
+234
dot_config/private_fish/functions/nvm.fish
··· 1 + function nvm --description "Node version manager" 2 + for silent in --silent -s 3 + if set --local index (contains --index -- $silent $argv) 4 + set --erase argv[$index] && break 5 + end 6 + set --erase silent 7 + end 8 + 9 + set --local cmd $argv[1] 10 + set --local ver $argv[2] 11 + 12 + if set --query silent && ! set --query cmd[1] 13 + echo "nvm: Version number not specified (see nvm -h for usage)" >&2 14 + return 1 15 + end 16 + 17 + if ! set --query ver[1] && contains -- "$cmd" install use 18 + for file in .nvmrc .node-version 19 + set file (_nvm_find_up $PWD $file) && read ver <$file && break 20 + end 21 + 22 + if ! set --query ver[1] 23 + echo "nvm: Invalid version or missing \".nvmrc\" file" >&2 24 + return 1 25 + end 26 + end 27 + 28 + set --local their_version $ver 29 + 30 + switch "$cmd" 31 + case -v --version 32 + echo "nvm, version 2.2.13" 33 + case "" -h --help 34 + echo "Usage: nvm install <version> Download and activate the specified Node version" 35 + echo " nvm install Install the version specified in the nearest .nvmrc file" 36 + echo " nvm use <version> Activate the specified Node version in the current shell" 37 + echo " nvm use Activate the version specified in the nearest .nvmrc file" 38 + echo " nvm list List installed Node versions" 39 + echo " nvm list-remote List available Node versions to install" 40 + echo " nvm list-remote <regex> List Node versions matching a given regex pattern" 41 + echo " nvm current Print the currently-active Node version" 42 + echo " nvm uninstall <version> Uninstall the specified Node version" 43 + echo "Options:" 44 + echo " -s, --silent Suppress standard output" 45 + echo " -v, --version Print the version of nvm" 46 + echo " -h, --help Print this help message" 47 + echo "Variables:" 48 + echo " nvm_arch Override architecture, e.g. x64-musl" 49 + echo " nvm_mirror Use a mirror for downloading Node binaries" 50 + echo " nvm_default_version Set the default version for new shells" 51 + echo " nvm_default_packages Install a list of packages every time a Node version is installed" 52 + echo "Examples:" 53 + echo " nvm install latest Install the latest version of Node" 54 + echo " nvm use 14.15.1 Use Node version 14.15.1" 55 + echo " nvm use system Activate the system's Node version" 56 + 57 + case install 58 + _nvm_index_update 59 + 60 + string match --entire --regex -- (_nvm_version_match $ver) <$nvm_data/.index | read ver alias 61 + 62 + if ! set --query ver[1] 63 + echo "nvm: Invalid version number or alias: \"$their_version\"" >&2 64 + return 1 65 + end 66 + 67 + if test ! -e $nvm_data/$ver 68 + set --local os (command uname -s | string lower) 69 + set --local ext tar.gz 70 + set --local arch (command uname -m) 71 + 72 + switch $os 73 + case aix 74 + set arch ppc64 75 + case sunos 76 + case linux 77 + case darwin 78 + case {MSYS_NT,MINGW\*_NT}\* 79 + set os win 80 + set ext zip 81 + case \* 82 + echo "nvm: Unsupported operating system: \"$os\"" >&2 83 + return 1 84 + end 85 + 86 + switch $arch 87 + case i\*86 88 + set arch x86 89 + case x86_64 90 + set arch x64 91 + case arm64 92 + string match --regex --quiet "v(?<major>\d+)" $ver 93 + if test "$os" = darwin -a $major -lt 16 94 + set arch x64 95 + end 96 + case armv6 armv6l 97 + set arch armv6l 98 + case armv7 armv7l 99 + set arch armv7l 100 + case armv8 armv8l aarch64 101 + set arch arm64 102 + end 103 + 104 + set --query nvm_arch && set arch $nvm_arch 105 + 106 + set --local dir "node-$ver-$os-$arch" 107 + set --local url $nvm_mirror/$ver/$dir.$ext 108 + 109 + command mkdir -p $nvm_data/$ver 110 + 111 + if ! set --query silent 112 + echo -e "Installing Node \x1b[1m$ver\x1b[22m $alias" 113 + echo -e "Fetching \x1b[4m$url\x1b[24m\x1b[7m" 114 + end 115 + 116 + if ! command curl $silent --progress-bar --location $url | 117 + command tar --extract --gzip --directory $nvm_data/$ver 2>/dev/null 118 + command rm -rf $nvm_data/$ver 119 + echo -e "\033[F\33[2K\x1b[0mnvm: Invalid mirror or host unavailable: \"$url\"" >&2 120 + return 1 121 + end 122 + 123 + set --query silent || echo -en "\033[F\33[2K\x1b[0m" 124 + 125 + if test "$os" = win 126 + command mv $nvm_data/$ver/$dir $nvm_data/$ver/bin 127 + else 128 + command mv $nvm_data/$ver/$dir/* $nvm_data/$ver 129 + command rm -rf $nvm_data/$ver/$dir 130 + end 131 + end 132 + 133 + if test $ver != "$nvm_current_version" 134 + set --query nvm_current_version && _nvm_version_deactivate $nvm_current_version 135 + _nvm_version_activate $ver 136 + 137 + set --query nvm_default_packages[1] && npm install --global $silent $nvm_default_packages 138 + end 139 + 140 + set --query silent || printf "Now using Node %s (npm %s) %s\n" (_nvm_node_info) 141 + case use 142 + test $ver = default && set ver $nvm_default_version 143 + _nvm_list | string match --entire --regex -- (_nvm_version_match $ver) | read ver __ 144 + 145 + if ! set --query ver[1] 146 + echo "nvm: Can't use Node \"$their_version\", version must be installed first" >&2 147 + return 1 148 + end 149 + 150 + if test $ver != "$nvm_current_version" 151 + set --query nvm_current_version && _nvm_version_deactivate $nvm_current_version 152 + test $ver != system && _nvm_version_activate $ver 153 + end 154 + 155 + set --query silent || printf "Now using Node %s (npm %s) %s\n" (_nvm_node_info) 156 + case uninstall 157 + if test -z "$ver" 158 + echo "nvm: Not enough arguments for command: \"$cmd\"" >&2 159 + return 1 160 + end 161 + 162 + test $ver = default && test ! -z "$nvm_default_version" && set ver $nvm_default_version 163 + 164 + _nvm_list | string match --entire --regex -- (_nvm_version_match $ver) | read ver __ 165 + 166 + if ! set -q ver[1] 167 + echo "nvm: Node version not installed or invalid: \"$their_version\"" >&2 168 + return 1 169 + end 170 + 171 + set --query silent || printf "Uninstalling Node %s %s\n" $ver (string replace ~ \~ "$nvm_data/$ver/bin/node") 172 + 173 + _nvm_version_deactivate $ver 174 + 175 + command rm -rf $nvm_data/$ver 176 + case current 177 + _nvm_current 178 + case ls list 179 + _nvm_list | _nvm_list_format (_nvm_current) $argv[2] 180 + case lsr {ls,list}-remote 181 + _nvm_index_update || return 182 + _nvm_list | command awk ' 183 + FILENAME == "-" && (is_local[$1] = FNR == NR) { next } { 184 + print $0 (is_local[$1] ? " ✓" : "") 185 + } 186 + ' - $nvm_data/.index | _nvm_list_format (_nvm_current) $argv[2] 187 + case \* 188 + echo "nvm: Unknown command or option: \"$cmd\" (see nvm -h for usage)" >&2 189 + return 1 190 + end 191 + end 192 + 193 + function _nvm_find_up --argument-names path file 194 + test -e "$path/$file" && echo $path/$file || begin 195 + test ! -z "$path" || return 196 + _nvm_find_up (string replace --regex -- '/[^/]*$' "" $path) $file 197 + end 198 + end 199 + 200 + function _nvm_version_match --argument-names ver 201 + string replace --regex -- '^v?(\d+|\d+\.\d+)$' 'v$1.' $ver | 202 + string replace --filter --regex -- '^v?(\d+)' 'v$1' | 203 + string escape --style=regex || string lower '\b'$ver'(?:/\w+)?$' 204 + end 205 + 206 + function _nvm_list_format --argument-names current regex 207 + command awk -v current="$current" -v regex="$regex" ' 208 + $0 ~ regex { 209 + aliases[versions[i++] = $1] = $2 " " $3 210 + pad = (n = length($1)) > pad ? n : pad 211 + } 212 + END { 213 + if (!i) exit 1 214 + while (i--) 215 + printf((current == versions[i] ? " ▶ " : " ") "%"pad"s %s\n", 216 + versions[i], aliases[versions[i]]) 217 + } 218 + ' 219 + end 220 + 221 + function _nvm_current 222 + command --search --quiet node || return 223 + set --query nvm_current_version && echo $nvm_current_version || echo system 224 + end 225 + 226 + function _nvm_node_info 227 + set --local npm_path (string replace bin/npm-cli.js "" (realpath (command --search npm))) 228 + test -f $npm_path/package.json || set --local npm_version_default (command npm --version) 229 + command node --eval " 230 + console.log(process.version) 231 + console.log('$npm_version_default' ? '$npm_version_default': require('$npm_path/package.json').version) 232 + console.log(process.execPath) 233 + " | string replace -- ~ \~ 234 + end