diff --git a/.config/fish/completions/fisher.fish b/.config/fish/completions/fisher.fish new file mode 100644 index 0000000..6d23ce4 --- /dev/null +++ b/.config/fish/completions/fisher.fish @@ -0,0 +1,7 @@ +complete --command fisher --exclusive --long help --description "Print help" +complete --command fisher --exclusive --long version --description "Print version" +complete --command fisher --exclusive --condition __fish_use_subcommand --arguments install --description "Install plugins" +complete --command fisher --exclusive --condition __fish_use_subcommand --arguments update --description "Update installed plugins" +complete --command fisher --exclusive --condition __fish_use_subcommand --arguments remove --description "Remove installed plugins" +complete --command fisher --exclusive --condition __fish_use_subcommand --arguments list --description "List installed plugins matching regex" +complete --command fisher --exclusive --condition "__fish_seen_subcommand_from update remove" --arguments "(fisher list)" diff --git a/.config/fish/completions/git.fish b/.config/fish/completions/git.fish new file mode 100644 index 0000000..e69de29 diff --git a/.config/fish/completions/nvm.fish b/.config/fish/completions/nvm.fish new file mode 100644 index 0000000..14be1b7 --- /dev/null +++ b/.config/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/.config/fish/completions/rustup.fish b/.config/fish/completions/rustup.fish new file mode 100644 index 0000000..1bfc9a1 --- /dev/null +++ b/.config/fish/completions/rustup.fish @@ -0,0 +1,202 @@ +complete -c rustup -n "__fish_use_subcommand" -s v -l verbose -d 'Enable verbose output' +complete -c rustup -n "__fish_use_subcommand" -s q -l quiet -d 'Disable progress output' +complete -c rustup -n "__fish_use_subcommand" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_use_subcommand" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_use_subcommand" -f -a "dump-testament" -d 'Dump information about the build' +complete -c rustup -n "__fish_use_subcommand" -f -a "show" -d 'Show the active and installed toolchains or profiles' +complete -c rustup -n "__fish_use_subcommand" -f -a "install" -d 'Update Rust toolchains' +complete -c rustup -n "__fish_use_subcommand" -f -a "uninstall" -d 'Uninstall Rust toolchains' +complete -c rustup -n "__fish_use_subcommand" -f -a "update" -d 'Update Rust toolchains and rustup' +complete -c rustup -n "__fish_use_subcommand" -f -a "check" -d 'Check for updates to Rust toolchains and rustup' +complete -c rustup -n "__fish_use_subcommand" -f -a "default" -d 'Set the default toolchain' +complete -c rustup -n "__fish_use_subcommand" -f -a "toolchain" -d 'Modify or query the installed toolchains' +complete -c rustup -n "__fish_use_subcommand" -f -a "target" -d 'Modify a toolchain\'s supported targets' +complete -c rustup -n "__fish_use_subcommand" -f -a "component" -d 'Modify a toolchain\'s installed components' +complete -c rustup -n "__fish_use_subcommand" -f -a "override" -d 'Modify directory toolchain overrides' +complete -c rustup -n "__fish_use_subcommand" -f -a "run" -d 'Run a command with an environment configured for a given toolchain' +complete -c rustup -n "__fish_use_subcommand" -f -a "which" -d 'Display which binary will be run for a given command' +complete -c rustup -n "__fish_use_subcommand" -f -a "doc" -d 'Open the documentation for the current toolchain' +complete -c rustup -n "__fish_use_subcommand" -f -a "man" -d 'View the man page for a given command' +complete -c rustup -n "__fish_use_subcommand" -f -a "self" -d 'Modify the rustup installation' +complete -c rustup -n "__fish_use_subcommand" -f -a "set" -d 'Alter rustup settings' +complete -c rustup -n "__fish_use_subcommand" -f -a "completions" -d 'Generate tab-completion scripts for your shell' +complete -c rustup -n "__fish_use_subcommand" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)' +complete -c rustup -n "__fish_seen_subcommand_from dump-testament" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from dump-testament" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from show" -s v -l verbose -d 'Enable verbose output with rustc information for all installed toolchains' +complete -c rustup -n "__fish_seen_subcommand_from show" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from show" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from show" -f -a "active-toolchain" -d 'Show the active toolchain' +complete -c rustup -n "__fish_seen_subcommand_from show" -f -a "home" -d 'Display the computed value of RUSTUP_HOME' +complete -c rustup -n "__fish_seen_subcommand_from show" -f -a "profile" -d 'Show the current profile' +complete -c rustup -n "__fish_seen_subcommand_from show" -f -a "keys" -d 'Display the known PGP keys' +complete -c rustup -n "__fish_seen_subcommand_from show" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)' +complete -c rustup -n "__fish_seen_subcommand_from active-toolchain" -s v -l verbose -d 'Enable verbose output with rustc information' +complete -c rustup -n "__fish_seen_subcommand_from active-toolchain" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from active-toolchain" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from home" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from home" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from profile" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from profile" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from keys" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from keys" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from help" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from help" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from install" -l profile -r -f -a "minimal default complete" +complete -c rustup -n "__fish_seen_subcommand_from install" -l no-self-update -d 'Don\'t perform self-update when running the `rustup install` command' +complete -c rustup -n "__fish_seen_subcommand_from install" -l force -d 'Force an update, even if some components are missing' +complete -c rustup -n "__fish_seen_subcommand_from install" -l force-non-host -d 'Install toolchains that require an emulator. See https://github.com/rust-lang/rustup/wiki/Non-host-toolchains' +complete -c rustup -n "__fish_seen_subcommand_from install" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from install" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from uninstall" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from uninstall" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from update" -l no-self-update -d 'Don\'t perform self update when running the `rustup update` command' +complete -c rustup -n "__fish_seen_subcommand_from update" -l force -d 'Force an update, even if some components are missing' +complete -c rustup -n "__fish_seen_subcommand_from update" -l force-non-host -d 'Install toolchains that require an emulator. See https://github.com/rust-lang/rustup/wiki/Non-host-toolchains' +complete -c rustup -n "__fish_seen_subcommand_from update" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from update" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from check" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from check" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from default" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from default" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from toolchain" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from toolchain" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from toolchain" -f -a "list" -d 'List installed toolchains' +complete -c rustup -n "__fish_seen_subcommand_from toolchain" -f -a "install" -d 'Install or update a given toolchain' +complete -c rustup -n "__fish_seen_subcommand_from toolchain" -f -a "uninstall" -d 'Uninstall a toolchain' +complete -c rustup -n "__fish_seen_subcommand_from toolchain" -f -a "link" -d 'Create a custom toolchain by symlinking to a directory' +complete -c rustup -n "__fish_seen_subcommand_from toolchain" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)' +complete -c rustup -n "__fish_seen_subcommand_from list" -s v -l verbose -d 'Enable verbose output with toolchain information' +complete -c rustup -n "__fish_seen_subcommand_from list" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from list" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from install" -l profile -r -f -a "minimal default complete" +complete -c rustup -n "__fish_seen_subcommand_from install" -s c -l component -d 'Add specific components on installation' +complete -c rustup -n "__fish_seen_subcommand_from install" -s t -l target -d 'Add specific targets on installation' +complete -c rustup -n "__fish_seen_subcommand_from install" -l no-self-update -d 'Don\'t perform self update when running the`rustup toolchain install` command' +complete -c rustup -n "__fish_seen_subcommand_from install" -l force -d 'Force an update, even if some components are missing' +complete -c rustup -n "__fish_seen_subcommand_from install" -l allow-downgrade -d 'Allow rustup to downgrade the toolchain to satisfy your component choice' +complete -c rustup -n "__fish_seen_subcommand_from install" -l force-non-host -d 'Install toolchains that require an emulator. See https://github.com/rust-lang/rustup/wiki/Non-host-toolchains' +complete -c rustup -n "__fish_seen_subcommand_from install" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from install" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from uninstall" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from uninstall" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from link" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from link" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from help" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from help" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from target" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from target" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from target" -f -a "list" -d 'List installed and available targets' +complete -c rustup -n "__fish_seen_subcommand_from target" -f -a "add" -d 'Add a target to a Rust toolchain' +complete -c rustup -n "__fish_seen_subcommand_from target" -f -a "remove" -d 'Remove a target from a Rust toolchain' +complete -c rustup -n "__fish_seen_subcommand_from target" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)' +complete -c rustup -n "__fish_seen_subcommand_from list" -l toolchain -d 'Toolchain name, such as \'stable\', \'nightly\', or \'1.8.0\'. For more information see `rustup help toolchain`' +complete -c rustup -n "__fish_seen_subcommand_from list" -l installed -d 'List only installed targets' +complete -c rustup -n "__fish_seen_subcommand_from list" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from list" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from add" -l toolchain -d 'Toolchain name, such as \'stable\', \'nightly\', or \'1.8.0\'. For more information see `rustup help toolchain`' +complete -c rustup -n "__fish_seen_subcommand_from add" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from add" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from remove" -l toolchain -d 'Toolchain name, such as \'stable\', \'nightly\', or \'1.8.0\'. For more information see `rustup help toolchain`' +complete -c rustup -n "__fish_seen_subcommand_from remove" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from remove" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from help" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from help" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from component" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from component" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from component" -f -a "list" -d 'List installed and available components' +complete -c rustup -n "__fish_seen_subcommand_from component" -f -a "add" -d 'Add a component to a Rust toolchain' +complete -c rustup -n "__fish_seen_subcommand_from component" -f -a "remove" -d 'Remove a component from a Rust toolchain' +complete -c rustup -n "__fish_seen_subcommand_from component" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)' +complete -c rustup -n "__fish_seen_subcommand_from list" -l toolchain -d 'Toolchain name, such as \'stable\', \'nightly\', or \'1.8.0\'. For more information see `rustup help toolchain`' +complete -c rustup -n "__fish_seen_subcommand_from list" -l installed -d 'List only installed components' +complete -c rustup -n "__fish_seen_subcommand_from list" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from list" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from add" -l toolchain -d 'Toolchain name, such as \'stable\', \'nightly\', or \'1.8.0\'. For more information see `rustup help toolchain`' +complete -c rustup -n "__fish_seen_subcommand_from add" -l target +complete -c rustup -n "__fish_seen_subcommand_from add" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from add" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from remove" -l toolchain -d 'Toolchain name, such as \'stable\', \'nightly\', or \'1.8.0\'. For more information see `rustup help toolchain`' +complete -c rustup -n "__fish_seen_subcommand_from remove" -l target +complete -c rustup -n "__fish_seen_subcommand_from remove" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from remove" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from help" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from help" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from override" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from override" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from override" -f -a "list" -d 'List directory toolchain overrides' +complete -c rustup -n "__fish_seen_subcommand_from override" -f -a "set" -d 'Set the override toolchain for a directory' +complete -c rustup -n "__fish_seen_subcommand_from override" -f -a "unset" -d 'Remove the override toolchain for a directory' +complete -c rustup -n "__fish_seen_subcommand_from override" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)' +complete -c rustup -n "__fish_seen_subcommand_from list" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from list" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from set" -l path -d 'Path to the directory' +complete -c rustup -n "__fish_seen_subcommand_from set" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from set" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from unset" -l path -d 'Path to the directory' +complete -c rustup -n "__fish_seen_subcommand_from unset" -l nonexistent -d 'Remove override toolchain for all nonexistent directories' +complete -c rustup -n "__fish_seen_subcommand_from unset" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from unset" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from help" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from help" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from run" -l install -d 'Install the requested toolchain if needed' +complete -c rustup -n "__fish_seen_subcommand_from run" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from run" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from which" -l toolchain -d 'Toolchain name, such as \'stable\', \'nightly\', or \'1.8.0\'. For more information see `rustup help toolchain`' +complete -c rustup -n "__fish_seen_subcommand_from which" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from which" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from doc" -l toolchain -d 'Toolchain name, such as \'stable\', \'nightly\', or \'1.8.0\'. For more information see `rustup help toolchain`' +complete -c rustup -n "__fish_seen_subcommand_from doc" -l path -d 'Only print the path to the documentation' +complete -c rustup -n "__fish_seen_subcommand_from doc" -l alloc -d 'The Rust core allocation and collections library' +complete -c rustup -n "__fish_seen_subcommand_from doc" -l book -d 'The Rust Programming Language book' +complete -c rustup -n "__fish_seen_subcommand_from doc" -l cargo -d 'The Cargo Book' +complete -c rustup -n "__fish_seen_subcommand_from doc" -l core -d 'The Rust Core Library' +complete -c rustup -n "__fish_seen_subcommand_from doc" -l edition-guide -d 'The Rust Edition Guide' +complete -c rustup -n "__fish_seen_subcommand_from doc" -l nomicon -d 'The Dark Arts of Advanced and Unsafe Rust Programming' +complete -c rustup -n "__fish_seen_subcommand_from doc" -l proc_macro -d 'A support library for macro authors when defining new macros' +complete -c rustup -n "__fish_seen_subcommand_from doc" -l reference -d 'The Rust Reference' +complete -c rustup -n "__fish_seen_subcommand_from doc" -l rust-by-example -d 'A collection of runnable examples that illustrate various Rust concepts and standard libraries' +complete -c rustup -n "__fish_seen_subcommand_from doc" -l rustc -d 'The compiler for the Rust programming language' +complete -c rustup -n "__fish_seen_subcommand_from doc" -l rustdoc -d 'Generate documentation for Rust projects' +complete -c rustup -n "__fish_seen_subcommand_from doc" -l std -d 'Standard library API documentation' +complete -c rustup -n "__fish_seen_subcommand_from doc" -l test -d 'Support code for rustc\'s built in unit-test and micro-benchmarking framework' +complete -c rustup -n "__fish_seen_subcommand_from doc" -l unstable-book -d 'The Unstable Book' +complete -c rustup -n "__fish_seen_subcommand_from doc" -l embedded-book -d 'The Embedded Rust Book' +complete -c rustup -n "__fish_seen_subcommand_from doc" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from doc" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from man" -l toolchain -d 'Toolchain name, such as \'stable\', \'nightly\', or \'1.8.0\'. For more information see `rustup help toolchain`' +complete -c rustup -n "__fish_seen_subcommand_from man" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from man" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from self" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from self" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from self" -f -a "update" -d 'Download and install updates to rustup' +complete -c rustup -n "__fish_seen_subcommand_from self" -f -a "uninstall" -d 'Uninstall rustup.' +complete -c rustup -n "__fish_seen_subcommand_from self" -f -a "upgrade-data" -d 'Upgrade the internal data format.' +complete -c rustup -n "__fish_seen_subcommand_from self" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)' +complete -c rustup -n "__fish_seen_subcommand_from update" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from update" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from uninstall" -s y +complete -c rustup -n "__fish_seen_subcommand_from uninstall" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from uninstall" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from upgrade-data" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from upgrade-data" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from help" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from help" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from set" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from set" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from set" -f -a "default-host" -d 'The triple used to identify toolchains when not specified' +complete -c rustup -n "__fish_seen_subcommand_from set" -f -a "profile" -d 'The default components installed' +complete -c rustup -n "__fish_seen_subcommand_from set" -f -a "auto-self-update" -d 'The rustup auto self update mode' +complete -c rustup -n "__fish_seen_subcommand_from set" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)' +complete -c rustup -n "__fish_seen_subcommand_from default-host" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from default-host" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from profile" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from profile" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from auto-self-update" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from auto-self-update" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from help" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from help" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from completions" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from completions" -s V -l version -d 'Prints version information' +complete -c rustup -n "__fish_seen_subcommand_from help" -s h -l help -d 'Prints help information' +complete -c rustup -n "__fish_seen_subcommand_from help" -s V -l version -d 'Prints version information' diff --git a/.config/fish/conf.d/git.fish b/.config/fish/conf.d/git.fish new file mode 100644 index 0000000..45c9f3a --- /dev/null +++ b/.config/fish/conf.d/git.fish @@ -0,0 +1,10 @@ +# Remove legacy hooks to prevent errors when upgrading. +# This can be removed when we cleanup other universal abbr code. +functions -e _git_install _git_update _git_uninstall + +# fisher initialization, protected as omf also tries to run it. +set -q fisher_path; or set -l fisher_path $__fish_config_dir +if test -f $fisher_path/functions/__git.init.fish + source $fisher_path/functions/__git.init.fish + __git.init +end diff --git a/.config/fish/conf.d/nvm.fish b/.config/fish/conf.d/nvm.fish new file mode 100644 index 0000000..e060f2f --- /dev/null +++ b/.config/fish/conf.d/nvm.fish @@ -0,0 +1,28 @@ +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 diff --git a/.config/fish/conf.d/sway.fish b/.config/fish/conf.d/sway.fish new file mode 100644 index 0000000..e904e75 --- /dev/null +++ b/.config/fish/conf.d/sway.fish @@ -0,0 +1,5 @@ +if status --is-login + if test (tty) = /dev/tty1 + exec sway + end +end diff --git a/.config/fish/conf.d/z.fish b/.config/fish/conf.d/z.fish new file mode 100644 index 0000000..59c960f --- /dev/null +++ b/.config/fish/conf.d/z.fish @@ -0,0 +1,63 @@ +if test -z "$Z_DATA" + if test -z "$XDG_DATA_HOME" + set -U Z_DATA_DIR "$HOME/.local/share/z" + else + set -U Z_DATA_DIR "$XDG_DATA_HOME/z" + end + set -U Z_DATA "$Z_DATA_DIR/data" +end + +if test ! -e "$Z_DATA" + if test ! -e "$Z_DATA_DIR" + mkdir -p -m 700 "$Z_DATA_DIR" + end + touch "$Z_DATA" +end + +if test -z "$Z_CMD" + set -U Z_CMD z +end + +set -U ZO_CMD "$Z_CMD"o + +if test ! -z $Z_CMD + function $Z_CMD -d "jump around" + __z $argv + end +end + +if test ! -z $ZO_CMD + function $ZO_CMD -d "open target dir" + __z -d $argv + end +end + +if not set -q Z_EXCLUDE + set -U Z_EXCLUDE "^$HOME\$" +else if contains $HOME $Z_EXCLUDE + # Workaround: migrate old default values to a regex (see #90). + set Z_EXCLUDE (string replace -r -- "^$HOME\$" '^'$HOME'$$' $Z_EXCLUDE) +end + +# Setup completions once first +__z_complete + +function __z_on_variable_pwd --on-variable PWD + __z_add +end + +function __z_uninstall --on-event z_uninstall + functions -e __z_on_variable_pwd + functions -e $Z_CMD + functions -e $ZO_CMD + + if test ! -z "$Z_DATA" + printf "To completely erase z's data, remove:\n" >/dev/stderr + printf "%s\n" "$Z_DATA" >/dev/stderr + end + + set -e Z_CMD + set -e ZO_CMD + set -e Z_DATA + set -e Z_EXCLUDE +end diff --git a/.config/fish/config.fish b/.config/fish/config.fish new file mode 100644 index 0000000..94f00bf --- /dev/null +++ b/.config/fish/config.fish @@ -0,0 +1,5 @@ +set fish_greeting +if status is-interactive + # Commands to run in interactive sessions can go here +end + diff --git a/.config/fish/fish_plugins b/.config/fish/fish_plugins new file mode 100644 index 0000000..db4d0f1 --- /dev/null +++ b/.config/fish/fish_plugins @@ -0,0 +1,4 @@ +jorgebucaran/fisher +jhillyerd/plugin-git +jethrokuan/z +jorgebucaran/nvm.fish diff --git a/.config/fish/fish_variables b/.config/fish/fish_variables new file mode 100644 index 0000000..f94f59a --- /dev/null +++ b/.config/fish/fish_variables @@ -0,0 +1,56 @@ +# This file contains fish universal variable definitions. +# VERSION: 3.0 +SETUVAR --export ELECTRON_OZONE_PLATFORM_HINT:auto +SETUVAR --export --path PATH:/usr/local/bin\x1e/usr/local/sbin\x1e/usr/bin\x1e/usr/sbin\x1e/usr/local/go/bin +SETUVAR ZO_CMD:zo +SETUVAR Z_CMD:z +SETUVAR Z_DATA:/home/foton/\x2elocal/share/z/data +SETUVAR Z_DATA_DIR:/home/foton/\x2elocal/share/z +SETUVAR Z_EXCLUDE:\x5e/home/foton\x24 +SETUVAR __fish_initialized:3400 +SETUVAR _fisher_jethrokuan_2F_z_files:\x7e/\x2econfig/fish/functions/__z\x2efish\x1e\x7e/\x2econfig/fish/functions/__z_add\x2efish\x1e\x7e/\x2econfig/fish/functions/__z_clean\x2efish\x1e\x7e/\x2econfig/fish/functions/__z_complete\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/z\x2efish +SETUVAR _fisher_jhillyerd_2F_plugin_2D_git_files:\x7e/\x2econfig/fish/functions/__git\x2ebranch_has_wip\x2efish\x1e\x7e/\x2econfig/fish/functions/__git\x2ecurrent_branch\x2efish\x1e\x7e/\x2econfig/fish/functions/__git\x2edefault_branch\x2efish\x1e\x7e/\x2econfig/fish/functions/__git\x2edestroy\x2efish\x1e\x7e/\x2econfig/fish/functions/__git\x2einit\x2efish\x1e\x7e/\x2econfig/fish/functions/gbage\x2efish\x1e\x7e/\x2econfig/fish/functions/gbda\x2efish\x1e\x7e/\x2econfig/fish/functions/gdv\x2efish\x1e\x7e/\x2econfig/fish/functions/gignored\x2efish\x1e\x7e/\x2econfig/fish/functions/glp\x2efish\x1e\x7e/\x2econfig/fish/functions/grename\x2efish\x1e\x7e/\x2econfig/fish/functions/grt\x2efish\x1e\x7e/\x2econfig/fish/functions/gtest\x2efish\x1e\x7e/\x2econfig/fish/functions/gtl\x2efish\x1e\x7e/\x2econfig/fish/functions/gunwip\x2efish\x1e\x7e/\x2econfig/fish/functions/gwip\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/git\x2efish +SETUVAR _fisher_jorgebucaran_2F_fisher_files:\x7e/\x2econfig/fish/functions/fisher\x2efish\x1e\x7e/\x2econfig/fish/completions/fisher\x2efish +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/fisher\x1ejhillyerd/plugin\x2dgit\x1ejethrokuan/z\x1ejorgebucaran/nvm\x2efish +SETUVAR _fisher_upgraded_to_4_4:\x1d +SETUVAR fish_color_autosuggestion:4c566a +SETUVAR fish_color_cancel:\x2d\x2dreverse +SETUVAR fish_color_command:81a1c1 +SETUVAR fish_color_comment:434c5e +SETUVAR fish_color_cwd:green +SETUVAR fish_color_cwd_root:red +SETUVAR fish_color_end:88c0d0 +SETUVAR fish_color_error:ebcb8b +SETUVAR fish_color_escape:00a6b2 +SETUVAR fish_color_history_current:\x2d\x2dbold +SETUVAR fish_color_host:normal +SETUVAR fish_color_host_remote:\x1d +SETUVAR fish_color_keyword:\x1d +SETUVAR fish_color_match:\x2d\x2dbackground\x3dbrblue +SETUVAR fish_color_normal:normal +SETUVAR fish_color_operator:00a6b2 +SETUVAR fish_color_option:\x1d +SETUVAR fish_color_param:eceff4 +SETUVAR fish_color_quote:a3be8c +SETUVAR fish_color_redirection:b48ead +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_key_bindings:fish_default_key_bindings +SETUVAR fish_pager_color_background:\x1d +SETUVAR fish_pager_color_completion:normal +SETUVAR fish_pager_color_description:B3A06D +SETUVAR fish_pager_color_prefix:normal\x1e\x2d\x2dbold\x1e\x2d\x2dunderline +SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan +SETUVAR fish_pager_color_secondary_background:\x1d +SETUVAR fish_pager_color_secondary_completion:\x1d +SETUVAR fish_pager_color_secondary_description:\x1d +SETUVAR fish_pager_color_secondary_prefix:\x1d +SETUVAR fish_pager_color_selected_background:\x2d\x2dbackground\x3dbrblack +SETUVAR fish_pager_color_selected_completion:\x1d +SETUVAR fish_pager_color_selected_description:\x1d +SETUVAR fish_pager_color_selected_prefix:\x1d +SETUVAR fish_user_paths:/home/foton/\x2ebin\x1e/opt/Obsidian\x1e/home/foton/go/bin\x1e/home/foton/code/dart\x2dsdk/bin\x1e/home/greg/\x2elocal/bin\x1e/home/greg/\x2ebin\x1e/home/greg/\x2ecargo/bin\x1e/home/greg/go/bin\x1e/usr/local/go/bin diff --git a/.config/fish/functions/__git.branch_has_wip.fish b/.config/fish/functions/__git.branch_has_wip.fish new file mode 100644 index 0000000..60dc37f --- /dev/null +++ b/.config/fish/functions/__git.branch_has_wip.fish @@ -0,0 +1,3 @@ +function __git.branch_has_wip -d "Returns 0 if branch has --wip--, otherwise 1" + git log -n 1 2>/dev/null | grep -qc "\-\-wip\-\-" +end diff --git a/.config/fish/functions/__git.current_branch.fish b/.config/fish/functions/__git.current_branch.fish new file mode 100644 index 0000000..34f5324 --- /dev/null +++ b/.config/fish/functions/__git.current_branch.fish @@ -0,0 +1,6 @@ +function __git.current_branch -d "Output git's current branch name" + begin + git symbolic-ref HEAD; or \ + git rev-parse --short HEAD; or return + end 2>/dev/null | sed -e 's|^refs/heads/||' +end diff --git a/.config/fish/functions/__git.default_branch.fish b/.config/fish/functions/__git.default_branch.fish new file mode 100644 index 0000000..856a3b0 --- /dev/null +++ b/.config/fish/functions/__git.default_branch.fish @@ -0,0 +1,11 @@ +function __git.default_branch -d "Use init.defaultBranch if it's set and exists, otherwise use main if it exists. Falls back to master" + command git rev-parse --git-dir &>/dev/null; or return + if set -l default_branch (command git config --get init.defaultBranch) + and command git show-ref -q --verify refs/heads/{$default_branch} + echo $default_branch + else if command git show-ref -q --verify refs/heads/main + echo main + else + echo master + end +end diff --git a/.config/fish/functions/__git.destroy.fish b/.config/fish/functions/__git.destroy.fish new file mode 100644 index 0000000..421e19b --- /dev/null +++ b/.config/fish/functions/__git.destroy.fish @@ -0,0 +1,7 @@ +function __git.destroy + for ab in $__git_plugin_abbreviations + abbr -e $ab + end + set -Ue __git_plugin_abbreviations + set -Ue __git_plugin_initialized +end diff --git a/.config/fish/functions/__git.init.fish b/.config/fish/functions/__git.init.fish new file mode 100644 index 0000000..a9dc8e2 --- /dev/null +++ b/.config/fish/functions/__git.init.fish @@ -0,0 +1,200 @@ +function __git.init + function __git.create_abbr -d "Create Git plugin abbreviation" + set -l name $argv[1] + set -l body $argv[2..-1] + + # TODO: global scope abbr will be default in fish 3.6.0 + abbr -a -g $name $body + end + + # Provide a smooth transition from universal to global abbreviations by + # deleting the old univeral ones. Can be removed after fish 3.6 is in + # wide-spread use, i.e. 2024. __git.destroy should also be removed + # at the same time. + if set -q __git_plugin_initialized + __git.destroy + end + + # git abbreviations + __git.create_abbr g git + __git.create_abbr ga git add + __git.create_abbr gaa git add --all + __git.create_abbr gau git add --update + __git.create_abbr gapa git add --patch + __git.create_abbr gap git apply + __git.create_abbr gb git branch -vv + __git.create_abbr gba git branch -a -v + __git.create_abbr gban git branch -a -v --no-merged + __git.create_abbr gbd git branch -d + __git.create_abbr gbD git branch -D + __git.create_abbr ggsup git branch --set-upstream-to=origin/\(__git.current_branch\) + __git.create_abbr gbl git blame -b -w + __git.create_abbr gbs git bisect + __git.create_abbr gbsb git bisect bad + __git.create_abbr gbsg git bisect good + __git.create_abbr gbsr git bisect reset + __git.create_abbr gbss git bisect start + __git.create_abbr gc git commit -v + __git.create_abbr gc! git commit -v --amend + __git.create_abbr gcn! git commit -v --no-edit --amend + __git.create_abbr gca git commit -v -a + __git.create_abbr gca! git commit -v -a --amend + __git.create_abbr gcan! git commit -v -a --no-edit --amend + __git.create_abbr gcv git commit -v --no-verify + __git.create_abbr gcav git commit -a -v --no-verify + __git.create_abbr gcav! git commit -a -v --no-verify --amend + __git.create_abbr gcm git commit -m + __git.create_abbr gcam git commit -a -m + __git.create_abbr gcs git commit -S + __git.create_abbr gscam git commit -S -a -m + __git.create_abbr gcfx git commit --fixup + __git.create_abbr gcf git config --list + __git.create_abbr gcl git clone + __git.create_abbr gclean git clean -di + __git.create_abbr gclean! git clean -dfx + __git.create_abbr gclean!! "git reset --hard; and git clean -dfx" + __git.create_abbr gcount git shortlog -sn + __git.create_abbr gcp git cherry-pick + __git.create_abbr gcpa git cherry-pick --abort + __git.create_abbr gcpc git cherry-pick --continue + __git.create_abbr gd git diff + __git.create_abbr gdca git diff --cached + __git.create_abbr gds git diff --stat + __git.create_abbr gdsc git diff --stat --cached + __git.create_abbr gdt git diff-tree --no-commit-id --name-only -r + __git.create_abbr gdw git diff --word-diff + __git.create_abbr gdwc git diff --word-diff --cached + __git.create_abbr gdto git difftool + __git.create_abbr gignore git update-index --assume-unchanged + __git.create_abbr gf git fetch + __git.create_abbr gfa git fetch --all --prune + __git.create_abbr gfm "git fetch origin (__git.default_branch) --prune; and git merge FETCH_HEAD" + __git.create_abbr gfo git fetch origin + __git.create_abbr gl git pull + __git.create_abbr ggl git pull origin \(__git.current_branch\) + __git.create_abbr gll git pull origin + __git.create_abbr glr git pull --rebase + __git.create_abbr glg git log --stat + __git.create_abbr glgg git log --graph + __git.create_abbr glgga git log --graph --decorate --all + __git.create_abbr glo git log --oneline --decorate --color + __git.create_abbr glog git log --oneline --decorate --color --graph + __git.create_abbr gloga git log --oneline --decorate --color --graph --all + __git.create_abbr glom git log --oneline --decorate --color \(__git.default_branch\).. + __git.create_abbr glod git log --oneline --decorate --color develop.. + __git.create_abbr gloo "git log --pretty=format:'%C(yellow)%h %Cred%ad %Cblue%an%Cgreen%d %Creset%s' --date=short" + __git.create_abbr gm git merge + __git.create_abbr gmt git mergetool --no-prompt + __git.create_abbr gmom git merge origin/\(__git.default_branch\) + __git.create_abbr gp git push + __git.create_abbr gp! git push --force-with-lease + __git.create_abbr gpo git push origin + __git.create_abbr gpo! git push --force-with-lease origin + __git.create_abbr gpv git push --no-verify + __git.create_abbr gpv! git push --no-verify --force-with-lease + __git.create_abbr ggp git push origin \(__git.current_branch\) + __git.create_abbr ggp! git push origin \(__git.current_branch\) --force-with-lease + __git.create_abbr gpu git push origin \(__git.current_branch\) --set-upstream + __git.create_abbr gpoat "git push origin --all; and git push origin --tags" + __git.create_abbr ggpnp "git pull origin (__git.current_branch); and git push origin (__git.current_branch)" + __git.create_abbr gr git remote -vv + __git.create_abbr gra git remote add + __git.create_abbr grb git rebase + __git.create_abbr grba git rebase --abort + __git.create_abbr grbc git rebase --continue + __git.create_abbr grbi git rebase --interactive + __git.create_abbr grbm git rebase \(__git.default_branch\) + __git.create_abbr grbmi git rebase \(__git.default_branch\) --interactive + __git.create_abbr grbmia git rebase \(__git.default_branch\) --interactive --autosquash + __git.create_abbr grbom "git fetch origin (__git.default_branch); and git rebase FETCH_HEAD" + __git.create_abbr grbomi "git fetch origin (__git.default_branch); and git rebase FETCH_HEAD --interactive" + __git.create_abbr grbomia "git fetch origin (__git.default_branch); and git rebase FETCH_HEAD --interactive --autosquash" + __git.create_abbr grbd git rebase develop + __git.create_abbr grbdi git rebase develop --interactive + __git.create_abbr grbdia git rebase develop --interactive --autosquash + __git.create_abbr grbs git rebase --skip + __git.create_abbr ggu git pull --rebase origin \(__git.current_branch\) + __git.create_abbr grev git revert + __git.create_abbr grh git reset + __git.create_abbr grhh git reset --hard + __git.create_abbr grhpa git reset --patch + __git.create_abbr grm git rm + __git.create_abbr grmc git rm --cached + __git.create_abbr grmv git remote rename + __git.create_abbr grpo git remote prune origin + __git.create_abbr grrm git remote remove + __git.create_abbr grs git restore + __git.create_abbr grset git remote set-url + __git.create_abbr grss git restore --source + __git.create_abbr grst git restore --staged + __git.create_abbr grup git remote update + __git.create_abbr grv git remote -v + __git.create_abbr gsh git show + __git.create_abbr gsd git svn dcommit + __git.create_abbr gsr git svn rebase + __git.create_abbr gsb git status -sb + __git.create_abbr gss git status -s + __git.create_abbr gst git status + __git.create_abbr gsta git stash + __git.create_abbr gstd git stash drop + __git.create_abbr gstl git stash list + __git.create_abbr gstp git stash pop + __git.create_abbr gsts git stash show --text + __git.create_abbr gsu git submodule update + __git.create_abbr gsur git submodule update --recursive + __git.create_abbr gsuri git submodule update --recursive --init + __git.create_abbr gts git tag -s + __git.create_abbr gtv git tag | sort -V + __git.create_abbr gsw git switch + __git.create_abbr gswc git switch --create + __git.create_abbr gunignore git update-index --no-assume-unchanged + __git.create_abbr gup git pull --rebase + __git.create_abbr gupv git pull --rebase -v + __git.create_abbr gupa git pull --rebase --autostash + __git.create_abbr gupav git pull --rebase --autostash -v + __git.create_abbr gwch git whatchanged -p --abbrev-commit --pretty=medium + + # git checkout abbreviations + __git.create_abbr gco git checkout + __git.create_abbr gcb git checkout -b + __git.create_abbr gcod git checkout develop + __git.create_abbr gcom git checkout \(__git.default_branch\) + + # git flow abbreviations + __git.create_abbr gfb git flow bugfix + __git.create_abbr gff git flow feature + __git.create_abbr gfr git flow release + __git.create_abbr gfh git flow hotfix + __git.create_abbr gfs git flow support + + __git.create_abbr gfbs git flow bugfix start + __git.create_abbr gffs git flow feature start + __git.create_abbr gfrs git flow release start + __git.create_abbr gfhs git flow hotfix start + __git.create_abbr gfss git flow support start + + __git.create_abbr gfbt git flow bugfix track + __git.create_abbr gfft git flow feature track + __git.create_abbr gfrt git flow release track + __git.create_abbr gfht git flow hotfix track + __git.create_abbr gfst git flow support track + + __git.create_abbr gfp git flow publish + + # git worktree abbreviations + __git.create_abbr gwt git worktree + __git.create_abbr gwta git worktree add + __git.create_abbr gwtls git worktree list + __git.create_abbr gwtlo git worktree lock + __git.create_abbr gwtmv git worktree move + __git.create_abbr gwtpr git worktree prune + __git.create_abbr gwtrm git worktree remove + __git.create_abbr gwtulo git worktree unlock + + # GitLab push options + __git.create_abbr gmr git push origin \(__git.current_branch\) --set-upstream -o merge_request.create + __git.create_abbr gmwps git push origin \(__git.current_branch\) --set-upstream -o merge_request.create -o merge_request.merge_when_pipeline_succeeds + + # Cleanup declared functions + functions -e __git.create_abbr +end diff --git a/.config/fish/functions/__z.fish b/.config/fish/functions/__z.fish new file mode 100644 index 0000000..f72ff0e --- /dev/null +++ b/.config/fish/functions/__z.fish @@ -0,0 +1,174 @@ +function __z -d "Jump to a recent directory." + function __print_help -d "Print z help." + printf "Usage: $Z_CMD [-celrth] string1 string2...\n\n" + printf " -c --clean Removes directories that no longer exist from $Z_DATA\n" + printf " -d --dir Opens matching directory using system file manager.\n" + printf " -e --echo Prints best match, no cd\n" + printf " -l --list List matches and scores, no cd\n" + printf " -p --purge Delete all entries from $Z_DATA\n" + printf " -r --rank Search by rank\n" + printf " -t --recent Search by recency\n" + printf " -x --delete Removes the current directory from $Z_DATA\n" + printf " -h --help Print this help\n\n" + end + function __z_legacy_escape_regex + # taken from escape_string_pcre2 in fish + # used to provide compatibility with fish 2 + for c in (string split '' $argv) + if contains $c (string split '' '.^$*+()?[{}\\|-]') + printf \\ + end + printf '%s' $c + end + end + + set -l options h/help c/clean e/echo l/list p/purge r/rank t/recent d/directory x/delete + + argparse $options -- $argv + + if set -q _flag_help + __print_help + return 0 + else if set -q _flag_clean + __z_clean + printf "%s cleaned!\n" $Z_DATA + return 0 + else if set -q _flag_purge + echo >$Z_DATA + printf "%s purged!\n" $Z_DATA + return 0 + else if set -q _flag_delete + sed -i -e "\:^$PWD|.*:d" $Z_DATA + return 0 + end + + set -l typ + + if set -q _flag_rank + set typ rank + else if set -q _flag_recent + set typ recent + end + + set -l z_script ' + function frecent(rank, time) { + dx = t-time + if( dx < 3600 ) return rank*4 + if( dx < 86400 ) return rank*2 + if( dx < 604800 ) return rank/2 + return rank/4 + } + + function output(matches, best_match, common) { + # list or return the desired directory + if( list ) { + cmd = "sort -nr" + for( x in matches ) { + if( matches[x] ) { + printf "%-10s %s\n", matches[x], x | cmd + } + } + } else { + if( common ) best_match = common + print best_match + } + } + + function common(matches) { + # find the common root of a list of matches, if it exists + for( x in matches ) { + if( matches[x] && (!short || length(x) < length(short)) ) { + short = x + } + } + if( short == "/" ) return + for( x in matches ) if( matches[x] && index(x, short) != 1 ) { + return + } + return short + } + + BEGIN { + hi_rank = ihi_rank = -9999999999 + } + { + if( typ == "rank" ) { + rank = $2 + } else if( typ == "recent" ) { + rank = $3 - t + } else rank = frecent($2, $3) + if( $1 ~ q ) { + matches[$1] = rank + } else if( tolower($1) ~ tolower(q) ) imatches[$1] = rank + if( matches[$1] && matches[$1] > hi_rank ) { + best_match = $1 + hi_rank = matches[$1] + } else if( imatches[$1] && imatches[$1] > ihi_rank ) { + ibest_match = $1 + ihi_rank = imatches[$1] + } + } + + END { + # prefer case sensitive + if( best_match ) { + output(matches, best_match, common(matches)) + } else if( ibest_match ) { + output(imatches, ibest_match, common(imatches)) + } + } + ' + + set -l qs + for arg in $argv + set -l escaped $arg + if string escape --style=regex '' >/dev/null 2>&1 # use builtin escape if available + set escaped (string escape --style=regex $escaped) + else + set escaped (__z_legacy_escape_regex $escaped) + end + # Need to escape twice, see https://www.math.utah.edu/docs/info/gawk_5.html#SEC32 + set escaped (string replace --all \\ \\\\ $escaped) + set qs $qs $escaped + end + set -l q (string join '.*' $qs) + + if set -q _flag_list + # Handle list separately as it can print common path information to stderr + # which cannot be captured from a subcommand. + command awk -v t=(date +%s) -v list="list" -v typ="$typ" -v q="$q" -F "|" $z_script "$Z_DATA" + return + end + + set target (command awk -v t=(date +%s) -v typ="$typ" -v q="$q" -F "|" $z_script "$Z_DATA") + + if test "$status" -gt 0 + return + end + + if test -z "$target" + printf "'%s' did not match any results\n" "$argv" + return 1 + end + + if set -q _flag_echo + printf "%s\n" "$target" + else if set -q _flag_directory + if test -n "$ZO_METHOD" + type -q "$ZO_METHOD"; and "$ZO_METHOD" "$target"; and return $status + echo "Cannot open with ZO_METHOD set to $ZO_METHOD"; and return 1 + else if test "$OS" = Windows_NT + # Be careful, in msys2, explorer always return 1 + type -q explorer; and explorer "$target" + return 0 + echo "Cannot open file explorer" + return 1 + else + type -q xdg-open; and xdg-open "$target"; and return $status + type -q open; and open "$target"; and return $status + echo "Not sure how to open file manager"; and return 1 + end + else + pushd "$target" + end +end diff --git a/.config/fish/functions/__z_add.fish b/.config/fish/functions/__z_add.fish new file mode 100644 index 0000000..20d5d7e --- /dev/null +++ b/.config/fish/functions/__z_add.fish @@ -0,0 +1,49 @@ +function __z_add -d "Add PATH to .z file" + test -n "$fish_private_mode"; and return 0 + + for i in $Z_EXCLUDE + if string match -r $i $PWD >/dev/null + return 0 #Path excluded + end + end + + set -l tmpfile (mktemp $Z_DATA.XXXXXX) + + if test -f $tmpfile + set -l path (string replace --all \\ \\\\ $PWD) + command awk -v path=$path -v now=(date +%s) -F "|" ' + BEGIN { + rank[path] = 1 + time[path] = now + } + $2 >= 1 { + if( $1 == path ) { + rank[$1] = $2 + 1 + time[$1] = now + } + else { + rank[$1] = $2 + time[$1] = $3 + } + count += $2 + } + END { + if( count > 1000 ) { + for( i in rank ) print i "|" 0.9*rank[i] "|" time[i] # aging + } + else for( i in rank ) print i "|" rank[i] "|" time[i] + } + ' $Z_DATA 2>/dev/null >$tmpfile + + if test ! -z "$Z_OWNER" + chown $Z_OWNER:(id -ng $Z_OWNER) $tmpfile + end + # + # Don't use redirection here as it can lead to a race condition where $Z_DATA is clobbered. + # Note: There is a still a possible race condition where an old version of $Z_DATA is + # read by one instance of Fish before another instance of Fish writes its copy. + # + command mv $tmpfile $Z_DATA + or command rm $tmpfile + end +end diff --git a/.config/fish/functions/__z_clean.fish b/.config/fish/functions/__z_clean.fish new file mode 100644 index 0000000..ae1721a --- /dev/null +++ b/.config/fish/functions/__z_clean.fish @@ -0,0 +1,11 @@ +function __z_clean -d "Clean up .z file to remove paths no longer valid" + set -l tmpfile (mktemp $Z_DATA.XXXXXX) + + if test -f $tmpfile + while read line + set -l path (string split '|' $line)[1] + test -d $path; and echo $line + end <$Z_DATA >$tmpfile + command mv -f $tmpfile $Z_DATA + end +end diff --git a/.config/fish/functions/__z_complete.fish b/.config/fish/functions/__z_complete.fish new file mode 100644 index 0000000..a626456 --- /dev/null +++ b/.config/fish/functions/__z_complete.fish @@ -0,0 +1,13 @@ +function __z_complete -d "add completions" + complete -c $Z_CMD -a "(__z -l | string replace -r '^\\S*\\s*' '')" -f -k + complete -c $ZO_CMD -a "(__z -l | string replace -r '^\\S*\\s*' '')" -f -k + + complete -c $Z_CMD -s c -l clean -d "Cleans out $Z_DATA" + complete -c $Z_CMD -s e -l echo -d "Prints best match, no cd" + complete -c $Z_CMD -s l -l list -d "List matches, no cd" + complete -c $Z_CMD -s p -l purge -d "Purges $Z_DATA" + complete -c $Z_CMD -s r -l rank -d "Searches by rank, cd" + complete -c $Z_CMD -s t -l recent -d "Searches by recency, cd" + complete -c $Z_CMD -s h -l help -d "Print help" + complete -c $Z_CMD -s x -l delete -d "Removes the current directory from $Z_DATA" +end diff --git a/.config/fish/functions/_nvm_index_update.fish b/.config/fish/functions/_nvm_index_update.fish new file mode 100644 index 0000000..c66753d --- /dev/null +++ b/.config/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/.config/fish/functions/_nvm_list.fish b/.config/fish/functions/_nvm_list.fish new file mode 100644 index 0000000..1623bb8 --- /dev/null +++ b/.config/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/.config/fish/functions/_nvm_version_activate.fish b/.config/fish/functions/_nvm_version_activate.fish new file mode 100644 index 0000000..f7dfef7 --- /dev/null +++ b/.config/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/.config/fish/functions/_nvm_version_deactivate.fish b/.config/fish/functions/_nvm_version_deactivate.fish new file mode 100644 index 0000000..24dd36e --- /dev/null +++ b/.config/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/.config/fish/functions/cfg.fish b/.config/fish/functions/cfg.fish new file mode 100644 index 0000000..d3b0fd7 --- /dev/null +++ b/.config/fish/functions/cfg.fish @@ -0,0 +1,4 @@ +function cfg --wraps='/usr/bin/git --git-dir=$HOME/.cfgstore/ --work-tree=$HOME' --description 'alias cfg=/usr/bin/git --git-dir=$HOME/.cfgstore/ --work-tree=$HOME' + /usr/bin/git --git-dir=$HOME/.cfgstore/ --work-tree=$HOME $argv + +end diff --git a/.config/fish/functions/fish_prompt.fish b/.config/fish/functions/fish_prompt.fish new file mode 100644 index 0000000..8b1d19c --- /dev/null +++ b/.config/fish/functions/fish_prompt.fish @@ -0,0 +1,90 @@ +function fish_prompt + set -l __last_command_exit_status $status + + if not set -q -g __fish_arrow_functions_defined + set -g __fish_arrow_functions_defined + function _git_branch_name + set -l branch (git symbolic-ref --quiet HEAD 2>/dev/null) + if set -q branch[1] + echo (string replace -r '^refs/heads/' '' $branch) + else + echo (git rev-parse --short HEAD 2>/dev/null) + end + end + + function _is_git_dirty + not command git diff-index --cached --quiet HEAD -- &>/dev/null + or not command git diff --no-ext-diff --quiet --exit-code &>/dev/null + end + + function _is_git_repo + type -q git + or return 1 + git rev-parse --git-dir >/dev/null 2>&1 + end + + function _hg_branch_name + echo (hg branch 2>/dev/null) + end + + function _is_hg_dirty + set -l stat (hg status -mard 2>/dev/null) + test -n "$stat" + end + + function _is_hg_repo + fish_print_hg_root >/dev/null + end + + function _repo_branch_name + _$argv[1]_branch_name + end + + function _is_repo_dirty + _is_$argv[1]_dirty + end + + function _repo_type + if _is_hg_repo + echo hg + return 0 + else if _is_git_repo + echo git + return 0 + end + return 1 + end + end + + set -l cyan (set_color -o cyan) + set -l yellow (set_color -o yellow) + set -l red (set_color -o red) + set -l green (set_color -o green) + set -l blue (set_color -o blue) + set -l normal (set_color normal) + + set -l arrow_color "$green" + if test $__last_command_exit_status != 0 + set arrow_color "$red" + end + + set -l arrow "$arrow_color➜ " + if fish_is_root_user + set arrow "$arrow_color# " + end + + set -l cwd $cyan(basename (prompt_pwd)) + + set -l repo_info + if set -l repo_type (_repo_type) + set -l repo_branch $red(_repo_branch_name $repo_type) + set repo_info "$blue $repo_type:($repo_branch$blue)" + + if _is_repo_dirty $repo_type + set -l dirty "$yellow ✗" + set repo_info "$repo_info$dirty" + end + end + + echo -n -s $arrow ' '$cwd $repo_info $normal ' ' +end diff --git a/.config/fish/functions/fisher.fish b/.config/fish/functions/fisher.fish new file mode 100644 index 0000000..b1513d3 --- /dev/null +++ b/.config/fish/functions/fisher.fish @@ -0,0 +1,240 @@ +function fisher --argument-names cmd --description "A plugin manager for Fish" + set --query fisher_path || set --local fisher_path $__fish_config_dir + set --local fisher_version 4.4.4 + set --local fish_plugins $__fish_config_dir/fish_plugins + + switch "$cmd" + case -v --version + echo "fisher, version $fisher_version" + case "" -h --help + echo "Usage: fisher install Install plugins" + echo " fisher remove Remove installed plugins" + echo " fisher update Update installed plugins" + echo " fisher update Update all installed plugins" + echo " fisher list [] List installed plugins matching regex" + echo "Options:" + echo " -v, --version Print version" + echo " -h, --help Print this help message" + echo "Variables:" + echo " \$fisher_path Plugin installation path. Default: $__fish_config_dir" | string replace --regex -- $HOME \~ + case ls list + string match --entire --regex -- "$argv[2]" $_fisher_plugins + case install update remove + isatty || read --local --null --array stdin && set --append argv $stdin + + set --local install_plugins + set --local update_plugins + set --local remove_plugins + set --local arg_plugins $argv[2..-1] + set --local old_plugins $_fisher_plugins + set --local new_plugins + + test -e $fish_plugins && set --local file_plugins (string match --regex -- '^[^\s]+$' <$fish_plugins) + + if ! set --query argv[2] + if test "$cmd" != update + echo "fisher: Not enough arguments for command: \"$cmd\"" >&2 && return 1 + else if ! set --query file_plugins + echo "fisher: \"$fish_plugins\" file not found: \"$cmd\"" >&2 && return 1 + end + set arg_plugins $file_plugins + end + + for plugin in $arg_plugins + set plugin (test -e "$plugin" && realpath $plugin || string lower -- $plugin) + contains -- "$plugin" $new_plugins || set --append new_plugins $plugin + end + + if set --query argv[2] + for plugin in $new_plugins + if contains -- "$plugin" $old_plugins + test "$cmd" = remove && + set --append remove_plugins $plugin || + set --append update_plugins $plugin + else if test "$cmd" = install + set --append install_plugins $plugin + else + echo "fisher: Plugin not installed: \"$plugin\"" >&2 && return 1 + end + end + else + for plugin in $new_plugins + contains -- "$plugin" $old_plugins && + set --append update_plugins $plugin || + set --append install_plugins $plugin + end + + for plugin in $old_plugins + contains -- "$plugin" $new_plugins || set --append remove_plugins $plugin + end + end + + set --local pid_list + set --local source_plugins + set --local fetch_plugins $update_plugins $install_plugins + set --local fish_path (status fish-path) + + echo (set_color --bold)fisher $cmd version $fisher_version(set_color normal) + + for plugin in $fetch_plugins + set --local source (command mktemp -d) + set --append source_plugins $source + + command mkdir -p $source/{completions,conf.d,themes,functions} + + $fish_path --command " + if test -e $plugin + command cp -Rf $plugin/* $source + else + set temp (command mktemp -d) + set repo (string split -- \@ $plugin) || set repo[2] HEAD + + if set path (string replace --regex -- '^(https://)?gitlab.com/' '' \$repo[1]) + set name (string split -- / \$path)[-1] + set url https://gitlab.com/\$path/-/archive/\$repo[2]/\$name-\$repo[2].tar.gz + else + set url https://api.github.com/repos/\$repo[1]/tarball/\$repo[2] + end + + echo Fetching (set_color --underline)\$url(set_color normal) + + if command curl -q --silent -L \$url | command tar -xzC \$temp -f - 2>/dev/null + command cp -Rf \$temp/*/* $source + else + echo fisher: Invalid plugin name or host unavailable: \\\"$plugin\\\" >&2 + command rm -rf $source + end + + command rm -rf \$temp + end + + set files $source/* && string match --quiet --regex -- .+\.fish\\\$ \$files + " & + + set --append pid_list (jobs --last --pid) + end + + wait $pid_list 2>/dev/null + + for plugin in $fetch_plugins + if set --local source $source_plugins[(contains --index -- "$plugin" $fetch_plugins)] && test ! -e $source + if set --local index (contains --index -- "$plugin" $install_plugins) + set --erase install_plugins[$index] + else + set --erase update_plugins[(contains --index -- "$plugin" $update_plugins)] + end + end + end + + for plugin in $update_plugins $remove_plugins + if set --local index (contains --index -- "$plugin" $_fisher_plugins) + set --local plugin_files_var _fisher_(string escape --style=var -- $plugin)_files + + if contains -- "$plugin" $remove_plugins + for name in (string replace --filter --regex -- '.+/conf\.d/([^/]+)\.fish$' '$1' $$plugin_files_var) + emit {$name}_uninstall + end + printf "%s\n" Removing\ (set_color red --bold)$plugin(set_color normal) " "$$plugin_files_var | string replace -- \~ ~ + set --erase _fisher_plugins[$index] + end + + command rm -rf (string replace -- \~ ~ $$plugin_files_var) + + functions --erase (string replace --filter --regex -- '.+/functions/([^/]+)\.fish$' '$1' $$plugin_files_var) + + for name in (string replace --filter --regex -- '.+/completions/([^/]+)\.fish$' '$1' $$plugin_files_var) + complete --erase --command $name + end + + set --erase $plugin_files_var + end + end + + if set --query update_plugins[1] || set --query install_plugins[1] + command mkdir -p $fisher_path/{functions,themes,conf.d,completions} + end + + for plugin in $update_plugins $install_plugins + set --local source $source_plugins[(contains --index -- "$plugin" $fetch_plugins)] + set --local files $source/{functions,themes,conf.d,completions}/* + + if set --local index (contains --index -- $plugin $install_plugins) + set --local user_files $fisher_path/{functions,themes,conf.d,completions}/* + set --local conflict_files + + for file in (string replace -- $source/ $fisher_path/ $files) + contains -- $file $user_files && set --append conflict_files $file + end + + if set --query conflict_files[1] && set --erase install_plugins[$index] + echo -s "fisher: Cannot install \"$plugin\": please remove or move conflicting files first:" \n" "$conflict_files >&2 + continue + end + end + + for file in (string replace -- $source/ "" $files) + command cp -RLf $source/$file $fisher_path/$file + end + + set --local plugin_files_var _fisher_(string escape --style=var -- $plugin)_files + + set --query files[1] && set --universal $plugin_files_var (string replace -- $source $fisher_path $files | string replace -- ~ \~) + + contains -- $plugin $_fisher_plugins || set --universal --append _fisher_plugins $plugin + contains -- $plugin $install_plugins && set --local event install || set --local event update + + printf "%s\n" Installing\ (set_color --bold)$plugin(set_color normal) " "$$plugin_files_var | string replace -- \~ ~ + + for file in (string match --regex -- '.+/[^/]+\.fish$' $$plugin_files_var | string replace -- \~ ~) + source $file + if set --local name (string replace --regex -- '.+conf\.d/([^/]+)\.fish$' '$1' $file) + emit {$name}_$event + end + end + end + + command rm -rf $source_plugins + + if set --query _fisher_plugins[1] + set --local commit_plugins + + for plugin in $file_plugins + contains -- (string lower -- $plugin) (string lower -- $_fisher_plugins) && set --append commit_plugins $plugin + end + + for plugin in $_fisher_plugins + contains -- (string lower -- $plugin) (string lower -- $commit_plugins) || set --append commit_plugins $plugin + end + + printf "%s\n" $commit_plugins >$fish_plugins + else + set --erase _fisher_plugins + command rm -f $fish_plugins + end + + set --local total (count $install_plugins) (count $update_plugins) (count $remove_plugins) + + test "$total" != "0 0 0" && echo (string join ", " ( + test $total[1] = 0 || echo "Installed $total[1]") ( + test $total[2] = 0 || echo "Updated $total[2]") ( + test $total[3] = 0 || echo "Removed $total[3]") + ) plugin/s + case \* + echo "fisher: Unknown command: \"$cmd\"" >&2 && return 1 + end +end + +if ! set --query _fisher_upgraded_to_4_4 + set --universal _fisher_upgraded_to_4_4 + if functions --query _fisher_list + set --query XDG_DATA_HOME[1] || set --local XDG_DATA_HOME ~/.local/share + command rm -rf $XDG_DATA_HOME/fisher + functions --erase _fisher_{list,plugin_parse} + fisher update >/dev/null 2>/dev/null + else + for var in (set --names | string match --entire --regex '^_fisher_.+_files$') + set $var (string replace -- ~ \~ $$var) + end + functions --erase _fisher_fish_postexec + end +end diff --git a/.config/fish/functions/gbage.fish b/.config/fish/functions/gbage.fish new file mode 100644 index 0000000..d1f107d --- /dev/null +++ b/.config/fish/functions/gbage.fish @@ -0,0 +1,5 @@ +function gbage -d "List local branches and display their age" + git for-each-ref --sort=committerdate refs/heads/ \ + --format="%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))" +end + diff --git a/.config/fish/functions/gbda.fish b/.config/fish/functions/gbda.fish new file mode 100644 index 0000000..ae389d6 --- /dev/null +++ b/.config/fish/functions/gbda.fish @@ -0,0 +1,14 @@ +function gbda -d "Delete all branches merged in current HEAD, including squashed" + git branch --merged | \ + command grep -vE '^\*|^\s*(master|main|develop)\s*$' | \ + command xargs -r -n 1 git branch -d + + set -l default_branch (__git.default_branch) + git for-each-ref refs/heads/ "--format=%(refname:short)" | \ + while read branch + set -l merge_base (git merge-base $default_branch $branch) + if string match -q -- '-*' (git cherry $default_branch (git commit-tree (git rev-parse $branch\^{tree}) -p $merge_base -m _)) + git branch -D $branch + end + end +end diff --git a/.config/fish/functions/gdv.fish b/.config/fish/functions/gdv.fish new file mode 100644 index 0000000..cb648fe --- /dev/null +++ b/.config/fish/functions/gdv.fish @@ -0,0 +1,3 @@ +function gdv -w "git diff -w" -d "Pipe `git diff` to `view` command" + git diff -w $argv | view - +end diff --git a/.config/fish/functions/gignored.fish b/.config/fish/functions/gignored.fish new file mode 100644 index 0000000..622b223 --- /dev/null +++ b/.config/fish/functions/gignored.fish @@ -0,0 +1,3 @@ +function gignored -w 'grep "^[[:lower:]]"' -d "list temporarily ignored files" + git ls-files -v | grep "^[[:lower:]]" $argv +end diff --git a/.config/fish/functions/glp.fish b/.config/fish/functions/glp.fish new file mode 100644 index 0000000..6b55085 --- /dev/null +++ b/.config/fish/functions/glp.fish @@ -0,0 +1,5 @@ +function glp -d "git log at requested pretty level" -a format + set -q format[1]; and git log --pretty=$format +end + +complete -c glp -x -a "(complete -C 'git log --pretty=' | sed 's/^--pretty=//')" diff --git a/.config/fish/functions/grename.fish b/.config/fish/functions/grename.fish new file mode 100644 index 0000000..90531a5 --- /dev/null +++ b/.config/fish/functions/grename.fish @@ -0,0 +1,11 @@ +function grename -d "Rename 'old' branch to 'new', including in origin remote" -a old new + if test (count $argv) -ne 2 + echo "Usage: "(status -u)" old_branch new_branch" + return 1 + end + git branch -m $old $new + git push origin :$old + and git push --set-upstream origin $new +end + +complete -c grename -x -a "(complete -C 'git branch ')" diff --git a/.config/fish/functions/grt.fish b/.config/fish/functions/grt.fish new file mode 100644 index 0000000..f70e0d0 --- /dev/null +++ b/.config/fish/functions/grt.fish @@ -0,0 +1,3 @@ +function grt -d "cd into the top of the current repository or submodule" + cd (git rev-parse --show-toplevel; or echo ".") +end diff --git a/.config/fish/functions/gtest.fish b/.config/fish/functions/gtest.fish new file mode 100644 index 0000000..1b6bf96 --- /dev/null +++ b/.config/fish/functions/gtest.fish @@ -0,0 +1,21 @@ +# gtest: test a command against git staged changes. +# +# example usage: +# gtest make test +function gtest -d "test command on staged changes only" + # Stash working dir, keeping index changes. + git stash push -q --keep-index --include-untracked; or return + + # Run test command against index changes only. + command $argv + set cmdstatus $status + + # Return working dir and index to original state. + # Note: reset + restore is required to prevent merge conflicts + # when popping the stash. + git reset -q + git restore . + git stash pop -q --index; or return $status + + return $cmdstatus +end diff --git a/.config/fish/functions/gtl.fish b/.config/fish/functions/gtl.fish new file mode 100644 index 0000000..5ff8ae2 --- /dev/null +++ b/.config/fish/functions/gtl.fish @@ -0,0 +1,3 @@ +function gtl -d "List tags matching prefix" -a prefix + git tag --sort=-v:refname -n -l $prefix\* +end diff --git a/.config/fish/functions/gunwip.fish b/.config/fish/functions/gunwip.fish new file mode 100644 index 0000000..d95a4d7 --- /dev/null +++ b/.config/fish/functions/gunwip.fish @@ -0,0 +1,7 @@ +# Work In Progress (wip) +# These features allow to pause a branch development and switch to another one +# When you want to go back to work, just unwip it +# +function gunwip -d "git uncommit the work-in-progress branch" + git log -n 1 | grep -q -c "\--wip--"; and git reset HEAD~1 +end diff --git a/.config/fish/functions/gwip.fish b/.config/fish/functions/gwip.fish new file mode 100644 index 0000000..2e01aed --- /dev/null +++ b/.config/fish/functions/gwip.fish @@ -0,0 +1,7 @@ +# Work In Progress (wip) +# These features allow to pause a branch development and switch to another one +# When you want to go back to work, just unwip it +# +function gwip -d "git commit a work-in-progress branch" + git add -A; git rm (git ls-files --deleted) 2> /dev/null; git commit -m "--wip--" --no-verify +end diff --git a/.config/fish/functions/nvm.fish b/.config/fish/functions/nvm.fish new file mode 100644 index 0000000..b7d70de --- /dev/null +++ b/.config/fish/functions/nvm.fish @@ -0,0 +1,234 @@ +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 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 "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(?\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 diff --git a/.config/fish/functions/tt.fish b/.config/fish/functions/tt.fish new file mode 100644 index 0000000..ad09897 --- /dev/null +++ b/.config/fish/functions/tt.fish @@ -0,0 +1,4 @@ +function tt --wraps='setfont -d; echo 3 > /sys/class/graphics/fbcon/rotate_all' --description 'alias tt=setfont -d; echo 3 > /sys/class/graphics/fbcon/rotate_all' + setfont -d; echo 3 > /sys/class/graphics/fbcon/rotate_all $argv + +end diff --git a/.config/fish/functions/v.fish b/.config/fish/functions/v.fish new file mode 100644 index 0000000..157b999 --- /dev/null +++ b/.config/fish/functions/v.fish @@ -0,0 +1,4 @@ +function v --wraps=nvim --description 'alias v=nvim' + nvim $argv + +end