feat: sync .config dotfiles, transition Node to mise, integrate 1Password CLI/SSH Agent, and add optional AI CLI tools
This commit is contained in:
+1
@@ -0,0 +1 @@
|
||||
/Applications/OrbStack.app/Contents/MacOS/../Resources/completions/fish/docker.fish
|
||||
+1
@@ -0,0 +1 @@
|
||||
/Applications/OrbStack.app/Contents/MacOS/../Resources/completions/fish/kubectl.fish
|
||||
@@ -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
@@ -0,0 +1 @@
|
||||
/Applications/OrbStack.app/Contents/MacOS/../Resources/completions/fish/orbctl.fish
|
||||
@@ -8,6 +8,8 @@ alias update-system="brew update && brew upgrade && npm update -g"
|
||||
alias do-st="docker compose"
|
||||
alias do-re="docker compose down && docker compose up -d"
|
||||
alias hetzi="ssh root@128.140.71.88"
|
||||
alias hdock="ssh dockerserver-1@192.168.0.156"
|
||||
alias proxi="ssh root@192.168.0.31"
|
||||
alias qaserv="TERM=xterm-256color ssh root@195.201.17.47"
|
||||
alias kc1="set -gx KUBECONFIG ~/.kube/config"
|
||||
alias kc2="set -gx KUBECONFIG ~/.kube/mobilistics"
|
||||
@@ -35,10 +37,12 @@ alias kdesc="kubectl describe"
|
||||
alias kpf="kubectl port-forward"
|
||||
|
||||
# Testing
|
||||
alias pw="npx playwright"
|
||||
alias pwt="npx playwright test"
|
||||
alias pwh="npx playwright test --headed"
|
||||
alias pwr="npx playwright show-report"
|
||||
alias pw="pnpm exec playwright"
|
||||
alias pwt="pnpm exec playwright test"
|
||||
alias pwui="pnpm exec playwright test --ui"
|
||||
alias pwh="pnpm exec playwright test --headed"
|
||||
alias pwr="pnpm exec playwright show-report"
|
||||
alias dpwt="DEBUG=pw:api,pw:network pnpm exec playwright test"
|
||||
|
||||
# Python/Go
|
||||
alias py="python3"
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
function tiffy
|
||||
# --- KONFIGURATION ---
|
||||
set -l SOURCE_NAME "sources/github/Baerspektivo/projectTiffy"
|
||||
set -l SESSION_STORE "$HOME/.config/fish/tiffy_session"
|
||||
|
||||
# Hilfsfunktion zum Auflisten der verfuegbaren Repos
|
||||
if test "$argv[1]" = "--list-sources"
|
||||
echo "Suche verfuegbare Jules-Quellen..."
|
||||
curl -s "https://jules.googleapis.com/v1alpha/sources" -H "X-Goog-Api-Key: $JULES_API_KEY" | jq .
|
||||
return
|
||||
end
|
||||
|
||||
# Befehl zum Abholen der letzten Session (tiffy fetch oder tiffy gib)
|
||||
if test "$argv[1]" = "fetch"; or test "$argv[1]" = "gib"
|
||||
if test -f "$SESSION_STORE"
|
||||
read -l S_ID TARGET_FILE < "$SESSION_STORE"
|
||||
echo "Pruefe letzte Session $S_ID fuer Datei $TARGET_FILE..."
|
||||
set -l ACT (curl -s "https://jules.googleapis.com/v1alpha/sessions/$S_ID/activities" -H "X-Goog-Api-Key: $JULES_API_KEY")
|
||||
set -l RES (echo $ACT | jq -r '.activities[]? | (.progressUpdated?.description // .agentMessaged?.agentMessage // empty)' | grep "```" | tail -n 1)
|
||||
|
||||
if test -n "$RES"
|
||||
set -l DETECTED_LANG (echo "$RES" | string match -r '```(\w+)' | head -n 2 | tail -n 1)
|
||||
set -l EXT "ts"
|
||||
switch "$DETECTED_LANG"
|
||||
case "go"; set EXT "go"
|
||||
case "typescript" "ts"; set EXT "ts"
|
||||
case "javascript" "js"; set EXT "js"
|
||||
case "python" "py"; set EXT "py"
|
||||
case "html"; set EXT "html"
|
||||
case "json"; set EXT "json"
|
||||
end
|
||||
set -l FINAL_TARGET (string replace -r '\.[^.]+$' ".$EXT" "$TARGET_FILE")
|
||||
echo "$RES" | sed -n '/^```/,/^```/ p' | sed '1d;$d' > "$FINAL_TARGET"
|
||||
if test ! -s "$FINAL_TARGET"; echo "$RES" > "$FINAL_TARGET"; end
|
||||
echo "Code erfolgreich nachgeholt und gespeichert: $FINAL_TARGET"
|
||||
else
|
||||
echo "Noch kein Code in Session $S_ID gefunden."
|
||||
end
|
||||
return
|
||||
else
|
||||
echo "Keine gespeicherte Session gefunden."
|
||||
return 1
|
||||
end
|
||||
end
|
||||
|
||||
# Befehl um eine Folgefrage mit optionalen neuen Dateien zu senden
|
||||
if test "$argv[1]" = "ask"
|
||||
if test -f "$SESSION_STORE"
|
||||
read -l S_ID TARGET_FILE < "$SESSION_STORE"
|
||||
|
||||
set -l ASSET_FILES
|
||||
set -l MSG_PARTS
|
||||
# Argumente ab dem zweiten (nach "ask") auf Dateien pruefen
|
||||
for arg in $argv[2..-1]
|
||||
if test -f "$arg"
|
||||
set -a ASSET_FILES "$arg"
|
||||
else
|
||||
set -a MSG_PARTS "$arg"
|
||||
end
|
||||
end
|
||||
|
||||
set -l USER_MSG (string join " " $MSG_PARTS)
|
||||
set -l ADD_CONTEXT ""
|
||||
for f in $ASSET_FILES
|
||||
echo "Lese zusaetzliche Datei: $f"
|
||||
set ADD_CONTEXT "$ADD_CONTEXT\n\n--- FILE: $f ---\n"(cat "$f")
|
||||
end
|
||||
|
||||
set -l FOLLOW_UP (string join "\n" "$USER_MSG" "$ADD_CONTEXT")
|
||||
|
||||
if test -z (string trim "$FOLLOW_UP")
|
||||
echo "Fehler: Keine Nachricht oder Datei angegeben."
|
||||
return 1
|
||||
end
|
||||
|
||||
echo "Sende Nachricht und Kontext an bestehende Session $S_ID..."
|
||||
set -l ESCAPED_FOLLOW_UP (printf "%s" "$FOLLOW_UP" | python3 -c 'import json, sys; print(json.dumps(sys.stdin.read()), end="")')
|
||||
|
||||
curl -s "https://jules.googleapis.com/v1alpha/sessions/$S_ID:sendMessage" \
|
||||
-X POST -H "Content-Type: application/json" -H "X-Goog-Api-Key: $JULES_API_KEY" \
|
||||
-d "{ \"prompt\": $ESCAPED_FOLLOW_UP }" > /dev/null
|
||||
|
||||
# Polling
|
||||
set -l RESULT ""
|
||||
echo "Warte auf Antwort..."
|
||||
for i in (seq 1 36)
|
||||
sleep 5
|
||||
set -l ACT_RES (curl -s "https://jules.googleapis.com/v1alpha/sessions/$S_ID/activities" -H "X-Goog-Api-Key: $JULES_API_KEY")
|
||||
set RESULT (echo $ACT_RES | jq -r '.activities[]? | (.progressUpdated?.description // .agentMessaged?.agentMessage // empty)' | grep "```" | tail -n 1)
|
||||
if test -n "$RESULT"; break; end
|
||||
echo -n "."
|
||||
end
|
||||
|
||||
if test -n "$RESULT"
|
||||
echo -e "\nAntwort erhalten. Speichere..."
|
||||
set -l FINAL_TARGET (string replace -r '\.[^.]+$' ".ts" "$TARGET_FILE")
|
||||
echo "$RESULT" | sed -n '/^```/,/^```/ p' | sed '1d;$d' > "$FINAL_TARGET"
|
||||
echo "Code aktualisiert: $FINAL_TARGET"
|
||||
else
|
||||
echo -e "\nKeine schnelle Antwort. Nutze 'tiffy fetch' spaeter."
|
||||
end
|
||||
return
|
||||
else
|
||||
echo "Keine aktive Session zum Fortfuehren gefunden."
|
||||
return 1
|
||||
end
|
||||
end
|
||||
|
||||
# Resume-Modus fuer manuelle ID-Eingabe
|
||||
if test (count $argv) -eq 1; and string match -r '^\d+$' "$argv[1]" > /dev/null
|
||||
set -l S_ID "$argv[1]"
|
||||
set -l ACT (curl -s "[https://jules.googleapis.com/v1alpha/sessions/$S_ID/activities](https://jules.googleapis.com/v1alpha/sessions/$S_ID/activities)" -H "X-Goog-Api-Key: $JULES_API_KEY")
|
||||
set -l RES (echo $ACT | jq -r '.activities[]? | (.progressUpdated?.description // .agentMessaged?.agentMessage // empty)' | grep "```" | tail -n 1)
|
||||
echo "$RES"
|
||||
return
|
||||
end
|
||||
|
||||
# Normaler Session-Start (mehrere Dateien moeglich)
|
||||
set -l FILES
|
||||
set -l MSG_PARTS
|
||||
for arg in $argv
|
||||
if test -f "$arg"; set -a FILES "$arg"; else; set -a MSG_PARTS "$arg"; end
|
||||
end
|
||||
|
||||
if test (count $FILES) -eq 0; echo "Fehler: Datei nicht gefunden!"; return 1; end
|
||||
|
||||
set -l USER_MESSAGE (string join " " $MSG_PARTS)
|
||||
set -l CONTEXT ""
|
||||
for f in $FILES
|
||||
echo "Lese Datei: $f"
|
||||
set CONTEXT "$CONTEXT\n\n--- FILE: $f ---\n"(cat "$f")
|
||||
end
|
||||
|
||||
set -l ESCAPED_PROMPT (printf "%s" "$USER_MESSAGE\n$CONTEXT" | python3 -c 'import json, sys; print(json.dumps(sys.stdin.read()), end="")')
|
||||
|
||||
echo "Session-Start fuer $SOURCE_NAME..."
|
||||
set -l PAYLOAD "{ \"prompt\": $ESCAPED_PROMPT, \"sourceContext\": { \"source\": \"$SOURCE_NAME\", \"githubRepoContext\": { \"startingBranch\": \"main\" } } }"
|
||||
|
||||
set -l SESSION_RESPONSE (curl -s "https://jules.googleapis.com/v1alpha/sessions" \
|
||||
-X POST -H "Content-Type: application/json" -H "X-Goog-Api-Key: $JULES_API_KEY" -d "$PAYLOAD")
|
||||
|
||||
set -l SESSION_ID (echo $SESSION_RESPONSE | jq -r '.id // empty')
|
||||
if test -z "$SESSION_ID"; echo "API Fehler."; echo $SESSION_RESPONSE | jq .; return 1; end
|
||||
|
||||
# Speichert die erste Datei als Referenz fuer den Zielnamen
|
||||
echo "$SESSION_ID $FILES[1]" > "$SESSION_STORE"
|
||||
echo "Jules arbeitet... (Session: $SESSION_ID)"
|
||||
|
||||
set -l RESULT ""
|
||||
for i in (seq 1 36)
|
||||
sleep 5
|
||||
set -l ACT_RES (curl -s "https://jules.googleapis.com/v1alpha/sessions/$SESSION_ID/activities" -H "X-Goog-Api-Key: $JULES_API_KEY")
|
||||
set RESULT (echo $ACT_RES | jq -r '.activities[]? | (.progressUpdated?.description // .agentMessaged?.agentMessage // empty)' | grep "```" | tail -n 1)
|
||||
if test -n "$RESULT"; break; end
|
||||
echo -n "."
|
||||
end
|
||||
|
||||
if test -z "$RESULT"; echo -e "\nNutze 'tiffy fetch' zum Abrufen."; return 0; end
|
||||
|
||||
set -l DETECTED_LANG (echo "$RESULT" | string match -r '```(\w+)' | head -n 2 | tail -n 1)
|
||||
set -l EXT "ts"
|
||||
switch "$DETECTED_LANG"
|
||||
case "go"; set EXT "go"
|
||||
case "typescript" "ts"; set EXT "ts"
|
||||
case "javascript" "js"; set EXT "js"
|
||||
case "python" "py"; set EXT "py"
|
||||
end
|
||||
|
||||
set -l TARGET_FILE (string replace -r '\.[^.]+$' ".$EXT" "$FILES[1]")
|
||||
echo "$RESULT" | sed -n '/^```/,/^```/ p' | sed '1d;$d' > "$TARGET_FILE"
|
||||
echo -e "\nCode lokal gespeichert: $TARGET_FILE"
|
||||
end
|
||||
@@ -1,28 +0,0 @@
|
||||
set --query XDG_DATA_HOME || set --local XDG_DATA_HOME ~/.local/share
|
||||
set --query nvm_mirror || set --global nvm_mirror https://nodejs.org/dist
|
||||
set --query nvm_data || 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
|
||||
@@ -1,10 +1,10 @@
|
||||
# Go environment
|
||||
set -gx GOPATH ~/go
|
||||
set -gx GO111MODULE on
|
||||
|
||||
# Development paths
|
||||
fish_add_path /opt/homebrew/bin
|
||||
fish_add_path ~/.cargo/bin
|
||||
fish_add_path ~/.local/bin
|
||||
fish_add_path /usr/local/go/bin
|
||||
fish_add_path $GOPATH/bin
|
||||
|
||||
# Go environment
|
||||
set -gx GOPATH ~/go
|
||||
set -gx GO111MODULE on
|
||||
|
||||
@@ -2,3 +2,71 @@
|
||||
# Startup commands only
|
||||
neofetch
|
||||
|
||||
if type -q mise
|
||||
mise activate fish | source
|
||||
end
|
||||
|
||||
# Added by OrbStack: command-line tools and integration
|
||||
# This won't be added again if you remove it.
|
||||
source ~/.orbstack/shell/init2.fish 2>/dev/null || :
|
||||
|
||||
set -g fish_key_bindings fish_default_key_bindings
|
||||
|
||||
# This file was created by fish when upgrading to version 4.3, to migrate
|
||||
# theme variables from universal to global scope.
|
||||
# Don't edit this file, as it will be written by the web-config tool (`fish_config`).
|
||||
# To customize your theme, delete this file and see
|
||||
# help interactive#syntax-highlighting
|
||||
# or
|
||||
# man fish-interactive | less +/^SYNTAX.HIGHLIGHTING
|
||||
# for appropriate commands to add to ~/.config/fish/config.fish instead.
|
||||
# See also the release notes for fish 4.3.0 (run `help relnotes`).
|
||||
|
||||
fish_add_path /opt/homebrew/bin
|
||||
fish_add_path /Users/r.kallinich/go/bin
|
||||
fish_add_path /Users/r.kallinich/.cargo/bin
|
||||
fish_add_path /Applications/Ghostty.app/Contents/MacOS
|
||||
|
||||
|
||||
set --global fish_color_autosuggestion brblack
|
||||
set --global fish_color_cancel -r
|
||||
set --global fish_color_command normal
|
||||
set --global fish_color_comment red
|
||||
set --global fish_color_cwd green
|
||||
set --global fish_color_cwd_root red
|
||||
set --global fish_color_end green
|
||||
set --global fish_color_error brred
|
||||
set --global fish_color_escape brcyan
|
||||
set --global fish_color_history_current --bold
|
||||
set --global fish_color_host normal
|
||||
set --global fish_color_host_remote yellow
|
||||
set --global fish_color_normal normal
|
||||
set --global fish_color_operator brcyan
|
||||
set --global fish_color_param cyan
|
||||
set --global fish_color_quote yellow
|
||||
set --global fish_color_redirection cyan --bold
|
||||
set --global fish_color_search_match white --background=brblack
|
||||
set --global fish_color_selection white --bold --background=brblack
|
||||
set --global fish_color_status red
|
||||
set --global fish_color_user brgreen
|
||||
set --global fish_color_valid_path --underline
|
||||
set --global fish_pager_color_completion normal
|
||||
set --global fish_pager_color_description yellow -i
|
||||
set --global fish_pager_color_prefix normal --bold --underline
|
||||
set --global fish_pager_color_progress brwhite --background=cyan
|
||||
set --global fish_pager_color_selected_background -r
|
||||
|
||||
# API-Keys
|
||||
set -gx GEMINI_API_KEY "AIzaSyBu-u9JIHoPR_wIsjwjelo1lGUzzxKKofQ"
|
||||
set -gx JULES_API_KEY "AQ.Ab8RN6LXe33UjfpBGpityANYBO-pHUwZEG7wKoM4V7yWTAezoQ"
|
||||
set -gx GCP_PROJECT_ID "gen-lang-client-0990109275"
|
||||
# 1Password SSH Agent
|
||||
if test -e "$HOME/.1password/agent.sock"
|
||||
set -gx SSH_AUTH_SOCK "$HOME/.1password/agent.sock"
|
||||
else if test -e "$HOME/Library/Group Containers/2BU85C4SUE.com.1password/t/agent.sock"
|
||||
set -gx SSH_AUTH_SOCK "$HOME/Library/Group Containers/2BU85C4SUE.com.1password/t/agent.sock"
|
||||
end
|
||||
|
||||
|
||||
# Added by Antigravity CLI installer
|
||||
set -gx PATH "/Users/r.kallinich/.local/bin" $PATH
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
jorgebucaran/fisher
|
||||
jorgebucaran/nvm.fish
|
||||
patrickf1/fzf.fish
|
||||
franciscolourenco/done
|
||||
|
||||
@@ -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,237 +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.18"
|
||||
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 " nvm_data Set a custom directory for storing nvm data"
|
||||
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)
|
||||
set --local tarcmd tar
|
||||
|
||||
switch $os
|
||||
case aix
|
||||
set arch ppc64
|
||||
case sunos
|
||||
case linux
|
||||
case darwin
|
||||
case {msys_nt,mingw\*_nt}\*
|
||||
set os win
|
||||
set ext zip
|
||||
set tarcmd bsdtar
|
||||
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 $tarcmd --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
|
||||
Reference in New Issue
Block a user