diff --git a/fish/completions/copilot.fish b/fish/completions/copilot.fish new file mode 100644 index 0000000..17fdc40 --- /dev/null +++ b/fish/completions/copilot.fish @@ -0,0 +1,103 @@ +# fish completion for copilot +# Generated by `copilot completion fish`. Do not edit by hand. + +complete -c copilot -n '__fish_use_subcommand' -f -a 'login' -d 'Authenticate with Copilot' +complete -c copilot -n '__fish_use_subcommand' -f -a 'help' -d 'Display help information' +complete -c copilot -n '__fish_use_subcommand' -f -a 'init' -d 'Initialize Copilot instructions' +complete -c copilot -n '__fish_use_subcommand' -f -a 'update' -d 'Download the latest version' +complete -c copilot -n '__fish_use_subcommand' -f -a 'version' -d 'Display version information' +complete -c copilot -n '__fish_use_subcommand' -f -a 'plugin' -d 'Manage plugins' +complete -c copilot -n '__fish_use_subcommand' -f -a 'mcp' -d 'Manage MCP servers' +complete -c copilot -n '__fish_use_subcommand' -f -a 'completion' -d 'Generate a shell completion script' +complete -c copilot -l version -s v -f -d 'show version information' +complete -c copilot -l interactive -s i -r -d 'Start interactive mode and automatically execute this prompt' +complete -c copilot -l prompt -s p -r -d 'Execute a prompt in non-interactive mode (exits after completion)' +complete -c copilot -l silent -s s -f -d 'Output only the agent response (no stats), useful for scripting with -p' +complete -c copilot -l enable-memory -f -d 'Enable memory in prompt mode (disabled by default)' +complete -c copilot -l model -r -d 'Set the AI model to use (use \'auto\' to let Copilot pick automatically)' +complete -c copilot -l effort -l reasoning-effort -r -d 'Set the reasoning effort level' -a 'none low medium high xhigh max' +complete -c copilot -l context -r -d 'Set the context window tier (overrides persisted setting)' -a 'default long_context' +complete -c copilot -l enable-reasoning-summaries -f -d 'Request reasoning summaries for OpenAI models' +complete -c copilot -l agent -r -d 'Specify a custom agent to use' +complete -c copilot -l resume -s r -r -d 'Resume from a previous session (optionally specify existing session ID, task ID, ID prefix, or name; name matching is exact, case-insensitive)' +complete -c copilot -l continue -f -d 'Resume the most recent session' +complete -c copilot -l name -s n -r -d 'Set a name for the new session' +complete -c copilot -l session-id -r -d 'Resume an existing session or task by ID, or set the UUID for a new session' +complete -c copilot -l connect -r -d 'Connect directly to a remote session (optionally specify session ID or task ID)' +complete -c copilot -l allow-all-tools -f -d 'Allow all tools to run automatically without confirmation; required for non-interactive mode' +complete -c copilot -l allow-all-paths -f -d 'Disable file path verification and allow access to any path' +complete -c copilot -l disallow-temp-dir -f -d 'Prevent automatic access to the system temporary directory' +complete -c copilot -l no-custom-instructions -f -d 'Disable loading of custom instructions from AGENTS.md and related files' +complete -c copilot -l no-auto-update -f -d 'Disable downloading CLI update automatically (disabled by default in CI environments)' +complete -c copilot -l no-ask-user -f -d 'Disable the ask_user tool (agent works autonomously without asking questions)' +complete -c copilot -l banner -f -d 'Show the startup banner' +complete -c copilot -l no-color -f -d 'Disable all color output' +complete -c copilot -l screen-reader -f -d 'Enable screen reader optimizations' +complete -c copilot -l plain-diff -f -d 'Disable rich diff rendering (syntax highlighting via diff tool specified by git config)' +complete -c copilot -s C -r -d 'Change working directory before doing anything else' +complete -c copilot -l log-dir -r -d 'Set log file directory (default: ~/.copilot/logs/)' +complete -c copilot -l extension-sdk-path -r -d 'Override the bundled @github/copilot-sdk injected into extension subprocesses with a local `copilot-sdk/` folder. Invalid paths fall back to the bundled SDK.' +complete -c copilot -l log-level -r -d 'Set the log level' -a 'none error warning info debug all default' +complete -c copilot -l stream -r -d 'Enable or disable streaming mode' -a 'on off' +complete -c copilot -l output-format -r -d 'Output format: \'text\' (default) or \'json\' (JSONL, one JSON object per line)' -a 'text json' +complete -c copilot -l share -r -d 'Share session to markdown file after completion in non-interactive mode (default: ./copilot-session-.md)' +complete -c copilot -l share-gist -f -d 'Share session to a secret GitHub gist after completion in non-interactive mode' +complete -c copilot -l add-dir -r -d 'Add a directory to the allowed list for file access (can be used multiple times)' +complete -c copilot -l attachment -r -d 'Attach a file (image or native document) to the initial prompt; only valid in non-interactive mode (can be used multiple times)' +complete -c copilot -l disable-mcp-server -r -d 'Disable a specific MCP server (can be used multiple times)' +complete -c copilot -l disable-builtin-mcps -f -d 'Disable all built-in MCP servers (currently: github-mcp-server)' +complete -c copilot -l enable-all-github-mcp-tools -f -d 'Enable all GitHub MCP server tools instead of the default CLI subset. Overrides --add-github-mcp-toolset and --add-github-mcp-tool options.' +complete -c copilot -l add-github-mcp-toolset -r -d 'Add a toolset to enable for the GitHub MCP server instead of the default CLI subset (can be used multiple times). Use "all" for all toolsets.' +complete -c copilot -l add-github-mcp-tool -r -d 'Add a tool to enable for the GitHub MCP server instead of the default CLI subset (can be used multiple times). Use "*" for all tools.' +complete -c copilot -l plugin-dir -r -d 'Load a plugin from a local directory (can be used multiple times)' +complete -c copilot -l additional-mcp-config -r -d 'Additional MCP servers configuration as JSON string or file path (prefix with @) (can be used multiple times; augments config from ~/.copilot/mcp-config.json for this session)' +complete -c copilot -l allow-tool -r -d 'Tools the CLI has permission to use; will not prompt for permission' +complete -c copilot -l deny-tool -r -d 'Tools the CLI does not have permission to use; will not prompt for permission' +complete -c copilot -l available-tools -r -d 'Only these tools will be available to the model' +complete -c copilot -l excluded-tools -r -d 'These tools will not be available to the model' +complete -c copilot -l secret-env-vars -r -d 'Environment variable names whose values are stripped from shell and MCP server environments and redacted from output (e.g., --secret-env-vars=MY_KEY,OTHER_KEY)' +complete -c copilot -l allow-url -r -d 'Allow access to specific URLs or domains' +complete -c copilot -l deny-url -r -d 'Deny access to specific URLs or domains, takes precedence over --allow-url' +complete -c copilot -l allow-all-urls -f -d 'Allow access to all URLs without confirmation' +complete -c copilot -l allow-all -f -d 'Enable all permissions (equivalent to --allow-all-tools --allow-all-paths --allow-all-urls)' +complete -c copilot -l yolo -f -d 'Enable all permissions (equivalent to --allow-all-tools --allow-all-paths --allow-all-urls)' +complete -c copilot -l max-autopilot-continues -r -d 'Maximum number of continuation messages in autopilot mode' +complete -c copilot -l mode -r -d 'Set the initial agent mode' -a 'interactive plan autopilot' +complete -c copilot -l autopilot -f -d 'Start in autopilot mode' +complete -c copilot -l plan -f -d 'Start in plan mode' +complete -c copilot -l experimental -f -d 'Enable experimental features' +complete -c copilot -l no-experimental -f -d 'Disable experimental features' +complete -c copilot -l bash-env -r -d 'Enable BASH_ENV support for bash shells (on|off)' +complete -c copilot -l no-bash-env -f -d 'Disable BASH_ENV support for bash shells' +complete -c copilot -l mouse -r -d 'Enable mouse support in alt screen mode (on|off)' +complete -c copilot -l no-mouse -f -d 'Disable mouse support in alt screen mode' +complete -c copilot -l acp -f -d 'Start as Agent Client Protocol server' +complete -c copilot -l remote -f -d 'Enable remote control of your session from GitHub web and mobile' +complete -c copilot -l no-remote -f -d 'Disable remote control of your session from GitHub web and mobile' +complete -c copilot -n '__fish_seen_subcommand_from login' -l host -r -d 'GitHub host URL (default: https://github.com)' +complete -c copilot -n '__fish_seen_subcommand_from plugin' -f -a 'install' -d 'Install a plugin' +complete -c copilot -n '__fish_seen_subcommand_from plugin' -f -a 'uninstall' -d 'Uninstall a plugin' +complete -c copilot -n '__fish_seen_subcommand_from plugin' -f -a 'update' -d 'Update a plugin' +complete -c copilot -n '__fish_seen_subcommand_from plugin' -f -a 'list' -d 'List installed plugins' +complete -c copilot -n '__fish_seen_subcommand_from plugin' -f -a 'marketplace' -d 'Manage plugin marketplaces' +complete -c copilot -n '__fish_seen_subcommand_from plugin; and __fish_seen_subcommand_from update' -l all -f -d 'Update all installed plugins' +complete -c copilot -n '__fish_seen_subcommand_from plugin; and __fish_seen_subcommand_from marketplace' -f -a 'add' -d 'Add a marketplace' +complete -c copilot -n '__fish_seen_subcommand_from plugin; and __fish_seen_subcommand_from marketplace' -f -a 'remove' -d 'Remove a marketplace' +complete -c copilot -n '__fish_seen_subcommand_from plugin; and __fish_seen_subcommand_from marketplace' -f -a 'list' -d 'List registered marketplaces' +complete -c copilot -n '__fish_seen_subcommand_from plugin; and __fish_seen_subcommand_from marketplace' -f -a 'browse' -d 'Browse plugins in a marketplace' +complete -c copilot -n '__fish_seen_subcommand_from plugin; and __fish_seen_subcommand_from marketplace' -f -a 'update' -d 'Update marketplace plugin catalogs' +complete -c copilot -n '__fish_seen_subcommand_from plugin; and __fish_seen_subcommand_from marketplace; and __fish_seen_subcommand_from remove' -l force -s f -f -d 'Force removal even if plugins are installed' +complete -c copilot -n '__fish_seen_subcommand_from mcp' -f -a 'list' -d 'List configured MCP servers' +complete -c copilot -n '__fish_seen_subcommand_from mcp' -f -a 'get' -d 'Show server details' +complete -c copilot -n '__fish_seen_subcommand_from mcp' -f -a 'add' -d 'Add an MCP server' +complete -c copilot -n '__fish_seen_subcommand_from mcp' -f -a 'remove' -d 'Remove an MCP server' +complete -c copilot -n '__fish_seen_subcommand_from mcp; and __fish_seen_subcommand_from list' -l json -f -d 'Output as JSON' +complete -c copilot -n '__fish_seen_subcommand_from mcp; and __fish_seen_subcommand_from get' -l json -f -d 'Output as JSON' +complete -c copilot -n '__fish_seen_subcommand_from mcp; and __fish_seen_subcommand_from get' -l show-secrets -f -d 'Show full environment variable and header values (masked by default)' +complete -c copilot -n '__fish_seen_subcommand_from mcp; and __fish_seen_subcommand_from add' -l transport -r -d 'Server transport' -a 'stdio http sse' +complete -c copilot -n '__fish_seen_subcommand_from mcp; and __fish_seen_subcommand_from add' -l env -r -d 'Environment variable (KEY=VALUE, can be repeated)' +complete -c copilot -n '__fish_seen_subcommand_from mcp; and __fish_seen_subcommand_from add' -l header -r -d 'HTTP header for remote servers, can be repeated' +complete -c copilot -n '__fish_seen_subcommand_from mcp; and __fish_seen_subcommand_from add' -l tools -r -d 'Tool filter: "*" for all, comma-separated list, or "" for none' +complete -c copilot -n '__fish_seen_subcommand_from mcp; and __fish_seen_subcommand_from add' -l timeout -r -d 'Timeout in milliseconds' +complete -c copilot -n '__fish_seen_subcommand_from mcp; and __fish_seen_subcommand_from add' -l json -f -d 'Output added config as JSON' +complete -c copilot -n '__fish_seen_subcommand_from mcp; and __fish_seen_subcommand_from add' -l show-secrets -f -d 'Show full environment variable and header values in output, masked by default' diff --git a/fish/completions/nvm.fish b/fish/completions/nvm.fish new file mode 100644 index 0000000..14be1b7 --- /dev/null +++ b/fish/completions/nvm.fish @@ -0,0 +1,21 @@ +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 +)" diff --git a/fish/conf.d/fish_frozen_key_bindings.fish b/fish/conf.d/fish_frozen_key_bindings.fish new file mode 100644 index 0000000..495aee9 --- /dev/null +++ b/fish/conf.d/fish_frozen_key_bindings.fish @@ -0,0 +1,14 @@ +# This file was created by fish when upgrading to version 4.3, to migrate +# the 'fish_key_bindings' variable from its old default scope (universal) +# to its new default scope (global). We recommend you delete this file +# and configure key bindings in ~/.config/fish/config.fish if needed. + +# set --global fish_key_bindings fish_default_key_bindings + +# Prior to version 4.3, fish shipped an event handler that runs +# `set --universal fish_key_bindings fish_default_key_bindings` +# whenever the fish_key_bindings variable is erased. +# This means that as long as any fish < 4.3 is still running on this system, +# we cannot complete the migration. +# As a workaround, erase the universal variable at every shell startup. +set --erase --universal fish_key_bindings diff --git a/fish/conf.d/nvm.fish b/fish/conf.d/nvm.fish new file mode 100644 index 0000000..7545699 --- /dev/null +++ b/fish/conf.d/nvm.fish @@ -0,0 +1,28 @@ +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 diff --git a/fish/conf.d/rustup.fish b/fish/conf.d/rustup.fish new file mode 100644 index 0000000..e4cb363 --- /dev/null +++ b/fish/conf.d/rustup.fish @@ -0,0 +1 @@ +source "$HOME/.cargo/env.fish" diff --git a/fish/config.fish b/fish/config.fish new file mode 100644 index 0000000..e548720 --- /dev/null +++ b/fish/config.fish @@ -0,0 +1,48 @@ +set fish_greeting "" +if status is-interactive + # Commands to run in interactive sessions can go here + set -Ux EDITOR nvim + +end + +alias reloadwaybar='pkill -SIGUSR2 waybar' +alias cd='z' +alias man='wikiman' +alias ovim='vim' +alias vim='nvim' +alias edit='nvim' +source "$HOME/.cargo/env.fish" + +# Start ssh-agent if not already running +#if not pgrep -u (id -u) ssh-agent >/dev/null +# ssh-agent -c | source +#end + +# Add SSH keys if not already added +#if test -f ~/.ssh/id_ed25519 +# ssh-add -l >/dev/null 2>&1 +# or ssh-add ~/.ssh/id_ed25519 +#end + +zoxide init fish | source + +# Added by LM Studio CLI (lms) +set -gx PATH $PATH /home/sortedcord/.lmstudio/bin +# End of LM Studio CLI section + +# pnpm +set -gx PNPM_HOME "/home/sortedcord/.local/share/pnpm" +if not string match -q -- $PNPM_HOME $PATH + set -gx PATH "$PNPM_HOME" $PATH +end +# pnpm end + +# claurst +fish_add_path /home/sortedcord/.claurst/bin + + +# Added by Antigravity CLI installer +set -gx PATH "/home/sortedcord/.local/bin" $PATH + +# Generated for envman. Do not edit. +test -s ~/.config/envman/load.fish; and source ~/.config/envman/load.fish diff --git a/fish/fish_plugins b/fish/fish_plugins new file mode 100644 index 0000000..aea2aa0 --- /dev/null +++ b/fish/fish_plugins @@ -0,0 +1 @@ +jorgebucaran/nvm.fish diff --git a/fish/fish_variables b/fish/fish_variables new file mode 100644 index 0000000..fe45fe5 --- /dev/null +++ b/fish/fish_variables @@ -0,0 +1,8 @@ +# This file contains fish universal variable definitions. +# VERSION: 3.0 +SETUVAR --export EDITOR:nvim +SETUVAR __fish_initialized:4300 +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 +SETUVAR _fisher_plugins:jorgebucaran/nvm\x2efish +SETUVAR _fisher_upgraded_to_4_4:\x1d +SETUVAR fish_user_paths:/home/sortedcord/go/bin\x1e/home/sortedcord/\x2eclaurst/bin\x1e/home/sortedcord/\x2elocal/bin diff --git a/fish/functions/_nvm_index_update.fish b/fish/functions/_nvm_index_update.fish new file mode 100644 index 0000000..c66753d --- /dev/null +++ b/fish/functions/_nvm_index_update.fish @@ -0,0 +1,20 @@ +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 diff --git a/fish/functions/_nvm_list.fish b/fish/functions/_nvm_list.fish new file mode 100644 index 0000000..1623bb8 --- /dev/null +++ b/fish/functions/_nvm_list.fish @@ -0,0 +1,14 @@ +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 diff --git a/fish/functions/_nvm_version_activate.fish b/fish/functions/_nvm_version_activate.fish new file mode 100644 index 0000000..f7dfef7 --- /dev/null +++ b/fish/functions/_nvm_version_activate.fish @@ -0,0 +1,4 @@ +function _nvm_version_activate --argument-names ver + set --global --export nvm_current_version $ver + set --prepend PATH $nvm_data/$ver/bin +end diff --git a/fish/functions/_nvm_version_deactivate.fish b/fish/functions/_nvm_version_deactivate.fish new file mode 100644 index 0000000..24dd36e --- /dev/null +++ b/fish/functions/_nvm_version_deactivate.fish @@ -0,0 +1,5 @@ +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 diff --git a/fish/functions/jpg2png.fish b/fish/functions/jpg2png.fish new file mode 100644 index 0000000..51b658b --- /dev/null +++ b/fish/functions/jpg2png.fish @@ -0,0 +1,26 @@ +function jpg2png --description "Convert a JPG image from URL to PNG format" + if test (count $argv) -ne 2 + echo "Usage: jpg2png " + return 1 + end + + set source $argv[1] + set destination $argv[2] + + set temp_jpg (mktemp --suffix=.jpg) + + if not wget -O $temp_jpg $source 2>&1 + echo "Error: Failed to download JPG from $source" + rm -f $temp_jpg + return 1 + end + + if not magick $temp_jpg $destination + echo "Error: Failed to convert JPG to PNG" + rm -f $temp_jpg + return 1 + end + + rm -f $temp_jpg + echo "Successfully converted and saved to $destination" +end diff --git a/fish/functions/nvm.fish b/fish/functions/nvm.fish new file mode 100644 index 0000000..64d94c5 --- /dev/null +++ b/fish/functions/nvm.fish @@ -0,0 +1,237 @@ +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 Download and activate the specified Node version" + echo " nvm install Install the version specified in the nearest .nvmrc file" + echo " nvm use 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 List Node versions matching a given regex pattern" + echo " nvm current Print the currently-active Node version" + echo " nvm uninstall 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(?\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 diff --git a/fish/functions/y.fish b/fish/functions/y.fish new file mode 100644 index 0000000..a846c63 --- /dev/null +++ b/fish/functions/y.fish @@ -0,0 +1,8 @@ +function y + set tmp (mktemp -t "yazi-cwd.XXXXXX") + yazi $argv --cwd-file="$tmp" + if read -z cwd <"$tmp"; and [ -n "$cwd" ]; and [ "$cwd" != "$PWD" ] + builtin cd -- "$cwd" + end + rm -f -- "$tmp" +end