diff --git a/.editorconfig b/.editorconfig index bed92f3e4..a5c417ee6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -20,3 +20,9 @@ indent_size = 2 [Dockerfile] indent_size = 2 + +[share/{completions,functions}/**.fish] +max_line_length = none + +[COMMIT_EDITMSG] +max_line_length = 80 diff --git a/.gitattributes b/.gitattributes index d552647a1..6e8a7e557 100644 --- a/.gitattributes +++ b/.gitattributes @@ -21,11 +21,13 @@ /.github/* export-ignore /.builds export-ignore /.builds/* export-ignore -/.travis.yml export-ignore # for linguist; let github identify our project as C++ instead of C due to pcre2 -pcre2/* linguist-vendored +pcre2/** linguist-vendored angular.js linguist-vendored -doc_src/* linguist-documentation +angular-*.js linguist-vendored +doc_src/** linguist-documentation *.fish linguist-language=fish src/*.h linguist-language=c++ +src/builtins/*.h linguist-language=c++ +share/completions/*.fish linguist-documentation diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 03b2b48a7..29168a105 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -12,3 +12,5 @@ Please tell us if you tried fish without third-party customizations by executing Tell us how to reproduce the problem. Including an asciinema.org recording is useful for problems that involve the visual display of fish output such as its prompt. --> + +**YOUR TEXT HERE** diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 000000000..258b3a3bf --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,43 @@ +name: "CodeQL" + +on: + push: + branches: [ master ] + schedule: + - cron: '18 22 * * 2' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: true + matrix: + language: [ 'cpp', 'javascript', 'python' ] + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4f06d1ba7..54f3711a4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,9 +1,10 @@ -name: Test +name: make test on: [push, pull_request] env: CTEST_PARALLEL_LEVEL: "1" + CMAKE_BUILD_PARALLEL_LEVEL: "4" jobs: ubuntu: diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 29160a079..e54d8c7e4 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,5 +1,5 @@ -fish 3.4.0 (released ???) -========================= +fish 3.4.0 (released March 12, 2022) +==================================== Notable improvements and fixes ------------------------------ @@ -16,8 +16,8 @@ Notable improvements and fixes foo $(bar) # this will still split on newlines only. -- Complimenting the ``prompt`` command in 3.3.0, ``fish_config`` gained a ``theme`` subcommand to show and pick from the sample themes (meaning color schemes) directly in the terminal, instead of having to open a webbrowser. For example ``fish_config theme choose Nord`` loads the Nord theme in the current session (:issue:`8132`). The current theme can be saved with ``fish_config theme dump`` and custom themes can be added by saving them in ``~/.config/fish/themes/``. -- ``set`` learned a new option ``--function`` to set a variable in the function's top scope. This should be a more familiar way of scoping variables and avoids issues with ``--local``, which is actually block-scoped (:issue:`565`, :issue:`8145`):: +- Complementing the ``prompt`` command in 3.3.0, ``fish_config`` gained a ``theme`` subcommand to show and pick from the sample themes (meaning color schemes) directly in the terminal, instead of having to open a Web browser. For example ``fish_config theme choose Nord`` loads the Nord theme in the current session (:issue:`8132`). The current theme can be saved with ``fish_config theme dump``, and custom themes can be added by saving them in ``~/.config/fish/themes/``. +- ``set`` and ``read`` learned a new option, ``--function``, to set a variable in the function's top scope. This should be a more familiar way of scoping variables and avoids issues with ``--local``, which is actually block-scoped (:issue:`565`, :issue:`8145`):: function demonstration if true @@ -33,8 +33,9 @@ Notable improvements and fixes > string length --visible (set_color red)foo 3 -- Performance improvements to globbing, especially on systems using glibc (by avoiding its slow iswalnum() function). In some cases (large directories with files with many numbers in the names) this almost doubles performance. -- Autosuggestions can now be turned off by setting ``$fish_autosuggestion_enabled`` to 0, and (almost) all highlighting can be turned off by choosing the new "None" theme. The exception is necessary colors, e.g. to distinguish autosuggestions from the actual commandline. (:issue:`8376`) +- Performance improvements to globbing, especially on systems using glibc. In some cases (large directories with files with many numbers in the names) this almost halves the time taken to expand the glob. +- Autosuggestions can now be turned off by setting ``$fish_autosuggestion_enabled`` to 0, and (almost) all highlighting can be turned off by choosing the new "None" theme. The exception is necessary colors, like those which distinguish autosuggestions from the actual command line. (:issue:`8376`) +- The ``fish_git_prompt`` function, which is included in the default prompts, now overrides ``git`` to avoid running commands set by per-repository configuration. This avoids a potential security issue in some circumstances, and has been assigned CVE-2022-20001 (:issue:`8589`). Deprecations and removed features --------------------------------- @@ -45,10 +46,15 @@ Deprecations and removed features # with both ampersand-nobg-in-token and qmark-noglob, this argument has no special characters anymore > open https://www.youtube.com/watch?v=dQw4w9WgXcQ&feature=youtu.be + As a reminder, feature flags can be set on startup with ``fish --features ampersand-nobg-in-token,qmark-noglob`` or with a universal variable called ``fish_features``:: + + > set -Ua fish_features ampersand-nobg-in-token + - ``$status`` is now forbidden as a command, to prevent a surprisingly common error among new users: Running ``if $status`` (:issue:`8171`). This applies *only* to ``$status``, other variables are still allowed. -- ``set --query`` now returns a falsy status of 255 if given no variable names. This means ``if set -q $foo`` will not enter the if-block if ``$foo`` is empty or unset. To restore the previous behavior you would use something like ``if not set -q foo; or set -q $foo``. We do not expect anyone to have used this on purpose, any places this happens are almost certainly buggy (:issue:`8214`). -- Mac OS X 10.9 is no longer supported. The minimum Mac version is now 10.10 "Yosemite." +- ``set --query`` now returns an exit status of 255 if given no variable names. This means ``if set -q $foo`` will not enter the if-block if ``$foo`` is empty or unset. To restore the previous behavior, use ``if not set -q foo; or set -q $foo`` - but this is unlikely to be desireable (:issue:`8214`). - ``_`` is now a reserved keyword (:issue:`8342`). +- The special input functions ``delete-or-exit``, ``nextd-or-forward-word`` and ``prevd-or-backward-word`` replace fish functions of the same names (:issue:`8538`). +- Mac OS X 10.9 is no longer supported. The minimum Mac version is now 10.10 "Yosemite." Scripting improvements ---------------------- @@ -61,43 +67,70 @@ Scripting improvements 'blue ' - ``$fish_user_paths`` is now automatically deduplicated to fix a common user error of appending to it in config.fish when it is universal (:issue:`8117`). :ref:`fish_add_path ` remains the recommended way to add to $PATH. -- ``return`` can now be used outside of functions. In scripts it does the same thing as :program:`cmd`, in the commandline it sets ``$status`` without exiting (:issue:`8148`). -- An oversight prevented all syntax checks from running on commands given to ``fish -c`` (:issue:`8171`). This includes checks like e.g. ``exec`` not being allowed in a pipeline and ``$$`` not being a valid variable. Most of these would have triggered an assert or other error before. +- ``return`` can now be used outside functions. In scripts, it does the same thing as ``exit``. In interactive mode,it sets ``$status`` without exiting (:issue:`8148`). +- An oversight prevented all syntax checks from running on commands given to ``fish -c`` (:issue:`8171`). This includes checks such as ``exec`` not being allowed in a pipeline, and ``$$`` not being a valid variable. Generally, another error was generated anyway. - ``fish_indent`` now correctly reformats tokens that end with a backslash followed by a newline (:issue:`8197`). -- ``commandline`` gained an ``--is-valid`` option to check if the commandline is syntactically valid and complete. This allows basic implementation of transient prompts (:issue:`8142`). +- ``commandline`` gained an ``--is-valid`` option to check if the command line is syntactically valid and complete. This allows basic implementation of transient prompts (:issue:`8142`). +- ``commandline`` gained a ``--paging-full-mode`` option to check if the pager is showing all the possible lines (no "7 more rows" message) (:issue:`8485`). - List expansion correctly reports an error when used with all zero indexes (:issue:`8213`). -- Running ``fish`` with a directory instead of a script as argument (e.g. ``fish .``) no longer leads to an infinite loop. Instead it errors out immediately (:issue:`8258`) +- Running ``fish`` with a directory instead of a script as argument (eg ``fish .``) no longer leads to an infinite loop. Instead it errors out immediately (:issue:`8258`) - Some error messages occuring after fork, like "text file busy" have been replaced by bespoke error messages for fish (like "File is currently open for writing"). This also restores error messages with current glibc versions that removed sys_errlist (:issue:`8234`, :issue:`4183`). - The ``realpath`` builtin now also squashes leading slashes with the ``--no-symlinks`` option (:issue:`8281`). - When trying to ``cd`` to a dangling (broken) symbolic link, fish will print an error noting that the target is a broken link (:issue:`8264`). - On MacOS terminals that are not granted permissions to access a folder, ``cd`` would print a spurious "rotten symlink" error, which has been corrected to "permission denied" (:issue:`8264`). -- Since fish 3.0, for-loops would trigger a variable handler an additional time before the loop was entered. This has been corrected (:issue:`8384`). +- Since fish 3.0, ``for`` loops would trigger a variable handler function before the loop was entered. As the variable had not actually changed or been set, this was a spurious event and has been removed (:issue:`8384`). - ``math`` now correctly prints negative values and values larger than ``2**31`` when in hex or octal bases (:issue:`8417`). - ``dirs`` always produces an exit status of 0, instead of sometimes returning 1 (:issue:`8211`). - ``cd ""`` no longer crashes fish (:issue:`8147`). -- ``set --query`` can now query whether a variable is a pathvar via ``--path`` or ``--unpath`` (:issue:`8494`). +- ``set --query`` can now query whether a variable is a path variable via ``--path`` or ``--unpath`` (:issue:`8494`). - Tilde characters (``~``) produced by custom completions are no longer escaped when applied to the command line, making it easier to use the output of a recursive ``complete -C`` in completion scripts (:issue:`4570`). -- Most ``string`` subcommands no longer print a final newline if such is missing from stdin (:issue:`3847`). +- ``set --show`` reports when a variable is read-only (:issue:`8179`). +- Erasing ``$fish_emoji_width`` will reset fish to the default guessed emoji width (:issue:`8274`). +- The ``la`` function no longer lists entries for "." and "..", matching other systems defaults (:issue:`8519`). +- ``abbr -q`` returns the correct exit status when given multiple abbreviation names as arguments (:issue:`8431`). +- ``command -v`` returns an exit status of 127 instead of 1 if no command was found (:issue:`8547`). +- ``argparse`` with ``--ignore-unknown`` no longer breaks with multiple unknown options in a short option group (:issue:`8637`). +- Comments inside command substitutions or brackets now correctly ignore parentheses, quotes, and brackets (:issue:`7866`, :issue:`8022`, :issue:`8695`). +- ``complete -C`` supports a new ``--escape`` option, which turns on escaping in returned completion strings (:issue:`3469`). +- Invalid byte or unicode escapes like ``\Utest`` or ``\xNotHex`` are now a tokenizer error instead of causing the token to be truncated (:issue:`8545`). Interactive improvements ------------------------ -- Vi mode cursors are now set properly after :kbd:`Control-C`. (:issue:`8125`). -- Vi mode cursors are enabled in Apple Terminal (:issue:`8167`). +- Vi mode cursors are now set properly after :kbd:`Control-C` (:issue:`8125`). - ``funced`` will try to edit the whole file containing a function definition, if there is one (:issue:`391`). -- Running a commandline consisting of just spaces now deletes an ephemeral (starting with space) history item again (:issue:`8232`). +- Running a command line consisting of just spaces now deletes an ephemeral (starting with space) history item again (:issue:`8232`). - Command substitutions no longer respect job control, instead running inside fish's own process group (:issue:`8172`). This more closely matches other shells, and improves :kbd:`Control-C` reliability inside a command substitution. - ``history`` and ``__fish_print_help`` now properly support ``less`` before version 530, including the version that ships with macOS. (:issue:`8157`). - ``help`` now knows which section is in which document again (:issue:`8245`). - fish's highlighter will now color options (starting with ``-`` or ``--``) with the color given in the new $fish_color_option, up to the first ``--``. It falls back on $fish_color_param, so nothing changes for existing setups (:issue:`8292`). - When executing a command, abbreviations are no longer expanded when the cursor is separated from the command by spaces, making it easier to suppress abbreviation expansion of commands without arguments. (:issue:`8423`). -- ``fish_key_reader``'s output was simplified. By default it now only prints a bind statement, the full per-character timing information can be gotten with a new ``--verbose`` switch. (:issue:`8467`) -- Custom completions are now also loaded for commands that contain tildes or variables like ``~/$bin/fish`` (:issue:`8442`). +- ``fish_key_reader``'s output was simplified. By default, it now only prints a bind statement. The previous per-character timing information can be seen with a new ``--verbose`` switch (:issue:`8467`). +- Custom completions are now also loaded for commands that contain tildes or variables like ``~/bin/fish`` or ``$PWD/fish`` (:issue:`8442`). +- Command lines spanning multiple lines will not be overwritten by the completion pager when it fills the entire terminal (:issue:`8509`, :issue:`8405`). +- When redrawing a multiline prompt, the old prompt is now properly cleared (:issue:`8163`). +- Interactive completion would occasionally ignore the last word on the command line due to a race condition. This has been fixed (:issue:`8175`). +- Propagation of universal variables from a fish process that is closing is faster (:issue:`8209`). +- The command line is drawn in the correct place if the prompt ends with a newline (:issue:`8298`). +- ``history`` learned a new subcommand ``clear-session`` to erase all history from the current session (:issue:`5791`). +- Pressing :kbd:`Control-C` in ``fish_key_reader`` will no longer print the incorrect "Press [ctrl-C] again to exit" message (:issue:`8510`). +- The default command-not-found handler for Fedora/PackageKit now passes the whole command line, allowing for functionality such as running the suggested command directly (:issue:`8579`). +- When looking for locale information, the Debian configuration is now used when available (:issue:`8557`). +- Pasting text containing quotes from the clipboard trims spaces more appropriately (:issue:`8550`). +- The clipboard bindings ignore X-based clipboard programs if the ``DISPLAY`` environment variable is not set, which helps prefer the Windows clipboard when it is available (such as on WSL). +- ``funcsave`` will remove a saved copy of a function that has been erased with ``functions --erase``. +- The Web-based configuration tool gained a number of improvements, including the ability to set pager colors. +- The default ``fish_title`` prints a shorter title with shortened $PWD and no more redundant "fish" (:issue:`8641`). +- Holding down an arrow key won't freeze the terminal with long periods of flashing (:issue:`8610`). +- Multi-char bindings are no longer interrupted if a signal handler enqueues an event. (:issue:`8628`). New or improved bindings ^^^^^^^^^^^^^^^^^^^^^^^^ +- :kbd:`Escape` can now bound without breaking arrow key bindings (:issue:`8428`). +- The :kbd:`Alt-H` binding (to open a command’s manual page) now also ignores ``command`` (:issue:`8447`). Improved prompts ^^^^^^^^^^^^^^^^ +- The ``fish_status_to_signal`` helper function returns the correct signal names for the current platform, rather than Linux (:issue:`8530`). - The ``prompt_pwd`` helper function learned a ``--full-length-dirs N`` option to keep the last N directory components unshortened. In addition the number of characters to shorten each component should be shortened to can now be given as ``-d N`` or ``--dir-length N``. (:issue:`8208`):: > prompt_pwd --full-length-dirs 2 -d 1 ~/dev/fish-shell/share/tools/web_config @@ -107,32 +140,47 @@ Completions ^^^^^^^^^^^ - Added completions for: - - ``istioctl`` (:issue:`8343`) - - ``black`` (:issue:`8123`) - - ``exif`` (:issue:`8246`) - - ``gping`` (:issue:`8181`) - - Angular's ``ng`` (:issue:`8111`) - - ``zef`` (:issue:`8114`) - - ``rakudo`` (:issue:`8113`) + - Apple's ``shortcuts`` + - ``argparse`` (:issue:`8434`) + - ``asd`` (:issue:`8759`) - ``az`` (:issue:`8141`) - - ``qmk`` (:issue:`8180`) - - ``cpupower`` - - ``dart`` - - ``sbcl`` - - ``roswell`` - - ``clasp`` - - Windows Subsystem for Linux (WSL)'s ``wslpath`` (:issue:`8364`) - - Various wine tools (:issue:`8411`) - - mono (:issue:`8415`) - - elvish (:issue:`8416`) - - pabcnet_clear (:issue:`8421`) - - ``ethtool`` + - ``black`` (:issue:`8123`) + - ``clasp`` (:issue:`8373`) + - ``cpupower`` (:issue:`8302`) + - ``dart`` (:issue:`8315`) + - ``dscacheutil`` + - ``elvish`` (:issue:`8416`) + - ``ethtool`` (:issue:`8283`) + - ``exif`` (:issue:`8246`) + - ``findstr`` (:issue:`8481`) + - ``git-sizer`` (:issue:`8156`) + - ``gnome-extensions`` (:issue:`8732`) + - ``gping`` (:issue:`8181`) + - ``isatty`` (:issue:`8609`) + - ``istioctl`` (:issue:`8343`) - ``kmutil`` - - ``shortcuts`` + - ``kubectl`` (:issue:`8734`) + - ``matlab`` (:issue:`8505`) + - ``mono`` (:issue:`8415`) and related tools ``csharp``, ``gacutil``, ``gendarme``, ``ikdasm``, ``ilasm``, ``mkbundle``, ``monodis``, ``monop``, ``sqlsharp`` and ``xsp`` (:issue:`8452`) + - Angular's ``ng`` (:issue:`8111`) + - ``nodeenv`` (:issue:`8533`) + - ``octave`` (:issue:`8505`) + - ``pabcnet_clear`` (:issue:`8421`) + - ``qmk`` (:issue:`8180`) + - ``rakudo`` (:issue:`8113`) + - ``rc-status`` (:issue:`8757`) + - ``roswell`` (:issue:`8330`) + - ``sbcl`` (:issue:`8330`) + - ``starship`` (:issue:`8520`) + - ``topgrade`` (:issue:`8651`) + - ``wine``, ``wineboot`` and ``winemaker`` (:issue:`8411`) + - Windows Subsystem for Linux (WSL)'s ``wslpath`` (:issue:`8364`) + - Windows' ``color`` (:issue:`8483`), ``attrib``, ``attributes``, ``choice``, ``clean``, ``cleanmgr``, ``cmd``, ``cmdkey``, ``comp``, ``forfiles``, ``powershell``, ``reg``, ``schtasks``, ``setx`` (:issue:`8486`) + - ``zef`` (:issue:`8114`) -- Improvements to many completions, especially for ``git`` aliases (:issue:`8129`) and subcommands (:issue:`8134`). -- Add missing completions for the ``-p`` option of ``xbps-query``. -- The ``fish_is_nth_token`` function, which is particularly useful in completions for identifying the token number within the command line, replaces various internal functions to do the same (:issue:`8008`). +- Improvements to many completions, especially for ``git`` aliases (:issue:`8129`), subcommands (:issue:`8134`) and submodules (:issue:`8716`). +- Many adjustments to complete correct options for system utilities on BSD and macOS. +- When evaluating custom completions, the command line state no longer includes variable overrides (``var=val``). This unbreaks completions that read ``commandline -op``. Improved terminal support ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -141,17 +189,26 @@ Improved terminal support - fish now assumes Unicode 9+ widths for emoji under iTerm 2 (:issue:`8200`). - Skin-tone emoji modifiers (U+1F3FB through U+1F3FF) are now measured as width 0 (:issue:`8275`). - fish's escape sequence removal now also knows Tmux's wrapped escapes. +- Vi mode cursors are enabled in Apple Terminal.app (:issue:`8167`). - Vi cursor shaping and $PWD reporting is now also enabled on foot (:issue:`8422`). +- ``ls`` will use colors also on newer versions of Apple Terminal.app (:issue:`8309`). +- The :kbd:`Delete` and :kbd:`Shift-Tab` keys work more reliably under ``st`` (:issue:`8352`, :issue:`8354`). Other improvements ------------------------------- -- Fish's test suite now uses ``ctest``, and has become much faster to run. It is now also possible to run only specific tests. (:issue:`7851`) -- The HTML version of the documentation now includes copy buttons for any code examples if JavaScript is available (:issue:`8218`). +------------------ +- Fish's test suite now uses ``ctest``, and has become much faster to run. It is now also possible to run only specific tests with targets named ``test_$filename`` - ``make test_set.fish`` only runs the set.fish test. (:issue:`7851`) +- The HTML version of the documentation now includes copy buttons for code examples (:issue:`8218`). +- The HTML version of the documentation and the web-based configuration tool now pick more modern system fonts instead of falling back to Arial and something like Courier New most of the time (:issue:`8632`). +- The Debian & Ubuntu package linked from fishshell.com is now a single package, rather than split into ``fish`` and ``fish-common`` (:issue:`7845`). +- The macOS installer does not assert that Rosetta is required to install fish on machines with Apple Silicon (:issue:`8566`). +- The macOS installer now cleans up previous .pkg installations when upgrading. (:issue:`2963`). For distributors ---------------- -- The minimum version of CMake required to build fish was raised to 3.5.0. +- The minimum version of CMake required to build fish is now 3.5.0. - The CMake installation supports absolute paths for ``CMAKE_INSTALL_DATADIR`` (:issue:`8150`). +- Building using NetBSD curses works on any platform (:issue:`8087`). +- The build system now uses the default linker instead of forcing use of the gold or lld linker (:issue:`8152`). -------------- @@ -184,7 +241,7 @@ Deprecations and removed features --------------------------------- - The ``$fish_history`` value "default" is no longer special. It used to be treated the same as "fish" (:issue:`7650`). - Redirection to standard error with the ``^`` character has been disabled by default. It can be turned back on using the ``stderr-nocaret`` feature flag, but will eventually be disabled completely (:issue:`7105`). -- Specifying an initial tab to ``fish_config`` now only works with ``fish_config browse`` (e.g. ``fish_config browse variables``), otherwise it would interfere with the new ``prompt`` subcommand (see below) (:issue:`7958`). +- Specifying an initial tab to ``fish_config`` now only works with ``fish_config browse`` (eg ``fish_config browse variables``), otherwise it would interfere with the new ``prompt`` subcommand (see below) (:issue:`7958`). Scripting improvements ---------------------- @@ -3293,3 +3350,5 @@ to call ttyname() on OS X. We’ve got some work to do to be as lean as bash, but we’re on the right track. + +.. vim: ft=rst : tw=0 : diff --git a/CMakeLists.txt b/CMakeLists.txt index d02ede576..51805628f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,7 +110,7 @@ set(FISH_SRCS src/null_terminated_array.cpp src/operation_context.cpp src/output.cpp src/pager.cpp src/parse_execution.cpp src/parse_tree.cpp src/parse_util.cpp src/parser.cpp src/parser_keywords.cpp src/path.cpp src/postfork.cpp - src/proc.cpp src/reader.cpp src/redirection.cpp src/sanity.cpp src/screen.cpp + src/proc.cpp src/reader.cpp src/redirection.cpp src/screen.cpp src/signal.cpp src/termsize.cpp src/timer.cpp src/tinyexpr.cpp src/tokenizer.cpp src/topic_monitor.cpp src/trace.cpp src/utf8.cpp src/util.cpp src/wait_handle.cpp src/wcstringutil.cpp src/wgetopt.cpp src/wildcard.cpp diff --git a/COPYING b/COPYING index 2ad0e187c..88d862bc6 100644 --- a/COPYING +++ b/COPYING @@ -1,7 +1,7 @@ Fish is a smart and user-friendly command line shell. Copyright (C) 2005-2009 Axel Liljencrantz -Copyright (C) 2009-2021 fish-shell contributors +Copyright (C) 2009-2022 fish-shell contributors fish is free software. diff --git a/README.rst b/README.rst index a95445d7e..052757218 100644 --- a/README.rst +++ b/README.rst @@ -48,8 +48,8 @@ and can be installed using the following commands: :: sudo apt-add-repository ppa:fish-shell/release-3 - sudo apt-get update - sudo apt-get install fish + sudo apt update + sudo apt install fish Instructions for other distributions may be found at `fishshell.com `__. @@ -212,7 +212,7 @@ On Debian or Ubuntu you want: :: - sudo apt-get install build-essential cmake ncurses-dev libncurses5-dev libpcre2-dev gettext + sudo apt install build-essential cmake ncurses-dev libncurses5-dev libpcre2-dev gettext On RedHat, CentOS, or Amazon EC2: @@ -231,15 +231,12 @@ Contact Us Questions, comments, rants and raves can be posted to the official fish mailing list at https://lists.sourceforge.net/lists/listinfo/fish-users or join us on our `gitter.im -channel `__. Or use the `fish -tag on -Stackoverflow `__ for -questions related to fish script and the `fish tag on -Superuser `__ for all other -questions (e.g., customizing colors, changing key bindings). +channel `__. Or use the `fish tag +on Unix & Linux Stackexchange `__. +There is also a fish tag on Stackoverflow, but it is typically a poor fit. Found a bug? Have an awesome idea? Please `open an issue `__. -.. |Build Status| image:: https://github.com/fish-shell/fish-shell/workflows/C/C++%20CI/badge.svg +.. |Build Status| image:: https://github.com/fish-shell/fish-shell/workflows/make%20test/badge.svg :target: https://github.com/fish-shell/fish-shell/actions diff --git a/benchmarks/driver.sh b/benchmarks/driver.sh index ed5235c16..1c155ae0c 100755 --- a/benchmarks/driver.sh +++ b/benchmarks/driver.sh @@ -9,20 +9,32 @@ FISH_PATH=$1 FISH2_PATH=$2 BENCHMARKS_DIR=$(dirname "$0")/benchmarks +quote() { + # Single-quote the given string for a POSIX shell, except in common cases that don't need it. + printf %s "$1" | + sed "/[^[:alnum:]\/.-]/ { + s/'/'\\\''/g + s/^/'/ + s/\$/'/ + }" +} + for benchmark in "$BENCHMARKS_DIR"/*; do basename "$benchmark" [ -n "$FISH2_PATH" ] && echo "$FISH_PATH" - ${FISH_PATH} --print-rusage-self "$benchmark" > /dev/null + "${FISH_PATH}" --print-rusage-self "$benchmark" > /dev/null if [ -n "$FISH2_PATH" ]; then echo "$FISH2_PATH" - ${FISH2_PATH} --print-rusage-self "$benchmark" > /dev/null + "${FISH2_PATH}" --print-rusage-self "$benchmark" > /dev/null fi if command -v hyperfine >/dev/null 2>&1; then + cmd1="$(quote "${FISH_PATH}") $(quote "$benchmark") > /dev/null" if [ -n "$FISH2_PATH" ]; then - hyperfine "${FISH_PATH} $benchmark > /dev/null" "${FISH2_PATH} $benchmark > /dev/null" + cmd2="$(quote "${FISH2_PATH}") $(quote "$benchmark") > /dev/null" + hyperfine "$cmd1" "$cmd2" else - hyperfine "${FISH_PATH} $benchmark > /dev/null" + hyperfine "$cmd1" fi fi done diff --git a/build_tools/bin/README.txt b/build_tools/bin/README.txt deleted file mode 100644 index bd718e937..000000000 --- a/build_tools/bin/README.txt +++ /dev/null @@ -1 +0,0 @@ -mac_xar_116 is http://mackyle.github.io/xar/, compiled for Mac. It is used by mac_sign_package.sh as a replacement for productsign. diff --git a/build_tools/bin/mac_xar_116 b/build_tools/bin/mac_xar_116 deleted file mode 100755 index 591d99715..000000000 Binary files a/build_tools/bin/mac_xar_116 and /dev/null differ diff --git a/build_tools/mac_sign_package.sh b/build_tools/mac_sign_package.sh deleted file mode 100755 index 12d4272ee..000000000 --- a/build_tools/mac_sign_package.sh +++ /dev/null @@ -1,122 +0,0 @@ -#!/usr/bin/env bash - -# This codesigns a Mac .pkg (installer) file. -# Normally we could use `productsign` but that no longer produces -# installers compatible with 10.11. -# See https://github.com/fish-shell/fish-shell/issues/7656 -# -# So instead we use the flow described here: -# http://users.wfu.edu/cottrell/productsign/productsign_linux.html -# -# This script expects the following: -# -# 1. A variable $MAC_PRODUCTSIGN_CERTS_DIR pointing at a directory containing files cert00, cert01, cert02 -# 2. A variable $MAC_PRODUCTSIGN_P12_FILE containing the "Mac Developer ID Installer" keychain item, exported as p12. See below. - -die() { echo "$*" 1>&2 ; exit 1; } - -# Exit on error. -set -e - -# Our input package file. -INPUT_PKG=$(realpath $1) -test -f "$INPUT_PKG" || die "${INPUT_PKG} not a valid package" - -# Find where our mac_xar_116 binary is. -XAR_116="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/bin/mac_xar_116 - -# Here's what we need to be set. -test -f "${MAC_PRODUCTSIGN_P12_FILE}" || die "MAC_PRODUCTSIGN_P12_FILE not set or not a p12 file" -test -d "${MAC_PRODUCTSIGN_CERTS_DIR}" || die "MAC_PRODUCTSIGN_CERTS_DIR not set or not a directory" -test -f "${MAC_PRODUCTSIGN_CERTS_DIR}/cert00" \ - && test -f "${MAC_PRODUCTSIGN_CERTS_DIR}/cert01" \ - && test -f "${MAC_PRODUCTSIGN_CERTS_DIR}/cert02" \ - || die "MAC_PRODUCTSIGN_CERTS_DIR does not contain cert00, cert01, cert02" -test -x "${XAR_116}" || die "mac_xar_116 binary not found or executable at ${XAR_116}" - -TMP=$(mktemp -d) -KEYFILE="${TMP}/key.pem" -DIGFILE="${TMP}/digestinfo.dat" -SIGFILE="${TMP}/signature.dat" - -set -x - -openssl pkcs12 -in "${MAC_PRODUCTSIGN_P12_FILE}" -nodes | openssl rsa -out "${KEYFILE}" -test -f "${KEYFILE}" || die "openssl did not create key.pem" -SIGSIZE=$(openssl dgst -sign "${KEYFILE}" -binary < /dev/null | wc -c | xargs) - -# Prepare data for signing. -${XAR_116} --sign -f ${INPUT_PKG} --digestinfo-to-sign "${DIGFILE}" \ - --sig-size "${SIGSIZE}" \ - --cert-loc "${MAC_PRODUCTSIGN_CERTS_DIR}/cert00" \ - --cert-loc "${MAC_PRODUCTSIGN_CERTS_DIR}/cert01" \ - --cert-loc "${MAC_PRODUCTSIGN_CERTS_DIR}/cert02" - -# Create the signature. -openssl rsautl -sign -inkey "${KEYFILE}" -in "${DIGFILE}" -out "${SIGFILE}" - -# Add it to the archive, in place, then move it back. -${XAR_116} --inject-sig "${SIGFILE}" -f "${INPUT_PKG}" - -# Remove all our junk. -rm -rf "${TMP}" - -# Check the signature! -pkgutil --check-signature "${INPUT_PKG}" - -# The following is taken from http://users.wfu.edu/cottrell/productsign/productsign_linux.html -# Saved here for posterity. - -# Signing a Mac OS X package on Linux - -# Premises - -# You are a software developer who's at home on Linux but you want to produce builds of your software for other platforms, including Mac OS X. -# You've already figured out cross-compilation. And in regard to OS X you've figured out how to build a (flat) pkg file on Linux – or if not, you can do so quite quickly by looking at the bomutils doc: https://github.com/hogliux/bomutils. -# You are grudgingly willing to pay the Apple tax (the fee for becoming a registered developer) so that you can get a certificate with which to sign your package, in order that your gentle users don't get off-putting messages from Gatekeeper. -# But you're wondering how to sign your package without having to use Apple's productsign on a Mac. -# If you match on all points, we're in business! Here's the drill as I have figured it out. You will need: openssl, recent xar (see below), and one-time access to an actual Mac. - -# Procedure - -# Step 0: Build your program and create an OS X pkg file (xar archive). This you will do (on Linux) whenever you want to create a new release or snapshot. - -# Step 1: This is a one-time step to be performed on a Mac. There may be a way around it, but I'm not aware of one. Please let me know if you're cleverer than I when it comes to certificates and all that. But anyway, follow the Apple directions for installing your developer certificate(s) on OS X, and use productsign to sign your package on the Mac – just this once! (Copy it across from Linux.) And then, before leaving the Mac, open Keychain Access and find your developer cert, the one with "Developer ID Installer" in its title (it should have a private key tucked under it). Highlight it and select "Export items" under the File menu to save as a p12 file. Copy your signed package and the exported p12 file (let's say it's called certs.p12) to your Linux box. - -# Step 2: Back on Linux you're going to need a reasonably recent version of xar, specifically 1.6.1 or higher to support signing. Arch Linux installs xar 1.6.1 if you do pacman -S xar. Fedora's dnf install xar gets version 1.5, which won't do the job. I don't know about other distros, but if need be you can find the source for xar 1.6.1 at http://mackyle.github.io/xar/. Anyway, here's another one-time step: you'll extract the certs you need from the pkg file that you signed on the Mac, and the private key from the p12 file you exported from Keychain Access. (You'll need the passphrase that you set on the p12 when exporting it, so I hope you haven't forgotten that.) - -# I'll assume (unimaginatively) that your package is called foo.pkg. - -# # extract the certs from signed foo.pkg -# mkdir certs -# xar -f foo.pkg --extract-certs certs -# You should find certs00, certs01 and probably certs02 in the certs directory. Perhaps more. - -# # extract the private key from certs.p12 (requires passphrase) -# openssl pkcs12 -in certs.p12 -nodes | openssl rsa -out key.pem -# At this point you have the materials to sign future versions of your package natively on Linux. I'll now assume that a new unsigned foo.pkg is sitting in a directory containing the key.pem generated above and also the certs subdirectory created above. So now (with many thanks to mackyle!) you do: - -# PKG=foo.pkg - -# # determine the size of the signature -# : | openssl dgst -sign key.pem -binary | wc -c > siglen.txt - -# # prepare data for signing -- may have to adjust depending -# # on the contents of the certs subdir in your case -# xar --sign -f $PKG --digestinfo-to-sign digestinfo.dat \ -# --sig-size `cat siglen.txt` \ -# --cert-loc certs/cert00 \ -# --cert-loc certs/cert01 \ -# --cert-loc certs/cert02 - -# # create the signature -# openssl rsautl -sign -inkey key.pem -in digestinfo.dat \ -# -out signature.dat - -# # stuff it into the archive -# xar --inject-sig signature.dat -f $PKG - -# # and clean up -# rm -f signature.dat digestinfo.dat siglen.txt -# From this point on, just build your package on Linux and sign it on Linux using xar along with the certs and key that you got from the Mac. - diff --git a/build_tools/make_pkg.sh b/build_tools/make_pkg.sh index ad3fd4f44..d4fcd9934 100755 --- a/build_tools/make_pkg.sh +++ b/build_tools/make_pkg.sh @@ -31,17 +31,10 @@ mkdir -p "$PKGDIR/build" "$PKGDIR/root" "$PKGDIR/intermediates" "$PKGDIR/dst" pkgbuild --scripts "$SRC_DIR/build_tools/osx_package_scripts" --root "$PKGDIR/root/" --identifier 'com.ridiculousfish.fish-shell-pkg' --version "$VERSION" "$PKGDIR/intermediates/fish.pkg" productbuild --package-path "$PKGDIR/intermediates" --distribution "$SRC_DIR/build_tools/osx_distribution.xml" --resources "$SRC_DIR/build_tools/osx_package_resources/" "$OUTPUT_PATH/fish-$VERSION.pkg" -# Here is the historical way to sign the installer package. -# But when run on macOS 11.1, the resulting installers don't work on 10.11. -# So we have our own script instead. See issue #7656. -# Also see https://developer.apple.com/forums/thread/664842 -# If/when productsign is fixed to support 10.11, we can switch back to this. -# MAC_PRODUCTSIGN_ID=${MAC_PRODUCTSIGN_ID:--} -# productsign --sign "${MAC_PRODUCTSIGN_ID}" "$OUTPUT_PATH/fish-$VERSION.pkg" "$OUTPUT_PATH/fish-$VERSION-signed.pkg" && mv "$OUTPUT_PATH/fish-$VERSION-signed.pkg" "$OUTPUT_PATH/fish-$VERSION.pkg" - -"$SRC_DIR/build_tools/mac_sign_package.sh" "$OUTPUT_PATH/fish-$VERSION.pkg" +MAC_PRODUCTSIGN_ID=${MAC_PRODUCTSIGN_ID:--} +productsign --sign "${MAC_PRODUCTSIGN_ID}" "$OUTPUT_PATH/fish-$VERSION.pkg" "$OUTPUT_PATH/fish-$VERSION-signed.pkg" && mv "$OUTPUT_PATH/fish-$VERSION-signed.pkg" "$OUTPUT_PATH/fish-$VERSION.pkg" # Make the app -{ cd "$PKGDIR/build" && make signed_fish_macapp && zip -r "$OUTPUT_PATH/fish-$VERSION.app.zip" fish.app; } +{ cd "$PKGDIR/build" && make -j 12 signed_fish_macapp && zip -r "$OUTPUT_PATH/fish-$VERSION.app.zip" fish.app; } rm -r "$PKGDIR" diff --git a/build_tools/osx_distribution.xml b/build_tools/osx_distribution.xml index 1c42fecb9..96df99e48 100644 --- a/build_tools/osx_distribution.xml +++ b/build_tools/osx_distribution.xml @@ -1,10 +1,11 @@ fish shell - + - + + diff --git a/build_tools/osx_package_resources/welcome.html b/build_tools/osx_package_resources/welcome.html new file mode 100644 index 000000000..9e6078b45 --- /dev/null +++ b/build_tools/osx_package_resources/welcome.html @@ -0,0 +1,29 @@ + + + + + +

+ fish is a smart and user-friendly command line shell. For more information, visit fishshell.com. +

+

+ fish will be installed into /usr/local/, and its path will be added to /etc/shells if necessary. +

+

+ Your default shell will not be changed. To make fish your login shell after the installation, run: +

+

+ chsh -s /usr/local/bin/fish +

+

Enjoy! Bugs can be reported on GitHub.

+ + diff --git a/build_tools/osx_package_resources/welcome.rtf b/build_tools/osx_package_resources/welcome.rtf deleted file mode 100644 index 3be3d8914..000000000 --- a/build_tools/osx_package_resources/welcome.rtf +++ /dev/null @@ -1,26 +0,0 @@ -{\rtf1\ansi\ansicpg1252\cocoartf1485\cocoasubrtf410 -{\fonttbl\f0\fnil\fcharset0 HelveticaNeue;\f1\fnil\fcharset0 Menlo-Regular;} -{\colortbl;\red255\green255\blue255;} -{\*\expandedcolortbl;\csgenericrgb\c100000\c100000\c100000;} -{\info -{\author dlkfjslfjsfdlkfk}}\margl1440\margr1440\vieww10800\viewh8400\viewkind0 -\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0 - -\f0\fs30 \cf0 Fish is a smart and user friendly command line shell. For more information, visit {\field{\*\fldinst{HYPERLINK "https://fishshell.com"}}{\fldrslt https://fishshell.com}}\ -\ -fish will be installed into -\f1\fs26 /usr/local/ -\f0\fs30 , and fish will be added to -\f1\fs26 /etc/shells -\f0\fs30 if necessary.\ -\ -Your default shell will -\i not -\i0 be changed. To make fish your default, run:\ -\ - -\f1 chsh -s /usr/local/bin/fish -\f0 \ -\ -Enjoy!\ -} \ No newline at end of file diff --git a/build_tools/osx_package_scripts/postinstall b/build_tools/osx_package_scripts/postinstall index 544fd1de1..abd59603a 100755 --- a/build_tools/osx_package_scripts/postinstall +++ b/build_tools/osx_package_scripts/postinstall @@ -1,3 +1,3 @@ #!/bin/sh -x -./add-shell /usr/local/bin/fish > /tmp/fish_postinstall_output.log +./add-shell ${DSTVOLUME}usr/local/bin/fish diff --git a/build_tools/osx_package_scripts/preinstall b/build_tools/osx_package_scripts/preinstall new file mode 100755 index 000000000..359174617 --- /dev/null +++ b/build_tools/osx_package_scripts/preinstall @@ -0,0 +1,7 @@ +#!/bin/sh -x + +echo "Removing any previous installation" +pkgutil --pkg-info ${INSTALL_PKG_SESSION_ID} && pkgutil --only-files --files ${INSTALL_PKG_SESSION_ID} | while read installed + do rm -v ${DSTVOLUME}${installed} +done +echo "... removed" diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake index 9c75ae668..2e2d5e567 100644 --- a/cmake/ConfigureChecks.cmake +++ b/cmake/ConfigureChecks.cmake @@ -115,7 +115,14 @@ check_struct_has_member("struct stat" st_mtim.tv_nsec "sys/stat.h" HAVE_STRUCT_S LANGUAGE CXX) check_include_file_cxx(sys/ioctl.h HAVE_SYS_IOCTL_H) check_include_file_cxx(sys/select.h HAVE_SYS_SELECT_H) + +# glibc 2.30 deprecated because that's what glibc does. +# Checking for that here rather than hardcoding a check on the glibc +# version in the C++ sources at point of use makes more sense. +SET(OLD_CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") check_include_files("sys/types.h;sys/sysctl.h" HAVE_SYS_SYSCTL_H) +SET(CMAKE_C_FLAGS "${OLD_CMAKE_C_FLAGS}") check_cxx_symbol_exists(eventfd sys/eventfd.h HAVE_EVENTFD) check_cxx_symbol_exists(pipe2 unistd.h HAVE_PIPE2) diff --git a/cmake/Docs.cmake b/cmake/Docs.cmake index e5c81c852..27e94be22 100644 --- a/cmake/Docs.cmake +++ b/cmake/Docs.cmake @@ -9,7 +9,6 @@ include(FeatureSummary) set(SPHINX_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/doc_src") set(SPHINX_ROOT_DIR "${CMAKE_CURRENT_BINARY_DIR}/user_doc") set(SPHINX_BUILD_DIR "${SPHINX_ROOT_DIR}/build") -set(SPHINX_CACHE_DIR "${SPHINX_ROOT_DIR}/doctrees") set(SPHINX_HTML_DIR "${SPHINX_ROOT_DIR}/html") set(SPHINX_MANPAGE_DIR "${SPHINX_ROOT_DIR}/man") @@ -22,7 +21,7 @@ add_custom_target(sphinx-docs -j auto -q -b html -c "${SPHINX_SRC_DIR}" - -d "${SPHINX_CACHE_DIR}" + -d "${SPHINX_ROOT_DIR}/.doctrees-html" "${SPHINX_SRC_DIR}" "${SPHINX_HTML_DIR}" DEPENDS ${SPHINX_SRC_DIR}/fish_indent_lexer.py fish_indent @@ -35,7 +34,7 @@ add_custom_target(sphinx-manpages -j auto -q -b man -c "${SPHINX_SRC_DIR}" - -d "${SPHINX_CACHE_DIR}" + -d "${SPHINX_ROOT_DIR}/.doctrees-man" "${SPHINX_SRC_DIR}" # TODO: This only works if we only have section 1 manpages. "${SPHINX_MANPAGE_DIR}/man1" diff --git a/cmake/Mac.cmake b/cmake/Mac.cmake index bdfe9282c..e02ba97a5 100644 --- a/cmake/Mac.cmake +++ b/cmake/Mac.cmake @@ -1,6 +1,4 @@ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.10" CACHE STRING "Minimum OS X deployment version") -# list of possibly relevent new stuff in 10.10 compared to 10.9: -# https://gist.github.com/floam/586f9c8a338357e16a97fa596b330e37 # Code signing ID on Mac. # If this is falsey, codesigning is disabled. @@ -13,10 +11,10 @@ set(MAC_INJECT_GET_TASK_ALLOW ON CACHE BOOL "Inject get-task-allow on Mac") # When building a Mac build, it is common for fish to link against a # pcre2 built for the host platform (e.g. macOS 10.15) while fish wants -# to link for macOS 10.10. This warning would be of interest for releases, +# to link for macOS 10.9. This warning would be of interest for releases, # but is just noise for daily development. Unfortunately it has no flag # of its own, so suppress all linker warnings in debug builds. -#set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -w") +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -w") function(CODESIGN_ON_MAC target) if((APPLE) AND (MAC_CODESIGN_ID)) diff --git a/doc_src/cmds/_.rst b/doc_src/cmds/_.rst index c1b73464e..a8d11e8b8 100644 --- a/doc_src/cmds/_.rst +++ b/doc_src/cmds/_.rst @@ -6,9 +6,9 @@ _ - call fish's translations Synopsis -------- -:: +.. synopsis:: - _ STRING... + _ STRING Description ----------- @@ -19,19 +19,17 @@ It is equivalent to ``gettext fish STRING``, meaning it can only be used to look It requires fish to be built with gettext support. If that support is disabled, or there is no translation it will simply echo the argument back. -The language depends on the current locale, set with ``$LANG`` and ``$LC_MESSAGES``. +The language depends on the current locale, set with :envvar:`LANG` and :envvar:`LC_MESSAGES`. Options ------- -``_`` has no options. +``_`` takes no options. Examples -------- - - :: > _ File diff --git a/doc_src/cmds/abbr.rst b/doc_src/cmds/abbr.rst index 52344a8e8..2f0682698 100644 --- a/doc_src/cmds/abbr.rst +++ b/doc_src/cmds/abbr.rst @@ -6,66 +6,75 @@ abbr - manage fish abbreviations Synopsis -------- -:: +.. synopsis:: abbr --add [SCOPE] WORD EXPANSION - abbr --erase WORD... + abbr --erase WORD ... abbr --rename [SCOPE] OLD_WORD NEW_WORD abbr --show abbr --list - abbr --query WORD... + abbr --query WORD ... Description ----------- ``abbr`` manages abbreviations - user-defined words that are replaced with longer phrases after they are entered. -For example, a frequently-run command like ``git checkout`` can be abbreviated to ``gco``. After entering ``gco`` and pressing :kbd:`Space` or :kbd:`Enter`, the full text ``git checkout`` will appear in the command line. +For example, a frequently-run command like ``git checkout`` can be abbreviated to ``gco``. +After entering ``gco`` and pressing :kbd:`Space` or :kbd:`Enter`, the full text ``git checkout`` will appear in the command line. Options ------- The following options are available: -- ``-a WORD EXPANSION`` or ``--add WORD EXPANSION`` Adds a new abbreviation, causing WORD to be expanded to EXPANSION. +**-a** *WORD* *EXPANSION* or **--add** *WORD* *EXPANSION* + Adds a new abbreviation, causing *WORD* to be expanded to *EXPANSION* -- ``-r OLD_WORD NEW_WORD`` or ``--rename OLD_WORD NEW_WORD`` Renames an abbreviation, from OLD_WORD to NEW_WORD. +**-r** *OLD_WORD* *NEW_WORD* or **--rename** *OLD_WORD* *NEW_WORD* + Renames an abbreviation, from *OLD_WORD* to *NEW_WORD* -- ``-s`` or ``--show`` Show all abbreviations in a manner suitable for export and import. +**-s** or **--show** + Show all abbreviations in a manner suitable for import and export -- ``-l`` or ``--list`` Lists all abbreviated words. +**-l** or **--list** + Lists all abbreviated words -- ``-e WORD`` or ``--erase WORD...`` Erase the given abbreviations. +**-e** *WORD* or **--erase** *WORD* ... + Erase the given abbreviations -- ``-q`` or ``--query`` Return 0 (true) if one of the WORDs is an abbreviation. +**-q** or **--query** + Return 0 (true) if one of the *WORD* is an abbreviation. -In addition, when adding or renaming abbreviations: +**-h** or **--help** + Displays help about using this command. -- ``-g`` or ``--global`` to use a global variable. -- ``-U`` or ``--universal`` to use a universal variable (default). +In addition, when adding or renaming abbreviations, one of the following **SCOPE** options can be used: + +**-g** or **--global** + Use a global variable + +**-U** or **--universal** + Use a universal variable (default) See the "Internals" section for more on them. Examples -------- - - :: abbr -a -g gco git checkout -Add a new abbreviation where ``gco`` will be replaced with ``git checkout`` global to the current shell. This abbreviation will not be automatically visible to other shells unless the same command is run in those shells (such as when executing the commands in config.fish). - - +Add a new abbreviation where ``gco`` will be replaced with ``git checkout`` global to the current shell. +This abbreviation will not be automatically visible to other shells unless the same command is run in those shells (such as when executing the commands in config.fish). :: abbr -a -U l less -Add a new abbreviation where ``l`` will be replaced with ``less`` universal to all shells. Note that you omit the ``-U`` since it is the default. - - +Add a new abbreviation where ``l`` will be replaced with ``less`` universal to all shells. +Note that you omit the **-U** since it is the default. :: @@ -73,16 +82,12 @@ Add a new abbreviation where ``l`` will be replaced with ``less`` universal to a Renames an existing abbreviation from ``gco`` to ``gch``. - - :: abbr -e gco Erase the ``gco`` abbreviation. - - :: ssh another_host abbr -s | source @@ -91,20 +96,8 @@ Import the abbreviations defined on another_host over SSH. Internals --------- -Each abbreviation is stored in its own global or universal variable. The name consists of the prefix ``_fish_abbr_`` followed by the WORD after being transformed by ``string escape style=var``. The WORD cannot contain a space but all other characters are legal. +Each abbreviation is stored in its own global or universal variable. +The name consists of the prefix ``_fish_abbr_`` followed by the WORD after being transformed by ``string escape style=var``. +The WORD cannot contain a space but all other characters are legal. -Defining an abbreviation with global scope is slightly faster than universal scope (which is the default). But in general you'll only want to use the global scope when defining abbreviations in a startup script like ``~/.config/fish/config.fish`` like this: - - - -:: - - if status --is-interactive - abbr --add --global first 'echo my first abbreviation' - abbr --add --global second 'echo my second abbreviation' - abbr --add --global gco git checkout - # etcetera - end - - -You can create abbreviations interactively and they will be visible to other fish sessions if you use the ``-U`` or ``--universal`` flag or don't explicitly specify the scope and the abbreviation isn't already defined with global scope. If you want it to be visible only to the current shell use the ``-g`` or ``--global`` flag. +Abbreviations created with the **--universal** flag will be visible to other fish sessions, whilst **--global** will be limited to the current session. diff --git a/doc_src/cmds/alias.rst b/doc_src/cmds/alias.rst index b97b8c0cc..000b29004 100644 --- a/doc_src/cmds/alias.rst +++ b/doc_src/cmds/alias.rst @@ -6,11 +6,11 @@ alias - create a function Synopsis -------- -:: +.. synopsis:: alias - alias [OPTIONS] NAME DEFINITION - alias [OPTIONS] NAME=DEFINITION + alias [--save] NAME DEFINITION + alias [--save] NAME=DEFINITION Description @@ -21,23 +21,23 @@ Description ``fish`` marks functions that have been created by ``alias`` by including the command used to create them in the function description. You can list ``alias``-created functions by running ``alias`` without arguments. They must be erased using ``functions -e``. - ``NAME`` is the name of the alias -- ``DEFINITION`` is the actual command to execute. The string ``$argv`` will be appended. +- ``DEFINITION`` is the actual command to execute. ``alias`` automatically appends ``$argv``, so that all parameters used with the alias are passed to the actual command. You cannot create an alias to a function with the same name. Note that spaces need to be escaped in the call to ``alias`` just like at the command line, *even inside quoted parts*. The following options are available: -- ``-h`` or ``--help`` displays help about using this command. +**-h** or **--help** + Displays help about using this command. -- ``-s`` or ``--save`` Automatically save the function created by the alias into your fish configuration directory using :ref:`funcsave `. +**-s** or **--save** + Saves the function created by the alias into your fish configuration directory using :ref:`funcsave `. Example ------- The following code will create ``rmi``, which runs ``rm`` with additional arguments on every invocation. - - :: alias rmi="rm -i" @@ -55,6 +55,6 @@ The following code will create ``rmi``, which runs ``rm`` with additional argume See more -------- -1. The :ref:`function ` builtin this builds on. +1. The :ref:`function ` command this builds on. 2. :ref:`Functions `. 3. :ref:`Function wrappers `. diff --git a/doc_src/cmds/and.rst b/doc_src/cmds/and.rst index 5e3a3c18c..1b5b477b4 100644 --- a/doc_src/cmds/and.rst +++ b/doc_src/cmds/and.rst @@ -6,9 +6,9 @@ and - conditionally execute a command Synopsis -------- -:: +.. synopsis:: - COMMAND1; and COMMAND2 + PREVIOUS; and COMMAND Description ----------- @@ -19,6 +19,8 @@ Description ``and`` does not change the current exit status itself, but the command it runs most likely will. The exit status of the last foreground command to exit can always be accessed using the :ref:`$status ` variable. +The **-h** or **--help** option displays help about using this command. + Example ------- @@ -32,3 +34,4 @@ See Also -------- - :ref:`or ` command +- :ref:`not ` command diff --git a/doc_src/cmds/argparse.rst b/doc_src/cmds/argparse.rst index f7547bdcf..49c148266 100644 --- a/doc_src/cmds/argparse.rst +++ b/doc_src/cmds/argparse.rst @@ -6,54 +6,60 @@ argparse - parse options passed to a fish script or function Synopsis -------- -:: +.. synopsis:: - argparse [OPTIONS] OPTION_SPEC... -- [ARG...] + argparse [OPTIONS] OPTION_SPEC ... -- [ARG ...] Description ----------- -This command makes it easy for fish scripts and functions to handle arguments like how fish builtin commands handle their arguments. You pass arguments that define the known options, followed by a literal ``--``, then the arguments to be parsed (which might also include a literal ``--``). ``argparse`` then sets variables to indicate the passed options with their values, and sets $argv (and always $argv) to the remaining arguments. More on this in the :ref:`usage ` section below. +This command makes it easy for fish scripts and functions to handle arguments. You pass arguments that define the known options, followed by a literal **--**, then the arguments to be parsed (which might also include a literal **--**). ``argparse`` then sets variables to indicate the passed options with their values, and sets ``$argv`` to the remaining arguments. See the :ref:`usage ` section below. Each option specification (``OPTION_SPEC``) is written in the :ref:`domain specific language ` described below. All OPTION_SPECs must appear after any argparse flags and before the ``--`` that separates them from the arguments to be parsed. -Each option that is seen in the ARG list will result in variables named ``_flag_X``, where ``X`` is the short flag letter and the long flag name (if they are defined). For example a ``--help`` option could cause argparse to define one variable called ``_flag_h`` and another called ``_flag_help``. +Each option that is seen in the ARG list will result in variables named ``_flag_X``, where **X** is the short flag letter and the long flag name (if they are defined). For example a **--help** option could cause argparse to define one variable called ``_flag_h`` and another called ``_flag_help``. The variables will be set with local scope (i.e., as if the script had done ``set -l _flag_X``). If the flag is a boolean (that is, it just is passed or not, it doesn't have a value) the values are the short and long flags seen. If the option is not a boolean the values will be zero or more values corresponding to the values collected when the ARG list is processed. If the flag was not seen the flag variable will not be set. Options ------- -The following ``argparse`` options are available. They must appear before all OPTION_SPECs: +The following ``argparse`` options are available. They must appear before all *OPTION_SPEC*\ s: -- ``-n`` or ``--name`` is the command name for use in error messages. By default the current function name will be used, or ``argparse`` if run outside of a function. +**-n** or **--name** + The command name for use in error messages. By default the current function name will be used, or ``argparse`` if run outside of a function. -- ``-x`` or ``--exclusive`` should be followed by a comma separated list of short or long options that are mutually exclusive. You can use this more than once to define multiple sets of mutually exclusive options. +**-x** or **--exclusive** *OPTIONS* + A comma separated list of options that are mutually exclusive. You can use this more than once to define multiple sets of mutually exclusive options. -- ``-N`` or ``--min-args`` is followed by an integer that defines the minimum number of acceptable non-option arguments. The default is zero. +**-N** or **--min-args** *NUMBER* + The minimum number of acceptable non-option arguments. The default is zero. -- ``-X`` or ``--max-args`` is followed by an integer that defines the maximum number of acceptable non-option arguments. The default is infinity. +**-X** or **--max-args** *NUMBER* + The maximum number of acceptable non-option arguments. The default is infinity. -- ``-i`` or ``--ignore-unknown`` ignores unknown options, keeping them and their arguments in $argv instead. +**-i** or **--ignore-unknown** + Ignores unknown options, keeping them and their arguments in $argv instead. -- ``-s`` or ``--stop-nonopt`` causes scanning the arguments to stop as soon as the first non-option argument is seen. Among other things, this is useful to implement subcommands that have their own options. +**-s** or **--stop-nonopt** + Causes scanning the arguments to stop as soon as the first non-option argument is seen. Among other things, this is useful to implement subcommands that have their own options. -- ``-h`` or ``--help`` displays help about using this command. +**-h** or **--help** + Displays help about using this command. .. _cmd-argparse-usage: Usage ----- -To use this command, pass the option specifications (``OPTION_SPEC``), then a mandatory ``--``, and then the arguments you want to have parsed. +To use this command, pass the option specifications (**OPTION_SPEC**), a mandatory **--**, and then the arguments to be parsed. A simple example:: argparse --name=my_function 'h/help' 'n/name=' -- $argv or return - If ``$argv`` is empty then there is nothing to parse and ``argparse`` returns zero to indicate success. If ``$argv`` is not empty then it is checked for flags ``-h``, ``--help``, ``-n`` and ``--name``. If they are found they are removed from the arguments and local variables called ``_flag_OPTION`` are set so the script can determine which options were seen. If ``$argv`` doesn't have any errors, like a missing mandatory value for an option, then ``argparse`` exits with a status of zero. Otherwise it writes appropriate error messages to stderr and exits with a status of one. The ``or return`` means that the function returns ``argparse``'s status if it failed, so if it goes on ``argparse`` succeeded. @@ -63,7 +69,6 @@ The ``--`` argument is required. You do not have to include any arguments after set -l argv argparse 'h/help' 'n/name' -- $argv - But this is not:: set -l argv @@ -78,17 +83,17 @@ Option Specifications Each option specification consists of: -- An optional alphanumeric short flag letter, followed by a ``/`` if the short flag can be used by someone invoking your command or, for backwards compatibility, a ``-`` if it should not be exposed as a valid short flag (in which case it will also not be exposed as a flag variable). +- An optional alphanumeric short flag character, followed by a ``/`` if the short flag can be used by someone invoking your command or, for backwards compatibility, a ``-`` if it should not be exposed as a valid short flag (in which case it will also not be exposed as a flag variable). -- An optional long flag name. If not present then only the short flag letter can be used, and if that is not present either it's an error. +- An optional long flag name, which if not present the short flag can be used, and if that is also not present, an error is reported - Nothing if the flag is a boolean that takes no argument or is an integer flag, or -- ``=`` if it requires a value and only the last instance of the flag is saved, or + - **=** if it requires a value and only the last instance of the flag is saved, or -- ``=?`` it takes an optional value and only the last instance of the flag is saved, or + - **=?** if it takes an optional value and only the last instance of the flag is saved, or -- ``=+`` if it requires a value and each instance of the flag is saved. + - **=+** if it requires a value and each instance of the flag is saved. - Optionally a ``!`` followed by fish script to validate the value. Typically this will be a function to run. If the exit status is zero the value for the flag is valid. If non-zero the value is invalid. Any error messages should be written to stdout (not stderr). See the section on :ref:`Flag Value Validation ` for more information. @@ -160,7 +165,7 @@ Fish ships with a ``_validate_int`` function that accepts a ``--min`` and ``--ma Example OPTION_SPECs -------------------- -Some OPTION_SPEC examples: +Some *OPTION_SPEC* examples: - ``h/help`` means that both ``-h`` and ``--help`` are valid. The flag is a boolean and can be used more than once. If either flag is used then ``_flag_h`` and ``_flag_help`` will be set to the count of how many times either flag was seen. @@ -187,3 +192,18 @@ Some OPTION_SPEC examples: After parsing the arguments the ``argv`` variable is set with local scope to any values not already consumed during flag processing. If there are no unbound values the variable is set but ``count $argv`` will be zero. If an error occurs during argparse processing it will exit with a non-zero status and print error messages to stderr. + +Limitations +----------- + +One limitation with **--ignore-unknown** is that, if an unknown option is given in a group with known options, the entire group will be kept in $argv. ``argparse`` will not do any permutations here. + +For instance:: + + argparse --ignore-unknown h -- -ho + echo $_flag_h # is -h, because -h was given + echo $argv # is still -ho + +This limitation may be lifted in future. + +Additionally, it can only parse known options up to the first unknown option in the group - the unknown option could take options, so it isn't clear what any character after an unknown option means. diff --git a/doc_src/cmds/begin.rst b/doc_src/cmds/begin.rst index 542e00294..668d99de2 100644 --- a/doc_src/cmds/begin.rst +++ b/doc_src/cmds/begin.rst @@ -6,30 +6,28 @@ begin - start a new block of code Synopsis -------- -:: - - begin; [COMMANDS...;] end +.. synopsis:: + begin; [COMMANDS ...]; end Description ----------- ``begin`` is used to create a new block of code. -A block allows the introduction of a new variable scope, redirection of the input or output of a set of commands as a group, or to specify precedence when using the conditional commands like ``and``. +A block allows the introduction of a new :ref:`variable scope `, redirection of the input or output of a set of commands as a group, or to specify precedence when using the conditional commands like ``and``. The block is unconditionally executed. ``begin; ...; end`` is equivalent to ``if true; ...; end``. ``begin`` does not change the current exit status itself. After the block has completed, ``$status`` will be set to the status returned by the most recent command. +The **-h** or **--help** option displays help about using this command. Example ------- The following code sets a number of variables inside of a block scope. Since the variables are set inside the block and have local scope, they will be automatically deleted when the block ends. - - :: begin @@ -45,8 +43,6 @@ The following code sets a number of variables inside of a block scope. Since the In the following code, all output is redirected to the file out.html. - - :: begin @@ -57,4 +53,3 @@ In the following code, all output is redirected to the file out.html. end ... end > out.html - diff --git a/doc_src/cmds/bg.rst b/doc_src/cmds/bg.rst index fc7550285..b84ac2cc8 100644 --- a/doc_src/cmds/bg.rst +++ b/doc_src/cmds/bg.rst @@ -6,9 +6,9 @@ bg - send jobs to background Synopsis -------- -:: +.. synopsis:: - bg [PID...] + bg [PID ...] Description ----------- @@ -24,6 +24,8 @@ When at least one of the arguments isn't a valid job specifier, When all arguments are valid job specifiers, ``bg`` will background all matching jobs that exist. +The **-h** or **--help** option displays help about using this command. + Example ------- diff --git a/doc_src/cmds/bind.rst b/doc_src/cmds/bind.rst index 7db572e5a..37970a07b 100644 --- a/doc_src/cmds/bind.rst +++ b/doc_src/cmds/bind.rst @@ -5,14 +5,14 @@ bind - handle fish key bindings Synopsis -------- -:: +.. synopsis:: - bind [(-M | --mode) MODE] [(-m | --sets-mode) NEW_MODE] [--preset | --user] [(-s | --silent)] [(-k | --key)] SEQUENCE COMMAND [COMMAND...] - bind [(-M | --mode) MODE] [(-k | --key)] [--preset] [--user] SEQUENCE - bind (-K | --key-names) [(-a | --all)] [--preset] [--user] + bind [(-M | --mode) MODE] [(-m | --sets-mode) NEW_MODE] [--preset | --user] [-s | --silent] [-k | --key] SEQUENCE COMMAND ... + bind [(-M | --mode) MODE] [-k | --key] [--preset] [--user] SEQUENCE + bind (-K | --key-names) [-a | --all] [--preset] [--user] bind (-f | --function-names) bind (-L | --list-modes) - bind (-e | --erase) [(-M | --mode) MODE] [--preset] [--user] (-a | --all | [(-k | --key)] SEQUENCE [SEQUENCE...]) + bind (-e | --erase) [(-M | --mode) MODE] [--preset] [--user] [-a | --all] | [-k | --key] SEQUENCE ... Description ----------- @@ -47,179 +47,279 @@ Options ------- The following options are available: -- ``-k`` or ``--key`` Specify a key name, such as 'left' or 'backspace' instead of a character sequence +**-k** or **--key** + Specify a key name, such as 'left' or 'backspace' instead of a character sequence -- ``-K`` or ``--key-names`` Display a list of available key names. Specifying ``-a`` or ``--all`` includes keys that don't have a known mapping +**-K** or **--key-names** + Display a list of available key names. Specifying **-a** or **--all** includes keys that don't have a known mapping -- ``-f`` or ``--function-names`` Display a list of available input functions +**-f** or **--function-names** + Display a list of available input functions -- ``-L`` or ``--list-modes`` Display a list of defined bind modes +**-L** or **--list-modes** + Display a list of defined bind modes -- ``-M MODE`` or ``--mode MODE`` Specify a bind mode that the bind is used in. Defaults to "default" +**-M MODE** or **--mode** *MODE* + Specify a bind mode that the bind is used in. Defaults to "default" -- ``-m NEW_MODE`` or ``--sets-mode NEW_MODE`` Change the current mode to ``NEW_MODE`` after this binding is executed +**-m NEW_MODE** or **--sets-mode** *NEW_MODE* + Change the current mode to *NEW_MODE* after this binding is executed -- ``-e`` or ``--erase`` Erase the binding with the given sequence and mode instead of defining a new one. Multiple sequences can be specified with this flag. Specifying ``-a`` or ``--all`` with ``-M`` or ``--mode`` erases all binds in the given mode regardless of sequence. Specifying ``-a`` or ``--all`` without ``-M`` or ``--mode`` erases all binds in all modes regardless of sequence. +**-e** or **--erase** + Erase the binding with the given sequence and mode instead of defining a new one. + Multiple sequences can be specified with this flag. + Specifying **-a** or **--all** with **-M** or **--mode** erases all binds in the given mode regardless of sequence. + Specifying **-a** or **--all** without **-M** or **--mode** erases all binds in all modes regardless of sequence. -- ``-a`` or ``--all`` See ``--erase`` and ``--key-names`` +**-a** or **--all** + See **--erase** and **--key-names** -- ``--preset`` and ``--user`` specify if bind should operate on user or preset bindings. User bindings take precedence over preset bindings when fish looks up mappings. By default, all ``bind`` invocations work on the "user" level except for listing, which will show both levels. All invocations except for inserting new bindings can operate on both levels at the same time (if both ``--preset`` and ``--user`` are given). ``--preset`` should only be used in full binding sets (like when working on ``fish_vi_key_bindings``). +**--preset** and **--user** + Specify if bind should operate on user or preset bindings. + User bindings take precedence over preset bindings when fish looks up mappings. + By default, all ``bind`` invocations work on the "user" level except for listing, which will show both levels. + All invocations except for inserting new bindings can operate on both levels at the same time (if both **--preset** and **--user** are given). + **--preset** should only be used in full binding sets (like when working on ``fish_vi_key_bindings``). + +**-h** or **--help** + Displays help about using this command. Special input functions ----------------------- The following special input functions are available: -- ``and``, only execute the next function if the previous succeeded (note: only some functions report success) +``and`` + only execute the next function if the previous succeeded (note: only some functions report success) -- ``accept-autosuggestion``, accept the current autosuggestion completely +``accept-autosuggestion`` + accept the current autosuggestion -- ``backward-char``, moves one character to the left +``backward-char`` + move one character to the left. + If the completion pager is active, select the previous completion instead. -- ``backward-bigword``, move one whitespace-delimited word to the left +``backward-bigword`` + move one whitespace-delimited word to the left -- ``backward-delete-char``, deletes one character of input to the left of the cursor +``backward-delete-char`` + deletes one character of input to the left of the cursor -- ``backward-kill-bigword``, move the whitespace-delimited word to the left of the cursor to the killring +``backward-kill-bigword`` + move the whitespace-delimited word to the left of the cursor to the killring -- ``backward-kill-line``, move everything from the beginning of the line to the cursor to the killring +``backward-kill-line`` + move everything from the beginning of the line to the cursor to the killring -- ``backward-kill-path-component``, move one path component to the left of the cursor to the killring. A path component is everything likely to belong to a path component, i.e. not any of the following: `/={,}'\":@ |;<>&`, plus newlines and tabs. +``backward-kill-path-component`` + move one path component to the left of the cursor to the killring. A path component is everything likely to belong to a path component, i.e. not any of the following: `/={,}'\":@ |;<>&`, plus newlines and tabs. -- ``backward-kill-word``, move the word to the left of the cursor to the killring. The "word" here is everything up to punctuation or whitespace. +``backward-kill-word`` + move the word to the left of the cursor to the killring. The "word" here is everything up to punctuation or whitespace. -- ``backward-word``, move one word to the left +``backward-word`` + move one word to the left -- ``beginning-of-buffer``, moves to the beginning of the buffer, i.e. the start of the first line +``beginning-of-buffer`` + moves to the beginning of the buffer, i.e. the start of the first line -- ``beginning-of-history``, move to the beginning of the history +``beginning-of-history`` + move to the beginning of the history -- ``beginning-of-line``, move to the beginning of the line +``beginning-of-line`` + move to the beginning of the line -- ``begin-selection``, start selecting text +``begin-selection`` + start selecting text -- ``cancel``, cancel the current commandline and replace it with a new empty one +``cancel`` + cancel the current commandline and replace it with a new empty one -- ``cancel-commandline``, cancel the current commandline and replace it with a new empty one, leaving the old one in place with a marker to show that it was cancelled +``cancel-commandline`` + cancel the current commandline and replace it with a new empty one, leaving the old one in place with a marker to show that it was cancelled -- ``capitalize-word``, make the current word begin with a capital letter +``capitalize-word`` + make the current word begin with a capital letter -- ``complete``, guess the remainder of the current token +``complete`` + guess the remainder of the current token -- ``complete-and-search``, invoke the searchable pager on completion options (for convenience, this also moves backwards in the completion pager) +``complete-and-search`` + invoke the searchable pager on completion options (for convenience, this also moves backwards in the completion pager) -- ``delete-char``, delete one character to the right of the cursor +``delete-char`` + delete one character to the right of the cursor -- ``delete-or-exit``, deletes one character to the right of the cursor or exits the shell if the commandline is empty. +``delete-or-exit`` + delete one character to the right of the cursor, or exit the shell if the commandline is empty -- ``down-line``, move down one line +``down-line`` + move down one line -- ``downcase-word``, make the current word lowercase +``downcase-word`` + make the current word lowercase -- ``end-of-buffer``, moves to the end of the buffer, i.e. the end of the first line +``end-of-buffer`` + moves to the end of the buffer, i.e. the end of the first line -- ``end-of-history``, move to the end of the history +``end-of-history`` + move to the end of the history -- ``end-of-line``, move to the end of the line +``end-of-line`` + move to the end of the line -- ``end-selection``, end selecting text +``end-selection`` + end selecting text -- ``expand-abbr``, expands any abbreviation currently under the cursor +``expand-abbr`` + expands any abbreviation currently under the cursor -- ``execute``, run the current commandline +``execute`` + run the current commandline -- ``exit``, exit the shell +``exit`` + exit the shell -- ``forward-bigword``, move one whitespace-delimited word to the right +``forward-bigword`` + move one whitespace-delimited word to the right -- ``forward-char``, move one character to the right +``forward-char`` + move one character to the right; or if at the end of the commandline, accept the current autosuggestion. + If the completion pager is active, select the next completion instead. -- ``forward-single-char``, move one character to the right; if an autosuggestion is available, only take a single char from it +``forward-single-char`` + move one character to the right; or if at the end of the commandline, accept a single char from the current autosuggestion. -- ``forward-word``, move one word to the right +``forward-word`` + move one word to the right; or if at the end of the commandline, accept one word + from the current autosuggestion. -- ``history-search-backward``, search the history for the previous match +``history-search-backward`` + search the history for the previous match -- ``history-search-forward``, search the history for the next match +``history-search-forward`` + search the history for the next match -- ``history-prefix-search-backward``, search the history for the previous prefix match +``history-prefix-search-backward`` + search the history for the previous prefix match -- ``history-prefix-search-forward``, search the history for the next prefix match +``history-prefix-search-forward`` + search the history for the next prefix match -- ``history-token-search-backward``, search the history for the previous matching argument +``history-token-search-backward`` + search the history for the previous matching argument -- ``history-token-search-forward``, search the history for the next matching argument +``history-token-search-forward`` + search the history for the next matching argument -- ``forward-jump`` and ``backward-jump``, read another character and jump to its next occurence after/before the cursor +``forward-jump`` and ``backward-jump`` + read another character and jump to its next occurence after/before the cursor -- ``forward-jump-till`` and ``backward-jump-till``, jump to right *before* the next occurence +``forward-jump-till`` and ``backward-jump-till`` + jump to right *before* the next occurence -- ``repeat-jump`` and ``repeat-jump-reverse``, redo the last jump in the same/opposite direction +``repeat-jump`` and ``repeat-jump-reverse`` + redo the last jump in the same/opposite direction -- ``kill-bigword``, move the next whitespace-delimited word to the killring +``kill-bigword`` + move the next whitespace-delimited word to the killring -- ``kill-line``, move everything from the cursor to the end of the line to the killring +``kill-line`` + move everything from the cursor to the end of the line to the killring -- ``kill-selection``, move the selected text to the killring +``kill-selection`` + move the selected text to the killring -- ``kill-whole-line``, move the line to the killring +``kill-whole-line`` + move the line to the killring -- ``kill-word``, move the next word to the killring +``kill-word`` + move the next word to the killring -- ``or``, only execute the next function if the previous succeeded (note: only some functions report success) +``nextd-or-forward-word`` + if the commandline is empty, then move forward in the directory history, otherwise move one word to the right; + or if at the end of the commandline, accept one word from the current autosuggestion. -- ``pager-toggle-search``, toggles the search field if the completions pager is visible. +``or`` + only execute the next function if the previous succeeded (note: only some functions report success) -- ``repaint``, reexecutes the prompt functions and redraws the prompt (also ``force-repaint`` for backwards-compatibility) +``pager-toggle-search`` + toggles the search field if the completions pager is visible. -- ``repaint-mode``, reexecutes the :ref:`fish_mode_prompt ` and redraws the prompt. This is useful for vi-mode. If no ``fish_mode_prompt`` exists or it prints nothing, it acts like a normal repaint. +``prevd-or-backward-word`` + if the commandline is empty, then move backward in the directory history, otherwise move one word to the left -- ``self-insert``, inserts the matching sequence into the command line +``repaint`` + reexecutes the prompt functions and redraws the prompt (also ``force-repaint`` for backwards-compatibility) -- ``self-insert-notfirst``, inserts the matching sequence into the command line, unless the cursor is at the beginning +``repaint-mode`` + reexecutes the :ref:`fish_mode_prompt ` and redraws the prompt. This is useful for vi-mode. If no ``fish_mode_prompt`` exists or it prints nothing, it acts like a normal repaint. -- ``suppress-autosuggestion``, remove the current autosuggestion. Returns true if there was a suggestion to remove. +``self-insert`` + inserts the matching sequence into the command line -- ``swap-selection-start-stop``, go to the other end of the highlighted text without changing the selection +``self-insert-notfirst`` + inserts the matching sequence into the command line, unless the cursor is at the beginning -- ``transpose-chars``, transpose two characters to the left of the cursor +``suppress-autosuggestion`` + remove the current autosuggestion. Returns true if there was a suggestion to remove. -- ``transpose-words``, transpose two words to the left of the cursor +``swap-selection-start-stop`` + go to the other end of the highlighted text without changing the selection -- ``togglecase-char``, toggle the capitalisation (case) of the character under the cursor +``transpose-chars`` + transpose two characters to the left of the cursor -- ``togglecase-selection``, toggle the capitalisation (case) of the selection +``transpose-words`` + transpose two words to the left of the cursor -- ``insert-line-under``, add a new line under the current line +``togglecase-char`` + toggle the capitalisation (case) of the character under the cursor -- ``insert-line-over``, add a new line over the current line +``togglecase-selection`` + toggle the capitalisation (case) of the selection -- ``up-line``, move up one line +``insert-line-under`` + add a new line under the current line -- ``undo`` and ``redo``, revert or redo the most recent edits on the command line +``insert-line-over`` + add a new line over the current line -- ``upcase-word``, make the current word uppercase +``up-line`` + move up one line -- ``yank``, insert the latest entry of the killring into the buffer +``undo`` and ``redo`` + revert or redo the most recent edits on the command line -- ``yank-pop``, rotate to the previous entry of the killring +``upcase-word`` + make the current word uppercase + +``yank`` + insert the latest entry of the killring into the buffer + +``yank-pop`` + rotate to the previous entry of the killring Additional functions -------------------- The following functions are included as normal functions, but are particularly useful for input editing: -- ``up-or-search`` and ``down-or-search``, which move the cursor or search the history depending on the cursor position and current mode +``up-or-search`` and ``down-or-search`` + move the cursor or search the history depending on the cursor position and current mode -- ``edit_command_buffer``, open the visual editor (controlled by the ``VISUAL`` or ``EDITOR`` environment variables) with the current command-line contents +``edit_command_buffer`` + open the visual editor (controlled by the :envvar:`VISUAL` or :envvar:`EDITOR` environment variables) with the current command-line contents -- ``delete-or-exit``, quit the shell if the current command-line is empty, or delete the character under the cursor if not +``fish_clipboard_copy`` + copy the current selection to the system clipboard -- ``fish_clipboard_copy``, copy the current selection to the system clipboard +``fish_clipboard_paste`` + paste the current selection from the system clipboard before the cursor -- ``fish_clipboard_paste``, paste the current selection from the system clipboard before the cursor +``fish_commandline_append`` + append the argument to the command-line. If the command-line already ends with the argument, this removes the suffix instead. Starts with the last command from history if the command-line is empty. -- ``fish_commandline_append``, append the argument to the command-line. If the command-line already ends with the argument, this removes the suffix instead. Starts with the last command from history if the command-line is empty. - -- ``fish_commandline_prepend``, prepend the argument to the command-line. If the command-line already starts with the argument, this removes the prefix instead. Starts with the last command from history if the command-line is empty. +``fish_commandline_prepend`` + prepend the argument to the command-line. If the command-line already starts with the argument, this removes the prefix instead. Starts with the last command from history if the command-line is empty. Examples -------- diff --git a/doc_src/cmds/block.rst b/doc_src/cmds/block.rst index b813ef8b2..cc01cf525 100644 --- a/doc_src/cmds/block.rst +++ b/doc_src/cmds/block.rst @@ -6,10 +6,10 @@ block - temporarily block delivery of events Synopsis -------- -:: - - block [OPTIONS...] +.. synopsis:: + block [(--local | --global)] + block --erase Description ----------- @@ -22,18 +22,24 @@ The block can be removed. Any events which triggered while the block was in plac Event blocks should not be confused with code blocks, which are created with ``begin``, ``if``, ``while`` or ``for`` -The following parameters are available: +Without options, the ``block`` command acts with function scope. -- ``-l`` or ``--local`` Release the block automatically at the end of the current innermost code block scope +The following options are available: -- ``-g`` or ``--global`` Never automatically release the lock +**-l** or **--local** + Release the block automatically at the end of the current innermost code block scope. -- ``-e`` or ``--erase`` Release global block +**-g** or **--global** + Never automatically release the lock. +**-e** or **--erase** + Release global block. + +**-h** or **--help** + Displays help about using this command. Example ------- - :: # Create a function that listens for events @@ -48,8 +54,7 @@ Example block -e # 'foo fired' will now be printed - Notes ----- -Note that events are only received from the current fish process as there is no way to send events from one fish process to another. +Events are only received from the current fish process as there is no way to send events from one fish process to another (yet). diff --git a/doc_src/cmds/break.rst b/doc_src/cmds/break.rst index d95f20805..7049bec75 100644 --- a/doc_src/cmds/break.rst +++ b/doc_src/cmds/break.rst @@ -6,19 +6,21 @@ break - stop the current inner loop Synopsis -------- -:: - - LOOP_CONSTRUCT; [COMMANDS...] break; [COMMANDS...] end +.. synopsis:: + LOOP_CONSTRUCT + [COMMANDS ...] + break + [COMMANDS ...] + end Description ----------- -``break`` halts a currently running loop, such as a :ref:`switch `, :ref:`for ` or :ref:`while ` loop. It is usually added inside of a conditional block such as an :ref:`if ` block. +``break`` halts a currently running loop (*LOOP_CONSTRUCT*), such as a :ref:`switch `, :ref:`for ` or :ref:`while ` loop. It is usually added inside of a conditional block such as an :ref:`if ` block. There are no parameters for ``break``. - Example ------- The following code searches all .c files for "smurf", and halts at the first occurrence. diff --git a/doc_src/cmds/breakpoint.rst b/doc_src/cmds/breakpoint.rst index b81923d21..48c225e5f 100644 --- a/doc_src/cmds/breakpoint.rst +++ b/doc_src/cmds/breakpoint.rst @@ -6,11 +6,10 @@ breakpoint - launch debug mode Synopsis -------- -:: +.. synopsis:: breakpoint - Description ----------- diff --git a/doc_src/cmds/builtin.rst b/doc_src/cmds/builtin.rst index b802ac61a..48cce29ab 100644 --- a/doc_src/cmds/builtin.rst +++ b/doc_src/cmds/builtin.rst @@ -6,27 +6,31 @@ builtin - run a builtin command Synopsis -------- -:: +.. synopsis:: - builtin [OPTIONS...] BUILTINNAME - builtin --query BUILTINNAMES... + builtin [OPTIONS] BUILTINNAME + builtin --query BUILTINNAME ... + builtin --names Description ----------- -``builtin`` forces the shell to use a builtin command, rather than a function or program. +``builtin`` forces the shell to use a builtin command named *BUILTIN*, rather than a function or external program. -The following parameters are available: +The following options are available: -- ``-n`` or ``--names`` List the names of all defined builtins -- ``-q`` or ``--query`` tests if any of the specified builtins exists +**-n** or **--names** + Lists the names of all defined builtins. +**-q** or **--query** *BUILTIN* + Tests if any of the specified builtins exist. + +**-h** or **--help** + Displays help about using this command. Example ------- - - :: builtin jobs diff --git a/doc_src/cmds/case.rst b/doc_src/cmds/case.rst index 155022c6b..e971108b8 100644 --- a/doc_src/cmds/case.rst +++ b/doc_src/cmds/case.rst @@ -6,9 +6,12 @@ case - conditionally execute a block of commands Synopsis -------- -:: +.. synopsis:: - switch VALUE; [case [WILDCARD...]; [COMMANDS...]; ...] end + switch VALUE + [case [GLOB ...] + [COMMAND ...]] + end Description ----------- diff --git a/doc_src/cmds/cd.rst b/doc_src/cmds/cd.rst index 09831cec7..e26032816 100644 --- a/doc_src/cmds/cd.rst +++ b/doc_src/cmds/cd.rst @@ -6,7 +6,7 @@ cd - change directory Synopsis -------- -:: +.. synopsis:: cd [DIRECTORY] @@ -14,16 +14,22 @@ Description ----------- ``cd`` changes the current working directory. -If ``DIRECTORY`` is given, it will become the new directory. If no parameter is given, the ``$HOME`` environment variable will be used. +If *DIRECTORY* is given, it will become the new directory. If no parameter is given, the :envvar:`HOME` environment variable will be used. -If ``DIRECTORY`` is a relative path, all the paths in the ``$CDPATH`` will be tried as prefixes for it, in addition to ``$PWD``. It is recommended to keep ``.`` as the first element of ``$CDPATH``, or ``$PWD`` will be tried last. +If *DIRECTORY* is a relative path, all the paths in the :envvar:`CDPATH` will be tried as prefixes for it, in addition to :envvar:`PWD`. +It is recommended to keep **.** as the first element of :envvar:`CDPATH`, or :envvar:`PWD` will be tried last. -Fish will also try to change directory if given a command that looks like a directory (starting with ``.``, ``/`` or ``~``, or ending with ``/``), without explicitly requiring ``cd``. +Fish will also try to change directory if given a command that looks like a directory (starting with **.**, **/** or **~**, or ending with **/**), without explicitly requiring **cd**. -Fish also ships a wrapper function around the builtin ``cd`` that understands ``cd -`` as changing to the previous directory. See also :ref:`prevd `. This wrapper function maintains a history of the 25 most recently visited directories in the ``$dirprev`` and ``$dirnext`` global variables. If you make those universal variables your ``cd`` history is shared among all fish instances. +Fish also ships a wrapper function around the builtin **cd** that understands ``cd -`` as changing to the previous directory. +See also :ref:`prevd `. +This wrapper function maintains a history of the 25 most recently visited directories in the ``$dirprev`` and ``$dirnext`` global variables. +If you make those universal variables your **cd** history is shared among all fish instances. As a special case, ``cd .`` is equivalent to ``cd $PWD``, which is useful in cases where a mountpoint has been recycled or a directory has been removed and recreated. +The **--help** or **-h** option displays help about using this command, and does not change the directory. + Examples -------- diff --git a/doc_src/cmds/cdh.rst b/doc_src/cmds/cdh.rst index 8c9a4d7de..b6ee6c089 100644 --- a/doc_src/cmds/cdh.rst +++ b/doc_src/cmds/cdh.rst @@ -6,16 +6,21 @@ cdh - change to a recently visited directory Synopsis -------- -:: +.. synopsis:: - cdh [ directory ] + cdh [DIRECTORY] Description ----------- -``cdh`` with no arguments presents a list of :ref:`recently visited directories `. You can then select one of the entries by letter or number. You can also press :kbd:`Tab` to use the completion pager to select an item from the list. If you give it a single argument it is equivalent to ``cd directory``. +``cdh`` with no arguments presents a list of :ref:`recently visited directories `. +You can then select one of the entries by letter or number. +You can also press :kbd:`Tab` to use the completion pager to select an item from the list. +If you give it a single argument it is equivalent to ``cd DIRECTORY``. -Note that the ``cd`` command limits directory history to the 25 most recently visited directories. The history is stored in the ``$dirprev`` and ``$dirnext`` variables which this command manipulates. If you make those universal variables your ``cd`` history is shared among all fish instances. +Note that the ``cd`` command limits directory history to the 25 most recently visited directories. +The history is stored in the :envvar:`dirprev` and :envvar:`$dirnext` variables, which this command manipulates. +If you make those universal variables, your ``cd`` history is shared among all fish instances. See Also -------- diff --git a/doc_src/cmds/command.rst b/doc_src/cmds/command.rst index 7e1368dd2..24f6147a4 100644 --- a/doc_src/cmds/command.rst +++ b/doc_src/cmds/command.rst @@ -6,32 +6,36 @@ command - run a program Synopsis -------- -:: +.. synopsis:: - command [OPTIONS] COMMANDNAME [ARGS...] + command [OPTIONS] [COMMANDNAME [ARG ...]] Description ----------- -``command`` forces the shell to execute the program ``COMMANDNAME`` and ignore any functions or builtins with the same name. +**command** forces the shell to execute the program *COMMANDNAME* and ignore any functions or builtins with the same name. The following options are available: -- ``-a`` or ``--all`` returns all the external COMMANDNAMEs that are found in ``$PATH`` in the order they are found. +**-a** or **--all** + Prints all *COMMAND* found in :envvar:`PATH`, in the order found. -- ``-q`` or ``--query``, silences the output and prints nothing, setting only the exit status. Implies ``--search``. For compatibility with old fish versions this is also ``--quiet`` (but this is deprecated). +**-q** or **--query** + Silence output and print nothing, setting only exit status. + Implies **--search**. + For compatibility, this is also **--quiet** (deprecated). -- ``-s`` or ``--search`` returns the name of the external command that would be executed, or nothing if no file with the specified name could be found in the ``$PATH``. +**-v** (or **-s** or **--search**) + Prints the external command that would be executed, or prints nothing if no file with the specified name could be found in :envvar:`PATH`. -With the ``-s`` option, ``command`` treats every argument as a separate command to look up and sets the exit status to 0 if any of the specified commands were found, or 1 if no commands could be found. Additionally passing a ``-q`` or ``--quiet`` option prevents any paths from being printed, like ``type -q``, for testing only the exit status. +**-h** or **--help** + Displays help about using this command. -For basic compatibility with POSIX ``command``, the ``-v`` flag is recognized as an alias for ``-s``. +With the **-v** option, ``command`` treats every argument as a separate command to look up and sets the exit status to 0 if any of the specified commands were found, or 127 if no commands could be found. **--quiet** used with **-v** prevents commands being printed, like ``type -q``. Examples -------- -``command ls`` causes fish to execute the ``ls`` program, even if an ``ls`` function exists. - -``command -s ls`` returns the path to the ``ls`` program. - -``command -q git; and command git log`` runs ``git log`` only if ``git`` exists. +| ``command ls`` executes the ``ls`` program, even if an ``ls`` function also exists. +| ``command -s ls`` prints the path to the ``ls`` program. +| ``command -q git; and command git log`` runs ``git log`` only if ``git`` exists. diff --git a/doc_src/cmds/commandline.rst b/doc_src/cmds/commandline.rst index e8e118017..77799a6be 100644 --- a/doc_src/cmds/commandline.rst +++ b/doc_src/cmds/commandline.rst @@ -6,7 +6,7 @@ commandline - set or get the current command line buffer Synopsis -------- -:: +.. synopsis:: commandline [OPTIONS] [CMD] @@ -17,51 +17,81 @@ Description With no parameters, ``commandline`` returns the current value of the command line. -With ``CMD`` specified, the command line buffer is erased and replaced with the contents of ``CMD``. +With **CMD** specified, the command line buffer is erased and replaced with the contents of **CMD**. The following options are available: -- ``-C`` or ``--cursor`` set or get the current cursor position, not the contents of the buffer. If no argument is given, the current cursor position is printed, otherwise the argument is interpreted as the new cursor position. If one of the options ``-j``, ``-p`` or ``-t`` is given, the position is relative to the respective substring instead of the entire command line buffer. +**-C** or **--cursor** + Set or get the current cursor position, not the contents of the buffer. + If no argument is given, the current cursor position is printed, otherwise the argument is interpreted as the new cursor position. + If one of the options **-j**, **-p** or **-t** is given, the position is relative to the respective substring instead of the entire command line buffer. -- ``-f`` or ``--function`` causes any additional arguments to be interpreted as input functions, and puts them into the queue, so that they will be read before any additional actual key presses are. This option cannot be combined with any other option. See :ref:`bind ` for a list of input functions. +**-f** or **--function** + Causes any additional arguments to be interpreted as input functions, and puts them into the queue, so that they will be read before any additional actual key presses are. + This option cannot be combined with any other option. + See :ref:`bind ` for a list of input functions. + +**-h** or **--help** + Displays help about using this command. The following options change the way ``commandline`` updates the command line buffer: -- ``-a`` or ``--append`` do not remove the current commandline, append the specified string at the end of it +**-a** or **--append** + Do not remove the current commandline, append the specified string at the end of it. -- ``-i`` or ``--insert`` do not remove the current commandline, insert the specified string at the current cursor position +**-i** or **--insert** + Do not remove the current commandline, insert the specified string at the current cursor position -- ``-r`` or ``--replace`` remove the current commandline and replace it with the specified string (default) +**-r** or **--replace** + Remove the current commandline and replace it with the specified string (default) The following options change what part of the commandline is printed or updated: -- ``-b`` or ``--current-buffer`` select the entire commandline, not including any displayed autosuggestion (default) +**-b** or **--current-buffer** + Select the entire commandline, not including any displayed autosuggestion (default). -- ``-j`` or ``--current-job`` select the current job - a `job` here is one pipeline. It stops at logical operators or terminators (``;``, ``&`` or newlines). +**-j** or **--current-job** + Select the current job - a **job** here is one pipeline. + Stops at logical operators or terminators (**;**, **&**, and newlines). -- ``-p`` or ``--current-process`` select the current process - a `process` here is one simple command. It stops at logical operators, terminators or pipes. +**-p** or **--current-process** + Select the current process - a **process** here is one command. + Stops at logical operators, terminators, and pipes. -- ``-s`` or ``--current-selection`` selects the current selection +**-s** or **--current-selection** + Selects the current selection -- ``-t`` or ``--current-token`` select the current token +**-t** or **--current-token** + Selects the current token The following options change the way ``commandline`` prints the current commandline buffer: -- ``-c`` or ``--cut-at-cursor`` only print selection up until the current cursor position +**-c** or **--cut-at-cursor** + Only print selection up until the current cursor position. -- ``-o`` or ``--tokenize`` tokenize the selection and print one string-type token per line +**-o** or **--tokenize** + Tokenize the selection and print one string-type token per line. If ``commandline`` is called during a call to complete a given string using ``complete -C STRING``, ``commandline`` will consider the specified string to be the current contents of the command line. The following options output metadata about the commandline state: -- ``-L`` or ``--line`` print the line that the cursor is on, with the topmost line starting at 1 +**-L** or **--line** + Print the line that the cursor is on, with the topmost line starting at 1. -- ``-S`` or ``--search-mode`` evaluates to true if the commandline is performing a history search +**-S** or **--search-mode** + Evaluates to true if the commandline is performing a history search. -- ``-P`` or ``--paging-mode`` evaluates to true if the commandline is showing pager contents, such as tab completions +**-P** or **--paging-mode** + Evaluates to true if the commandline is showing pager contents, such as tab completions. -- ``--is-valid`` returns true when the commandline is syntactically valid and complete. If it is, it would be executed when the ``execute`` bind function is called. If the commandline is incomplete, it returns 2, if it is erroneus, it returns 1. +**--paging-full-mode** + Evaluates to true if the commandline is showing pager contents, such as tab completions and all lines are shown (no " more rows" message). + +**--is-valid** + Returns true when the commandline is syntactically valid and complete. + If it is, it would be executed when the ``execute`` bind function is called. + If the commandline is incomplete, return 2, if erroneus, return 1. Example ------- @@ -82,7 +112,7 @@ The ``echo $flounder >&`` is the first process, ``less`` the second and ``and ec ``echo $flounder >&2 | less`` is the first job, ``and echo $catfish`` the second. -``$flounder`` is the current token. +**$flounder** is the current token. More examples: diff --git a/doc_src/cmds/complete.rst b/doc_src/cmds/complete.rst index 2b19ac272..0326d54f9 100644 --- a/doc_src/cmds/complete.rst +++ b/doc_src/cmds/complete.rst @@ -6,23 +6,10 @@ complete - edit command specific tab-completions Synopsis -------- -:: +.. synopsis:: - complete [( -c | --command | -p | --path )] COMMAND - [( -c | --command | -p | --path ) COMMAND]... - [( -e | --erase )] - [( -s | --short-option ) SHORT_OPTION]... - [( -l | --long-option | -o | --old-option ) LONG_OPTION]... - [( -a | --arguments ) ARGUMENTS] - [( -k | --keep-order )] - [( -f | --no-files )] - [( -F | --force-files )] - [( -r | --require-parameter )] - [( -x | --exclusive )] - [( -w | --wraps ) WRAPPED_COMMAND]... - [( -n | --condition ) CONDITION] - [( -d | --description ) DESCRIPTION] - complete ( -C [STRING] | --do-complete[=STRING] ) + complete ((-c | --command) | (-p | --path)) COMMAND [OPTIONS] + complete (-C | --do-complete) [--escape] STRING Description ----------- @@ -32,35 +19,58 @@ Description For an introduction to writing your own completions, see :ref:`Writing your own completions ` in the fish manual. -- ``-c COMMAND`` or ``--command COMMAND`` specifies that ``COMMAND`` is the name of the command. If there is no ``-c`` or ``-p``, one non-option argument will be used as the command. +The following options are available: -- ``-p COMMAND`` or ``--path COMMAND`` specifies that ``COMMAND`` is the absolute path of the command (optionally containing wildcards). +**-c** or **--command** *COMMAND* + Specifies that *COMMAND* is the name of the command. If there is no **-c** or **-p**, one non-option argument will be used as the command. -- ``-e`` or ``--erase`` deletes the specified completion. +**-p** or **--path** *COMMAND* + Specifies that *COMMAND* is the absolute path of the command (optionally containing wildcards). -- ``-s SHORT_OPTION`` or ``--short-option=SHORT_OPTION`` adds a short option to the completions list. +**-e** or **--erase** + Deletes the specified completion. -- ``-l LONG_OPTION`` or ``--long-option=LONG_OPTION`` adds a GNU style long option to the completions list. +**-s** or **--short-option** *SHORT_OPTION* + Adds a short option to the completions list. -- ``-o LONG_OPTION`` or ``--old-option=LONG_OPTION`` adds an old style long option to the completions list (See below for details). +**-l** or **--long-option** *LONG_OPTION* + Adds a GNU style long option to the completions list. -- ``-a ARGUMENTS`` or ``--arguments=ARGUMENTS`` adds the specified option arguments to the completions list. +**-o** or **--old-option** *LONG_OPTION* + Adds an old style long option to the completions list (see below for details). -- ``-k`` or ``--keep-order`` keeps the order of ``ARGUMENTS`` instead of sorting alphabetically. Multiple ``complete`` calls with ``-k`` result in arguments of the later ones displayed first. +**-a** or **--arguments** *ARGUMENTS* + Adds the specified option arguments to the completions list. -- ``-f`` or ``--no-files`` says that this completion may not be followed by a filename. +**-k** or **--keep-order** + Keeps the order of *ARGUMENTS* instead of sorting alphabetically. Multiple ``complete`` calls with **-k** result in arguments of the later ones displayed first. -- ``-F`` or ``--force-files`` says that this completion may be followed by a filename, even if another applicable ``complete`` specified ``--no-files``. +**-f** or **--no-files** + This completion may not be followed by a filename. -- ``-r`` or ``--require-parameter`` says that this completion must have an option argument, i.e. may not be followed by another option. +**-F** or **--force-files** + This completion may be followed by a filename, even if another applicable ``complete`` specified **--no-files**. -- ``-x`` or ``--exclusive`` is short for ``-r`` and ``-f``. +**-r** or **--require-parameter** + This completion must have an option argument, i.e. may not be followed by another option. -- ``-w WRAPPED_COMMAND`` or ``--wraps=WRAPPED_COMMAND`` causes the specified command to inherit completions from the wrapped command (See below for details). +**-x** or **--exclusive** + Short for **-r** and **-f**. -- ``-n CONDITION`` or ``--condition CONDITION`` specifies that this completion should only be used if the CONDITION (a shell command) returns 0. This makes it possible to specify completions that should only be used in some cases. +**-w** or **--wraps** *WRAPPED_COMMAND* + Causes the specified command to inherit completions from *WRAPPED_COMMAND* (see below for details). -- ``-C STRING`` or ``--do-complete=STRING`` makes complete try to find all possible completions for the specified string. If there is no STRING, the current commandline is used instead. +**-n** or **--condition** *CONDITION* + This completion should only be used if the *CONDITION* (a shell command) returns 0. This makes it possible to specify completions that should only be used in some cases. + +**-C** or **--do-complete** *STRING* + Makes ``complete`` try to find all possible completions for the specified string. If there is no *STRING*, the current commandline is used instead. + +**--escape** + When used with ``-C``, escape special characters in completions. + +**-h** or **--help** + Displays help about using this command. Command specific tab-completions in ``fish`` are based on the notion of options and arguments. An option is a parameter which begins with a hyphen, such as ``-h``, ``-help`` or ``--help``. Arguments are parameters that do not begin with a hyphen. Fish recognizes three styles of options, the same styles as the GNU getopt library. These styles are: diff --git a/doc_src/cmds/contains.rst b/doc_src/cmds/contains.rst index 71db0f9fc..fa8bf8435 100644 --- a/doc_src/cmds/contains.rst +++ b/doc_src/cmds/contains.rst @@ -6,27 +6,32 @@ contains - test if a word is present in a list Synopsis -------- -:: +.. synopsis:: - contains [OPTIONS] KEY [VALUES...] + contains [OPTIONS] KEY [VALUES ...] Description ----------- -``contains`` tests whether the set ``VALUES`` contains the string ``KEY``. If so, ``contains`` exits with status 0; if not, it exits with status 1. +``contains`` tests whether the set *VALUES* contains the string *KEY*. +If so, ``contains`` exits with code 0; if not, it exits with code 1. The following options are available: -- ``-i`` or ``--index`` print the word index +**-i** or **--index** + Print the index (number of the element in the set) of the first matching element. -Note that, like GNU tools and most of fish's builtins, ``contains`` interprets all arguments starting with a ``-`` as options to contains, until it reaches an argument that is ``--`` (two dashes). See the examples below. +**-h** or **--help** + Displays help about using this command. + +Note that ``contains`` interprets all arguments starting with a **-** as an option to ``contains``, until an **--** argument is reached. + +See the examples below. Example ------- -If $animals is a list of animals, the following will test if it contains a cat: - - +If *animals* is a list of animals, the following will test if *animals* contains "cat": :: @@ -35,9 +40,7 @@ If $animals is a list of animals, the following will test if it contains a cat: end -This code will add some directories to $PATH if they aren't yet included: - - +This code will add some directories to :envvar:`PATH` if they aren't yet included: :: @@ -48,9 +51,7 @@ This code will add some directories to $PATH if they aren't yet included: end -While this will check if ``hasargs`` was run with the ``-q`` option: - - +While this will check if function ``hasargs`` is being ran with the **-q** option: :: @@ -61,4 +62,5 @@ While this will check if ``hasargs`` was run with the ``-q`` option: end -The ``--`` here stops ``contains`` from treating ``-q`` to an option to itself. Instead it treats it as a normal string to check. +The **--** here stops ``contains`` from treating **-q** to an option to itself. +Instead it treats it as a normal string to check. diff --git a/doc_src/cmds/continue.rst b/doc_src/cmds/continue.rst index 532f6b866..275976c76 100644 --- a/doc_src/cmds/continue.rst +++ b/doc_src/cmds/continue.rst @@ -6,9 +6,9 @@ continue - skip the remainder of the current iteration of the current inner loop Synopsis -------- -:: +.. synopsis:: - LOOP_CONSTRUCT; [COMMANDS...;] continue; [COMMANDS...;] end + LOOP_CONSTRUCT; [COMMANDS ...;] continue; [COMMANDS ...;] end Description ----------- diff --git a/doc_src/cmds/count.rst b/doc_src/cmds/count.rst index 44a1c644c..657dc8467 100644 --- a/doc_src/cmds/count.rst +++ b/doc_src/cmds/count.rst @@ -6,11 +6,11 @@ count - count the number of elements of a list Synopsis -------- -:: +.. synopsis:: - count $VARIABLE + count STRING1 STRING2 ... COMMAND | count - count < FILE + count [...] < FILE Description ----------- diff --git a/doc_src/cmds/dirh.rst b/doc_src/cmds/dirh.rst index f60c43d6a..d226a257d 100644 --- a/doc_src/cmds/dirh.rst +++ b/doc_src/cmds/dirh.rst @@ -6,7 +6,7 @@ dirh - print directory history Synopsis -------- -:: +.. synopsis:: dirh diff --git a/doc_src/cmds/dirs.rst b/doc_src/cmds/dirs.rst index 0b6541e29..cb0d20050 100644 --- a/doc_src/cmds/dirs.rst +++ b/doc_src/cmds/dirs.rst @@ -6,21 +6,26 @@ dirs - print directory stack Synopsis -------- -:: +.. synopsis:: - dirs - dirs -c + dirs [-c] Description ----------- ``dirs`` prints the current :ref:`directory stack `, as created by :ref:`pushd ` and modified by :ref:`popd `. -With "-c", it clears the directory stack instead. +The following options are available: -``dirs`` does not accept any parameters. +**-c**: + Clear the directory stack instead of printing it. + +**-h** or **--help** + Displays help about using this command. + +``dirs`` does not accept any arguments. See Also -------- -- the :ref:`cdh ` command which provides a more intuitive way to navigate to recently visited directories. +- the :ref:`cdh ` command, which provides a more intuitive way to navigate to recently visited directories. diff --git a/doc_src/cmds/disown.rst b/doc_src/cmds/disown.rst index ac7d1a104..f73d86f7c 100644 --- a/doc_src/cmds/disown.rst +++ b/doc_src/cmds/disown.rst @@ -6,9 +6,9 @@ disown - remove a process from the list of jobs Synopsis -------- -:: +.. synopsis:: - disown [ PID ... ] + disown [PID ...] Description ----------- @@ -23,6 +23,8 @@ If a job is stopped, it is sent a signal to continue running, and a warning is p ``disown`` returns 0 if all specified jobs were disowned successfully, and 1 if any problems were encountered. +The **--help** or **-h** option displays help about using this command. + Example ------- diff --git a/doc_src/cmds/echo.rst b/doc_src/cmds/echo.rst index b76d9db5c..d6143bf1f 100644 --- a/doc_src/cmds/echo.rst +++ b/doc_src/cmds/echo.rst @@ -6,24 +6,28 @@ echo - display a line of text Synopsis -------- -:: +.. synopsis:: echo [OPTIONS] [STRING] Description ----------- -``echo`` displays a string of text. +``echo`` displays *STRING* of text. The following options are available: -- ``-n``, Do not output a newline +- **-n** + Do not output a newline. -- ``-s``, Do not separate arguments with spaces +**-s** + Do not separate arguments with spaces. -- ``-E``, Disable interpretation of backslash escapes (default) +**-E** + Disable interpretation of backslash escapes (default). -- ``-e``, Enable interpretation of backslash escapes +**-e** + Enable interpretation of backslash escapes. Unlike other shells, this echo accepts ``--`` to signal the end of the options. diff --git a/doc_src/cmds/else.rst b/doc_src/cmds/else.rst index 2355dafd4..62aa655d0 100644 --- a/doc_src/cmds/else.rst +++ b/doc_src/cmds/else.rst @@ -6,22 +6,22 @@ else - execute command if a condition is not met Synopsis -------- -:: +.. synopsis:: - if CONDITION; COMMANDS_TRUE...; [else; COMMANDS_FALSE...;] end + if CONDITION; COMMANDS_TRUE ...; [else; COMMANDS_FALSE ...;] end Description ----------- -:ref:`if ` will execute the command ``CONDITION``. If the condition's exit status is 0, the commands ``COMMANDS_TRUE`` will execute. If it is not 0 and ``else`` is given, ``COMMANDS_FALSE`` will be executed. +:ref:`if ` will execute the command *CONDITION**. +If the condition's exit status is 0, the commands *COMMANDS_TRUE* will execute. +If it is not 0 and **else** is given, *COMMANDS_FALSE* will be executed. Example ------- -The following code tests whether a file ``foo.txt`` exists as a regular file. - - +The following code tests whether a file *foo.txt* exists as a regular file. :: diff --git a/doc_src/cmds/emit.rst b/doc_src/cmds/emit.rst index 7a8c13c75..e2fc4100a 100644 --- a/doc_src/cmds/emit.rst +++ b/doc_src/cmds/emit.rst @@ -6,15 +6,16 @@ emit - emit a generic event Synopsis -------- -:: +.. synopsis:: - emit EVENT_NAME [ARGUMENTS...] + emit EVENT_NAME [ARGUMENTS ...] Description ----------- ``emit`` emits, or fires, an event. Events are delivered to, or caught by, special functions called :ref:`event handlers `. The arguments are passed to the event handlers as function arguments. +The **--help** or **-h** option displays help about using this command. Example ------- diff --git a/doc_src/cmds/end.rst b/doc_src/cmds/end.rst index 697c437ee..9ceb17e1e 100644 --- a/doc_src/cmds/end.rst +++ b/doc_src/cmds/end.rst @@ -6,23 +6,29 @@ end - end a block of commands Synopsis -------- -:: +.. synopsis:: - begin; [COMMANDS...] end - function NAME [OPTIONS]; COMMANDS...; end - if CONDITION; COMMANDS_TRUE...; [else; COMMANDS_FALSE...;] end - switch VALUE; [case [WILDCARD...]; [COMMANDS...]; ...] end - while CONDITION; COMMANDS...; end - for VARNAME in [VALUES...]; COMMANDS...; end + begin + [COMMANDS ...] + end + +.. synopsis:: + + function NAME [OPTIONS]; COMMANDS ...; end + if CONDITION; COMMANDS_TRUE ...; [else; COMMANDS_FALSE ...;] end + switch VALUE; [case [WILDCARD ...]; [COMMANDS ...]; ...] end + while CONDITION; COMMANDS ...; end + for VARNAME in [VALUES ...]; COMMANDS ...; end Description ----------- -``end`` ends a block of commands started by one of the following commands: +The **end** keyword ends a block of commands started by one of the following commands: - :ref:`begin ` to start a block of commands - :ref:`function ` to define a function - :ref:`if `, :ref:`switch ` to conditionally execute commands - :ref:`while `, :ref:`for ` to perform commands multiple times -The ``end`` command does not change the current exit status. Instead, the status after it will be the status returned by the most recent command. +The **end** keyword does not change the current exit status. +Instead, the status after it will be the status returned by the most recent command. diff --git a/doc_src/cmds/eval.rst b/doc_src/cmds/eval.rst index ddd8254c6..2b05fdb84 100644 --- a/doc_src/cmds/eval.rst +++ b/doc_src/cmds/eval.rst @@ -6,20 +6,19 @@ eval - evaluate the specified commands Synopsis -------- -:: - - eval [COMMANDS...] +.. synopsis:: + eval [COMMANDS ...] Description ----------- -``eval`` evaluates the specified parameters as a command. If more than one parameter is specified, all parameters will be joined using a space character as a separator. +**eval** evaluates the specified parameters as a command. +If more than one parameter is specified, all parameters will be joined using a space character as a separator. -If your command does not need access to stdin, consider using :ref:`source ` instead. +If the command does not need access to stdin, consider using :ref:`source ` instead. If no piping or other compound shell constructs are required, variable-expansion-as-command, as in ``set cmd ls -la; $cmd``, is also an option. - Example ------- @@ -30,4 +29,3 @@ The following code will call the ls command and truncate each filename to the fi set cmd ls \| cut -c 1-12 eval $cmd - diff --git a/doc_src/cmds/exec.rst b/doc_src/cmds/exec.rst index 37b7d9298..e8fffdfcb 100644 --- a/doc_src/cmds/exec.rst +++ b/doc_src/cmds/exec.rst @@ -6,15 +6,16 @@ exec - execute command in current process Synopsis -------- -:: +.. synopsis:: - exec COMMAND [OPTIONS...] + exec COMMAND Description ----------- ``exec`` replaces the currently running shell with a new command. On successful completion, ``exec`` never returns. ``exec`` cannot be used inside a pipeline. +The **--help** or **-h** option displays help about using this command. Example ------- diff --git a/doc_src/cmds/exit.rst b/doc_src/cmds/exit.rst index 9121f6ee2..5b1edeff4 100644 --- a/doc_src/cmds/exit.rst +++ b/doc_src/cmds/exit.rst @@ -7,12 +7,16 @@ exit - exit the shell Synopsis -------- -**exit** [*code*] +.. synopsis:: + + exit [CODE] Description ----------- -``exit`` is a special builtin that causes the shell to exit. Either 255 or the *code* supplied is used, whichever is lesser. +**exit** is a special builtin that causes the shell to exit. Either 255 or the *CODE* supplied is used, whichever is lesser. Otherwise, the exit status will be that of the last command executed. If exit is called while sourcing a file (using the :ref:`source ` builtin) the rest of the file will be skipped, but the shell itself will not exit. + +The **--help** or **-h** option displays help about using this command. diff --git a/doc_src/cmds/false.rst b/doc_src/cmds/false.rst index e7c5ec9f6..1910e8647 100644 --- a/doc_src/cmds/false.rst +++ b/doc_src/cmds/false.rst @@ -6,7 +6,9 @@ false - return an unsuccessful result Synopsis -------- -**false** +.. synopsis:: + + false Description ----------- diff --git a/doc_src/cmds/fg.rst b/doc_src/cmds/fg.rst index 26b9b81db..e35cf12ff 100644 --- a/doc_src/cmds/fg.rst +++ b/doc_src/cmds/fg.rst @@ -6,16 +6,22 @@ fg - bring job to foreground Synopsis -------- -:: +.. synopsis:: fg [PID] Description ----------- -``fg`` brings the specified :ref:`job ` to the foreground, resuming it if it is stopped. While a foreground job is executed, fish is suspended. If no job is specified, the last job to be used is put in the foreground. If ``PID`` is specified, the job containing a process with the specified process ID is put in the foreground. +The **fg** builtin brings the specified :ref:`job ` to the foreground, resuming it if it is stopped. +While a foreground job is executed, fish is suspended. +If no job is specified, the last job to be used is put in the foreground. +If ``PID`` is specified, the job containing a process with the specified process ID is put in the foreground. -For compatibility with other shells, job expansion syntax is supported for ``fg``. A ``PID`` of the format ``%1`` will foreground job 1. Job numbers can be seen in the output of :ref:`jobs `. +For compatibility with other shells, job expansion syntax is supported for ``fg``. A *PID* of the format **%1** will foreground job 1. +Job numbers can be seen in the output of :ref:`jobs `. + +The **--help** or **-h** option displays help about using this command. Example ------- diff --git a/doc_src/cmds/fish.rst b/doc_src/cmds/fish.rst index 7cc2b55da..559c1f8c0 100644 --- a/doc_src/cmds/fish.rst +++ b/doc_src/cmds/fish.rst @@ -7,9 +7,10 @@ fish - the friendly interactive shell Synopsis -------- -**fish** [*OPTIONS*] [*FILE* [*ARGS* ...]] +.. synopsis:: -**fish** [*OPTIONS*] [**-c** *COMMAND* [*ARGS* ...]] + fish [OPTIONS] [FILE [ARG ...]] + fish [OPTIONS] [-c COMMAND [ARG ...]] Description ----------- @@ -22,39 +23,55 @@ The :ref:`tutorial ` is available as HTML via ``help tutorial`` or in The following options are available: -- ``-c`` or ``--command=COMMANDS`` evaluate the specified commands instead of reading from the commandline, passing any additional positional arguments via ``$argv``. - Note that, unlike other shells, the first argument is *not* the name of the program ``$0``, but simply the first normal argument. +**-c** or **--command=COMMAND** + Evaluate the specified commands instead of reading from the commandline, passing additional positional arguments through ``$argv``. -- ``-C`` or ``--init-command=COMMANDS`` evaluate the specified commands after reading the configuration, before running the command specified by ``-c`` or reading interactive input. +**-C** or **--init-command=COMMANDS** + Evaluate specified commands after reading the configuration but before executing command specified by **-c** or reading interactive input. -- ``-d`` or ``--debug=DEBUG_CATEGORIES`` enable debug output and specify a pattern for matching debug categories. See :ref:`Debugging ` below for details. +**-d** or **--debug=DEBUG_CATEGORIES** + Enables debug output and specify a pattern for matching debug categories. + See :ref:`Debugging ` below for details. -- ``-o`` or ``--debug-output=DEBUG_FILE`` specify a file path to receive the debug output, including categories and :envvar:`fish_trace`. The default is stderr. +**-o** or **--debug-output=DEBUG_FILE** + Specifies a file path to receive the debug output, including categories and :envvar:`fish_trace`. + The default is stderr. -- ``-i`` or ``--interactive`` specify that fish is to run in interactive mode +**-i** or **--interactive** + The shell is interactive. -- ``-l`` or ``--login`` specify that fish is to run as a login shell +**-l** or **--login** + Act as if invoked as a login shell. -- ``-N`` or ``--no-config`` do not read configuration files +**-N** or **--no-config** + Do not read configuration files. -- ``-n`` or ``--no-execute`` do not execute any commands, only perform syntax checking +**-n** or **--no-execute** + Do not execute any commands, only perform syntax checking. -- ``-p`` or ``--profile=PROFILE_FILE`` when :command:`fish` exits, output timing information on all executed commands to the specified file. This excludes time spent starting up and reading the configuration. +**-p** or **--profile=PROFILE_FILE** + when :command:`fish` exits, output timing information on all executed commands to the specified file. + This excludes time spent starting up and reading the configuration. -- ``--profile-startup=PROFILE_FILE`` will write timing information for fish's startup to the specified file. This is useful to profile your configuration. +**--profile-startup=PROFILE_FILE** + Will write timing for ``fish`` startup to specified file. -- ``-P`` or ``--private`` enables :ref:`private mode `, so fish will not access old or store new history. +**-P** or **--private** + Enables :ref:`private mode `: **fish** will not access old or store new history. -- ``--print-rusage-self`` when :command:`fish` exits, output stats from getrusage. +**--print-rusage-self** + When :command:`fish` exits, output stats from getrusage. -- ``--print-debug-categories`` outputs the list of debug categories, and then exits. +**--print-debug-categories** + Print all debug categories, and then exit. -- ``-v`` or ``--version`` display version and exit. +**-v** or **--version** + Print version and exit. -- ``-f`` or ``--features=FEATURES`` enables one or more :ref:`feature flags ` (separated by a comma). - These are how fish stages changes that might break scripts. +**-f** or **--features=FEATURES** + Enables one or more comma-separated :ref:`feature flags `. -The fish exit status is generally the :ref:`exit status of the last foreground command `. +The ``fish`` exit status is generally the :ref:`exit status of the last foreground command `. .. _debugging-fish: @@ -62,24 +79,24 @@ Debugging --------- While fish provides extensive support for :ref:`debugging fish scripts `, it is also possible to debug and instrument its internals. -Debugging can be enabled by passing the ``--debug`` option. +Debugging can be enabled by passing the **--debug** option. For example, the following command turns on debugging for background IO thread events, in addition to the default categories, i.e. *debug*, *error*, *warning*, and *warning-path*: :: > fish --debug=iothread -Available categories are listed by ``fish --print-debug-categories``. The ``--debug`` option accepts a comma-separated list of categories, and supports glob syntax. +Available categories are listed by ``fish --print-debug-categories``. The **--debug** option accepts a comma-separated list of categories, and supports glob syntax. The following command turns on debugging for *complete*, *history*, *history-file*, and *profile-history*, as well as the default categories: :: > fish --debug='complete,*history*' -Debug messages output to stderr by default. Note that if ``fish_trace`` is set, execution tracing also outputs to stderr by default. You can output to a file using the ``--debug-output`` option: +Debug messages output to stderr by default. Note that if :envvar:`fish_trace` is set, execution tracing also outputs to stderr by default. You can output to a file using the **--debug-output** option: :: > fish --debug='complete,*history*' --debug-output=/tmp/fish.log --init-command='set fish_trace on' These options can also be changed via the :envvar:`FISH_DEBUG` and :envvar:`FISH_DEBUG_OUTPUT` variables. -The categories enabled via ``--debug`` are *added* to the ones enabled by $FISH_DEBUG, so they can be disabled by prefixing them with ``-`` (``reader-*,-ast*`` enables reader debugging and disables ast debugging). +The categories enabled via **--debug** are *added* to the ones enabled by $FISH_DEBUG, so they can be disabled by prefixing them with **-** (**reader-*,-ast*** enables reader debugging and disables ast debugging). -The file given in ``--debug-output`` takes precedence over the file in :envvar:`FISH_DEBUG_OUTPUT`. +The file given in **--debug-output** takes precedence over the file in :envvar:`FISH_DEBUG_OUTPUT`. diff --git a/doc_src/cmds/fish_add_path.rst b/doc_src/cmds/fish_add_path.rst index 28b482d0c..3a97cf232 100644 --- a/doc_src/cmds/fish_add_path.rst +++ b/doc_src/cmds/fish_add_path.rst @@ -7,9 +7,10 @@ fish_add_path - add to the path Synopsis -------- -**fish_add_path** *path*... +.. synopsis:: -**fish_add_path** [(*-g* | *--global*) | (*-U* | *--universal*) | (*-P* | *--path*)] [(*-m* | *--move*)] [(*-a* | *--append*) | (*-p* | *--prepend*)] [(*-v* | *--verbose*) | (*-n* | *--dry-run*)] *paths*... + fish_add_path path ... + fish_add_path [(-g | --global) | (-U | --universal) | (-P | --path)] [(-m | --move)] [(-a | --append) | (-p | --prepend)] [(-v | --verbose) | (-n | --dry-run)] PATHS ... Description @@ -23,21 +24,39 @@ Components are normalized by :ref:`realpath `. Trailing slashes ar Components are added in the order they are given, and they are prepended to the path unless ``--append`` is given (if $fish_user_paths is used, that means they are last in $fish_user_paths, which is itself prepended to $PATH, so they still stay ahead of the system paths). -If no component is new, the variable ($fish_user_paths or $PATH) is not set again or otherwise modified, so variable handlers are not triggered. +If no component is new, the variable (:envvar:`fish_user_paths` or :envvar:`$PATH`) is not set again or otherwise modified, so variable handlers are not triggered. If a component is not an existing directory, ``fish_add_path`` ignores it. Options ------- -- ``-a`` or ``--append`` causes the components to be added to the *end* of the variable -- ``-p`` or ``--prepend`` causes the components to be added to the *front* of the variable (this is the default) -- ``-g`` or ``--global`` means to use a global $fish_user_paths -- ``-U`` or ``--universal`` means to use a universal $fish_user_paths - this is the default if it doesn't already exist -- ``-P`` or ``--path`` means to use $PATH directly -- ``-m`` or ``--move`` means to move already existing components to the place they would be added - by default they would be left in place and not added again -- ``-v`` or ``--verbose`` means to print the :ref:`set ` command used -- ``-n`` or ``--dry-run`` means to print the ``set`` command that would be used without executing it +**-a** or **--append** + Add components to the *end* of the variable. + +**-p** or **--prepend** + Add components to the *front* of the variable (this is the default). + +**-g** or **--global** + Use a global :envvar:`fish_user_paths`. + +**-U** or **--universal** + Use a universal :envvar:`fish_user_paths` - this is the default if it doesn't already exist. + +**-P** or **--path** + Manipulate :envvar:`PATH` directly. + +**-m** or **--move** + Move already-existing components to the place they would be added - by default they would be left in place and not added again. + +**-v** or **--verbose** + Print the :ref:`set ` command used. + +**-n** or **--dry-run** + Print the ``set`` command that would be used without executing it. + +**-h** or **--help** + Displays help about using this command. If ``--move`` is used, it may of course lead to the path swapping order, so you should be careful doing that in config.fish. diff --git a/doc_src/cmds/fish_breakpoint_prompt.rst b/doc_src/cmds/fish_breakpoint_prompt.rst index 784add5a0..af8f12838 100644 --- a/doc_src/cmds/fish_breakpoint_prompt.rst +++ b/doc_src/cmds/fish_breakpoint_prompt.rst @@ -6,6 +6,10 @@ fish_breakpoint_prompt - define the prompt when stopped at a breakpoint Synopsis -------- +.. synopsis:: + + fish_breakpoint_prompt + :: function fish_breakpoint_prompt diff --git a/doc_src/cmds/fish_command_not_found.rst b/doc_src/cmds/fish_command_not_found.rst index cdc0b6fa7..007f4ef00 100644 --- a/doc_src/cmds/fish_command_not_found.rst +++ b/doc_src/cmds/fish_command_not_found.rst @@ -6,11 +6,11 @@ fish_command_not_found - what to do when a command wasn't found Synopsis -------- -:: +.. synopsis:: - function fish_command_not_found - ... - end + function fish_command_not_found + ... + end Description diff --git a/doc_src/cmds/fish_config.rst b/doc_src/cmds/fish_config.rst index f11438143..6fe8ba988 100644 --- a/doc_src/cmds/fish_config.rst +++ b/doc_src/cmds/fish_config.rst @@ -6,10 +6,9 @@ fish_config - start the web-based configuration interface Synopsis -------- -:: +.. synopsis:: - fish_config - fish_config browse + fish_config [browse] fish_config prompt (choose | list | save | show) fish_config theme (choose | demo | dump | list | save | show) @@ -44,6 +43,8 @@ Available subcommands for the ``theme`` command: The themes are loaded from the theme directory shipped with fish or a ``themes`` directory in the fish configuration directory (typically ``~/.config/fish/themes``). +The **-h** or **--help** option displays help about using this command. + Example ------- diff --git a/doc_src/cmds/fish_git_prompt.rst b/doc_src/cmds/fish_git_prompt.rst index 48dd15ac6..3d8a1623c 100644 --- a/doc_src/cmds/fish_git_prompt.rst +++ b/doc_src/cmds/fish_git_prompt.rst @@ -6,11 +6,16 @@ fish_git_prompt - output git information for use in a prompt Synopsis -------- +.. synopsis:: + + fish_git_prompt + :: - function fish_prompt - printf '%s' $PWD (fish_git_prompt) ' $ ' - end + function fish_prompt + printf '%s' $PWD (fish_git_prompt) ' $ ' + end + Description ----------- diff --git a/doc_src/cmds/fish_greeting.rst b/doc_src/cmds/fish_greeting.rst index f79e67276..c5c06b903 100644 --- a/doc_src/cmds/fish_greeting.rst +++ b/doc_src/cmds/fish_greeting.rst @@ -6,6 +6,10 @@ fish_greeting - display a welcome message in interactive shells Synopsis -------- +.. synopsis:: + + fish_greeting + :: function fish_greeting diff --git a/doc_src/cmds/fish_hg_prompt.rst b/doc_src/cmds/fish_hg_prompt.rst index e44a36630..b2f96dbc1 100644 --- a/doc_src/cmds/fish_hg_prompt.rst +++ b/doc_src/cmds/fish_hg_prompt.rst @@ -6,6 +6,10 @@ fish_hg_prompt - output Mercurial information for use in a prompt Synopsis -------- +.. synopsis:: + + fish_hg_prompt + :: function fish_prompt @@ -21,7 +25,7 @@ The fish_hg_prompt function displays information about the current Mercurial rep By default, only the current branch is shown because ``hg status`` can be slow on a large repository. You can enable a more informative prompt by setting the variable ``$fish_prompt_hg_show_informative_status``, for example:: - set --universal fish_prompt_hg_show_informative_status + set --universal fish_prompt_hg_show_informative_status If you enabled the informative status, there are numerous customization options, which can be controlled with fish variables. diff --git a/doc_src/cmds/fish_indent.rst b/doc_src/cmds/fish_indent.rst index e7ec1650c..dd96c730b 100644 --- a/doc_src/cmds/fish_indent.rst +++ b/doc_src/cmds/fish_indent.rst @@ -7,7 +7,9 @@ fish_indent - indenter and prettifier Synopsis -------- -**fish_indent** [*OPTIONS*] [*FILE*...] +.. synopsis:: + + fish_indent [OPTIONS] [FILE ...] Description @@ -17,20 +19,32 @@ Description The following options are available: -- ``-w`` or ``--write`` indents a specified file and immediately writes to that file. +**-w** or **--write** + Indents a specified file and immediately writes to that file. -- ``-i`` or ``--no-indent`` do not indent commands; only reformat to one job per line. +**-i** or **--no-indent** + Do not indent commands; only reformat to one job per line. -- ``-c`` or ``--check`` do not indent, only return 0 if the code is already indented as fish_indent would, the number of failed files otherwise. Also print the failed filenames if not reading from stdin. +**-c** or **--check** + Do not indent, only return 0 if the code is already indented as fish_indent would, the number of failed files otherwise. Also print the failed filenames if not reading from standard input. -- ``-v`` or ``--version`` displays the current fish version and then exits. +**-v** or **--version** + Displays the current :program:`fish` version and then exits. -- ``--ansi`` colorizes the output using ANSI escape sequences, appropriate for the current $TERM, using the colors defined in the environment (such as ``$fish_color_command``). +**--ansi** + Colorizes the output using ANSI escape sequences, appropriate for the current :envvar:`TERM`, using the colors defined in the environment (such as :envvar:`fish_color_command`). -- ``--html`` outputs HTML, which supports syntax highlighting if the appropriate CSS is defined. The CSS class names are the same as the variable names, such as ``fish_color_command``. +**--html** + Outputs HTML, which supports syntax highlighting if the appropriate CSS is defined. The CSS class names are the same as the variable names, such as ``fish_color_command``. -- ``-d`` or ``--debug=DEBUG_CATEGORIES`` enable debug output and specify a pattern for matching debug categories. See :ref:`Debugging ` in :ref:`fish ` (1) for details. +**-d** or **--debug=DEBUG_CATEGORIES** + Enable debug output and specify a pattern for matching debug categories. See :ref:`Debugging ` in :ref:`fish ` (1) for details. -- ``-o`` or ``--debug-output=DEBUG_FILE`` specify a file path to receive the debug output, including categories and ``fish_trace``. The default is stderr. +**-o** or **--debug-output=DEBUG_FILE** + Specify a file path to receive the debug output, including categories and ``fish_trace``. The default is standard error. -- ``--dump-parse-tree`` dumps information about the parsed statements to stderr. This is likely to be of interest only to people working on the fish source code. +**--dump-parse-tree** + Dumps information about the parsed statements to standard error. This is likely to be of interest only to people working on the fish source code. + +**-h** or **--help** + Displays help about using this command. diff --git a/doc_src/cmds/fish_is_root_user.rst b/doc_src/cmds/fish_is_root_user.rst index 106b4c1dc..9bfb73ba5 100644 --- a/doc_src/cmds/fish_is_root_user.rst +++ b/doc_src/cmds/fish_is_root_user.rst @@ -6,7 +6,7 @@ fish_is_root_user - check if the current user is root Synopsis -------- -:: +.. synopsis:: fish_is_root_user diff --git a/doc_src/cmds/fish_key_reader.rst b/doc_src/cmds/fish_key_reader.rst index 956e81b76..523306257 100644 --- a/doc_src/cmds/fish_key_reader.rst +++ b/doc_src/cmds/fish_key_reader.rst @@ -6,31 +6,35 @@ fish_key_reader - explore what characters keyboard keys send Synopsis -------- -:: +.. synopsis:: fish_key_reader [OPTIONS] Description ----------- -``fish_key_reader`` is used to explain how you would bind a certain key sequence. By default, it prints the :ref:`bind ` command for one key sequence read interactively over standard input. +:program:`fish_key_reader` is used to explain how you would bind a certain key sequence. By default, it prints the :ref:`bind ` command for one key sequence read interactively over standard input. -If the character sequence matches a special key name (see ``bind --key-names``), both ``bind CHARS ...`` and ``bind -k KEYNAME ...`` usage will be shown. In verbose mode (enabled by passing ``--verbose``), additional details about the characters received, such as the delay between chars, are written to stderr. +If the character sequence matches a special key name (see ``bind --key-names``), both ``bind CHARS ...`` and ``bind -k KEYNAME ...`` usage will be shown. In verbose mode (enabled by passing ``--verbose``), additional details about the characters received, such as the delay between chars, are written to standard error. The following options are available: -- ``-c`` or ``--continuous`` begins a session where multiple key sequences can be inspected. By default the program exits after capturing a single key sequence. +**-c** or **--continuous** + Begins a session where multiple key sequences can be inspected. By default the program exits after capturing a single key sequence. -- ``-V`` or ``--verbose`` tells fish_key_reader to output timing information and explain the sequence in more detail. +**-V** or **--verbose** + Tells fish_key_reader to output timing information and explain the sequence in more detail. -- ``-h`` or ``--help`` prints usage information. +**-h** or **--help** + Displays help about using this command. -- ``-v`` or ``--version`` prints fish_key_reader's version and exits. +**-v** or **--version** + Displays the current :program:`fish` version and then exits. Usage Notes ----------- -In verbose mode, the delay in milliseconds since the previous character was received is included in the diagnostic information written to stderr. This information may be useful to determine the optimal ``fish_escape_delay_ms`` setting or learn the amount of lag introduced by tools like ``ssh``, ``mosh`` or ``tmux``. +In verbose mode, the delay in milliseconds since the previous character was received is included in the diagnostic information written to standard error. This information may be useful to determine the optimal ``fish_escape_delay_ms`` setting or learn the amount of lag introduced by tools like ``ssh``, ``mosh`` or ``tmux``. ``fish_key_reader`` intentionally disables handling of many signals. To terminate ``fish_key_reader`` in ``--continuous`` mode do: diff --git a/doc_src/cmds/fish_mode_prompt.rst b/doc_src/cmds/fish_mode_prompt.rst index d5ab35655..42632f12c 100644 --- a/doc_src/cmds/fish_mode_prompt.rst +++ b/doc_src/cmds/fish_mode_prompt.rst @@ -6,6 +6,10 @@ fish_mode_prompt - define the appearance of the mode indicator Synopsis -------- +.. synopsis:: + + fish_mode_prompt + :: function fish_mode_prompt diff --git a/doc_src/cmds/fish_opt.rst b/doc_src/cmds/fish_opt.rst index ea1d93456..6960a9473 100644 --- a/doc_src/cmds/fish_opt.rst +++ b/doc_src/cmds/fish_opt.rst @@ -1,42 +1,48 @@ .. _cmd-fish_opt: -fish_opt - create an option spec for the argparse command -========================================================= +fish_opt - create an option specification for the argparse command +================================================================== Synopsis -------- -:: - - fish_opt [ -h | --help ] - fish_opt ( -s X | --short=X ) [ -l LONG | --long=LONG ] [ --long-only ] [ -o | --optional-val ] [ -r | --required-val ] [ --multiple-vals ] +.. synopsis:: + fish_opt [(-slor | --multiple-vals=) OPTNAME] + fish_opt --help Description ----------- -This command provides a way to produce option specifications suitable for use with the :ref:`argparse ` command. You can, of course, write the option specs by hand without using this command. But you might prefer to use this for the clarity it provides. +This command provides a way to produce option specifications suitable for use with the :ref:`argparse ` command. You can, of course, write the option specifications by hand without using this command. But you might prefer to use this for the clarity it provides. The following ``argparse`` options are available: -- ``-s`` or ``--short`` takes a single letter that is used as the short flag in the option being defined. This option is mandatory. +**-s** or **--short** + Takes a single letter that is used as the short flag in the option being defined. This option is mandatory. -- ``-l`` or ``--long`` takes a string that is used as the long flag in the option being defined. This option is optional and has no default. If no long flag is defined then only the short flag will be allowed when parsing arguments using the option spec. +**-l** or **--long** + Takes a string that is used as the long flag in the option being defined. This option is optional and has no default. If no long flag is defined then only the short flag will be allowed when parsing arguments using the option specification. -- ``--long-only`` means the option spec being defined will only allow the long flag name to be used. The short flag name must still be defined (i.e., ``--short`` must be specified) but it cannot be used when parsing args using this option spec. +**--long-only** + The option being defined will only allow the long flag name to be used. The short flag name must still be defined (i.e., **--short** must be specified) but it cannot be used when parsing arguments using this option specification. -- ``-o`` or ``--optional-val`` means the option being defined can take a value but it is optional rather than required. If the option is seen more than once when parsing arguments only the last value seen is saved. This means the resulting flag variable created by ``argparse`` will zero elements if no value was given with the option else it will have exactly one element. +**-o** or **--optional-val** + Tthe option being defined can take a value, but it is optional rather than required. If the option is seen more than once when parsing arguments, only the last value seen is saved. This means the resulting flag variable created by ``argparse`` will zero elements if no value was given with the option else it will have exactly one element. -- ``-r`` or ``--required-val`` means the option being defined requires a value. If the option is seen more than once when parsing arguments only the last value seen is saved. This means the resulting flag variable created by ``argparse`` will have exactly one element. +**-r** or **--required-val** + The option being defined requires a value. If the option is seen more than once when parsing arguments, only the last value seen is saved. This means the resulting flag variable created by ``argparse`` will have exactly one element. -- ``--multiple-vals`` means the option being defined requires a value each time it is seen. Each instance is stored. This means the resulting flag variable created by ``argparse`` will have one element for each instance of this option in the args. +**--multiple-vals** + The option being defined requires a value each time it is seen. Each instance is stored. This means the resulting flag variable created by ``argparse`` will have one element for each instance of this option in the arguments. -- ``-h`` or ``--help`` displays help about using this command. +**-h** or **--help** + Displays help about using this command. Examples -------- -Define a single option spec for the boolean help flag: +Define a single option specification for the boolean help flag: diff --git a/doc_src/cmds/fish_prompt.rst b/doc_src/cmds/fish_prompt.rst index e8df810b7..097bac4bd 100644 --- a/doc_src/cmds/fish_prompt.rst +++ b/doc_src/cmds/fish_prompt.rst @@ -6,6 +6,10 @@ fish_prompt - define the appearance of the command line prompt Synopsis -------- +.. synopsis:: + + fish_prompt + :: function fish_prompt diff --git a/doc_src/cmds/fish_status_to_signal.rst b/doc_src/cmds/fish_status_to_signal.rst index 6fd91caa7..4d81db8c1 100644 --- a/doc_src/cmds/fish_status_to_signal.rst +++ b/doc_src/cmds/fish_status_to_signal.rst @@ -1,11 +1,15 @@ .. _cmd-fish_status_to_signal: -fish_status_to_signal - Convert exit codes to human-friendly signals +fish_status_to_signal - convert exit codes to human-friendly signals ==================================================================== Synopsis -------- +.. synopsis:: + + fish_status_to_signal NUM + :: function fish_prompt @@ -26,4 +30,4 @@ Example >_ sleep 5 ^C⏎ >_ fish_status_to_signal $status - SIGINT \ No newline at end of file + SIGINT diff --git a/doc_src/cmds/fish_svn_prompt.rst b/doc_src/cmds/fish_svn_prompt.rst index c9c5b6190..59b7f3733 100644 --- a/doc_src/cmds/fish_svn_prompt.rst +++ b/doc_src/cmds/fish_svn_prompt.rst @@ -6,6 +6,10 @@ fish_svn_prompt - output Subversion information for use in a prompt Synopsis -------- +.. synopsis:: + + fish_svn_prompt + :: function fish_prompt @@ -21,47 +25,47 @@ The fish_svn_prompt function displays information about the current Subversion r There are numerous customization options, which can be controlled with fish variables. -- ``$__fish_svn_prompt_color_revision`` +- :envvar:`__fish_svn_prompt_color_revision` the colour of the revision number to display in the prompt -- ``$__fish_svn_prompt_char_separator`` +- :envvar:`__fish_svn_prompt_char_separator` the separator between status characters A number of variables control the symbol ("display") and color ("color") for the different status indicators: -- ``$__fish_svn_prompt_char_added_display`` -- ``$__fish_svn_prompt_char_added_color`` -- ``$__fish_svn_prompt_char_conflicted_display`` -- ``$__fish_svn_prompt_char_conflicted_color`` -- ``$__fish_svn_prompt_char_deleted_display`` -- ``$__fish_svn_prompt_char_deleted_color`` -- ``$__fish_svn_prompt_char_ignored_display`` -- ``$__fish_svn_prompt_char_ignored_color`` -- ``$__fish_svn_prompt_char_modified_display`` -- ``$__fish_svn_prompt_char_modified_color`` -- ``$__fish_svn_prompt_char_replaced_display`` -- ``$__fish_svn_prompt_char_replaced_color`` -- ``$__fish_svn_prompt_char_unversioned_external_display`` -- ``$__fish_svn_prompt_char_unversioned_external_color`` -- ``$__fish_svn_prompt_char_unversioned_display`` -- ``$__fish_svn_prompt_char_unversioned_color`` -- ``$__fish_svn_prompt_char_missing_display`` -- ``$__fish_svn_prompt_char_missing_color`` -- ``$__fish_svn_prompt_char_versioned_obstructed_display`` -- ``$__fish_svn_prompt_char_versioned_obstructed_color`` -- ``$__fish_svn_prompt_char_locked_display`` -- ``$__fish_svn_prompt_char_locked_color`` -- ``$__fish_svn_prompt_char_scheduled_display`` -- ``$__fish_svn_prompt_char_scheduled_color`` -- ``$__fish_svn_prompt_char_switched_display`` -- ``$__fish_svn_prompt_char_switched_color`` -- ``$__fish_svn_prompt_char_token_present_display`` -- ``$__fish_svn_prompt_char_token_present_color`` -- ``$__fish_svn_prompt_char_token_other_display`` -- ``$__fish_svn_prompt_char_token_other_color`` -- ``$__fish_svn_prompt_char_token_stolen_display`` -- ``$__fish_svn_prompt_char_token_stolen_color`` -- ``$__fish_svn_prompt_char_token_broken_display`` -- ``$__fish_svn_prompt_char_token_broken_color`` +- :envvar:`__fish_svn_prompt_char_added_display` +- :envvar:`__fish_svn_prompt_char_added_color` +- :envvar:`__fish_svn_prompt_char_conflicted_display` +- :envvar:`__fish_svn_prompt_char_conflicted_color` +- :envvar:`__fish_svn_prompt_char_deleted_display` +- :envvar:`__fish_svn_prompt_char_deleted_color` +- :envvar:`__fish_svn_prompt_char_ignored_display` +- :envvar:`__fish_svn_prompt_char_ignored_color` +- :envvar:`__fish_svn_prompt_char_modified_display` +- :envvar:`__fish_svn_prompt_char_modified_color` +- :envvar:`__fish_svn_prompt_char_replaced_display` +- :envvar:`__fish_svn_prompt_char_replaced_color` +- :envvar:`__fish_svn_prompt_char_unversioned_external_display` +- :envvar:`__fish_svn_prompt_char_unversioned_external_color` +- :envvar:`__fish_svn_prompt_char_unversioned_display` +- :envvar:`__fish_svn_prompt_char_unversioned_color` +- :envvar:`__fish_svn_prompt_char_missing_display` +- :envvar:`__fish_svn_prompt_char_missing_color` +- :envvar:`__fish_svn_prompt_char_versioned_obstructed_display` +- :envvar:`__fish_svn_prompt_char_versioned_obstructed_color` +- :envvar:`__fish_svn_prompt_char_locked_display` +- :envvar:`__fish_svn_prompt_char_locked_color` +- :envvar:`__fish_svn_prompt_char_scheduled_display` +- :envvar:`__fish_svn_prompt_char_scheduled_color` +- :envvar:`__fish_svn_prompt_char_switched_display` +- :envvar:`__fish_svn_prompt_char_switched_color` +- :envvar:`__fish_svn_prompt_char_token_present_display` +- :envvar:`__fish_svn_prompt_char_token_present_color` +- :envvar:`__fish_svn_prompt_char_token_other_display` +- :envvar:`__fish_svn_prompt_char_token_other_color` +- :envvar:`__fish_svn_prompt_char_token_stolen_display` +- :envvar:`__fish_svn_prompt_char_token_stolen_color` +- :envvar:`__fish_svn_prompt_char_token_broken_display` +- :envvar:`__fish_svn_prompt_char_token_broken_color` See also :ref:`fish_vcs_prompt `, which will call all supported version control prompt functions, including git, Mercurial and Subversion. diff --git a/doc_src/cmds/fish_title.rst b/doc_src/cmds/fish_title.rst index 1ac790ff0..d286d1445 100644 --- a/doc_src/cmds/fish_title.rst +++ b/doc_src/cmds/fish_title.rst @@ -6,6 +6,10 @@ fish_title - define the terminal's title Synopsis -------- +.. synopsis:: + + fish_title + :: function fish_title diff --git a/doc_src/cmds/fish_update_completions.rst b/doc_src/cmds/fish_update_completions.rst index 3651aa0d1..340dbb343 100644 --- a/doc_src/cmds/fish_update_completions.rst +++ b/doc_src/cmds/fish_update_completions.rst @@ -6,9 +6,9 @@ fish_update_completions - update completions using manual pages Synopsis -------- -:: +.. synopsis:: - fish_update_completions + fish_update_completions Description ----------- diff --git a/doc_src/cmds/fish_vcs_prompt.rst b/doc_src/cmds/fish_vcs_prompt.rst index 3921e0ead..62baec814 100644 --- a/doc_src/cmds/fish_vcs_prompt.rst +++ b/doc_src/cmds/fish_vcs_prompt.rst @@ -6,6 +6,10 @@ fish_vcs_prompt - output version control system information for use in a prompt Synopsis -------- +.. synopsis:: + + fish_vcs_prompt + :: function fish_prompt @@ -25,7 +29,7 @@ It calls out to VCS-specific functions. The currently supported systems are: If a VCS isn't installed, the respective function does nothing. -The svn prompt is disabled by default because it's slow on large svn repositories. To enable it, modify fish_vcs_prompt to uncomment it. See :ref:`funced `. +The Subversion prompt is disabled by default, because it's slow on large repositories. To enable it, modify ``fish_vcs_prompt`` to uncomment it. See :ref:`funced `. For more information, see the documentation for each of the functions above. diff --git a/doc_src/cmds/for.rst b/doc_src/cmds/for.rst index 3e472cde4..f6652f86d 100644 --- a/doc_src/cmds/for.rst +++ b/doc_src/cmds/for.rst @@ -6,22 +6,22 @@ for - perform a set of commands multiple times Synopsis -------- -:: +.. synopsis:: - for VARNAME in [VALUES...]; COMMANDS...; end + for VARNAME in [VALUES ...]; COMMANDS ...; end Description ----------- -``for`` is a loop construct. It will perform the commands specified by ``COMMANDS`` multiple times. On each iteration, the local variable specified by ``VARNAME`` is assigned a new value from ``VALUES``. If ``VALUES`` is empty, ``COMMANDS`` will not be executed at all. The ``VARNAME`` is visible when the loop terminates and will contain the last value assigned to it. If ``VARNAME`` does not already exist it will be set in the local scope. For our purposes if the ``for`` block is inside a function there must be a local variable with the same name. If the ``for`` block is not nested inside a function then global and universal variables of the same name will be used if they exist. +**for** is a loop construct. It will perform the commands specified by *COMMANDS* multiple times. On each iteration, the local variable specified by *VARNAME* is assigned a new value from *VALUES*. If *VALUES* is empty, *COMMANDS* will not be executed at all. The *VARNAME* is visible when the loop terminates and will contain the last value assigned to it. If *VARNAME* does not already exist it will be set in the local scope. For our purposes if the **for** block is inside a function there must be a local variable with the same name. If the **for** block is not nested inside a function then global and universal variables of the same name will be used if they exist. -Much like :ref:`set `, ``for`` does not modify $status, but the evaluation of its subordinate commands can. +Much like :ref:`set `, **for** does not modify $status, but the evaluation of its subordinate commands can. + +The **-h** or **--help** option displays help about using this command. Example ------- - - :: for i in foo bar baz; echo $i; end @@ -37,8 +37,6 @@ Notes The ``VARNAME`` was local to the for block in releases prior to 3.0.0. This means that if you did something like this: - - :: for var in a b c diff --git a/doc_src/cmds/funced.rst b/doc_src/cmds/funced.rst index e49194d09..9713da157 100644 --- a/doc_src/cmds/funced.rst +++ b/doc_src/cmds/funced.rst @@ -6,26 +6,32 @@ funced - edit a function interactively Synopsis -------- -:: +.. synopsis:: funced [OPTIONS] NAME Description ----------- -``funced`` provides an interface to edit the definition of the function ``NAME``. +``funced`` provides an interface to edit the definition of the function *NAME*. If the ``$VISUAL`` environment variable is set, it will be used as the program to edit the function. If ``$VISUAL`` is unset but ``$EDITOR`` is set, that will be used. Otherwise, a built-in editor will be used. Note that to enter a literal newline using the built-in editor you should press :kbd:`Alt`\ +\ :kbd:`Enter`. Pressing :kbd:`Enter` signals that you are done editing the function. This does not apply to an external editor like emacs or vim. ``funced`` will try to edit the original file that a function is defined in, which might include variable definitions or helper functions as well. If changes cannot be saved to the original file, a copy will be created in the user's function directory. -If there is no function called ``NAME``, a new function will be created with the specified name. +If there is no function called *NAME*, a new function will be created with the specified name. -- ``-e command`` or ``--editor command`` Open the function body inside the text editor given by the command (for example, ``-e vi``). The special command ``fish`` will use the built-in editor (same as specifying ``-i``). +**-e command** or **--editor command** + Open the function body inside the text editor given by the command (for example, **-e vi**). The special command ``fish`` will use the built-in editor (same as specifying **-i**). -- ``-i`` or ``--interactive`` Force opening the function body in the built-in editor even if ``$VISUAL`` or ``$EDITOR`` is defined. +**-i** or **--interactive** + Force opening the function body in the built-in editor even if ``$VISUAL`` or ``$EDITOR`` is defined. -- ``-s`` or ``--save`` Automatically save the function after successfully editing it. +**-s** or **--save** + Automatically save the function after successfully editing it. + +**-h** or **--help** + Displays help about using this command. Example ------- diff --git a/doc_src/cmds/funcsave.rst b/doc_src/cmds/funcsave.rst index ca5035567..76b3a0dde 100644 --- a/doc_src/cmds/funcsave.rst +++ b/doc_src/cmds/funcsave.rst @@ -6,10 +6,10 @@ funcsave - save the definition of a function to the user's autoload directory Synopsis -------- -:: +.. synopsis:: funcsave FUNCTION_NAME - funcsave [-q] [(-d | --directory) DIR ] FUNCTION_NAME + funcsave [-q] [(-d | --directory) DIR] FUNCTION_NAME Description @@ -17,6 +17,8 @@ Description ``funcsave`` saves a function to a file in the fish configuration directory. This function will be :ref:`automatically loaded ` by current and future fish sessions. This can be useful to commit functions created interactively for permanent use. +If you have erased a function using :ref:`functions `'s ``--erase`` option, ``funcsave`` will remove the saved function definition. + Because fish loads functions on-demand, saved functions cannot serve as :ref:`event handlers ` until they are run or otherwise sourced. To activate an event handler for every new shell, add the function to the :ref:`configuration file ` instead of using ``funcsave``. This is often used after :ref:`funced `, which opens the function in ``$EDITOR`` or ``$VISUAL`` and loads it into the current session afterwards. diff --git a/doc_src/cmds/function.rst b/doc_src/cmds/function.rst index 4e3b938da..95ef6290e 100644 --- a/doc_src/cmds/function.rst +++ b/doc_src/cmds/function.rst @@ -6,7 +6,7 @@ function - create a function Synopsis -------- -:: +.. synopsis:: function NAME [OPTIONS]; BODY; end @@ -14,35 +14,43 @@ Synopsis Description ----------- -``function`` creates a new function ``NAME`` with the body ``BODY``. +``function`` creates a new function *NAME* with the body *BODY*. A function is a list of commands that will be executed when the name of the function is given as a command. The following options are available: -- ``-a NAMES`` or ``--argument-names NAMES`` assigns the value of successive command-line arguments to the names given in NAMES. +**-a** *NAMES* or **--argument-names** *NAMES* + Assigns the value of successive command-line arguments to the names given in *NAMES*. -- ``-d DESCRIPTION`` or ``--description=DESCRIPTION`` is a description of what the function does, suitable as a completion description. +**-d** *DESCRIPTION* or **--description** *DESCRIPTION* + A description of what the function does, suitable as a completion description. -- ``-w WRAPPED_COMMAND`` or ``--wraps=WRAPPED_COMMAND`` causes the function to inherit completions from the given wrapped command. See the documentation for :ref:`complete ` for more information. +**-w** *WRAPPED_COMMAND* or **--wraps** *WRAPPED_COMMAND* + Inherit completions from the given *WRAPPED_COMMAND*. See the documentation for :ref:`complete ` for more information. -- ``-e`` or ``--on-event EVENT_NAME`` tells fish to run this function when the specified named event is emitted. Fish internally generates named events e.g. when showing the prompt. +**-e** *EVENT_NAME* or **--on-event** *EVENT_NAME* + Run this function when the specified named event is emitted. Fish internally generates named events, for example,when showing the prompt. Custom events can be emitted using the :ref:`emit ` command. -- ``-v`` or ``--on-variable VARIABLE_NAME`` tells fish to run this function when the variable VARIABLE_NAME changes value. Note that fish makes no guarantees on any particular timing or even that the function will be run for every single ``set``. Rather it will be run when the variable has been set at least once, possibly skipping some values or being run when the variable has been set to the same value (except for universal variables set in other shells - only changes in the value will be picked up for those). +**-v** *VARIABLE_NAME* or **--on-variable** *VARIABLE_NAME* + Run this function when the variable *VARIABLE_NAME* changes value. Note that :program:`fish`` makes no guarantees on any particular timing or even that the function will be run for every single ``set``. Rather it will be run when the variable has been set at least once, possibly skipping some values or being run when the variable has been set to the same value (except for universal variables set in other shells - only changes in the value will be picked up for those). -- ``-j PID`` or ``--on-job-exit PID`` tells fish to run this function when the job containing a child process with the given PID exits. Instead of PID, the string 'caller' can be specified. This is only legal when in a command substitution, and will result in the handler being triggered by the exit of the job which created this command substitution. +**-j** *PID* or **--on-job-exit** *PID* + Run this function when the job containing a child process with the given process identifier *PID* exits. Instead of a PID, the string 'caller' can be specified. This is only allowed when in a command substitution, and will result in the handler being triggered by the exit of the job which created this command substitution. -- ``-p PID`` or ``--on-process-exit PID`` tells fish to run this function when the fish child process - with process ID PID exits. Instead of a PID, for backward compatibility, - "``%self``" can be specified as an alias for ``$fish_pid``, and the function will be run when the - current fish instance exits. +**-p** *PID* or **--on-process-exit** *PID* + Run this function when the fish child process with process ID PID exits. Instead of a PID, for backward compatibility, "``%self``" can be specified as an alias for ``$fish_pid``, and the function will be run when the current fish instance exits. -- ``-s`` or ``--on-signal SIGSPEC`` tells fish to run this function when the signal ``SIGSPEC`` is delivered. ``SIGSPEC`` can be a signal number, or the signal name, such as ``SIGHUP`` (or just ``HUP``). Note that the signal must have been delivered to fish; for example, :kbd:`Ctrl-C` sends ``SIGINT`` to the foreground process group, which will not be fish if you are running another command at the time. +**-s** *SIGSPEC* or **--on-signal** *SIGSPEC* + Run this function when the signal ``SIGSPEC`` is delivered. ``SIGSPEC`` can be a signal number, or the signal name, such as ``SIGHUP`` (or just ``HUP``). Note that the signal must have been delivered to :program:`fish`; for example, :kbd:`Ctrl-C` sends ``SIGINT`` to the foreground process group, which will not be :program:`fish` if you are running another command at the time. -- ``-S`` or ``--no-scope-shadowing`` allows the function to access the variables of calling functions. Normally, any variables inside the function that have the same name as variables from the calling function are "shadowed", and their contents are independent of the calling function. - It's important to note that this does not capture referenced variables or the scope at the time of function declaration! At this time, fish does not have any concept of closures, and variable lifetimes are never extended. In other words, by using ``--no-scope-shadowing`` the scope of the function each time it is run is shared with the scope it was *called* from rather than the scope it was *defined* in. +**-S** or **--no-scope-shadowing** + Allows the function to access the variables of calling functions. Normally, any variables inside the function that have the same name as variables from the calling function are "shadowed", and their contents are independent of the calling function. -- ``-V`` or ``--inherit-variable NAME`` snapshots the value of the variable ``NAME`` and defines a local variable with that same name and value when the function is defined. This is similar to a closure in other languages like Python but a bit different. Note the word "snapshot" in the first sentence. If you change the value of the variable after defining the function, even if you do so in the same scope (typically another function) the new value will not be used by the function you just created using this option. See the ``function notify`` example below for how this might be used. + It's important to note that this does not capture referenced variables or the scope at the time of function declaration! At this time, fish does not have any concept of closures, and variable lifetimes are never extended. In other words, by using **--no-scope-shadowing** the scope of the function each time it is run is shared with the scope it was *called* from rather than the scope it was *defined* in. + +**-V** or **--inherit-variable NAME** + Snapshots the value of the variable ``NAME`` and defines a local variable with that same name and value when the function is defined. This is similar to a closure in other languages like Python but a bit different. Note the word "snapshot" in the first sentence. If you change the value of the variable after defining the function, even if you do so in the same scope (typically another function) the new value will not be used by the function you just created using this option. See the ``function notify`` example below for how this might be used. If the user enters any additional arguments after the function, they are inserted into the environment :ref:`variable list ` ``$argv``. If the ``--argument-names`` option is provided, the arguments are also assigned to names specified in that option. diff --git a/doc_src/cmds/functions.rst b/doc_src/cmds/functions.rst index 947644b67..cac61ab8e 100644 --- a/doc_src/cmds/functions.rst +++ b/doc_src/cmds/functions.rst @@ -6,13 +6,13 @@ functions - print or erase functions Synopsis -------- -:: +.. synopsis:: - functions [ -a | --all ] [ -n | --names ] - functions [ -D | --details ] [ -v ] FUNCTION + functions [-a | --all] [-n | --names] + functions [-D | --details] [-v] FUNCTION functions -c OLDNAME NEWNAME functions -d DESCRIPTION FUNCTION - functions [ -e | -q ] FUNCTIONS... + functions [-e | -q] FUNCTION ... Description ----------- @@ -21,35 +21,49 @@ Description The following options are available: -- ``-a`` or ``--all`` lists all functions, even those whose name starts with an underscore. +**-a** or **--all** + Lists all functions, even those whose name starts with an underscore. -- ``-c OLDNAME NEWNAME`` or ``--copy OLDNAME NEWNAME`` creates a new function named NEWNAME, using the definition of the OLDNAME function. +**-c** or **--copy** *OLDNAME* *NEWNAME* + Creates a new function named *NEWNAME*, using the definition of the *OLDNAME* function. -- ``-d DESCRIPTION`` or ``--description=DESCRIPTION`` changes the description of this function. +**-d** or **--description** *DESCRIPTION* + Changes the description of this function. -- ``-e`` or ``--erase`` causes the specified functions to be erased. This also means that it is prevented from autoloading. +**-e** or **--erase** + Causes the specified functions to be erased. This also means that it is prevented from autoloading in the current session. Use :ref:`funcsave ` to remove the saved copy. -- ``-D`` or ``--details`` reports the path name where the specified function is defined or could be autoloaded, ``stdin`` if the function was defined interactively or on the command line or by reading stdin, ``-`` if the function was created via :ref:`source `, and ``n/a`` if the function isn't available. (Functions created via :ref:`alias ` will return ``-``, because ``alias`` uses ``source`` internally.) If the ``--verbose`` option is also specified then five lines are written: +**-D** or **--details** + Reports the path name where the specified function is defined or could be autoloaded, ``stdin`` if the function was defined interactively or on the command line or by reading standard input, **-** if the function was created via :ref:`source `, and ``n/a`` if the function isn't available. (Functions created via :ref:`alias ` will return **-**, because ``alias`` uses ``source`` internally.) If the **--verbose** option is also specified then five lines are written: - the pathname as already described, - ``autoloaded``, ``not-autoloaded`` or ``n/a``, - the line number within the file or zero if not applicable, - - ``scope-shadowing`` if the function shadows the vars in the calling function (the normal case if it wasn't defined with ``--no-scope-shadowing``), else ``no-scope-shadowing``, or ``n/a`` if the function isn't defined, - - the function description minimally escaped so it is a single line or ``n/a`` if the function isn't defined. + - ``scope-shadowing`` if the function shadows the vars in the calling function (the normal case if it wasn't defined with **--no-scope-shadowing**), else ``no-scope-shadowing``, or ``n/a`` if the function isn't defined, + - the function description minimally escaped so it is a single line, or ``n/a`` if the function isn't defined or has no description. -You should not assume that only five lines will be written since we may add additional information to the output in the future. + You should not assume that only five lines will be written since we may add additional information to the output in the future. -- ``--no-details`` turns off function path reporting, so just the definition will be printed. +**--no-details** + Turns off function path reporting, so just the definition will be printed. -- ``-n`` or ``--names`` lists the names of all defined functions. +**-n** or **--names** + Lists the names of all defined functions. -- ``-q`` or ``--query`` tests if the specified functions exist. +**-q** or **--query** + Tests if the specified functions exist. -- ``-v`` or ``--verbose`` will make some output more verbose. +**-v** or **--verbose** + Make some output more verbose. -- ``-H`` or ``--handlers`` will show all event handlers. +**-H** or **--handlers** + Show all event handlers. -- ``-t`` or ``--handlers-type TYPE`` will show all event handlers matching the given type +**-t** or **--handlers-type** *TYPE* + Show all event handlers matching the given *TYPE*. + +**-h** or **--help** + Displays help about using this command. The default behavior of ``functions``, when called with no arguments, is to print the names of all defined functions. Unless the ``-a`` option is given, no functions starting with underscores are included in the output. diff --git a/doc_src/cmds/help.rst b/doc_src/cmds/help.rst index 4373318db..15c64461c 100644 --- a/doc_src/cmds/help.rst +++ b/doc_src/cmds/help.rst @@ -6,7 +6,7 @@ help - display fish documentation Synopsis -------- -:: +.. synopsis:: help [SECTION] @@ -15,16 +15,21 @@ Description ``help`` displays the fish help documentation. -If a ``SECTION`` is specified, the help for that command is shown. +If a *SECTION* is specified, the help for that command is shown. -If the BROWSER environment variable is set, it will be used to display the documentation. Otherwise, fish will search for a suitable browser. - -If you prefer to use a different browser (other than as described above) for fish help, you can set the fish_help_browser variable. This variable may be set as a list, where the first element is the browser command and the rest are browser options. - -Note that most builtin commands display their help in the terminal when given the ``--help`` option. +The **-h** or **--help** option displays help about using this command. +If the :envvar:`BROWSER`` environment variable is set, it will be used to display the documentation. +Otherwise, fish will search for a suitable browser. +To use a different browser than as described above, one can set the :envvar:`fish_help_browser` variable. +This variable may be set as a list, where the first element is the browser command and the rest are browser options. Example ------- ``help fg`` shows the documentation for the :ref:`fg ` builtin. + +Notes +----- + +Most builtin commands, including this one, display their help in the terminal when given the **--help** option. diff --git a/doc_src/cmds/history.rst b/doc_src/cmds/history.rst index 79e58b08a..959d8ce30 100644 --- a/doc_src/cmds/history.rst +++ b/doc_src/cmds/history.rst @@ -6,15 +6,17 @@ history - show and manipulate command history Synopsis -------- -:: +.. synopsis:: - history [ search ] [ --show-time ] [ --case-sensitive ] [ --exact | --prefix | --contains ] [ --max=n ] [ --null ] [ -R | --reverse ] [ "search string"... ] - history delete [ --show-time ] [ --case-sensitive ] [ --exact | --prefix | --contains ] "search string"... + history [search] [--show-time] [--case-sensitive] + [--exact | --prefix | --contains] [--max N] [--null] [--reverse] + [SEARCH_STRING ...] + history delete [--case-sensitive] + [--exact | --prefix | --contains] SEARCH_STRING ... history merge history save history clear history clear-session - history ( -h | --help ) Description ----------- @@ -23,39 +25,54 @@ Description The following operations (sub-commands) are available: -- ``search`` returns history items matching the search string. If no search string is provided it returns all history items. This is the default operation if no other operation is specified. You only have to explicitly say ``history search`` if you wish to search for one of the subcommands. The ``--contains`` search option will be used if you don't specify a different search option. Entries are ordered newest to oldest unless you use the ``--reverse`` flag. If stdout is attached to a tty the output will be piped through your pager by the history function. The history builtin simply writes the results to stdout. +**search** + Returns history items matching the search string. If no search string is provided it returns all history items. This is the default operation if no other operation is specified. You only have to explicitly say ``history search`` if you wish to search for one of the subcommands. The ``--contains`` search option will be used if you don't specify a different search option. Entries are ordered newest to oldest unless you use the ``--reverse`` flag. If stdout is attached to a tty the output will be piped through your pager by the history function. The history builtin simply writes the results to stdout. -- ``delete`` deletes history items. The ``--contains`` search option will be used if you don't specify a different search option. If you don't specify ``--exact`` a prompt will be displayed before any items are deleted asking you which entries are to be deleted. You can enter the word "all" to delete all matching entries. You can enter a single ID (the number in square brackets) to delete just that single entry. You can enter more than one ID separated by a space to delete multiple entries. Just press [enter] to not delete anything. Note that the interactive delete behavior is a feature of the history function. The history builtin only supports ``--exact --case-sensitive`` deletion. +**delete** + Deletes history items. The ``--contains`` search option will be used if you don't specify a different search option. If you don't specify ``--exact`` a prompt will be displayed before any items are deleted asking you which entries are to be deleted. You can enter the word "all" to delete all matching entries. You can enter a single ID (the number in square brackets) to delete just that single entry. You can enter more than one ID separated by a space to delete multiple entries. Just press [enter] to not delete anything. Note that the interactive delete behavior is a feature of the history function. The history builtin only supports ``--exact --case-sensitive`` deletion. -- ``merge`` immediately incorporates history changes from other sessions. Ordinarily ``fish`` ignores history changes from sessions started after the current one. This command applies those changes immediately. +**merge** + Immediately incorporates history changes from other sessions. Ordinarily ``fish`` ignores history changes from sessions started after the current one. This command applies those changes immediately. -- ``save`` immediately writes all changes to the history file. The shell automatically saves the history file; this option is provided for internal use and should not normally need to be used by the user. +**save** + Immediately writes all changes to the history file. The shell automatically saves the history file; this option is provided for internal use and should not normally need to be used by the user. -- ``clear`` clears the history file. A prompt is displayed before the history is erased asking you to confirm you really want to clear all history unless ``builtin history`` is used. +**clear** + Clears the history file. A prompt is displayed before the history is erased asking you to confirm you really want to clear all history unless ``builtin history`` is used. -- ``clear-session`` clears the history file from all activity of the current session. Note: If ``history merge`` or ``builtin history merge`` is run in a session only the history after this will be erased. +**clear-session** + Clears the history file from all activity of the current session. Note: If ``history merge`` or ``builtin history merge`` is run in a session, only the history after this will be erased. The following options are available: These flags can appear before or immediately after one of the sub-commands listed above. -- ``-C`` or ``--case-sensitive`` does a case-sensitive search. The default is case-insensitive. Note that prior to fish 2.4.0 the default was case-sensitive. +**-C** or **--case-sensitive** + Does a case-sensitive search. The default is case-insensitive. Note that prior to fish 2.4.0 the default was case-sensitive. -- ``-c`` or ``--contains`` searches or deletes items in the history that contain the specified text string. This is the default for the ``--search`` flag. This is not currently supported by the ``delete`` subcommand. +**-c** or **--contains** + Searches items in the history that contain the specified text string. This is the default for the **--search** flag. This is not currently supported by the **delete** subcommand. -- ``-e`` or ``--exact`` searches or deletes items in the history that exactly match the specified text string. This is the default for the ``delete`` subcommand. Note that the match is case-insensitive by default. If you really want an exact match, including letter case, you must use the ``-C`` or ``--case-sensitive`` flag. +**-e** or **--exact** + Searches or deletes items in the history that exactly match the specified text string. This is the default for the **delete** subcommand. Note that the match is case-insensitive by default. If you really want an exact match, including letter case, you must use the **-C** or **--case-sensitive** flag. -- ``-p`` or ``--prefix`` searches or deletes items in the history that begin with the specified text string. This is not currently supported by the ``--delete`` flag. +**-p** or **--prefix** + Searches items in the history that begin with the specified text string. This is not currently supported by the **delete** subcommand. -- ``-t`` or ``--show-time`` prepends each history entry with the date and time the entry was recorded. By default it uses the strftime format ``# %c%n``. You can specify another format; e.g., ``--show-time="%Y-%m-%d %H:%M:%S "`` or ``--show-time="%a%I%p"``. The short option, ``-t``, doesn't accept a strftime format string; it only uses the default format. Any strftime format is allowed, including ``%s`` to get the raw UNIX seconds since the epoch. +**-t** or **--show-time** + Prepends each history entry with the date and time the entry was recorded. By default it uses the strftime format ``# %c%n``. You can specify another format; e.g., ``--show-time="%Y-%m-%d %H:%M:%S "`` or ``--show-time="%a%I%p"``. The short option, **-t**, doesn't accept a strftime format string; it only uses the default format. Any strftime format is allowed, including ``%s`` to get the raw UNIX seconds since the epoch. -- ``-z`` or ``--null`` causes history entries written by the search operations to be terminated by a NUL character rather than a newline. This allows the output to be processed by ``read -z`` to correctly handle multiline history entries. +**-z** or **--null** + Causes history entries written by the search operations to be terminated by a NUL character rather than a newline. This allows the output to be processed by ``read -z`` to correctly handle multiline history entries. -- ``-`` ``-n `` or ``--max=`` limits the matched history items to the first "n" matching entries. This is only valid for ``history search``. +**-**\*NUMBER* **-n** *NUMBER* or **--max** *NUMBER* + Limits the matched history items to the first *NUMBER* matching entries. This is only valid for ``history search``. -- ``-R`` or ``--reverse`` causes the history search results to be ordered oldest to newest. Which is the order used by most shells. The default is newest to oldest. +**-R** or **--reverse** + Causes the history search results to be ordered oldest to newest. Which is the order used by most shells. The default is newest to oldest. -- ``-h`` or ``--help`` display help for this command. +**-h** or **--help** + Displays help for this command. Example ------- @@ -89,6 +106,6 @@ Other shells such as bash and zsh use a variable named ``HISTFILE`` for a simila Notes ----- -If you specify both ``--prefix`` and ``--contains`` the last flag seen is used. +If you specify both **--prefix** and **--contains** the last flag seen is used. Note that for backwards compatibility each subcommand can also be specified as a long option. For example, rather than ``history search`` you can type ``history --search``. Those long options are deprecated and will be removed in a future release. diff --git a/doc_src/cmds/if.rst b/doc_src/cmds/if.rst index 6e2e178b4..4d339f457 100644 --- a/doc_src/cmds/if.rst +++ b/doc_src/cmds/if.rst @@ -6,11 +6,11 @@ if - conditionally execute a command Synopsis -------- -:: +.. synopsis:: - if CONDITION; COMMANDS_TRUE...; - [else if CONDITION2; COMMANDS_TRUE2...;] - [else; COMMANDS_FALSE...;] + if CONDITION; COMMANDS_TRUE ...; + [else if CONDITION2; COMMANDS_TRUE2 ...;] + [else; COMMANDS_FALSE ...;] end Description @@ -22,6 +22,8 @@ You can use :ref:`and ` or :ref:`or ` in the condition. See the The exit status of the last foreground command to exit can always be accessed using the :ref:`$status ` variable. +The **-h** or **--help** option displays help about using this command. + Example ------- diff --git a/doc_src/cmds/isatty.rst b/doc_src/cmds/isatty.rst index 5ad6b2267..879f0d027 100644 --- a/doc_src/cmds/isatty.rst +++ b/doc_src/cmds/isatty.rst @@ -6,7 +6,7 @@ isatty - test if a file descriptor is a terminal Synopsis -------- -:: +.. synopsis:: isatty [FILE DESCRIPTOR] @@ -19,15 +19,12 @@ Description If the specified file descriptor is a terminal device, the exit status of the command is zero. Otherwise, the exit status is non-zero. No messages are printed to standard error. +The **-h** or **--help** option displays help about using this command. Examples -------- -From an interactive shell, the commands below exit with a return value of zero: - - - -:: +From an interactive shell, the commands below exit with a return value of zero:: isatty isatty stdout @@ -35,11 +32,7 @@ From an interactive shell, the commands below exit with a return value of zero: echo | isatty 1 -And these will exit non-zero: - - - -:: +And these will exit non-zero:: echo | isatty isatty 9 diff --git a/doc_src/cmds/jobs.rst b/doc_src/cmds/jobs.rst index 899a9e80b..56eae582d 100644 --- a/doc_src/cmds/jobs.rst +++ b/doc_src/cmds/jobs.rst @@ -6,9 +6,9 @@ jobs - print currently running jobs Synopsis -------- -:: +.. synopsis:: - jobs [OPTIONS] [ PID | %JOBID ] + jobs [OPTIONS] [PID | %JOBID] Description @@ -16,21 +16,29 @@ Description ``jobs`` prints a list of the currently running :ref:`jobs ` and their status. -jobs accepts the following switches: +``jobs`` accepts the following options: -- ``-c`` or ``--command`` prints the command name for each process in jobs. +**-c** or **--command** + Prints the command name for each process in jobs. -- ``-g`` or ``--group`` only prints the group ID of each job. +**-g** or **--group** + Only prints the group ID of each job. -- ``-l`` or ``--last`` prints only the last job to be started. +**-l** or **--last** + Prints only the last job to be started. -- ``-p`` or ``--pid`` prints the process ID for each process in all jobs. +**-p** or **--pid** + Prints the process ID for each process in all jobs. -- ``-q`` or ``--query`` prints no output for evaluation of jobs by exit status only. For compatibility with old fish versions this is also ``--quiet`` (but this is deprecated). +**-q** or **--query** + Prints no output for evaluation of jobs by exit status only. For compatibility with old fish versions this is also **--quiet** (but this is deprecated). + +**-h** or **--help** + Displays help about using this command. On systems that supports this feature, jobs will print the CPU usage of each job since the last command was executed. The CPU usage is expressed as a percentage of full CPU activity. Note that on multiprocessor systems, the total activity may be more than 100\%. -Arguments of the form ``PID`` or ``%JOBID`` restrict the output to jobs with the selected process identifiers or job numbers respectively. +Arguments of the form *PID* or *%JOBID* restrict the output to jobs with the selected process identifiers or job numbers respectively. If the output of ``jobs`` is redirected or if it is part of a command substitution, the column header that is usually printed is omitted, making it easier to parse. diff --git a/doc_src/cmds/math.rst b/doc_src/cmds/math.rst index 87ef44c30..1aac3eada 100644 --- a/doc_src/cmds/math.rst +++ b/doc_src/cmds/math.rst @@ -6,30 +6,50 @@ math - perform mathematics calculations Synopsis -------- -:: +.. synopsis:: - math [-sN | --scale=N] [-bBASE | --base=BASE] [--] EXPRESSION + math [(-s | --scale) N] [(-b | --base) BASE] EXPRESSION ... Description ----------- -``math`` performs mathematical calculations. It supports simple operations such as addition, subtraction, and so on, as well as functions like ``abs()``, ``sqrt()`` and ``ln()``. +``math`` performs mathematical calculations. +It supports simple operations such as addition, subtraction, and so on, as well as functions like ``abs()``, ``sqrt()`` and ``ln()``. -By default, the output is a floating-point number with trailing zeroes trimmed. To get a fixed representation, the ``--scale`` option can be used, including ``--scale=0`` for integer output. +By default, the output is a floating-point number with trailing zeroes trimmed. +To get a fixed representation, the ``--scale`` option can be used, including ``--scale=0`` for integer output. -Keep in mind that parameter expansion happens before expressions are evaluated. This can be very useful in order to perform calculations involving shell variables or the output of command substitutions, but it also means that parenthesis (``()``) and the asterisk (``*``) glob character have to be escaped or quoted. ``x`` can also be used to denote multiplication, but it needs to be followed by whitespace to distinguish it from hexadecimal numbers. +Keep in mind that parameter expansion happens before expressions are evaluated. +This can be very useful in order to perform calculations involving shell variables or the output of command substitutions, but it also means that parenthesis (``()``) and the asterisk (``*``) glob character have to be escaped or quoted. +``x`` can also be used to denote multiplication, but it needs to be followed by whitespace to distinguish it from hexadecimal numbers. -Parentheses for functions are optional - ``math sin pi`` prints ``0``. However, a comma will bind to the inner function, so ``math pow sin 3, 5`` is an error because it tries to give ``sin`` the arguments ``3`` and ``5``. When in doubt, use parentheses. - -``math`` ignores whitespace between arguments and takes its input as multiple arguments (internally joined with a space), so ``math 2 +2`` and ``math "2 + 2"`` work the same. ``math 2 2`` is an error. +Parentheses for functions are optional - ``math sin pi`` prints ``0``. +However, a comma will bind to the inner function, so ``math pow sin 3, 5`` is an error because it tries to give ``sin`` the arguments ``3`` and ``5``. +When in doubt, use parentheses. +``math`` ignores whitespace between arguments and takes its input as multiple arguments (internally joined with a space), so ``math 2 +2`` and ``math "2 + 2"`` work the same. +``math 2 2`` is an error. The following options are available: -- ``-sN`` or ``--scale=N`` sets the scale of the result. ``N`` must be an integer or the word "max" for the maximum scale. A scale of zero causes results to be rounded down to the nearest integer. So ``3/2`` returns ``1`` rather than ``2`` which ``1.5`` would normally round to. This is for compatibility with ``bc`` which was the basis for this command prior to fish 3.0.0. Scale values greater than zero causes the result to be rounded using the usual rules to the specified number of decimal places. +**-s** *N* or **--scale** *N* + Sets the scale of the result. + ``N`` must be an integer or the word "max" for the maximum scale. + A scale of zero causes results to be rounded down to the nearest integer. + So ``3/2`` returns ``1`` rather than ``2`` which ``1.5`` would normally round to. + This is for compatibility with ``bc`` which was the basis for this command prior to fish 3.0.0. + Scale values greater than zero causes the result to be rounded using the usual rules to the specified number of decimal places. -- ``-b BASE`` or ``--base BASE`` sets the numeric base used for output (``math`` always understands hexadecimal numbers as input). It currently understands "hex" or "16" for hexadecimal and "octal" or "8" for octal and implies a scale of 0 (other scales cause an error), so it will truncate the result down to an integer. This might change in the future. Hex numbers will be printed with a ``0x`` prefix. Octal numbers will have a prefix of ``0`` and aren't understood by ``math`` as input. +**-b** *BASE* or **--base** *BASE* + Sets the numeric base used for output (``math`` always understands hexadecimal numbers as input). + It currently understands "hex" or "16" for hexadecimal and "octal" or "8" for octal and implies a scale of 0 (other scales cause an error), so it will truncate the result down to an integer. + This might change in the future. + Hex numbers will be printed with a ``0x`` prefix. + Octal numbers will have a prefix of ``0`` but aren't understood by ``math`` as input. + +**-h** or **--help** + Displays help about using this command. Return Values ------------- @@ -41,22 +61,30 @@ Syntax ``math`` knows some operators, constants, functions and can (obviously) read numbers. -For numbers, ``.`` is always the radix character regardless of locale - ``2.5``, not ``2,5``. Scientific notation (``10e5``) and hexadecimal (``0xFF``) are also available. +For numbers, ``.`` is always the radix character regardless of locale - ``2.5``, not ``2,5``. +Scientific notation (``10e5``) and hexadecimal (``0xFF``) are also available. Operators --------- ``math`` knows the following operators: -- ``+`` for addition and ``-`` for subtraction. - -- ``*`` or ``x`` for multiplication, ``/`` for division. (Note that ``*`` is the glob character and needs to be quoted or escaped, ``x`` needs to be followed by whitespace or it looks like ``0x`` hexadecimal notation.) - -- ``^`` for exponentiation. - -- ``%`` for modulo. - -- ``(`` and ``)`` for grouping. (These need to be quoted or escaped because ``()`` denotes a command substitution.) +``+`` + for addition +``-`` + for subtraction +``*`` or ``x`` + for multiplication +``/`` + for division + (Note that ``*`` is the glob character and needs to be quoted or escaped, ``x`` needs to be followed by whitespace or it looks like ``0x`` hexadecimal notation.) +``^`` + for exponentiation +``%`` + for modulo +``(`` or ``)`` + for grouping. + (These need to be quoted or escaped because ``()`` denotes a command substitution.) They are all used in an infix manner - ``5 + 2``, not ``+ 5 2``. @@ -65,9 +93,13 @@ Constants ``math`` knows the following constants: -- ``e`` - Euler's number. -- ``pi`` - π. You know this one. Half of Tau. -- ``tau``. Equivalent to 2π, or the number of radians in a circle. +``e`` + Euler's number +``pi`` + π, you know this one. + Half of Tau +``tau`` + Equivalent to 2π, or the number of radians in a circle Use them without a leading ``$`` - ``pi - 3`` should be about 0. @@ -76,32 +108,59 @@ Functions ``math`` supports the following functions: -- ``abs`` - the absolute value, with positive sign -- ``acos`` - arc cosine -- ``asin`` - arc sine -- ``atan`` - arc tangent -- ``atan2`` - arc tangent of two variables -- ``bitand``, ``bitor`` and ``bitxor`` to perform bitwise operations. These will throw away any non-integer parts and interpret the rest as an int. -- ``ceil`` - round number up to nearest integer -- ``cos`` - the cosine -- ``cosh`` - hyperbolic cosine -- ``exp`` - the base-e exponential function -- ``fac`` - factorial - also known as ``x!`` (``x * (x - 1) * (x - 2) * ... * 1``) -- ``floor`` - round number down to nearest integer -- ``ln`` - the base-e logarithm -- ``log`` or ``log10`` - the base-10 logarithm -- ``log2`` - the base-2 logarithm -- ``max`` - returns the larger of two numbers -- ``min`` - returns the smaller of two numbers -- ``ncr`` - "from n choose r" combination function - how many subsets of size r can be taken from n (order doesn't matter) -- ``npr`` - the number of subsets of size r that can be taken from a set of n elements (including different order) -- ``pow(x,y)`` returns x to the y (and can be written as ``x ^ y``) -- ``round`` - rounds to the nearest integer, away from 0 -- ``sin`` - the sine function -- ``sinh`` - the hyperbolic sine -- ``sqrt`` - the square root - (can also be written as ``x ^ 0.5``) -- ``tan`` - the tangent -- ``tanh`` - the hyperbolic tangent +``abs`` + the absolute value, with positive sign +``acos`` + arc cosine +``asin`` + arc sine +``atan`` + arc tangent +``atan2`` + arc tangent of two variables +``bitand``, ``bitor`` and ``bitxor`` + perform bitwise operations. + These will throw away any non-integer parts andd interpret the rest as an int. +``ceil`` + round number up to nearest integer +``cos`` + the cosine +``cosh`` + hyperbolic cosine +``exp`` + the base-e exponential function +``fac`` + factorial - also known as ``x!`` (``x * (x - 1) * (x - 2) * ... * 1``) +``floor`` + round number down to nearest integer +``ln`` + the base-e logarithm +``log`` or ``log10`` + the base-10 logarithm +``log2`` + the base-2 logarithm +``max`` + returns the larger of two numbers +``min`` + returns the smaller of two numbers +``ncr`` + "from n choose r" combination function - how many subsets of size r can be taken from n (order doesn't matter) +``npr`` + the number of subsets of size r that can be taken from a set of n elements (including different order) +``pow(x,y)`` + returns x to the y (and can be written as ``x ^ y``) +``round`` + rounds to the nearest integer, away from 0 +``sin`` + the sine function +``sinh`` + the hyperbolic sine +``sqrt`` + the square root - (can also be written as ``x ^ 0.5``) +``tan`` + the tangent +``tanh`` + the hyperbolic tangent All of the trigonometric functions use radians (the pi-based scale, not 360°). diff --git a/doc_src/cmds/nextd.rst b/doc_src/cmds/nextd.rst index 0018868a6..0e79384c2 100644 --- a/doc_src/cmds/nextd.rst +++ b/doc_src/cmds/nextd.rst @@ -6,18 +6,20 @@ nextd - move forward through directory history Synopsis -------- -:: +.. synopsis:: - nextd [ -l | --list ] [POS] + nextd [-l | --list] [POS] Description ----------- -``nextd`` moves forwards ``POS`` positions in the :ref:`history of visited directories `; if the end of the history has been hit, a warning is printed. +``nextd`` moves forwards *POS* positions in the :ref:`history of visited directories `; if the end of the history has been hit, a warning is printed. -If the ``-l`` or ``--list`` flag is specified, the current directory history is also displayed. +If the **-l** or **--list** option is specified, the current directory history is also displayed. -Note that the ``cd`` command limits directory history to the 25 most recently visited directories. The history is stored in the ``$dirprev`` and ``$dirnext`` variables which this command manipulates. +The **-h** or **--help** option displays help about using this command. + +Note that the ``cd`` command limits directory history to the 25 most recently visited directories. The history is stored in the :envvar:`dirprev` and :envvar:`dirnext` variables which this command manipulates. Example ------- diff --git a/doc_src/cmds/not.rst b/doc_src/cmds/not.rst index 0c13eb5de..ceb22b6b7 100644 --- a/doc_src/cmds/not.rst +++ b/doc_src/cmds/not.rst @@ -6,9 +6,9 @@ not - negate the exit status of a job Synopsis -------- -:: +.. synopsis:: - not COMMAND [OPTIONS...] + not COMMAND [OPTIONS ...] Description @@ -16,6 +16,7 @@ Description ``not`` negates the exit status of another command. If the exit status is zero, ``not`` returns 1. Otherwise, ``not`` returns 0. +The **-h** or **--help** option displays help about using this command. Example ------- diff --git a/doc_src/cmds/open.rst b/doc_src/cmds/open.rst index 43dcbb2d4..9f9875d27 100644 --- a/doc_src/cmds/open.rst +++ b/doc_src/cmds/open.rst @@ -6,9 +6,9 @@ open - open file in its default application Synopsis -------- -:: +.. synopsis:: - open FILES... + open FILES ... Description diff --git a/doc_src/cmds/or.rst b/doc_src/cmds/or.rst index de4bbd055..3ef63cf03 100644 --- a/doc_src/cmds/or.rst +++ b/doc_src/cmds/or.rst @@ -6,7 +6,7 @@ or - conditionally execute a command Synopsis -------- -:: +.. synopsis:: COMMAND1; or COMMAND2 @@ -19,6 +19,8 @@ Description ``or`` does not change the current exit status itself, but the command it runs most likely will. The exit status of the last foreground command to exit can always be accessed using the :ref:`$status ` variable. +The **-h** or **--help** option displays help about using this command. + Example ------- diff --git a/doc_src/cmds/popd.rst b/doc_src/cmds/popd.rst index 86511e29b..c3b7bab78 100644 --- a/doc_src/cmds/popd.rst +++ b/doc_src/cmds/popd.rst @@ -6,7 +6,7 @@ popd - move through directory stack Synopsis -------- -:: +.. synopsis:: popd @@ -15,6 +15,8 @@ Description ``popd`` removes the top directory from the :ref:`directory stack ` and changes the working directory to the new top directory. Use :ref:`pushd ` to add directories to the stack. +The **-h** or **--help** option displays help about using this command. + Example ------- diff --git a/doc_src/cmds/prevd.rst b/doc_src/cmds/prevd.rst index 3efb4f131..7badafd71 100644 --- a/doc_src/cmds/prevd.rst +++ b/doc_src/cmds/prevd.rst @@ -6,18 +6,20 @@ prevd - move backward through directory history Synopsis -------- -:: +.. synopsis:: - prevd [ -l | --list ] [POS] + prevd [-l | --list] [POS] Description ----------- -``prevd`` moves backwards ``POS`` positions in the :ref:`history of visited directories `; if the beginning of the history has been hit, a warning is printed. +``prevd`` moves backwards *POS* positions in the :ref:`history of visited directories `; if the beginning of the history has been hit, a warning is printed. -If the ``-l`` or ``--list`` flag is specified, the current history is also displayed. +If the **-l** or **--list** flag is specified, the current history is also displayed. -Note that the ``cd`` command limits directory history to the 25 most recently visited directories. The history is stored in the ``$dirprev`` and ``$dirnext`` variables which this command manipulates. +Note that the ``cd`` command limits directory history to the 25 most recently visited directories. The history is stored in the :envvar:`dirprev` and :envvar:`dirnext` variables which this command manipulates. + +The **-h** or **--help** option displays help about using this command. Example ------- diff --git a/doc_src/cmds/printf.rst b/doc_src/cmds/printf.rst index 3bfd11e79..360b6d748 100644 --- a/doc_src/cmds/printf.rst +++ b/doc_src/cmds/printf.rst @@ -6,7 +6,7 @@ printf - display text according to a format string Synopsis -------- -:: +.. synopsis:: printf FORMAT [ARGUMENT ...] @@ -19,9 +19,9 @@ Description To see the documentation on the ``printf`` command you might have, use ``command man printf``. -printf uses the format string FORMAT to print the ARGUMENT arguments. This means that it takes format specifiers in the format string and replaces each with an argument. +``printf`` uses the format string *FORMAT* to print the *ARGUMENT* arguments. This means that it takes format specifiers in the format string and replaces each with an argument. -The ``format`` argument is re-used as many times as necessary to convert all of the given arguments. So ``printf %s\n flounder catfish clownfish shark`` will print four lines. +The *FORMAT* argument is re-used as many times as necessary to convert all of the given arguments. So ``printf %s\n flounder catfish clownfish shark`` will print four lines. Unlike :ref:`echo `, ``printf`` does not append a new line unless it is specified as part of the string. diff --git a/doc_src/cmds/prompt_hostname.rst b/doc_src/cmds/prompt_hostname.rst new file mode 100644 index 000000000..386e62138 --- /dev/null +++ b/doc_src/cmds/prompt_hostname.rst @@ -0,0 +1,31 @@ +.. _cmd-prompt_hostname: + +prompt_hostname - print the hostname, shortened for use in the prompt +===================================================================== + +Synopsis +-------- + +.. synopsis:: + + prompt_hostname + +Description +----------- + +``prompt_hostname`` prints a shortened version the current hostname for use in the prompt. It will print just the first component of the hostname, everything up to the first dot. + +Examples +-------- + +:: + + function fish_prompt + echo -n (whoami)@(prompt_hostname) (prompt_pwd) '$ ' + end + +:: + + # The machine's full hostname is foo.bar.com + >_ prompt_hostname + foo diff --git a/doc_src/cmds/prompt_login.rst b/doc_src/cmds/prompt_login.rst index 29e0d699b..d95631ab2 100644 --- a/doc_src/cmds/prompt_login.rst +++ b/doc_src/cmds/prompt_login.rst @@ -6,20 +6,23 @@ prompt_login - describe the login suitable for prompt Synopsis -------- +.. synopsis:: + + prompt_login + +Description +----------- + +``prompt_login`` is a function to describe the current login. It will show the user, the host and also whether the shell is running in a chroot (currently Debian's ``debian_chroot`` file is supported). + +Examples +-------- :: function fish_prompt echo -n (prompt_login) (prompt_pwd) '$ ' end -Description ------------ - -``prompt_login`` is a function to describe the current login. It will show the user, the host and also whether the shell is running in a chroot (currently debian's debian_chroot is supported). - -Examples --------- - :: >_ prompt_login diff --git a/doc_src/cmds/prompt_pwd.rst b/doc_src/cmds/prompt_pwd.rst index 84e2bbc65..c95259483 100644 --- a/doc_src/cmds/prompt_pwd.rst +++ b/doc_src/cmds/prompt_pwd.rst @@ -6,29 +6,32 @@ prompt_pwd - print pwd suitable for prompt Synopsis -------- -:: +.. synopsis:: - function fish_prompt - echo -n (prompt_pwd) '$ ' - end + prompt_pwd Description ----------- ``prompt_pwd`` is a function to print the current working directory in a way suitable for prompts. It will replace the home directory with "~" and shorten every path component but the last to a default of one character. -To change the number of characters per path component, pass ``--dir-length=`` or set ``$fish_prompt_pwd_dir_length`` to the number of characters. Setting it to 0 or an invalid value will disable shortening entirely. This defaults to 1. +To change the number of characters per path component, pass ``--dir-length=`` or set :envvar:`fish_prompt_pwd_dir_length` to the number of characters. Setting it to 0 or an invalid value will disable shortening entirely. This defaults to 1. -To keep some components unshortened, pass ``--full-length-dirs=`` or set ``$fish_prompt_pwd_full_dirs`` to the number of components. This defaults to 1, keeping the last component. +To keep some components unshortened, pass ``--full-length-dirs=`` or set :envvar:`$fish_prompt_pwd_full_dirs` to the number of components. This defaults to 1, keeping the last component. -If any positional arguments are given, prompt_pwd shortens them instead of $PWD. +If any positional arguments are given, ``prompt_pwd`` shortens them instead of $PWD. Options ------- -- ``-h`` or ``--help`` displays the help and exits -- ``-d`` or ``--dir-length=MAX`` causes the components to be shortened to MAX characters each. This overrides $fish_prompt_pwd_dir_length. -- ``-D`` or ``--full-length-dirs=NUM`` keeps NUM components (counted from the right) as full length without shortening. This overrides $fish_prompt_pwd_full_dirs. +**-d** or **--dir-length** *MAX* + Causes the components to be shortened to *MAX* characters each. This overrides :envvar:`fish_prompt_pwd_dir_length`. + +**-D** or **--full-length-dirs** *NUM* + Keeps *NUM* components (counted from the right) as full length without shortening. This overrides :envvar:`fish_prompt_pwd_full_dirs`. + +**-h** or **--help** + Displays help about using this command. Examples -------- diff --git a/doc_src/cmds/psub.rst b/doc_src/cmds/psub.rst index 188dd6a9a..92aa1587e 100644 --- a/doc_src/cmds/psub.rst +++ b/doc_src/cmds/psub.rst @@ -6,9 +6,9 @@ psub - perform process substitution Synopsis -------- -:: +.. synopsis:: - COMMAND1 ( COMMAND2 | psub [-F | --fifo] [-f | --file] [-s SUFFIX]) + COMMAND1 ( COMMAND2 | psub [-F | --fifo] [-f | --file] [(-s | --suffix) SUFFIX] ) Description ----------- @@ -17,11 +17,17 @@ Some shells (e.g., ksh, bash) feature a syntax that is a mix between command sub The following options are available: -- ``-f`` or ``--file`` will cause psub to use a regular file instead of a named pipe to communicate with the calling process. This will cause ``psub`` to be significantly slower when large amounts of data are involved, but has the advantage that the reading process can seek in the stream. This is the default. +**-f** or **--file** + Use a regular file instead of a named pipe to communicate with the calling process. This will cause ``psub`` to be significantly slower when large amounts of data are involved, but has the advantage that the reading process can seek in the stream. This is the default. -- ``-F`` or ``--fifo`` will cause psub to use a named pipe rather than a file. You should only use this if the command produces no more than 8 KiB of output. The limit on the amount of data a FIFO can buffer varies with the OS but is typically 8 KiB, 16 KiB or 64 KiB. If you use this option and the command on the left of the psub pipeline produces more output a deadlock is likely to occur. +**-F** or **--fifo** + Use a named pipe rather than a file. You should only use this if the command produces no more than 8 KiB of output. The limit on the amount of data a FIFO can buffer varies with the OS but is typically 8 KiB, 16 KiB or 64 KiB. If you use this option and the command on the left of the psub pipeline produces more output a deadlock is likely to occur. -- ``-s`` or ``--suffix`` will append SUFFIX to the filename. +**-s** or **--suffix** *SUFFIX* + Append SUFFIX to the filename. + +**-h** or **--help** + Displays help about using this command. Example ------- diff --git a/doc_src/cmds/pushd.rst b/doc_src/cmds/pushd.rst index 4b910f6f1..b941122a5 100644 --- a/doc_src/cmds/pushd.rst +++ b/doc_src/cmds/pushd.rst @@ -6,14 +6,14 @@ pushd - push directory to directory stack Synopsis -------- -:: +.. synopsis:: - pushd [DIRECTORY] + pushd DIRECTORY Description ----------- -The ``pushd`` function adds ``DIRECTORY`` to the top of the :ref:`directory stack ` and makes it the current working directory. :ref:`popd ` will pop it off and return to the original directory. +The ``pushd`` function adds *DIRECTORY* to the top of the :ref:`directory stack ` and makes it the current working directory. :ref:`popd ` will pop it off and return to the original directory. Without arguments, it exchanges the top two directories in the stack. @@ -21,6 +21,8 @@ Without arguments, it exchanges the top two directories in the stack. ``pushd -NUMBER`` rotates clockwise i.e. top to bottom. +The **-h** or **--help** option displays help about using this command. + Example ------- diff --git a/doc_src/cmds/pwd.rst b/doc_src/cmds/pwd.rst index fe6f13fc3..d094374ef 100644 --- a/doc_src/cmds/pwd.rst +++ b/doc_src/cmds/pwd.rst @@ -6,9 +6,10 @@ pwd - output the current working directory Synopsis -------- -:: +.. synopsis:: - pwd [(-P | --physical)] [(-L | --logical)] + pwd [-P | --physical] + pwd [-L | --logical] Description @@ -24,9 +25,14 @@ Description The following options are available: -- ``-L`` or ``--logical`` Output the logical working directory, without resolving symlinks (default behavior). +**-L** or **--logical** + Output the logical working directory, without resolving symlinks (default behavior). -- ``-P`` or ``--physical`` Output the physical working directory, with symlinks resolved. +**-P** or **--physical** + Output the physical working directory, with symlinks resolved. + +**-h** or **--help** + Displays help about using this command. See Also -------- diff --git a/doc_src/cmds/random.rst b/doc_src/cmds/random.rst index 5455ccc3b..a1ad74058 100644 --- a/doc_src/cmds/random.rst +++ b/doc_src/cmds/random.rst @@ -6,30 +6,34 @@ random - generate random number Synopsis -------- -:: +.. synopsis:: random random SEED random START END random START STEP END - random choice [ITEMS...] + random choice [ITEMS ...] Description ----------- ``random`` generates a pseudo-random integer from a uniform distribution. The range (inclusive) depends on the arguments. + No arguments indicate a range of 0 to 32767 (inclusive). If one argument is specified, the internal engine will be seeded with the argument for future invocations of ``random`` and no output will be produced. -Two arguments indicate a range from START to END (both START and END included). +Two arguments indicate a range from *START* to *END* (both *START* and *END* included). -Three arguments indicate a range from START to END with a spacing of STEP +Three arguments indicate a range from *START* to *END* with a spacing of *STEP* between possible outputs. + ``random choice`` will select one random item from the succeeding arguments. +The **-h** or **--help** option displays help about using this command. + Note that seeding the engine will NOT give the same result across different systems. diff --git a/doc_src/cmds/read.rst b/doc_src/cmds/read.rst index 08093b431..314d0009d 100644 --- a/doc_src/cmds/read.rst +++ b/doc_src/cmds/read.rst @@ -6,55 +6,72 @@ read - read line of input into variables Synopsis -------- -:: +.. synopsis:: read [OPTIONS] [VARIABLE ...] Description ----------- -``read`` reads from standard input and either writes the result back to standard output (for use in command substitution), or stores the result in one or more shell variables. By default, ``read`` reads a single line and splits it into variables on spaces or tabs. Alternatively, a null character or a maximum number of characters can be used to terminate the input, and other delimiters can be given. Unlike other shells, there is no default variable (such as ``REPLY``) for storing the result - instead, it is printed on standard output. +``read`` reads from standard input and either writes the result back to standard output (for use in command substitution), or stores the result in one or more shell variables. By default, ``read`` reads a single line and splits it into variables on spaces or tabs. Alternatively, a null character or a maximum number of characters can be used to terminate the input, and other delimiters can be given. Unlike other shells, there is no default variable (such as :envvar:`REPLY`) for storing the result - instead, it is printed on standard output. The following options are available: -- ``-c CMD`` or ``--command=CMD`` sets the initial string in the interactive mode command buffer to ``CMD``. +**-c** *CMD* or **--command** *CMD* + Sets the initial string in the interactive mode command buffer to *CMD*. -- ``-d DELIMITER`` or ``--delimiter=DELIMITER`` splits on DELIMITER. DELIMITER will be used as an entire string to split on, not a set of characters. +**-d** or **--delimiter** *DELIMITER* + Splits on *DELIMITER*. *DELIMITER* will be used as an entire string to split on, not a set of characters. -- ``-g`` or ``--global`` makes the variables global. +**-g** or **--global** + Makes the variables global. -- ``-s`` or ``--silent`` masks characters written to the terminal, replacing them with asterisks. This is useful for reading things like passwords or other sensitive information. +**-s** or **--silent** + Masks characters written to the terminal, replacing them with asterisks. This is useful for reading things like passwords or other sensitive information. -- ``-f`` or ``--function`` scopes the variable to the currently executing function. It is erased when the function ends. +**-f** or **--function** + Scopes the variable to the currently executing function. It is erased when the function ends. -- ``-l`` or ``--local`` scopes the variable to the currently executing block. It is erased when the block ends. Outside of a block, this is the same as ``--function``. +**-l** or **--local** + Scopes the variable to the currently executing block. It is erased when the block ends. Outside of a block, this is the same as **--function**. -- ``-n NCHARS`` or ``--nchars=NCHARS`` makes ``read`` return after reading NCHARS characters or the end of - the line, whichever comes first. +**-n** or **--nchars** *NCHARS* + Makes ``read`` return after reading *NCHARS* characters or the end of the line, whichever comes first. -- ``-p PROMPT_CMD`` or ``--prompt=PROMPT_CMD`` uses the output of the shell command ``PROMPT_CMD`` as the prompt for the interactive mode. The default prompt command is ``set_color green; echo read; set_color normal; echo "> "`` +**-p** or **--prompt** *PROMPT_CMD* + Uses the output of the shell command *PROMPT_CMD* as the prompt for the interactive mode. The default prompt command is ``set_color green; echo read; set_color normal; echo "> "`` -- ``-P PROMPT_STR`` or ``--prompt-str=PROMPT_STR`` uses the string as the prompt for the interactive mode. It is equivalent to ``echo PROMPT_STR`` and is provided solely to avoid the need to frame the prompt as a command. All special characters in the string are automatically escaped before being passed to the :ref:`echo ` command. +**-P** or **--prompt-str** *PROMPT_STR* + Uses the *PROMPT_STR* as the prompt for the interactive mode. It is equivalent to ``echo $PROMPT_STR`` and is provided solely to avoid the need to frame the prompt as a command. All special characters in the string are automatically escaped before being passed to the :ref:`echo ` command. -- ``-R RIGHT_PROMPT_CMD`` or ``--right-prompt=RIGHT_PROMPT_CMD`` uses the output of the shell command ``RIGHT_PROMPT_CMD`` as the right prompt for the interactive mode. There is no default right prompt command. +**-R** or **--right-prompt** *RIGHT_PROMPT_CMD* + Uses the output of the shell command *RIGHT_PROMPT_CMD* as the right prompt for the interactive mode. There is no default right prompt command. -- ``-S`` or ``--shell`` enables syntax highlighting, tab completions and command termination suitable for entering shellscript code in the interactive mode. NOTE: Prior to fish 3.0, the short opt for ``--shell`` was ``-s``, but it has been changed for compatibility with bash's ``-s`` short opt for ``--silent``. +**-S** or **--shell** + Enables syntax highlighting, tab completions and command termination suitable for entering shellscript code in the interactive mode. NOTE: Prior to fish 3.0, the short opt for **--shell** was **-s**, but it has been changed for compatibility with bash's **-s** short opt for **--silent**. -- ``-t`` -or ``--tokenize`` causes read to split the input into variables by the shell's tokenization rules. This means it will honor quotes and escaping. This option is of course incompatible with other options to control splitting like ``--delimiter`` and does not honor $IFS (like fish's tokenizer). It saves the tokens in the manner they'd be passed to commands on the commandline, so e.g. ``a\ b`` is stored as ``a b``. Note that currently it leaves command substitutions intact along with the parentheses. +**-t** -or **--tokenize** + Causes read to split the input into variables by the shell's tokenization rules. This means it will honor quotes and escaping. This option is of course incompatible with other options to control splitting like **--delimiter** and does not honor :envvar:`IFS` (like fish's tokenizer). It saves the tokens in the manner they'd be passed to commands on the commandline, so e.g. ``a\ b`` is stored as ``a b``. Note that currently it leaves command substitutions intact along with the parentheses. -- ``-u`` or ``--unexport`` prevents the variables from being exported to child processes (default behaviour). +**-u** or **--unexport** + Prevents the variables from being exported to child processes (default behaviour). -- ``-U`` or ``--universal`` causes the specified shell variable to be made universal. +**-U** or **--universal** + Causes the specified shell variable to be made universal. -- ``-x`` or ``--export`` exports the variables to child processes. +**-x** or **--export** + Exports the variables to child processes. -- ``-a`` or ``--list`` stores the result as a list in a single variable. This option is also available as ``--array`` for backwards compatibility. +**-a** or **--list** + Stores the result as a list in a single variable. This option is also available as **--array** for backwards compatibility. -- ``-z`` or ``--null`` marks the end of the line with the NUL character, instead of newline. This also disables interactive mode. +**-z** or **--null** + Marks the end of the line with the NUL character, instead of newline. This also disables interactive mode. -- ``-L`` or ``--line`` reads each line into successive variables, and stops after each variable has been filled. This cannot be combined with the ``--delimiter`` option. +**-L** or **--line** + Reads each line into successive variables, and stops after each variable has been filled. This cannot be combined with the ``--delimiter`` option. -Without the ``--line`` option, ``read`` reads a single line of input from standard input, breaks it into tokens, and then assigns one token to each variable specified in ``VARIABLES``. If there are more tokens than variables, the complete remainder is assigned to the last variable. +Without the ``--line`` option, ``read`` reads a single line of input from standard input, breaks it into tokens, and then assigns one token to each variable specified in *VARIABLES*. If there are more tokens than variables, the complete remainder is assigned to the last variable. If no option to determine how to split like ``--delimiter``, ``--line`` or ``--tokenize`` is given, the variable ``IFS`` is used as a list of characters to split on. Relying on the use of ``IFS`` is deprecated and this behaviour will be removed in future versions. The default value of ``IFS`` contains space, tab and newline characters. As a special case, if ``IFS`` is set to the empty string, each character of the input is considered a separate token. @@ -74,14 +91,14 @@ When ``read`` reaches the end-of-file (EOF) instead of the terminator, the exit Otherwise, it is set to 0. In order to protect the shell from consuming too many system resources, ``read`` will only consume a -maximum of 100 MiB (104857600 bytes); if the terminator is not reached before this limit then VARIABLE +maximum of 100 MiB (104857600 bytes); if the terminator is not reached before this limit then *VARIABLE* is set to empty and the exit status is set to 122. This limit can be altered with the -``fish_read_limit`` variable. If set to 0 (zero), the limit is removed. +:envvar:`fish_read_limit` variable. If set to 0 (zero), the limit is removed. Example ------- -The following code stores the value 'hello' in the shell variable ``$foo``. +The following code stores the value 'hello' in the shell variable :envvar:`$foo`. diff --git a/doc_src/cmds/realpath.rst b/doc_src/cmds/realpath.rst index 2c8b0d9b4..a3427fa32 100644 --- a/doc_src/cmds/realpath.rst +++ b/doc_src/cmds/realpath.rst @@ -7,7 +7,9 @@ realpath - convert a path to an absolute path without symlinks Synopsis -------- -**realpath** [*options*] *PATH* +.. synopsis:: + + realpath [OPTIONS] PATH Description ----------- @@ -25,4 +27,8 @@ If a :command:`realpath` command exists, that will be preferred. The following options are available: -- ``-s`` or ``--no-symlinks``: Don't resolve symlinks, only make paths absolute, squash multiple slashes and remove trailing slashes. +**-s** or **--no-symlinks** + Don't resolve symlinks, only make paths absolute, squash multiple slashes and remove trailing slashes. + +**-h** or **--help** + Displays help about using this command. diff --git a/doc_src/cmds/return.rst b/doc_src/cmds/return.rst index 9bd84d001..4bb16d36e 100644 --- a/doc_src/cmds/return.rst +++ b/doc_src/cmds/return.rst @@ -7,13 +7,15 @@ return - stop the current inner function Synopsis -------- -**return** [*n*] +.. synopsis:: + + return [N] Description ----------- :program:`return` halts a currently running function. -The exit status is set to ``n`` if it is given. +The exit status is set to *N* if it is given. If :program:`return` is invoked outside of a function or dot script it is equivalent to exit. It is often added inside of a conditional block such as an :ref:`if ` statement or a :ref:`switch ` statement to conditionally stop the executing function and return to the caller; it can also be used to specify the exit status of a function. @@ -21,6 +23,8 @@ It is often added inside of a conditional block such as an :ref:`if ` st If at the top level of a script, it exits with the given status, like :ref:`exit `. If at the top level in an interactive session, it will set :envvar:`status`, but not exit the shell. +The **-h** or **--help** option displays help about using this command. + Example ------- diff --git a/doc_src/cmds/set.rst b/doc_src/cmds/set.rst index 6ffac2bfc..7ccaf228e 100644 --- a/doc_src/cmds/set.rst +++ b/doc_src/cmds/set.rst @@ -6,22 +6,22 @@ set - display and change shell variables Synopsis -------- -:: +.. synopsis:: set [SCOPE_OPTIONS] - set [OPTIONS] VARIABLE_NAME VALUES... - set [OPTIONS] VARIABLE_NAME[INDICES]... VALUES... - set ( -q | --query ) [SCOPE_OPTIONS] VARIABLE_NAMES... - set ( -e | --erase ) [SCOPE_OPTIONS] VARIABLE_NAME... - set ( -e | --erase ) [SCOPE_OPTIONS] VARIABLE_NAME[INDICES]... - set ( -S | --show ) [VARIABLE_NAME]... + set [OPTIONS] VARIABLE VALUES ... + set [OPTIONS] VARIABLE[INDICES] VALUES ... + set (-q | --query) [SCOPE_OPTIONS] VARIABLE ... + set (-e | --erase) [SCOPE_OPTIONS] VARIABLE ... + set (-e | --erase) [SCOPE_OPTIONS] VARIABLE[INDICES] ... + set (-S | --show) VARIABLE ... Description ----------- ``set`` manipulates :ref:`shell variables `. -If both a variable name and values are provided, ``set`` assigns the values to the variable of that name. Because all variables in fish are :ref:`lists `, multiple values are allowed. +If both a *VARIABLE* and *VALUES* are provided, ``set`` assigns the values to the variable of that name. Because all variables in fish are :ref:`lists `, multiple values are allowed. If only a variable name has been given, ``set`` sets the variable to the empty list. @@ -33,40 +33,57 @@ With ``--show``, ``set`` will describe the given variable names, explaining how The following options control variable scope: -- ``-f`` or ``--function`` scopes the variable to the currently executing function. It is erased when the function ends. +**-f** or **--function** + Scopes the variable to the currently executing function. It is erased when the function ends. -- ``-l`` or ``--local`` scopes the variable to the currently executing block. It is erased when the block ends. Outside of a block, this is the same as ``--function``. +**-l** or **--local** + Scopes the variable to the currently executing block. It is erased when the block ends. Outside of a block, this is the same as **--function**. -- ``-g`` or ``--global`` causes the specified shell variable to be given a global scope. Global variables don't disappear and are available to all functions running in the same shell. They can even be modified. +**-g** or **--global** + Causes the specified shell variable to be given a global scope. Global variables don't disappear and are available to all functions running in the same shell. They can even be modified. -- ``-U`` or ``--universal`` causes the specified shell variable to be given a universal scope. If this option is supplied, the variable will be shared between all the current user's fish instances on the current computer, and will be preserved across restarts of the shell. +**-U** or **--universal** + Causes the specified shell variable to be given a universal scope. If this option is supplied, the variable will be shared between all the current user's fish instances on the current computer, and will be preserved across restarts of the shell. These options control additional variable options: -- ``-x`` or ``--export`` causes the specified shell variable to be exported to child processes (making it an "environment variable") +**-x** or **--export** + Causes the specified shell variable to be exported to child processes (making it an "environment variable") -- ``-u`` or ``--unexport`` causes the specified shell variable to NOT be exported to child processes +**-u** or **--unexport** + Causes the specified shell variable to NOT be exported to child processes -- ``--path`` causes the specified variable to be treated as a path variable, meaning it will automatically be split on colons, and joined using colons when quoted (``echo "$PATH"``) or exported. +**--path** + Causes the specified variable to be treated as a :ref:`path variable `, meaning it will automatically be split on colons, and joined using colons when quoted (``echo "$PATH"``) or exported. -- ``--unpath`` causes the specified variable to not be treated as a path variable. Variables with a name ending in "PATH" are automatically path variables, so this can be used to treat such a variable normally. +**--unpath** + Causes the specified variable to not be treated as a :ref:`path variable `. Variables with a name ending in "PATH" are automatically path variables, so this can be used to treat such a variable normally. The following other options are available: -- ``-a`` or ``--append`` causes the values to be appended to the current set of values for the variable. This can be used with ``--prepend`` to both append and prepend at the same time. This cannot be used when assigning to a variable slice. +**-a** or **--append** + Causes the values to be appended to the current set of values for the variable. This can be used with **--prepend** to both append and prepend at the same time. This cannot be used when assigning to a variable slice. -- ``-p`` or ``--prepend`` causes the values to be prepended to the current set of values for the variable. This can be used with ``--append`` to both append and prepend at the same time. This cannot be used when assigning to a variable slice. +**-p** or **--prepend** + Causes the values to be prepended to the current set of values for the variable. This can be used with **--append** to both append and prepend at the same time. This cannot be used when assigning to a variable slice. -- ``-e`` or ``--erase`` causes the specified shell variables to be erased +**-e** or **--erase** + Causes the specified shell variables to be erased -- ``-q`` or ``--query`` test if the specified variable names are defined. Does not output anything, but the builtins exit status is the number of variables specified that were not defined, up to a maximum of 255. If no variable was given, it also returns 255. +**-q** or **--query** + Test if the specified variable names are defined. Does not output anything, but the builtins exit status is the number of variables specified that were not defined, up to a maximum of 255. If no variable was given, it also returns 255. -- ``-n`` or ``--names``: List only the names of all defined variables, not their value. The names are guaranteed to be sorted. +**-n** or **--names** + List only the names of all defined variables, not their value. The names are guaranteed to be sorted. -- ``-S`` or ``--show`` shows information about the given variables. If no variable names are given then all variables are shown in sorted order. It shows the scopes the given variables are set in, along with the values in each and whether or not it is exported. No other flags can be used with this option. +**-S** or **--show** + Shows information about the given variables. If no variable names are given then all variables are shown in sorted order. It shows the scopes the given variables are set in, along with the values in each and whether or not it is exported. No other flags can be used with this option. -- ``-L`` or ``--long`` do not abbreviate long values when printing set variables +**-L** or **--long** + Do not abbreviate long values when printing set variables. +**-h** or **--help** + Displays help about using this command. If a variable is set to more than one value, the variable will be a list with the specified elements. If a variable is set to zero elements, it will become a list with zero elements. @@ -94,12 +111,12 @@ In query mode, the scope to be examined can be specified. Whether the variable h In erase mode, if variable indices are specified, only the specified slices of the list variable will be erased. -``set`` requires all options to come before any other arguments. For example, ``set flags -l`` will have the effect of setting the value of the variable ``flags`` to '-l', not making the variable local. +``set`` requires all options to come before any other arguments. For example, ``set flags -l`` will have the effect of setting the value of the variable :envvar:`flags` to '-l', not making the variable local. Exit status ----------- -In assignment mode, ``set`` does not modify the exit status, but passes along whatever $status was set, including by command substitutions. This allows capturing the output and exit status of a subcommand, like in ``if set output (command)``. +In assignment mode, ``set`` does not modify the exit status, but passes along whatever :envvar:`status` was set, including by command substitutions. This allows capturing the output and exit status of a subcommand, like in ``if set output (command)``. In query mode, the exit status is the number of variables that were not found. @@ -109,7 +126,6 @@ In erase mode, ``set`` exits with a zero exit status in case of success, with a Examples -------- - :: # Prints all global, exported variables. diff --git a/doc_src/cmds/set_color.rst b/doc_src/cmds/set_color.rst index 50a6cc212..db1ba1796 100644 --- a/doc_src/cmds/set_color.rst +++ b/doc_src/cmds/set_color.rst @@ -6,45 +6,61 @@ set_color - set the terminal color Synopsis -------- -:: +.. synopsis:: set_color [OPTIONS] VALUE Description ----------- -``set_color`` is used to control the color and styling of text in the terminal. ``VALUE`` describes that styling. ``VALUE`` can be a reserved color name like *red* or a RGB color value given as 3 or 6 hexadecimal digits ("F27" or "FF2277"). A special keyword *normal* resets text formatting to terminal defaults. +``set_color`` is used to control the color and styling of text in the terminal. *VALUE* describes that styling. *VALUE* can be a reserved color name like **red** or a RGB color value given as 3 or 6 hexadecimal digits ("F27" or "FF2277"). A special keyword **normal** resets text formatting to terminal defaults. Valid colors include: - - *black*, *red*, *green*, *yellow*, *blue*, *magenta*, *cyan*, *white* - - *brblack*, *brred*, *brgreen*, *bryellow*, *brblue*, *brmagenta*, *brcyan*, *brwhite* + - **black**, **red**, **green**, **yellow**, **blue**, **magenta**, **cyan**, **white** + - **brblack**, **brred**, **brgreen**, **bryellow**, **brblue**, **brmagenta**, **brcyan**, **brwhite** -The *br*- (as in 'bright') forms are full-brightness variants of the 8 standard-brightness colors on many terminals. *brblack* has higher brightness than *black* - towards gray. +The *br*- (as in 'bright') forms are full-brightness variants of the 8 standard-brightness colors on many terminals. **brblack** has higher brightness than **black** - towards gray. -An RGB value with three or six hex digits, such as A0FF33 or f2f can be used. ``fish`` will choose the closest supported color. A three digit value is equivalent to specifying each digit twice; e.g., ``set_color 2BC`` is the same as ``set_color 22BBCC``. Hexadecimal RGB values can be in lower or uppercase. Depending on the capabilities of your terminal (and the level of support ``set_color`` has for it) the actual color may be approximated by a nearby matching reserved color name or ``set_color`` may not have an effect on color. +An RGB value with three or six hex digits, such as A0FF33 or f2f can be used. Fish will choose the closest supported color. A three digit value is equivalent to specifying each digit twice; e.g., ``set_color 2BC`` is the same as ``set_color 22BBCC``. Hexadecimal RGB values can be in lower or uppercase. Depending on the capabilities of your terminal (and the level of support ``set_color`` has for it) the actual color may be approximated by a nearby matching reserved color name or ``set_color`` may not have an effect on color. A second color may be given as a desired fallback color. e.g. ``set_color 124212 brblue`` will instruct set_color to use *brblue* if a terminal is not capable of the exact shade of grey desired. This is very useful when an 8 or 16 color terminal might otherwise not use a color. The following options are available: -- ``-b``, ``--background`` *COLOR* sets the background color. -- ``-c``, ``--print-colors`` prints a list of the 16 named colors. -- ``-o``, ``--bold`` sets bold mode. -- ``-d``, ``--dim`` sets dim mode. -- ``-i``, ``--italics`` sets italics mode. -- ``-r``, ``--reverse`` sets reverse mode. -- ``-u``, ``--underline`` sets underlined mode. +**-b** or **--background** *COLOR* + Sets the background color. -Using the *normal* keyword will reset foreground, background, and all formatting back to default. +**-c** or **--print-colors** + Prints a list of the 16 named colors. + +**-o** or **--bold** + Sets bold mode. + +**-d** or **--dim** + Sets dim mode. + +**-i** or **--italics** + Sets italics mode. + +**-r** or **--reverse** + Sets reverse mode. + +**-u** or **--underline** + Sets underlined mode. + +**-h** or **--help** + Displays help about using this command. + +Using the **normal** keyword will reset foreground, background, and all formatting back to default. Notes ----- -1. Using the *normal* keyword will reset both background and foreground colors to whatever is the default for the terminal. +1. Using the **normal** keyword will reset both background and foreground colors to whatever is the default for the terminal. 2. Setting the background color only affects subsequently written characters. Fish provides no way to set the background color for the entire terminal window. Configuring the window background color (and other attributes such as its opacity) has to be done using whatever mechanisms the terminal provides. Look for a config option. 3. Some terminals use the ``--bold`` escape sequence to switch to a brighter color set rather than increasing the weight of text. -4. ``set_color`` works by printing sequences of characters to *stdout*. If used in command substitution or a pipe, these characters will also be captured. This may or may not be desirable. Checking the exit status of ``isatty stdout`` before using ``set_color`` can be useful to decide not to colorize output in a script. +4. ``set_color`` works by printing sequences of characters to standard output. If used in command substitution or a pipe, these characters will also be captured. This may or may not be desirable. Checking the exit status of ``isatty stdout`` before using ``set_color`` can be useful to decide not to colorize output in a script. Examples -------- @@ -65,13 +81,13 @@ Fish uses some heuristics to determine what colors a terminal supports to avoid In particular it will: -- Enable 256 colors if $TERM contains "xterm", except for known exceptions (like MacOS 10.6 Terminal.app) +- Enable 256 colors if :envvar:`TERM` contains "xterm", except for known exceptions (like MacOS 10.6 Terminal.app) - Enable 24-bit ("true-color") even if the $TERM entry only reports 256 colors. This includes modern xterm, VTE-based terminals like Gnome Terminal, Konsole and iTerm2. - Detect support for italics, dim, reverse and other modes. If terminfo reports 256 color support for a terminal, 256 color support will always be enabled. -To force true-color support on or off, set $fish_term24bit to "1" for on and 0 for off - ``set -g fish_term24bit 1``. +To force true-color support on or off, set :envvar:`fish_term24bit`` to "1" for on and 0 for off - ``set -g fish_term24bit 1``. To debug color palette problems, ``tput colors`` may be useful to see the number of colors in terminfo for a terminal. Fish launched as ``fish -d2`` will include diagnostic messages that indicate the color support mode in use. diff --git a/doc_src/cmds/source.rst b/doc_src/cmds/source.rst index af2203992..8dd1cd49c 100644 --- a/doc_src/cmds/source.rst +++ b/doc_src/cmds/source.rst @@ -6,27 +6,28 @@ source - evaluate contents of file Synopsis -------- -:: +.. synopsis:: - source FILENAME [ARGUMENTS...] - somecommand | source + source FILE [ARGUMENTS ...] + SOMECOMMAND | source Description ----------- -``source`` evaluates the commands of the specified file in the current shell as a new block of code. This is different from starting a new process to perform the commands (i.e. ``fish < FILENAME``) since the commands will be evaluated by the current shell, which means that changes in shell variables will affect the current shell. If additional arguments are specified after the file name, they will be inserted into the ``$argv`` variable. The ``$argv`` variable will not include the name of the sourced file. +``source`` evaluates the commands of the specified *FILE* in the current shell as a new block of code. This is different from starting a new process to perform the commands (i.e. ``fish < FILE``) since the commands will be evaluated by the current shell, which means that changes in shell variables will affect the current shell. If additional arguments are specified after the file name, they will be inserted into the :envvar:`argv` variable. The :envvar:`argv` variable will not include the name of the sourced file. -fish will search the working directory to resolve relative paths but will not search ``$PATH``. +fish will search the working directory to resolve relative paths but will not search :envvar:`PATH` . If no file is specified and stdin is not the terminal, or if the file name ``-`` is used, stdin will be read. The exit status of ``source`` is the exit status of the last job to execute. If something goes wrong while opening or reading the file, ``source`` exits with a non-zero status. -``.`` (a single period) is an alias for the ``source`` command. The use of ``.`` is deprecated in favour of ``source``, and ``.`` will be removed in a future version of fish. +**.** (a single period) is an alias for the ``source`` command. The use of **.** is deprecated in favour of ``source``, and **.** will be removed in a future version of fish. ``source`` creates a new :ref:`local scope`; ``set --local`` within a sourced block will not affect variables in the enclosing scope. +The **-h** or **--help** option displays help about using this command. Example ------- @@ -42,4 +43,4 @@ Example Caveats ------- -In fish versions prior to 2.3.0, the ``$argv`` variable would have a single element (the name of the sourced file) if no arguments are present. Otherwise, it would contain arguments without the name of the sourced file. That behavior was very confusing and unlike other shells such as bash and zsh. +In fish versions prior to 2.3.0, the :envvar:`argv` variable would have a single element (the name of the sourced file) if no arguments are present. Otherwise, it would contain arguments without the name of the sourced file. That behavior was very confusing and unlike other shells such as bash and zsh. diff --git a/doc_src/cmds/status.rst b/doc_src/cmds/status.rst index 760023ac8..1508fe8c3 100644 --- a/doc_src/cmds/status.rst +++ b/doc_src/cmds/status.rst @@ -6,7 +6,7 @@ status - query fish runtime information Synopsis -------- -:: +.. synopsis:: status status is-login @@ -34,46 +34,64 @@ Description With no arguments, ``status`` displays a summary of the current login and job control status of the shell. -The following operations (sub-commands) are available: +The following operations (subcommands) are available: -- ``is-command-substitution`` returns 0 if fish is currently executing a command substitution. Also ``-c`` or ``--is-command-substitution``. +**is-command-substitution**, **-c** or **--is-command-substitution** + Returns 0 if fish is currently executing a command substitution. -- ``is-block`` returns 0 if fish is currently executing a block of code. Also ``-b`` or ``--is-block``. +**is-block**, **-b** or **--is-block** + Returns 0 if fish is currently executing a block of code. -- ``is-breakpoint`` returns 0 if fish is currently showing a prompt in the context of a ``breakpoint`` command. See also the ``fish_breakpoint_prompt`` function. +**is-breakpoint** + Returns 0 if fish is currently showing a prompt in the context of a :ref:`breakpoint ` command. See also the :ref:`fish_breakpoint_prompt ` function. -- ``is-interactive`` returns 0 if fish is interactive - that is, connected to a keyboard. Also ``-i`` or ``--is-interactive``. +**is-interactive**, **-i** or **--is-interactive** + Returns 0 if fish is interactive - that is, connected to a keyboard. -- ``is-login`` returns 0 if fish is a login shell - that is, if fish should perform login tasks such as setting up the PATH. Also ``-l`` or ``--is-login``. +**is-login**, **-l** or **--is-login** + Returns 0 if fish is a login shell - that is, if fish should perform login tasks such as setting up :envvar:`PATH`. -- ``is-full-job-control`` returns 0 if full job control is enabled. Also ``--is-full-job-control`` (no short flag). +**is-full-job-control** or **--is-full-job-control** + Returns 0 if full job control is enabled. -- ``is-interactive-job-control`` returns 0 if interactive job control is enabled. Also, ``--is-interactive-job-control`` (no short flag). +**is-interactive-job-control** or **--is-interactive-job-control** + Returns 0 if interactive job control is enabled. -- ``is-no-job-control`` returns 0 if no job control is enabled. Also ``--is-no-job-control`` (no short flag). +**is-no-job-control** or **--is-no-job-control** + Returns 0 if no job control is enabled. -- ``current-command`` prints the name of the currently-running function or command, like the deprecated ``_`` variable. +**current-command** + Prints the name of the currently-running function or command, like the deprecated :envvar:`_` variable. -- ``filename`` prints the filename of the currently running script. Also ``current-filename``, ``-f`` or ``--current-filename``. This depends on how the script was called - if it was called via a symlink, the symlink will be returned, and if the current script was received via ``source`` it will be ``-``. +**filename**, **current-filename**, **-f** or **--current-filename** + Prints the filename of the currently-running script. If the current script was called via a symlink, this will return the symlink. If the current script was received by piping into :ref:`source `, then this will return ``-``. -- ``basename`` prints just the filename of the running script, without any path-components before. +**basename** + Prints just the filename of the running script, without any path components before. -- ``dirname`` prints just the path to the running script, without the actual filename itself. This can be relative to $PWD (including just "."), depending on how the script was called. This is the same as passing the ``filename`` to ``dirname(3)``. It's useful if you want to use other files in the current script's directory or similar. +**dirname** + Prints just the path to the running script, without the actual filename itself. This can be relative to :envvar:`PWD` (including just "."), depending on how the script was called. This is the same as passing the filename to ``dirname(3)``. It's useful if you want to use other files in the current script's directory or similar. -- ``fish-path`` prints the absolute path to the currently executing instance of fish. +**fish-path** + Prints the absolute path to the currently executing instance of fish. -- ``function`` prints the name of the currently called function if able, when missing displays "Not a - function" (or equivalent translated string). Also ``current-function``. +**function** or **current-function** + Prints the name of the currently called function if able, when missing displays "Not a function" (or equivalent translated string). -- ``line-number`` prints the line number of the currently running script. Also ``current-line-number``, ``-n`` or ``--current-line-number``. +**line-number**, **current-line-number**, **-n** or **--current-line-number** + Prints the line number of the currently running script. -- ``stack-trace`` prints a stack trace of all function calls on the call stack. Also ``print-stack-trace``, ``-t`` or ``--print-stack-trace``. +**stack-trace**, **print-stack-trace**, **-t** or **--print-stack-trace** + Prints a stack trace of all function calls on the call stack. -- ``job-control CONTROL_TYPE`` sets the job control type, which can be ``none``, ``full``, or ``interactive``. Also ``-j CONTROL_TYPE`` or ``--job-control CONTROL_TYPE``. +**job-control**, **-j** or **--job-control** *CONTROL_TYPE* + Sets the job control type to *CONTROL_TYPE*, which can be **none**, **full**, or **interactive**. -- ``features`` lists all available feature flags. +**features** + Lists all available feature flags. -- ``test-feature FEATURE`` returns 0 when FEATURE is enabled, 1 if it is disabled, and 2 if it is not recognized. +**test-feature** *FEATURE* + Returns 0 when FEATURE is enabled, 1 if it is disabled, and 2 if it is not recognized. Notes ----- diff --git a/doc_src/cmds/string-collect.rst b/doc_src/cmds/string-collect.rst index 19e757972..ad6d72826 100644 --- a/doc_src/cmds/string-collect.rst +++ b/doc_src/cmds/string-collect.rst @@ -6,9 +6,9 @@ Synopsis .. BEGIN SYNOPSIS -:: +.. synopsis:: - string collect [(-a | --allow-empty)] [(-N | --no-trim-newlines)] [STRING...] + string collect [-N | --no-trim-newlines] [STRING ...] .. END SYNOPSIS @@ -23,9 +23,9 @@ A command like ``echo (cmd | string collect)`` is mostly equivalent to a quoted If invoked with multiple arguments instead of input, ``string collect`` preserves each argument separately, where the number of output arguments is equal to the number of arguments given to ``string collect``. -Any trailing newlines on the input are trimmed, just as with ``"$(cmd)"`` substitution. Use ``--no-trim-newlines`` to disable this behavior, which may be useful when running a command such as ``set contents (cat filename | string collect -N)``. +Any trailing newlines on the input are trimmed, just as with ``"$(cmd)"`` substitution. Use **--no-trim-newlines** to disable this behavior, which may be useful when running a command such as ``set contents (cat filename | string collect -N)``. -With ``--allow-empty``, ``string collect`` always prints one (empty) argument. This can be used to prevent an argument from disappearing. +With **--allow-empty**, ``string collect`` always prints one (empty) argument. This can be used to prevent an argument from disappearing. .. END DESCRIPTION diff --git a/doc_src/cmds/string-escape.rst b/doc_src/cmds/string-escape.rst index 9584e5309..ba9bc250b 100644 --- a/doc_src/cmds/string-escape.rst +++ b/doc_src/cmds/string-escape.rst @@ -6,10 +6,10 @@ Synopsis .. BEGIN SYNOPSIS -:: +.. synopsis:: - string escape [(-n | --no-quoted)] [--style=xxx] [STRING...] - string unescape [--style=xxx] [STRING...] + string escape [-n | --no-quoted] [--style=] [STRING ...] + string unescape [--style=] [STRING ...] .. END SYNOPSIS @@ -18,15 +18,15 @@ Description .. BEGIN DESCRIPTION -``string escape`` escapes each STRING in one of three ways. The first is ``--style=script``. This is the default. It alters the string such that it can be passed back to ``eval`` to produce the original argument again. By default, all special characters are escaped, and quotes are used to simplify the output when possible. If ``-n`` or ``--no-quoted`` is given, the simplifying quoted format is not used. Exit status: 0 if at least one string was escaped, or 1 otherwise. +``string escape`` escapes each *STRING* in one of three ways. The first is **--style=script**. This is the default. It alters the string such that it can be passed back to ``eval`` to produce the original argument again. By default, all special characters are escaped, and quotes are used to simplify the output when possible. If **-n** or **--no-quoted** is given, the simplifying quoted format is not used. Exit status: 0 if at least one string was escaped, or 1 otherwise. -``--style=var`` ensures the string can be used as a variable name by hex encoding any non-alphanumeric characters. The string is first converted to UTF-8 before being encoded. +**--style=var** ensures the string can be used as a variable name by hex encoding any non-alphanumeric characters. The string is first converted to UTF-8 before being encoded. -``--style=url`` ensures the string can be used as a URL by hex encoding any character which is not legal in a URL. The string is first converted to UTF-8 before being encoded. +**--style=url** ensures the string can be used as a URL by hex encoding any character which is not legal in a URL. The string is first converted to UTF-8 before being encoded. -``--style=regex`` escapes an input string for literal matching within a regex expression. The string is first converted to UTF-8 before being encoded. +**--style=regex** escapes an input string for literal matching within a regex expression. The string is first converted to UTF-8 before being encoded. -``string unescape`` performs the inverse of the ``string escape`` command. If the string to be unescaped is not properly formatted it is ignored. For example, doing ``string unescape --style=var (string escape --style=var $str)`` will return the original string. There is no support for unescaping ``--style=regex``. +``string unescape`` performs the inverse of the ``string escape`` command. If the string to be unescaped is not properly formatted it is ignored. For example, doing ``string unescape --style=var (string escape --style=var $str)`` will return the original string. There is no support for unescaping **--style=regex**. .. END DESCRIPTION diff --git a/doc_src/cmds/string-join.rst b/doc_src/cmds/string-join.rst index 6a2effa1a..e9c01df33 100644 --- a/doc_src/cmds/string-join.rst +++ b/doc_src/cmds/string-join.rst @@ -6,10 +6,10 @@ Synopsis .. BEGIN SYNOPSIS -:: +.. synopsis:: - string join [(-q | --quiet)] SEP [STRING...] - string join0 [(-q | --quiet)] [STRING...] + string join [-q | --quiet] SEP [STRING ...] + string join0 [-q | --quiet] [STRING ...] .. END SYNOPSIS @@ -18,9 +18,9 @@ Description .. BEGIN DESCRIPTION -``string join`` joins its STRING arguments into a single string separated by SEP, which can be an empty string. Exit status: 0 if at least one join was performed, or 1 otherwise. +``string join`` joins its *STRING* arguments into a single string separated by *SEP*, which can be an empty string. Exit status: 0 if at least one join was performed, or 1 otherwise. -``string join0`` joins its STRING arguments into a single string separated by the zero byte (NUL), and adds a trailing NUL. This is most useful in conjunction with tools that accept NUL-delimited input, such as ``sort -z``. Exit status: 0 if at least one join was performed, or 1 otherwise. +``string join0`` joins its *STRING* arguments into a single string separated by the zero byte (NUL), and adds a trailing NUL. This is most useful in conjunction with tools that accept NUL-delimited input, such as ``sort -z``. Exit status: 0 if at least one join was performed, or 1 otherwise. Because Unix uses NUL as the string terminator, passing the output of ``string join0`` as an *argument* to a command (via a :ref:`command substitution `) won't actually work. Fish will pass the correct bytes along, but the command won't be able to tell where the argument ends. This is a limitation of Unix' argument passing. diff --git a/doc_src/cmds/string-length.rst b/doc_src/cmds/string-length.rst index 3b609b5f5..6f59b6fdb 100644 --- a/doc_src/cmds/string-length.rst +++ b/doc_src/cmds/string-length.rst @@ -8,9 +8,9 @@ Synopsis .. BEGIN SYNOPSIS -:: +.. synopsis:: - string length [(-q | --quiet)] [(-V | --visible)] [STRING...] + string length [-q | --quiet] [-V | --visible] [STRING ...] .. END SYNOPSIS @@ -19,9 +19,9 @@ Description .. BEGIN DESCRIPTION -``string length`` reports the length of each string argument in characters. Exit status: 0 if at least one non-empty STRING was given, or 1 otherwise. +``string length`` reports the length of each string argument in characters. Exit status: 0 if at least one non-empty *STRING* was given, or 1 otherwise. -With ``-V`` or ``--visible``, it uses the visible width of the arguments. That means it will discount escape sequences fish knows about, account for $fish_emoji_width and $fish_ambiguous_width. It will also count each line (separated by ``\n``) on its own, and with a carriage return (``\r``) count only the widest stretch on a line. The intent is to measure the number of columns the STRING would occupy in the current terminal. +With **-V** or **--visible**, it uses the visible width of the arguments. That means it will discount escape sequences fish knows about, account for $fish_emoji_width and $fish_ambiguous_width. It will also count each line (separated by ``\n``) on its own, and with a carriage return (``\r``) count only the widest stretch on a line. The intent is to measure the number of columns the *STRING* would occupy in the current terminal. .. END DESCRIPTION diff --git a/doc_src/cmds/string-lower.rst b/doc_src/cmds/string-lower.rst index 08e359efe..3188b621e 100644 --- a/doc_src/cmds/string-lower.rst +++ b/doc_src/cmds/string-lower.rst @@ -6,9 +6,9 @@ Synopsis .. BEGIN SYNOPSIS -:: +.. synopsis:: - string lower [(-q | --quiet)] [STRING...] + string lower [-q | --quiet] [STRING ...] .. END SYNOPSIS @@ -17,7 +17,7 @@ Description .. BEGIN DESCRIPTION -``string lower`` converts each string argument to lowercase. Exit status: 0 if at least one string was converted to lowercase, else 1. This means that in conjunction with the ``-q`` flag you can readily test whether a string is already lowercase. +``string lower`` converts each string argument to lowercase. Exit status: 0 if at least one string was converted to lowercase, else 1. This means that in conjunction with the **-q** flag you can readily test whether a string is already lowercase. .. END DESCRIPTION diff --git a/doc_src/cmds/string-match.rst b/doc_src/cmds/string-match.rst index 3a3eaa0e3..f0d58930a 100644 --- a/doc_src/cmds/string-match.rst +++ b/doc_src/cmds/string-match.rst @@ -6,32 +6,34 @@ Synopsis .. BEGIN SYNOPSIS -:: +.. synopsis:: - string match [(-a | --all)] [(-e | --entire)] [(-i | --ignore-case)] [(-g | --groups-only)] [(-r | --regex)] [(-n | --index)] [(-q | --quiet)] [(-v | --invert)] PATTERN [STRING...] + string match [-a | --all] [-e | --entire] [-i | --ignore-case] + [-r | --regex] [-n | --index] [-q | --quiet] [-v | --invert] + PATTERN [STRING ...] -. END SYNOPSIS +.. END SYNOPSIS Description ----------- .. BEGIN DESCRIPTION -``string match`` tests each STRING against PATTERN and prints matching substrings. Only the first match for each STRING is reported unless ``-a`` or ``--all`` is given, in which case all matches are reported. +``string match`` tests each *STRING* against *PATTERN* and prints matching substrings. Only the first match for each *STRING* is reported unless **-a** or **--all** is given, in which case all matches are reported. -If you specify the ``-e`` or ``--entire`` then each matching string is printed including any prefix or suffix not matched by the pattern (equivalent to ``grep`` without the ``-o`` flag). You can, obviously, achieve the same result by prepending and appending ``*`` or ``.*`` depending on whether or not you have specified the ``--regex`` flag. The ``--entire`` flag is simply a way to avoid having to complicate the pattern in that fashion and make the intent of the ``string match`` clearer. Without ``--entire`` and ``--regex``, a PATTERN will need to match the entire STRING before it will be reported. +If you specify the **-e** or **--entire** then each matching string is printed including any prefix or suffix not matched by the pattern (equivalent to ``grep`` without the **-o** flag). You can, obviously, achieve the same result by prepending and appending **\*** or **.*** depending on whether or not you have specified the **--regex** flag. The **--entire** flag is simply a way to avoid having to complicate the pattern in that fashion and make the intent of the ``string match`` clearer. Without **--entire** and **--regex**, a *PATTERN* will need to match the entire *STRING* before it will be reported. -Matching can be made case-insensitive with ``--ignore-case`` or ``-i``. +Matching can be made case-insensitive with **--ignore-case** or **-i**. -If ``--groups-only`` or ``-g`` is given, only the capturing groups will be reported - meaning the full match will be skipped. This is incompatible with ``--entire`` and ``--invert``, and requires ``--regex``. It is useful as a simple cutting tool instead of ``string replace``, so you can simply choose "this part" of a string. +If **--groups-only** or **-g** is given, only the capturing groups will be reported - meaning the full match will be skipped. This is incompatible with **--entire** and **--invert**, and requires **--regex**. It is useful as a simple cutting tool instead of ``string replace``, so you can simply choose "this part" of a string. -If ``--index`` or ``-n`` is given, each match is reported as a 1-based start position and a length. By default, PATTERN is interpreted as a glob pattern matched against each entire STRING argument. A glob pattern is only considered a valid match if it matches the entire STRING. +If **--index** or **-n** is given, each match is reported as a 1-based start position and a length. By default, PATTERN is interpreted as a glob pattern matched against each entire *STRING* argument. A glob pattern is only considered a valid match if it matches the entire *STRING*. -If ``--regex`` or ``-r`` is given, PATTERN is interpreted as a Perl-compatible regular expression, which does not have to match the entire STRING. For a regular expression containing capturing groups, multiple items will be reported for each match, one for the entire match and one for each capturing group. With this, only the matching part of the STRING will be reported, unless ``--entire`` is given. +If **--regex** or **-r** is given, *PATTERN* is interpreted as a Perl-compatible regular expression, which does not have to match the entire *STRING*. For a regular expression containing capturing groups, multiple items will be reported for each match, one for the entire match and one for each capturing group. With this, only the matching part of the *STRING* will be reported, unless **--entire** is given. -When matching via regular expressions, ``string match`` automatically sets variables for all named capturing groups (``(?expression)``). It will create a variable with the name of the group, in the default scope, for each named capturing group, and set it to the value of the capturing group in the first matched argument. If a named capture group matched an empty string, the variable will be set to the empty string (like ``set var ""``). If it did not match, the variable will be set to nothing (like ``set var``). When ``--regex`` is used with ``--all``, this behavior changes. Each named variable will contain a list of matches, with the first match contained in the first element, the second match in the second, and so on. If the group was empty or did not match, the corresponding element will be an empty string. +When matching via regular expressions, ``string match`` automatically sets variables for all named capturing groups (``(?expression)``). It will create a variable with the name of the group, in the default scope, for each named capturing group, and set it to the value of the capturing group in the first matched argument. If a named capture group matched an empty string, the variable will be set to the empty string (like ``set var ""``). If it did not match, the variable will be set to nothing (like ``set var``). When **--regex** is used with **--all**, this behavior changes. Each named variable will contain a list of matches, with the first match contained in the first element, the second match in the second, and so on. If the group was empty or did not match, the corresponding element will be an empty string. -If ``--invert`` or ``-v`` is used the selected lines will be only those which do not match the given glob pattern or regular expression. +If **--invert** or **-v** is used the selected lines will be only those which do not match the given glob pattern or regular expression. Exit status: 0 if at least one match was found, or 1 otherwise. diff --git a/doc_src/cmds/string-pad.rst b/doc_src/cmds/string-pad.rst index 6b1a0a5fc..e7f61a0a3 100644 --- a/doc_src/cmds/string-pad.rst +++ b/doc_src/cmds/string-pad.rst @@ -6,9 +6,10 @@ Synopsis .. BEGIN SYNOPSIS -:: +.. synopsis:: - string pad [(-r | --right)] [(-c | --char) CHAR] [(-w | --width) INTEGER] [STRING...] + string pad [-r | --right] [(-c | --char) CHAR] [(-w | --width) INTEGER] + [STRING ...] .. END SYNOPSIS @@ -17,15 +18,15 @@ Description .. BEGIN DESCRIPTION -``string pad`` extends each STRING to the given visible width by adding CHAR to the left. That means the width of all visible characters added together, excluding escape sequences and accounting for $fish_emoji_width and $fish_ambiguous_width. It is the amount of columns in a terminal the STRING occupies. +``string pad`` extends each *STRING* to the given visible width by adding *CHAR* to the left. That means the width of all visible characters added together, excluding escape sequences and accounting for :envvar:`fish_emoji_width` and :envvar:`fish_ambiguous_width`. It is the amount of columns in a terminal the *STRING* occupies. -The escape sequences reflect what *fish* knows about, and how it computes its output. Your terminal might support more escapes, or not support escape sequences that fish knows about. +The escape sequences reflect what fish knows about, and how it computes its output. Your terminal might support more escapes, or not support escape sequences that fish knows about. -If ``-r`` or ``--right`` is given, add the padding after a string. +If **-r** or **--right** is given, add the padding after a string. -If ``-c`` or ``--char`` is given, pad with CHAR instead of whitespace. +If **-c** or **--char** is given, pad with *CHAR* instead of whitespace. -The output is padded to the maximum width of all input strings. If ``-w`` or ``--width`` is given, use at least that. +The output is padded to the maximum width of all input strings. If **-w** or **--width** is given, use at least that. .. END DESCRIPTION diff --git a/doc_src/cmds/string-repeat.rst b/doc_src/cmds/string-repeat.rst index f5b597324..fdaf076d4 100644 --- a/doc_src/cmds/string-repeat.rst +++ b/doc_src/cmds/string-repeat.rst @@ -6,9 +6,10 @@ Synopsis .. BEGIN SYNOPSIS -:: +.. synopsis:: - string repeat [(-n | --count) COUNT] [(-m | --max) MAX] [(-N | --no-newline)] [(-q | --quiet)] [STRING...] + string repeat [(-n | --count) COUNT] [(-m | --max) MAX] [-N | --no-newline] + [-q | --quiet] [STRING ...] .. END SYNOPSIS @@ -17,7 +18,7 @@ Description .. BEGIN DESCRIPTION -``string repeat`` repeats the STRING ``-n`` or ``--count`` times. The ``-m`` or ``--max`` option will limit the number of outputted char (excluding the newline). This option can be used by itself or in conjunction with ``--count``. If both ``--count`` and ``--max`` are present, max char will be outputed unless the final repeated string size is less than max, in that case, the string will repeat until count has been reached. Both ``--count`` and ``--max`` will accept a number greater than or equal to zero, in the case of zero, nothing will be outputed. If ``-N`` or ``--no-newline`` is given, the output won't contain a newline character at the end. Exit status: 0 if yielded string is not empty, 1 otherwise. +``string repeat`` repeats the *STRING* **-n** or **--count** times. The **-m** or **--max** option will limit the number of outputted characters (excluding the newline). This option can be used by itself or in conjunction with **--count**. If both **--count** and **--max** are present, max char will be outputed unless the final repeated string size is less than max, in that case, the string will repeat until count has been reached. Both **--count** and **--max** will accept a number greater than or equal to zero, in the case of zero, nothing will be outputed. If **-N** or **--no-newline** is given, the output won't contain a newline character at the end. Exit status: 0 if yielded string is not empty, 1 otherwise. .. END DESCRIPTION diff --git a/doc_src/cmds/string-replace.rst b/doc_src/cmds/string-replace.rst index b9396873d..059c5c86f 100644 --- a/doc_src/cmds/string-replace.rst +++ b/doc_src/cmds/string-replace.rst @@ -6,9 +6,10 @@ Synopsis .. BEGIN SYNOPSIS -:: +.. synopsis:: - string replace [(-a | --all)] [(-f | --filter)] [(-i | --ignore-case)] [(-r | --regex)] [(-q | --quiet)] PATTERN REPLACEMENT [STRING...] + string replace [-a | --all] [-f | --filter] [-i | --ignore-case] + [-r | --regex] [-q | --quiet] PATTERN REPLACEMENT [STRING ...] .. END SYNOPSIS @@ -17,11 +18,11 @@ Description .. BEGIN DESCRIPTION -``string replace`` is similar to ``string match`` but replaces non-overlapping matching substrings with a replacement string and prints the result. By default, PATTERN is treated as a literal substring to be matched. +``string replace`` is similar to ``string match`` but replaces non-overlapping matching substrings with a replacement string and prints the result. By default, *PATTERN* is treated as a literal substring to be matched. -If ``-r`` or ``--regex`` is given, PATTERN is interpreted as a Perl-compatible regular expression, and REPLACEMENT can contain C-style escape sequences like ``\t`` as well as references to capturing groups by number or name as ``$n`` or ``${n}``. +If **-r** or **--regex** is given, *PATTERN* is interpreted as a Perl-compatible regular expression, and *REPLACEMENT* can contain C-style escape sequences like **\t** as well as references to capturing groups by number or name as *$n* or *${n}*. -If you specify the ``-f`` or ``--filter`` flag then each input string is printed only if a replacement was done. This is useful where you would otherwise use this idiom: ``a_cmd | string match pattern | string replace pattern new_pattern``. You can instead just write ``a_cmd | string replace --filter pattern new_pattern``. +If you specify the **-f** or **--filter** flag then each input string is printed only if a replacement was done. This is useful where you would otherwise use this idiom: ``a_cmd | string match pattern | string replace pattern new_pattern``. You can instead just write ``a_cmd | string replace --filter pattern new_pattern``. Exit status: 0 if at least one replacement was performed, or 1 otherwise. diff --git a/doc_src/cmds/string-split.rst b/doc_src/cmds/string-split.rst index a43d9aa86..084742e5a 100644 --- a/doc_src/cmds/string-split.rst +++ b/doc_src/cmds/string-split.rst @@ -6,10 +6,12 @@ Synopsis .. BEGIN SYNOPSIS -:: +.. synopsis:: - string split [(-f | --fields) FIELDS] [(-m | --max) MAX] [(-n | --no-empty)] [(-q | --quiet)] [(-r | --right)] SEP [STRING...] - string split0 [(-f | --fields) FIELDS] [(-m | --max) MAX] [(-n | --no-empty)] [(-q | --quiet)] [(-r | --right)] [STRING...] + string split [(-m | --max) MAX] [-n | --no-empty] [-q | --quiet] + [-r | --right] SEP [STRING ...] + string split0 [(-m | --max) MAX] [-n | --no-empty] [-q | --quiet] + [-r | --right] [STRING ...] .. END SYNOPSIS @@ -18,13 +20,13 @@ Description .. BEGIN DESCRIPTION -``string split`` splits each STRING on the separator SEP, which can be an empty string. If ``-m`` or ``--max`` is specified, at most MAX splits are done on each STRING. If ``-r`` or ``--right`` is given, splitting is performed right-to-left. This is useful in combination with ``-m`` or ``--max``. With ``-n`` or ``--no-empty``, empty results are excluded from consideration (e.g. ``hello\n\nworld`` would expand to two strings and not three). Exit status: 0 if at least one split was performed, or 1 otherwise. +``string split`` splits each *STRING* on the separator *SEP*, which can be an empty string. If **-m** or **--max** is specified, at most MAX splits are done on each *STRING*. If **-r** or **--right** is given, splitting is performed right-to-left. This is useful in combination with **-m** or **--max**. With **-n** or **--no-empty**, empty results are excluded from consideration (e.g. ``hello\n\nworld`` would expand to two strings and not three). Exit status: 0 if at least one split was performed, or 1 otherwise. -Use ``-f`` or ``--fields`` to print out specific fields. Unless ``--allow-empty`` is used, if a given field does not exist, then the command exits with status 1 and does not print anything. +Use **-f** or **--fields** to print out specific fields. Unless **--allow-empty** is used, if a given field does not exist, then the command exits with status 1 and does not print anything. -See also the ``--delimiter`` option of the :ref:`read ` command. +See also the **--delimiter** option of the :ref:`read ` command. -``string split0`` splits each STRING on the zero byte (NUL). Options are the same as ``string split`` except that no separator is given. +``string split0`` splits each *STRING* on the zero byte (NUL). Options are the same as ``string split`` except that no separator is given. ``split0`` has the important property that its output is not further split when used in a command substitution, allowing for the command substitution to produce elements containing newlines. This is most useful when used with Unix tools that produce zero bytes, such as ``find -print0`` or ``sort -z``. See split0 examples below. diff --git a/doc_src/cmds/string-sub.rst b/doc_src/cmds/string-sub.rst index a10d8f0fa..04c243eb8 100644 --- a/doc_src/cmds/string-sub.rst +++ b/doc_src/cmds/string-sub.rst @@ -6,9 +6,10 @@ Synopsis .. BEGIN SYNOPSIS -:: +.. synopsis:: - string sub [(-s | --start) START] [(-e | --end) END] [(-l | --length) LENGTH] [(-q | --quiet)] [STRING...] + string sub [(-s | --start) START] [(-l | --length) LENGTH] + [-q | --quiet] [STRING ...] .. END SYNOPSIS @@ -17,7 +18,7 @@ Description .. BEGIN DESCRIPTION -``string sub`` prints a substring of each string argument. The start/end of the substring can be specified with ``-s``/``-e`` or ``--start``/``--end`` followed by a 1-based index value. Positive index values are relative to the start of the string and negative index values are relative to the end of the string. The default start value is 1. The length of the substring can be specified with ``-l`` or ``--length``. If the length or end is not specified, the substring continues to the end of each STRING. Exit status: 0 if at least one substring operation was performed, 1 otherwise. ``--length`` is mutually exclusive with ``--end``. +``string sub`` prints a substring of each string argument. The start/end of the substring can be specified with **-s**/**-e** or **--start**/**--end** followed by a 1-based index value. Positive index values are relative to the start of the string and negative index values are relative to the end of the string. The default start value is 1. The length of the substring can be specified with **-l** or **--length**. If the length or end is not specified, the substring continues to the end of each STRING. Exit status: 0 if at least one substring operation was performed, 1 otherwise. **--length** is mutually exclusive with **--end**. .. END DESCRIPTION diff --git a/doc_src/cmds/string-trim.rst b/doc_src/cmds/string-trim.rst index 832f4f653..2e6ed048b 100644 --- a/doc_src/cmds/string-trim.rst +++ b/doc_src/cmds/string-trim.rst @@ -6,9 +6,10 @@ Synopsis .. BEGIN SYNOPSIS -:: +.. synopsis:: - string trim [(-l | --left)] [(-r | --right)] [(-c | --chars CHARS)] [(-q | --quiet)] [STRING...] + string trim [-l | --left] [-r | --right] [(-c | --chars) CHARS] + [-q | --quiet] [STRING ...] .. END SYNOPSIS @@ -17,7 +18,7 @@ Description .. BEGIN DESCRIPTION -``string trim`` removes leading and trailing whitespace from each STRING. If ``-l`` or ``--left`` is given, only leading whitespace is removed. If ``-r`` or ``--right`` is given, only trailing whitespace is trimmed. The ``-c`` or ``--chars`` switch causes the characters in CHARS to be removed instead of whitespace. Exit status: 0 if at least one character was trimmed, or 1 otherwise. +``string trim`` removes leading and trailing whitespace from each *STRING*. If **-l** or **--left** is given, only leading whitespace is removed. If **-r** or **--right** is given, only trailing whitespace is trimmed. The **-c** or **--chars** switch causes the characters in *CHARS* to be removed instead of whitespace. Exit status: 0 if at least one character was trimmed, or 1 otherwise. .. END DESCRIPTION diff --git a/doc_src/cmds/string-upper.rst b/doc_src/cmds/string-upper.rst index e73da7dfc..87c120630 100644 --- a/doc_src/cmds/string-upper.rst +++ b/doc_src/cmds/string-upper.rst @@ -6,9 +6,9 @@ Synopsis .. BEGIN SYNOPSIS -:: +.. synopsis:: - string upper [(-q | --quiet)] [STRING...] + string upper [-q | --quiet] [STRING ...] .. END SYNOPSIS @@ -17,7 +17,7 @@ Description .. BEGIN DESCRIPTION -``string upper`` converts each string argument to uppercase. Exit status: 0 if at least one string was converted to uppercase, else 1. This means that in conjunction with the ``-q`` flag you can readily test whether a string is already uppercase. +``string upper`` converts each string argument to uppercase. Exit status: 0 if at least one string was converted to uppercase, else 1. This means that in conjunction with the **-q** flag you can readily test whether a string is already uppercase. .. END DESCRIPTION diff --git a/doc_src/cmds/string.rst b/doc_src/cmds/string.rst index 854ff6191..a7a23484a 100644 --- a/doc_src/cmds/string.rst +++ b/doc_src/cmds/string.rst @@ -6,35 +6,44 @@ string - manipulate strings Synopsis -------- -:: +.. synopsis:: - string collect [(-N | --no-trim-newlines)] [STRING...] - string escape [(-n | --no-quoted)] [--style=xxx] [STRING...] - string join [(-q | --quiet)] SEP [STRING...] - string join0 [(-q | --quiet)] [STRING...] - string length [(-q | --quiet)] [STRING...] - string lower [(-q | --quiet)] [STRING...] - string match [(-a | --all)] [(-e | --entire)] [(-i | --ignore-case)] [(-r | --regex)] [(-n | --index)] [(-q | --quiet)] [(-v | --invert)] PATTERN [STRING...] - string pad [(-r | --right)] [(-c | --char) CHAR] [(-w | --width) INTEGER] [STRING...] - string repeat [(-n | --count) COUNT] [(-m | --max) MAX] [(-N | --no-newline)] [(-q | --quiet)] [STRING...] - string replace [(-a | --all)] [(-f | --filter)] [(-i | --ignore-case)] [(-r | --regex)] [(-q | --quiet)] PATTERN REPLACEMENT [STRING...] - string split [(-m | --max) MAX] [(-n | --no-empty)] [(-q | --quiet)] [(-r | --right)] SEP [STRING...] - string split0 [(-m | --max) MAX] [(-n | --no-empty)] [(-q | --quiet)] [(-r | --right)] [STRING...] - string sub [(-s | --start) START] [(-l | --length) LENGTH] [(-q | --quiet)] [STRING...] - string trim [(-l | --left)] [(-r | --right)] [(-c | --chars CHARS)] [(-q | --quiet)] [STRING...] - string unescape [--style=xxx] [STRING...] - string upper [(-q | --quiet)] [STRING...] + string collect [-N | --no-trim-newlines] [STRING ...] + string escape [-n | --no-quoted] [--style=] [STRING ...] + string join [-q | --quiet] SEP [STRING ...] + string join0 [-q | --quiet] [STRING ...] + string length [-q | --quiet] [STRING ...] + string lower [-q | --quiet] [STRING ...] + string match [-a | --all] [-e | --entire] [-i | --ignore-case] + [-r | --regex] [-n | --index] [-q | --quiet] [-v | --invert] + PATTERN [STRING ...] + string pad [-r | --right] [-c | --char CHAR] [-w | --width INTEGER] + [STRING ...] + string repeat [(-n | --count) COUNT] [(-m | --max) MAX] [-N | --no-newline] + [-q | --quiet] [STRING ...] + string replace [-a | --all] [-f | --filter] [-i | --ignore-case] + [-r | --regex] [-q | --quiet] PATTERN REPLACE [STRING ...] + string split [(-m | --max) MAX] [-n | --no-empty] [-q | --quiet] + [-r | --right] SEP [STRING ...] + string split0 [(-m | --max) MAX] [-n | --no-empty] [-q | --quiet] + [-r | --right] [STRING ...] + string sub [(-s | --start) START] [(-l | --length) LENGTH] + [-q | --quiet] [STRING ...] + string trim [-l | --left] [-r | --right] [(-c | --chars) CHARS] + [-q | --quiet] [STRING ...] + string unescape [--style=] [STRING ...] + string upper [-q | --quiet] [STRING ...] Description ----------- ``string`` performs operations on strings. -STRING arguments are taken from the command line unless standard input is connected to a pipe or a file, in which case they are read from standard input, one STRING per line. It is an error to supply STRING arguments on the command line and on standard input. +*STRING* arguments are taken from the command line unless standard input is connected to a pipe or a file, in which case they are read from standard input, one *STRING* per line. It is an error to supply *STRING* arguments on the command line and on standard input. Arguments beginning with ``-`` are normally interpreted as switches; ``--`` causes the following arguments not to be treated as switches even if they begin with ``-``. Switches and required arguments are recognized only on the command line. -Most subcommands accept a ``-q`` or ``--quiet`` switch, which suppresses the usual output but exits with the documented status. In this case these commands will quit early, without reading all of the available input. +Most subcommands accept a **-q** or **--quiet** switch, which suppresses the usual output but exits with the documented status. In this case these commands will quit early, without reading all of the available input. The following subcommands are available. @@ -265,7 +274,7 @@ Examples Regular Expressions ------------------- -Both the ``match`` and ``replace`` subcommand support regular expressions when used with the ``-r`` or ``--regex`` option. The dialect is that of PCRE2. +Both the ``match`` and ``replace`` subcommand support regular expressions when used with the **-r** or **--regex** option. The dialect is that of PCRE2. In general, special characters are special by default, so ``a+`` matches one or more "a"s, while ``a\+`` matches an "a" and then a "+". ``(a+)`` matches one or more "a"s in a capturing group (``(?:XXXX)`` denotes a non-capturing group). For the replacement parameter of ``replace``, ``$n`` refers to the n-th group of the match. In the match parameter, ``\n`` (e.g. ``\1``) refers back to groups. @@ -326,7 +335,7 @@ If you are familiar with these, it is useful to know how ``string`` differs from In contrast to these classics, ``string`` reads input either from stdin or as arguments. ``string`` also does not deal with files, so it requires redirections to be used with them. -In contrast to ``grep``, ``string``'s ``match`` defaults to glob-mode, while ``replace`` defaults to literal matching. If set to regex-mode, they use PCRE regular expressions, which is comparable to ``grep``'s ``-P`` option. ``match`` defaults to printing just the match, which is like ``grep`` with ``-o`` (use ``--entire`` to enable grep-like behavior). +In contrast to ``grep``, ``string``'s ``match`` defaults to glob-mode, while ``replace`` defaults to literal matching. If set to regex-mode, they use PCRE regular expressions, which is comparable to ``grep``'s ``-P`` option. ``match`` defaults to printing just the match, which is like ``grep`` with ``-o`` (use **--entire** to enable grep-like behavior). Like ``sed``'s ``s/old/new/`` command, ``string replace`` still prints strings that don't match. ``sed``'s ``-n`` in combination with a ``/p`` modifier or command is like ``string replace -f``. diff --git a/doc_src/cmds/suspend.rst b/doc_src/cmds/suspend.rst index b82ce5940..529beef71 100644 --- a/doc_src/cmds/suspend.rst +++ b/doc_src/cmds/suspend.rst @@ -6,11 +6,11 @@ suspend - suspend the current shell Synopsis -------- -:: +.. synopsis:: suspend [--force] Description ----------- -``suspend`` suspends execution of the current shell by sending it a SIGTSTP signal, returning to the controlling process. It can be resumed later by sending it a SIGCONT. In order to prevent suspending a shell that doesn't have a controlling process, it will not suspend the shell if it is a login shell. This requirement is bypassed if the ``--force`` option is given or the shell is not interactive. +``suspend`` suspends execution of the current shell by sending it a SIGTSTP signal, returning to the controlling process. It can be resumed later by sending it a SIGCONT. In order to prevent suspending a shell that doesn't have a controlling process, it will not suspend the shell if it is a login shell. This requirement is bypassed if the **--force** option is given or the shell is not interactive. diff --git a/doc_src/cmds/switch.rst b/doc_src/cmds/switch.rst index ca42f7519..0d7b1caa4 100644 --- a/doc_src/cmds/switch.rst +++ b/doc_src/cmds/switch.rst @@ -6,16 +6,16 @@ switch - conditionally execute a block of commands Synopsis -------- -:: +.. synopsis:: - switch VALUE; [case [WILDCARD...]; [COMMANDS...]; ...] end + switch VALUE; [case [GLOB ...]; [COMMANDS ...]; ...] end Description ----------- -``switch`` performs one of several blocks of commands, depending on whether a specified value equals one of several wildcarded values. ``case`` is used together with the ``switch`` statement in order to determine which block should be executed. +``switch`` performs one of several blocks of commands, depending on whether a specified value equals one of several globbed values. ``case`` is used together with the ``switch`` statement in order to determine which block should be executed. -Each ``case`` command is given one or more parameters. The first ``case`` command with a parameter that matches the string specified in the switch command will be evaluated. ``case`` parameters may contain wildcards. These need to be escaped or quoted in order to avoid regular wildcard expansion using filenames. +Each ``case`` command is given one or more parameters. The first ``case`` command with a parameter that matches the string specified in the switch command will be evaluated. ``case`` parameters may contain globs. These need to be escaped or quoted in order to avoid regular glob expansion using filenames. Note that fish does not fall through on case statements. Only the first matching case is executed. @@ -25,9 +25,7 @@ Note that command substitutions in a case statement will be evaluated even if it Example ------- -If the variable \$animal contains the name of an animal, the following code would attempt to classify it: - - +If the variable :envvar:`animal` contains the name of an animal, the following code would attempt to classify it: :: diff --git a/doc_src/cmds/test.rst b/doc_src/cmds/test.rst index dcb610efe..b3d865690 100644 --- a/doc_src/cmds/test.rst +++ b/doc_src/cmds/test.rst @@ -6,7 +6,7 @@ test - perform tests on files and text Synopsis -------- -:: +.. synopsis:: test [EXPRESSION] [ [EXPRESSION] ] @@ -23,7 +23,7 @@ Description Tests the expression given and sets the exit status to 0 if true, and 1 if false. An expression is made up of one or more operators and their arguments. -The first form (``test``) is preferred. For compatibility with other shells, the second form is available: a matching pair of square brackets (``[ [EXPRESSION ] ]``). +The first form (``test``) is preferred. For compatibility with other shells, the second form is available: a matching pair of square brackets (``[ [EXPRESSION] ]``). This test is mostly POSIX-compatible. @@ -32,86 +32,118 @@ When using a variable as an argument for a test operator you should almost alway Operators for files and directories ----------------------------------- -- ``-b FILE`` returns true if ``FILE`` is a block device. +**-b** *FILE* + Returns true if *FILE* is a block device. -- ``-c FILE`` returns true if ``FILE`` is a character device. +**-c** *FILE* + Returns true if *FILE* is a character device. -- ``-d FILE`` returns true if ``FILE`` is a directory. +**-d** *FILE* + Returns true if *FILE* is a directory. -- ``-e FILE`` returns true if ``FILE`` exists. +**-e** *FILE* + Returns true if *FILE* exists. -- ``-f FILE`` returns true if ``FILE`` is a regular file. +**-f** *FILE* + Returns true if *FILE* is a regular file. -- ``-g FILE`` returns true if ``FILE`` has the set-group-ID bit set. +**-g** *FILE* + Returns true if *FILE* has the set-group-ID bit set. -- ``-G FILE`` returns true if ``FILE`` exists and has the same group ID as the current user. +**-G** *FILE* + Returns true if *FILE* exists and has the same group ID as the current user. -- ``-k FILE`` returns true if ``FILE`` has the sticky bit set. If the OS does not support the concept it returns false. See https://en.wikipedia.org/wiki/Sticky_bit. +**-k** *FILE* + Returns true if *FILE* has the sticky bit set. If the OS does not support the concept it returns false. See https://en.wikipedia.org/wiki/Sticky_bit. -- ``-L FILE`` returns true if ``FILE`` is a symbolic link. +**-L** *FILE* + Returns true if *FILE* is a symbolic link. -- ``-O FILE`` returns true if ``FILE`` exists and is owned by the current user. +**-O** *FILE* + Returns true if *FILE* exists and is owned by the current user. -- ``-p FILE`` returns true if ``FILE`` is a named pipe. +**-p** *FILE* + Returns true if *FILE* is a named pipe. -- ``-r FILE`` returns true if ``FILE`` is marked as readable. +**-r** *FILE* + Returns true if *FILE* is marked as readable. -- ``-s FILE`` returns true if the size of ``FILE`` is greater than zero. +**-s** *FILE* + Returns true if the size of *FILE* is greater than zero. -- ``-S FILE`` returns true if ``FILE`` is a socket. +**-S** *FILE* + Returns true if *FILE* is a socket. -- ``-t FD`` returns true if the file descriptor ``FD`` is a terminal (TTY). +**-t** *FD* + Returns true if the file descriptor *FD* is a terminal (TTY). -- ``-u FILE`` returns true if ``FILE`` has the set-user-ID bit set. +**-u** *FILE* + Returns true if *FILE* has the set-user-ID bit set. -- ``-w FILE`` returns true if ``FILE`` is marked as writable; note that this does not check if the filesystem is read-only. +**-w** *FILE* + Returns true if *FILE* is marked as writable; note that this does not check if the filesystem is read-only. -- ``-x FILE`` returns true if ``FILE`` is marked as executable. +**-x** *FILE* + Returns true if *FILE* is marked as executable. Operators for text strings -------------------------- -- ``STRING1 = STRING2`` returns true if the strings ``STRING1`` and ``STRING2`` are identical. +*STRING1* **=** *STRING2* + Returns true if the strings *STRING1* and *STRING2* are identical. -- ``STRING1 != STRING2`` returns true if the strings ``STRING1`` and ``STRING2`` are not identical. +*STRING1* **!=** *STRING2* + Returns true if the strings *STRING1* and *STRING2* are not identical. -- ``-n STRING`` returns true if the length of ``STRING`` is non-zero. +**-n** *STRING* + Returns true if the length of *STRING* is non-zero. -- ``-z STRING`` returns true if the length of ``STRING`` is zero. +**-z** *STRING* + Returns true if the length of *STRING* is zero. Operators to compare and examine numbers ---------------------------------------- -- ``NUM1 -eq NUM2`` returns true if ``NUM1`` and ``NUM2`` are numerically equal. +*NUM1* **-eq** *NUM2* + Returns true if *NUM1* and *NUM2* are numerically equal. -- ``NUM1 -ne NUM2`` returns true if ``NUM1`` and ``NUM2`` are not numerically equal. +*NUM1* **-ne** *NUM2* + Returns true if *NUM1* and *NUM2* are not numerically equal. -- ``NUM1 -gt NUM2`` returns true if ``NUM1`` is greater than ``NUM2``. +*NUM1* **-gt** *NUM2* + Returns true if *NUM1* is greater than *NUM2*. -- ``NUM1 -ge NUM2`` returns true if ``NUM1`` is greater than or equal to ``NUM2``. +*NUM1* **-ge** *NUM2* + Returns true if *NUM1* is greater than or equal to *NUM2*. -- ``NUM1 -lt NUM2`` returns true if ``NUM1`` is less than ``NUM2``. +*NUM1* **-lt** *NUM2* + Returns true if *NUM1* is less than *NUM2*. -- ``NUM1 -le NUM2`` returns true if ``NUM1`` is less than or equal to ``NUM2``. +*NUM1* **-le** *NUM2* + Returns true if *NUM1* is less than or equal to *NUM2*. Both integers and floating point numbers are supported. Operators to combine expressions -------------------------------- -- ``COND1 -a COND2`` returns true if both ``COND1`` and ``COND2`` are true. +*COND1* **-a** *COND2* + Returns true if both *COND1* and *COND2* are true. -- ``COND1 -o COND2`` returns true if either ``COND1`` or ``COND2`` are true. +*COND1* **-o** *COND2* + Returns true if either *COND1* or *COND2* are true. -Expressions can be inverted using the ``!`` operator: +Expressions can be inverted using the **!** operator: -- ``! EXPRESSION`` returns true if ``EXPRESSION`` is false, and false if ``EXPRESSION`` is true. +**!** *EXPRESSION* + Returns true if *EXPRESSION* is false, and false if *EXPRESSION* is true. Expressions can be grouped using parentheses. -- ``( EXPRESSION )`` returns the value of ``EXPRESSION``. +**(** *EXPRESSION* **)** + Returns the value of *EXPRESSION*. - Note that parentheses will usually require escaping with ``\(`` to avoid being interpreted as a command substitution. +Note that parentheses will usually require escaping with ``\(`` to avoid being interpreted as a command substitution. Examples @@ -128,7 +160,7 @@ If the ``/tmp`` directory exists, copy the ``/etc/motd`` file to it: end -If the variable ``MANPATH`` is defined and not empty, print the contents. (If ``MANPATH`` is not defined, then it will expand to zero arguments, unless quoted.) +If the variable :envvar:`MANPATH` is defined and not empty, print the contents. (If :envvar:`MANPATH` is not defined, then it will expand to zero arguments, unless quoted.) @@ -161,7 +193,7 @@ Numerical comparisons will simply fail if one of the operands is not a number: end -A common comparison is with $status: +A common comparison is with :envvar:`status`: diff --git a/doc_src/cmds/time.rst b/doc_src/cmds/time.rst index 2521b1c21..064f642fc 100644 --- a/doc_src/cmds/time.rst +++ b/doc_src/cmds/time.rst @@ -6,9 +6,9 @@ time - measure how long a command or block takes Synopsis -------- -:: +.. synopsis:: - time COMMAND + time COMMAND Description ----------- diff --git a/doc_src/cmds/trap.rst b/doc_src/cmds/trap.rst index 37898497f..455fda2ee 100644 --- a/doc_src/cmds/trap.rst +++ b/doc_src/cmds/trap.rst @@ -6,7 +6,7 @@ trap - perform an action when the shell receives a signal Synopsis -------- -:: +.. synopsis:: trap [OPTIONS] [[ARG] REASON ... ] @@ -17,23 +17,30 @@ Description The following parameters are available: -- ``ARG`` is the command to be executed on signal delivery. +*ARG* + Command to be executed on signal delivery. -- ``REASON`` is the name of the event to trap. For example, a signal like ``INT`` or ``SIGINT``, or the special symbol ``EXIT``. +*REASON* + Name of the event to trap. For example, a signal like ``INT`` or ``SIGINT``, or the special symbol ``EXIT``. -- ``-l`` or ``--list-signals`` prints a list of signal names. +**-l** or **--list-signals** + Prints a list of signal names. -- ``-p`` or ``--print`` prints all defined signal handlers. +**-p** or **--print** + Prints all defined signal handlers. -If ``ARG`` and ``REASON`` are both specified, ``ARG`` is the command to be executed when the event specified by ``REASON`` occurs (e.g., the signal is delivered). +**-h** or **--help** + Displays help about using this command. -If ``ARG`` is absent (and there is a single REASON) or -, each specified signal is reset to its original disposition (the value it had upon entrance to the shell). If ``ARG`` is the null string the signal specified by each ``REASON`` is ignored by the shell and by the commands it invokes. +If *ARG* and *REASON* are both specified, *ARG* is the command to be executed when the event specified by *REASON* occurs (e.g., the signal is delivered). -If ``ARG`` is not present and ``-p`` has been supplied, then the trap commands associated with each ``REASON`` are displayed. If no arguments are supplied or if only ``-p`` is given, ``trap`` prints the list of commands associated with each signal. +If *ARG* is absent (and there is a single *REASON*) or ``-``, each specified signal is reset to its original disposition (the value it had upon entrance to the shell). If *ARG* is the null string the signal specified by each *REASON* is ignored by the shell and by the commands it invokes. + +If *ARG* is not present and **-p** has been supplied, then the trap commands associated with each *REASON* are displayed. If no arguments are supplied or if only **-p** is given, ``trap`` prints the list of commands associated with each signal. Signal names are case insensitive and the ``SIG`` prefix is optional. -The exit status is 1 if any ``REASON`` is invalid; otherwise trap returns 0. +The exit status is 1 if any *REASON* is invalid; otherwise trap returns 0. Example ------- diff --git a/doc_src/cmds/true.rst b/doc_src/cmds/true.rst index ef0c86779..9ffa1667f 100644 --- a/doc_src/cmds/true.rst +++ b/doc_src/cmds/true.rst @@ -6,7 +6,7 @@ true - return a successful result Synopsis -------- -:: +.. synopsis:: true diff --git a/doc_src/cmds/type.rst b/doc_src/cmds/type.rst index a7f8cdb37..4fb5d263f 100644 --- a/doc_src/cmds/type.rst +++ b/doc_src/cmds/type.rst @@ -6,30 +6,42 @@ type - locate a command and describe its type Synopsis -------- -**type** [*OPTIONS*] *NAME* [*NAME* ...] +.. synopsis:: + + type [OPTIONS] NAME [...] Description ----------- -With no options, :command:`type` indicates how each ``NAME`` would be interpreted if used as a command name. +With no options, :command:`type` indicates how each *NAME* would be interpreted if used as a command name. The following options are available: -- ``-a`` or ``--all`` prints all of possible definitions of the specified names. +**-a** or **--all** + Prints all of possible definitions of the specified names. -- ``-s`` or ``--short`` suppresses function expansion when used with no options or with ``-a``/``--all``. +**-s** or **--short** + Suppresses function expansion when used with no options or with **-a**/**--all**. -- ``-f`` or ``--no-functions`` suppresses function and builtin lookup. +**-f** or **--no-functions** + Suppresses function and builtin lookup. -- ``-t`` or ``--type`` prints ``function``, ``builtin``, or ``file`` if ``NAME`` is a shell function, builtin, or disk file, respectively. +**-t** or **--type** + Prints ``function``, ``builtin``, or ``file`` if *NAME* is a shell function, builtin, or disk file, respectively. -- ``-p`` or ``--path`` prints the path to ``NAME`` if ``NAME`` resolves to an executable file in :envvar:`PATH`, the path to the script containing the definition of the function ``NAME`` if ``NAME`` resolves to a function loaded from a file on disk (i.e. not interactively defined at the prompt), or nothing otherwise. +**-p** or **--path** + Prints the path to *NAME* if *NAME* resolves to an executable file in :envvar:`PATH`, the path to the script containing the definition of the function *NAME* if *NAME* resolves to a function loaded from a file on disk (i.e. not interactively defined at the prompt), or nothing otherwise. -- ``-P`` or ``--force-path`` returns the path to the executable file ``NAME``, presuming ``NAME`` is found in the :envvar:`PATH` environment variable, or nothing otherwise. ``--force-path`` explicitly resolves only the path to executable files in :envvar:`PATH`, regardless of whether ``$NAME`` is shadowed by a function or builtin with the same name. +**-P** or **--force-path** + Returns the path to the executable file *NAME*, presuming *NAME* is found in the :envvar:`PATH` environment variable, or nothing otherwise. **--force-path** explicitly resolves only the path to executable files in :envvar:`PATH`, regardless of whether *NAME* is shadowed by a function or builtin with the same name. -- ``-q`` or ``--query`` suppresses all output; this is useful when testing the exit status. For compatibility with old fish versions this is also ``--quiet``. +**-q** or **--query** + Suppresses all output; this is useful when testing the exit status. For compatibility with old fish versions this is also **--quiet**. -The ``-q``, ``-p``, ``-t`` and ``-P`` flags (and their long flag aliases) are mutually exclusive. Only one can be specified at a time. +**-h** or **--help** + Displays help about using this command. + +The **-q**, **-p**, **-t** and **-P** flags (and their long flag aliases) are mutually exclusive. Only one can be specified at a time. Example diff --git a/doc_src/cmds/ulimit.rst b/doc_src/cmds/ulimit.rst index 17273f2c1..620c9c94e 100644 --- a/doc_src/cmds/ulimit.rst +++ b/doc_src/cmds/ulimit.rst @@ -6,7 +6,7 @@ ulimit - set or get resource usage limits Synopsis -------- -:: +.. synopsis:: ulimit [OPTIONS] [LIMIT] @@ -18,51 +18,67 @@ Description Use one of the following switches to specify which resource limit to set or report: -- ``-c`` or ``--core-size``: the maximum size of core files created. By setting this limit to zero, core dumps can be disabled. +**-c** or **--core-size** + The maximum size of core files created. By setting this limit to zero, core dumps can be disabled. -- ``-d`` or ``--data-size``: the maximum size of a process' data segment. +**-d** or **--data-size** + The maximum size of a process' data segment. -- ``-f`` or ``--file-size``: the maximum size of files created by the shell. +**-f** or **--file-size** + The maximum size of files created by the shell. -- ``-l`` or ``--lock-size``: the maximum size that may be locked into memory. +**-l** or **--lock-size** + The maximum size that may be locked into memory. -- ``-m`` or ``--resident-set-size``: the maximum resident set size. +**-m** or **--resident-set-size** + The maximum resident set size. -- ``-n`` or ``--file-descriptor-count``: the maximum number of open file descriptors (most systems do not allow this value to be set). +**-n** or **--file-descriptor-count** + The maximum number of open file descriptors (most systems do not allow this value to be set). -- ``-s`` or ``--stack-size``: the maximum stack size. +**-s** or **--stack-size** + The maximum stack size. -- ``-t`` or ``--cpu-time``: the maximum amount of CPU time in seconds. +**-t** or **--cpu-time** + The maximum amount of CPU time in seconds. -- ``-u`` or ``--process-count``: the maximum number of processes available to a single user. +**-u** or **--process-count** + The maximum number of processes available to a single user. -- ``-v`` or ``--virtual-memory-size`` The maximum amount of virtual memory available to the shell. +**-v** or **--virtual-memory-size** + The maximum amount of virtual memory available to the shell. Note that not all these limits are available in all operating systems. The value of limit can be a number in the unit specified for the resource or one of the special values ``hard``, ``soft``, or ``unlimited``, which stand for the current hard limit, the current soft limit, and no limit, respectively. -If limit is given, it is the new value of the specified resource. If no option is given, then ``-f`` is assumed. Values are in kilobytes, except for ``-t``, which is in seconds and ``-n`` and ``-u``, which are unscaled values. The exit status is 0 unless an invalid option or argument is supplied, or an error occurs while setting a new limit. +If limit is given, it is the new value of the specified resource. If no option is given, then **-f** is assumed. Values are in kilobytes, except for **-t**, which is in seconds and **-n** and **-u**, which are unscaled values. The exit status is 0 unless an invalid option or argument is supplied, or an error occurs while setting a new limit. ``ulimit`` also accepts the following switches that determine what type of limit to set: -- ``-H`` or ``--hard`` sets hard resource limit +**-H** or **--hard** + Sets hard resource limit. -- ``-S`` or ``--soft`` sets soft resource limit +**-S** or **--soft** + Sets soft resource limit. -A hard limit can only be decreased. Once it is set it cannot be increased; a soft limit may be increased up to the value of the hard limit. If neither ``-H`` nor ``-S`` is specified, both the soft and hard limits are updated when assigning a new limit value, and the soft limit is used when reporting the current value. +A hard limit can only be decreased. Once it is set it cannot be increased; a soft limit may be increased up to the value of the hard limit. If neither **-H** nor **-S** is specified, both the soft and hard limits are updated when assigning a new limit value, and the soft limit is used when reporting the current value. The following additional options are also understood by ``ulimit``: -- ``-a`` or ``--all`` prints all current limits +**-a** or **--all** + Prints all current limits. + +**-h** or **--help** + Displays help about using this command. The ``fish`` implementation of ``ulimit`` should behave identically to the implementation in bash, except for these differences: -- Fish ``ulimit`` supports GNU-style long options for all switches +- Fish ``ulimit`` supports GNU-style long options for all switches. -- Fish ``ulimit`` does not support the ``-p`` option for getting the pipe size. The bash implementation consists of a compile-time check that empirically guesses this number by writing to a pipe and waiting for SIGPIPE. Fish does not do this because it this method of determining pipe size is unreliable. Depending on bash version, there may also be further additional limits to set in bash that do not exist in fish. +- Fish ``ulimit`` does not support the **-p** option for getting the pipe size. The bash implementation consists of a compile-time check that empirically guesses this number by writing to a pipe and waiting for SIGPIPE. Fish does not do this because it this method of determining pipe size is unreliable. Depending on bash version, there may also be further additional limits to set in bash that do not exist in fish. -- Fish ``ulimit`` does not support getting or setting multiple limits in one command, except reporting all values using the ``-a`` switch +- Fish ``ulimit`` does not support getting or setting multiple limits in one command, except reporting all values using the **-a** switch. Example diff --git a/doc_src/cmds/umask.rst b/doc_src/cmds/umask.rst index 4c374440d..3ebf608b3 100644 --- a/doc_src/cmds/umask.rst +++ b/doc_src/cmds/umask.rst @@ -6,7 +6,7 @@ umask - set or get the file creation mode mask Synopsis -------- -:: +.. synopsis:: umask [OPTIONS] [MASK] @@ -22,11 +22,14 @@ Access rights are explained in the manual page for the ``chmod(1)`` program. With no parameters, the current file creation mode mask is printed as an octal number. -- ``-h`` or ``--help`` prints this message. +**-S** or **--symbolic** + Prints the umask in symbolic form instead of octal form. -- ``-S`` or ``--symbolic`` prints the umask in symbolic form instead of octal form. +**-p** or **--as-command** + Outputs the umask in a form that may be reused as input. -- ``-p`` or ``--as-command`` outputs the umask in a form that may be reused as input +**-h** or **--help** + Displays help about using this command. If a numeric mask is specified as a parameter, the current shell's umask will be set to that value, and the rights specified by that mask will be removed from new files and directories by default. diff --git a/doc_src/cmds/vared.rst b/doc_src/cmds/vared.rst index c77599492..db10c3d96 100644 --- a/doc_src/cmds/vared.rst +++ b/doc_src/cmds/vared.rst @@ -6,7 +6,7 @@ vared - interactively edit the value of an environment variable Synopsis -------- -:: +.. synopsis:: vared VARIABLE_NAME @@ -15,6 +15,7 @@ Description ``vared`` is used to interactively edit the value of an environment variable. Array variables as a whole can not be edited using ``vared``, but individual list elements can. +The **-h** or **--help** option displays help about using this command. Example ------- diff --git a/doc_src/cmds/wait.rst b/doc_src/cmds/wait.rst index 2c11bdde3..25cba5b10 100644 --- a/doc_src/cmds/wait.rst +++ b/doc_src/cmds/wait.rst @@ -6,7 +6,7 @@ wait - wait for jobs to complete Synopsis -------- -:: +.. synopsis:: wait [-n | --any] [PID | PROCESS_NAME] ... @@ -15,16 +15,19 @@ Description ``wait`` waits for child jobs to complete. -- If a pid is specified, the command waits for the job that the process with the pid belongs to. -- If a process name is specified, the command waits for the jobs that the matched processes belong to. -- If neither a pid nor a process name is specified, the command waits for all background jobs. -- If the ``-n`` / ``--any`` flag is provided, the command returns as soon as the first job completes. If it is not provided, it returns after all jobs complete. +If a *PID* is specified, the command waits for the job that the process with that process ID belongs to. + +If a *PROCESS_NAME* is specified, the command waits for the jobs that the matched processes belong to. + +If neither a pid nor a process name is specified, the command waits for all background jobs. + +If the **-n** or **--any** flag is provided, the command returns as soon as the first job completes. If it is not provided, it returns after all jobs complete. + +The **-h** or **--help** option displays help about using this command. Example ------- - - :: sleep 10 & diff --git a/doc_src/cmds/while.rst b/doc_src/cmds/while.rst index 900780d01..77d0b592d 100644 --- a/doc_src/cmds/while.rst +++ b/doc_src/cmds/while.rst @@ -6,25 +6,24 @@ while - perform a set of commands multiple times Synopsis -------- -:: - - while CONDITION; COMMANDS...; end +.. synopsis:: + while CONDITION; COMMANDS; end Description ----------- -``while`` repeatedly executes ``CONDITION``, and if the exit status is 0, then executes ``COMMANDS``. +**while** repeatedly executes ``CONDITION``, and if the exit status is 0, then executes ``COMMANDS``. -The exit status of the while loop is the exit status of the last iteration of the ``COMMANDS`` executed, or 0 if none were executed. (This matches other shells and is POSIX-compatible.) +The exit status of the **while** loop is the exit status of the last iteration of the ``COMMANDS`` executed, or 0 if none were executed. (This matches other shells and is POSIX-compatible.) You can use :ref:`and ` or :ref:`or ` for complex conditions. Even more complex control can be achieved with ``while true`` containing a :ref:`break `. +The **-h** or **--help** option displays help about using this command. + Example ------- - - :: while test -f foo.txt; or test -f bar.txt ; echo file exists; sleep 10; end diff --git a/doc_src/commands.rst b/doc_src/commands.rst index 8f3191543..d8d8bfeb8 100644 --- a/doc_src/commands.rst +++ b/doc_src/commands.rst @@ -60,7 +60,7 @@ Known functions are a customization point. You can change them to change how you - :ref:`fish_command_not_found ` to tell fish what to do when a command is not found. - :ref:`fish_title ` to change the terminal's title. - :ref:`fish_greeting ` to show a greeting when fish starts. - + Helper functions ^^^^^^^^^^^^^^^^ @@ -72,6 +72,7 @@ Some helper functions, often to give you information for use in your prompt: - :ref:`fish_status_to_signal ` to give a signal name from a return status. - :ref:`prompt_pwd ` to give the current directory in a nicely formatted and shortened way. - :ref:`prompt_login ` to describe the current login, with user and hostname, and to explain if you are in a chroot or connected via ssh. +- :ref:`prompt_hostname ` to give the hostname, shortened for use in the prompt. - :ref:`fish_is_root_user ` to check if the current user is an administrator user like root. - :ref:`fish_add_path ` to easily add a path to $PATH. - :ref:`alias ` to quickly define wrapper functions ("aliases"). diff --git a/doc_src/conf.py b/doc_src/conf.py index d302b38a2..fee3ace93 100644 --- a/doc_src/conf.py +++ b/doc_src/conf.py @@ -8,10 +8,10 @@ import glob import os.path -import pygments import subprocess -from sphinx.errors import SphinxError, SphinxWarning -from docutils import nodes, utils +import sys +from sphinx.errors import SphinxWarning +from docutils import nodes # -- Helper functions -------------------------------------------------------- @@ -20,7 +20,6 @@ from docutils import nodes, utils # Used like :issue:`2364` def issue_role(name, rawtext, text, lineno, inliner, options=None, content=None): options = options or {} - config = inliner.document.settings.env.app.config try: issue_num = int(text.strip()) if issue_num <= 0: @@ -38,14 +37,17 @@ def issue_role(name, rawtext, text, lineno, inliner, options=None, content=None) # -- Load our extensions ------------------------------------------------- def setup(app): - # Our own pygments lexer + # Our own pygments lexers from sphinx.highlighting import lexers this_dir = os.path.dirname(os.path.realpath(__file__)) - fish_indent_lexer = pygments.lexers.load_lexer_from_file( - os.path.join(this_dir, "fish_indent_lexer.py"), lexername="FishIndentLexer" - ) - lexers["fish-docs-samples"] = fish_indent_lexer + sys.path.insert(0, this_dir) + from fish_indent_lexer import FishIndentLexer + from fish_synopsis import FishSynopsisDirective, FishSynopsisLexer + + lexers["fish-docs-samples"] = FishIndentLexer() + lexers["fish-synopsis"] = FishSynopsisLexer() + app.add_directive("synopsis", FishSynopsisDirective) app.add_config_value("issue_url", default=None, rebuild="html") app.add_role("issue", issue_role) @@ -54,21 +56,10 @@ def setup(app): # The default language to assume highlight_language = "fish-docs-samples" -# -- Path setup -------------------------------------------------------------- - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -# -# import os -# import sys -# sys.path.insert(0, os.path.abspath('.')) - - # -- Project information ----------------------------------------------------- project = "fish-shell" -copyright = "2021, fish-shell developers" +copyright = "2022, fish-shell developers" author = "fish-shell developers" issue_url = "https://github.com/fish-shell/fish-shell/issues" @@ -94,12 +85,14 @@ source_suffix = ".rst" # The master toctree document. master_doc = "index" -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. +# The languages this uses, also used for content autogenerated by Sphinx. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +# +# It also sets the html lang= attribute which would be useful to e.g. screenreaders. +# Currently we only have english. +language = "en" # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. @@ -167,11 +160,14 @@ latex_engine = 'xelatex' def get_command_description(path, name): """ Return the description for a command, by parsing its synopsis line """ - with open(path) as fd: - for line in fd: - if line.startswith(name + " - "): - _, desc = line.split(" - ", 1) + with open(path) as opened: + for line in opened: + if line.startswith(name + ' - '): + _, desc = line.split(' - ', 1) return desc.strip() + elif line.startswith('``' + name + '`` - '): + _, desc = line.split('`` - ', 1) + return desc.strip('`') raise SphinxWarning("No description in file %s" % os.path.basename(path)) # Newer sphinxen apparently create another subdirectory which breaks our man lookup. diff --git a/doc_src/design.rst b/doc_src/design.rst index 8fcc7edb9..885fa3d9e 100644 --- a/doc_src/design.rst +++ b/doc_src/design.rst @@ -9,7 +9,7 @@ This is a description of the design principles that have been used to design fis 2. Fish should be user friendly, but not at the expense of expressiveness. Most tradeoffs between power and ease of use can be avoided with careful design. -3. Whenever possible without breaking the above goals, fish should follow the Posix syntax. +3. Whenever possible without breaking the above goals, fish should follow POSIX. To achieve these high-level goals, the fish design relies on a number of more specific design principles. These are presented below, together with a rationale and a few examples for each. diff --git a/doc_src/faq.rst b/doc_src/faq.rst index 6b31d03fb..1fbe536a0 100644 --- a/doc_src/faq.rst +++ b/doc_src/faq.rst @@ -343,24 +343,6 @@ This also means that a few things are unsupportable: - Non-monospace fonts - there is *no way* for fish to figure out what width a specific character has as it has no influence on the terminal's font rendering. - Different widths for multiple ambiguous width characters - there is no way for fish to know which width you assign to each character. -How do I make fish my default shell? ------------------------------------- -If you installed fish manually (e.g. by compiling it, not by using a package manager), you first need to add fish to the list of shells by executing the following command (assuming you installed fish in /usr/local):: - - echo /usr/local/bin/fish | sudo tee -a /etc/shells - - -If you installed a prepackaged version of fish, the package manager should have already done this for you. - -In order to change your default shell, type:: - - chsh -s /usr/local/bin/fish - - -You may need to adjust the above path to e.g. ``/usr/bin/fish``. Use the command ``which fish`` if you are unsure of where fish is installed. - -Unfortunately, there is no way to make the changes take effect at once. You will need to log out and back in again. - .. _faq-uninstalling: Uninstalling fish diff --git a/doc_src/fish_for_bash_users.rst b/doc_src/fish_for_bash_users.rst index aff97ddfd..785f9306d 100644 --- a/doc_src/fish_for_bash_users.rst +++ b/doc_src/fish_for_bash_users.rst @@ -292,15 +292,15 @@ and a rough fish equivalent:: set -l prompt_symbol '$' fish_is_root_user; and set prompt_symbol '#' - echo -s $hostname (set_color blue) (prompt_pwd) \ + echo -s (prompt_hostname) (set_color blue) (prompt_pwd) \ (set_color yellow) $prompt_symbol (set_color normal) end This shows a few differences: - Fish provides :ref:`set_color ` to color text. It can use the 16 named colors and also RGB sequences (so you could also use ``set_color 5555FF``) -- Instead of introducing specific escapes like ``\h`` for the hostname, the prompt is simply a function, so you can use variables like ``$hostname``. -- Fish offers helper functions for adding things to the prompt, like :ref:`fish_vcs_prompt ` for adding a display for common version control systems (git, mercurial, svn) and :ref:`prompt_pwd ` for showing a shortened $PWD (the user's home directory becomes ``~`` and any path component is shortened). +- Instead of introducing specific escapes like ``\h`` for the hostname, the prompt is simply a function. To achieve the effect of ``\h``, fish provides helper functions like :ref:`prompt_hostname `, which prints a shortened version of the hostname. +- Fish offers other helper functions for adding things to the prompt, like :ref:`fish_vcs_prompt ` for adding a display for common version control systems (git, mercurial, svn), and :ref:`prompt_pwd ` for showing a shortened ``$PWD`` (the user's home directory becomes ``~`` and any path component is shortened). The default prompt is reasonably full-featured and its code can be read via ``type fish_prompt``. diff --git a/doc_src/fish_indent_lexer.py b/doc_src/fish_indent_lexer.py index c81a06867..f4b154e8c 100644 --- a/doc_src/fish_indent_lexer.py +++ b/doc_src/fish_indent_lexer.py @@ -3,10 +3,8 @@ # Example of how to use this: # env PATH="/dir/containing/fish/indent/:$PATH" pygmentize -f terminal256 -l /path/to/fish_indent_lexer.py:FishIndentLexer -x ~/test.fish -import os from pygments.lexer import Lexer from pygments.token import ( - Keyword, Name, Comment, String, @@ -23,9 +21,6 @@ from pygments.token import ( import re import subprocess -# The token type representing output to the console. -OUTPUT_TOKEN = Text - # A fallback token type. DEFAULT = Text @@ -34,10 +29,10 @@ ROLE_TO_TOKEN = { "normal": Name.Variable, "error": Generic.Error, "command": Name.Function, - "keyword": Keyword, + "keyword": Name.Function, "statement_terminator": Punctuation, "param": Name.Constant, - "option": Name.Literal, + "option": Name.Constant, "comment": Comment, "match": DEFAULT, "search_match": DEFAULT, @@ -131,5 +126,5 @@ class FishIndentLexer(Lexer): result.extend(tokenize_fish_command(m.group(2), m.start(2))) else: # Non-prompt line representing output from a command. - result.append((m.start(2), OUTPUT_TOKEN, m.group(2))) + result.append((m.start(2), Generic.Output, m.group(2))) return result diff --git a/doc_src/fish_synopsis.py b/doc_src/fish_synopsis.py new file mode 100644 index 000000000..51df271e1 --- /dev/null +++ b/doc_src/fish_synopsis.py @@ -0,0 +1,158 @@ +# Pygments lexer for a fish command synopsis. +# +# Example usage: +# echo 'string match [OPTIONS] [STRING]' | pygmentize -f terminal256 -l doc_src/fish_synopsis.py:FishSynopsisLexer -x + +from docutils import nodes +from pygments.lexer import Lexer +from pygments.token import ( + Generic, + Name, + Operator, + Punctuation, + Text, +) +import re +from sphinx.directives.code import CodeBlock + + +class FishSynopsisDirective(CodeBlock): + """A custom directive that describes a command's grammar.""" + + has_content = True + required_arguments = 0 + + def run(self): + if self.env.app.builder.name != "man": + self.arguments = ["fish-synopsis"] + return CodeBlock.run(self) + lexer = FishSynopsisLexer() + result = nodes.line_block() + for (start, tok, text) in lexer.get_tokens_unprocessed("\n".join(self.content)): + if ( # Literal text. + (tok in (Name.Function, Name.Constant) and not text.isupper()) + or text.startswith("-") # Literal option, even if it's uppercase. + or tok in (Operator, Punctuation) + or text + == " ]" # Tiny hack: the closing bracket of the test(1) alias is a literal. + ): + node = nodes.strong(text=text) + elif ( + tok in (Name.Constant, Name.Function) and text.isupper() + ): # Placeholder parameter. + node = nodes.emphasis(text=text) + else: # Grammar metacharacter or whitespace. + node = nodes.inline(text=text) + result.append(node) + return [result] + + +lexer_rules = [ + (re.compile(pattern), token) + for pattern, token in ( + # Hack: treat the "[ expr ]" alias of builtin test as command token (not as grammar + # metacharacter). This works because we write it without spaces in the grammar (like + # "[OPTIONS]"). + (r"\[ | \]", Name.Constant), + # Statement separators. + (r"\n", Text.Whitespace), + (r";", Punctuation), + (r" +", Text.Whitespace), + # Operators have different highlighting than commands or parameters. + (r"\b(and|not|or|time)\b", Operator), + # Keywords that are not in command position. + (r"\b(if|in)\b", Name.Function), + # Grammar metacharacters. + (r"[()[\]|]", Generic.Other), + (r"\.\.\.", Generic.Other), + # Parameters. + (r"[\w-]+", Name.Constant), + (r"[=%]", Name.Constant), + ( + r"[<>]", + Name.Constant, + ), # Redirection are highlighted like parameters by default. + ) +] + + +class FishSynopsisLexer(Lexer): + name = "FishSynopsisLexer" + aliases = ["fish-synopsis"] + + is_before_command_token = None + + def next_token(self, rule: str, offset: int, has_continuation_line: bool): + for pattern, token_kind in lexer_rules: + m = pattern.match(rule, pos=offset) + if m is None: + continue + if token_kind is Name.Constant and self.is_before_command_token: + token_kind = Name.Function + + if has_continuation_line: + # Traditional case: rules with continuation lines only have a single command. + self.is_before_command_token = False + else: + if m.group() in ("\n", ";") or token_kind is Operator: + self.is_before_command_token = True + elif token_kind in (Name.Constant, Name.Function): + self.is_before_command_token = False + + return m, token_kind, m.end() + return None, None, offset + + def get_tokens_unprocessed(self, input_text): + """Return a list of (start, tok, value) tuples. + + start is the index into the string + tok is the token type (as above) + value is the string contents of the token + """ + """ + A synopsis consists of multiple rules. Each rule can have continuation lines, which + are expected to be indented: + + cmd foo [--quux] + [ARGUMENT] ... + cmd bar + + We'll split the input into rules. This is easy for a traditional synopsis because each + non-indented line starts a new rule. However, we also want to support code blocks: + + switch VALUE + [case [GLOB ...] + [COMMAND ...]] + end + + which makes this format ambiguous. Hack around this by always adding "end" to the + current rule, which is enough in practice. + """ + rules = [] + rule = [] + for line in list(input_text.splitlines()) + [""]: + if rule and not line.startswith(" "): + rules.append(rule) + rule = [] + if line == "end": + rules[-1].append(line) + continue + rule.append(line) + result = [] + for rule in rules: + offset = 0 + self.is_before_command_token = True + has_continuation_line = rule[-1].startswith(" ") + rule = "\n".join(rule) + "\n" + while True: + match, token_kind, offset = self.next_token( + rule, offset, has_continuation_line + ) + if match is None: + break + text = match.group() + result.append((match.start(), token_kind, text)) + assert offset == len(rule), "cannot tokenize leftover text: '{}'".format( + rule[offset:] + ) + return result diff --git a/doc_src/index.rst b/doc_src/index.rst index e61f74746..95f501e53 100644 --- a/doc_src/index.rst +++ b/doc_src/index.rst @@ -56,15 +56,30 @@ Once fish has been installed, open a terminal. If fish is not the default shell: > exit +.. _default-shell: + Default Shell ------------- -To make fish your default shell: +There are multiple ways to switch to fish (or any other shell) as your default. -- Add the line ``/usr/local/bin/fish`` to ``/etc/shells``. -- Change your default shell with ``chsh -s /usr/local/bin/fish``. +The simpler is to set your terminal to start fish. See its configuration and set the program to start to ``/usr/local/bin/fish`` (if that's where fish is installed - substitute another location as appropriate). -For detailed instructions see :ref:`Switching to fish `. +The more involved and complete way is to set fish as your login shell. To do that, you need to: + +1. Add the shell to ``/etc/shells`` with:: + + > echo /usr/local/bin/fish | sudo tee -a /etc/shells + +2. Change your default shell with:: + + > chsh -s /usr/local/bin/fish + +Again, substitute the path to fish for /usr/local/bin/fish - see ``command -s fish`` inside fish. To change it back to another shell, just substitute ``/usr/local/bin/fish`` with ``/bin/bash``, ``/bin/tcsh`` or ``/bin/zsh`` as appropriate in the steps above. + +.. warning:: + + Setting fish as your login shell may have issues, because some operating systems (including a bunch of linux distributions) only do some of their configuration in shell startup files like /etc/profile. So you could notice e.g. $PATH being wrong, and you would have to redo that setup. Uninstalling ------------ @@ -94,7 +109,9 @@ To store configuration write it to a file called ``~/.config/fish/config.fish``. ``.fish`` scripts in ``~/.config/fish/conf.d/`` are also automatically executed before ``config.fish``. -These files are read on the startup of every shell, whether interactive and/or if they're login shells. Use ``status --is-interactive`` and ``status --is-login`` to discriminate. +These files are read on the startup of every shell, whether interactive and/or if they're login shells. Use ``status --is-interactive`` and ``status --is-login`` to do things only in interactive/login shells, respectively. + +This is the short version; for a full explanation, like for sysadmins or integration for developers of other software, see :ref:`Configuration files `. Examples: --------- diff --git a/doc_src/interactive.rst b/doc_src/interactive.rst index 88ad3b515..c2bc31573 100644 --- a/doc_src/interactive.rst +++ b/doc_src/interactive.rst @@ -200,23 +200,20 @@ This is an alternative to aliases, and has the advantage that you see the actual Programmable title ------------------ -When using most virtual terminals, it is possible to set the message displayed in the titlebar of the terminal window. This can be done automatically in fish by defining the :ref:`fish_title ` function. The :ref:`fish_title ` function is executed before and after a new command is executed or put into the foreground and the output is used as a titlebar message. The :ref:`status current-command ` builtin will always return the name of the job to be put into the foreground (or ``fish`` if control is returning to the shell) when the :ref:`fish_prompt ` function is called. The first argument to fish_title will contain the most recently executed foreground command as a string, starting with fish 2.2. +When using most virtual terminals, it is possible to set the message displayed in the titlebar of the terminal window. This can be done automatically in fish by defining the :ref:`fish_title ` function. The :ref:`fish_title ` function is executed before and after a new command is executed or put into the foreground and the output is used as a titlebar message. The :ref:`status current-command ` builtin will always return the name of the job to be put into the foreground (or ``fish`` if control is returning to the shell) when the :ref:`fish_prompt ` function is called. The first argument to fish_title will contain the most recently executed foreground command as a string. + +The default fish title shows the hostname if connected via ssh, the currently running command (unless it is fish) and the current working directory. All of this is shortened to not make the tab too wide. Examples: -The default fish title is:: +To show the last command and working directory in the title:: function fish_title - echo (status current-command) ' ' + # `prompt_pwd` shortens the title. This helps prevent tabs from becoming very wide. + echo $argv[1] (prompt_pwd) pwd end -To show the last command in the title:: - - function fish_title - echo $argv[1] - end - .. _prompt: Programmable prompt diff --git a/doc_src/language.rst b/doc_src/language.rst index dcb0ea1ce..1b6e97f28 100644 --- a/doc_src/language.rst +++ b/doc_src/language.rst @@ -1207,7 +1207,7 @@ A more robust approach to argument handling is :ref:`argparse `, w # If -h or --help is given, we print a little help text and return if set -q _flag_help - echo "mybetterfunction [-h|--help] [-s|--second] [ARGUMENTS...]" + echo "mybetterfunction [-h|--help] [-s|--second] [ARGUMENT ...]" return 0 end @@ -1246,6 +1246,16 @@ PATH variables act as normal lists, except they are implicitly joined and split echo "$MYPATH" # 1:2:3:4:5 +Path variables will also be exported in the colon form, so ``set -x MYPATH 1 2 3`` will have external commands see it as ``1:2:3``. + +:: + + > set -gx MYPATH /bin /usr/bin /sbin + > env | grep MYPATH + MYPATH=/bin:/usr/bin:/sbin + +This is for compatibility with other tools. Unix doesn't have variables with multiple elements, the closest thing it has are colon-lists like :envvar:`PATH`. For obvious reasons this means no element can contain a ``:``. + Variables can be marked or unmarked as PATH variables via the ``--path`` and ``--unpath`` options to ``set``. .. _variables-special: diff --git a/doc_src/license.rst b/doc_src/license.rst index 62f1a07a2..a87060dfb 100644 --- a/doc_src/license.rst +++ b/doc_src/license.rst @@ -4,7 +4,7 @@ License License for fish ---------------- -``fish`` Copyright © 2005-2009 Axel Liljencrantz, 2009-2021 fish-shell contributors. ``fish`` is released under the GNU General Public License, version 2. +``fish`` Copyright © 2005-2009 Axel Liljencrantz, 2009-2022 fish-shell contributors. ``fish`` is released under the GNU General Public License, version 2. ``fish`` includes other code licensed under the GNU General Public License, version 2, including GNU ``printf``. diff --git a/doc_src/python_docs_theme/static/pydoctheme.css b/doc_src/python_docs_theme/static/pydoctheme.css index 97fea3f04..3795956ff 100644 --- a/doc_src/python_docs_theme/static/pydoctheme.css +++ b/doc_src/python_docs_theme/static/pydoctheme.css @@ -11,17 +11,30 @@ html { body { background: linear-gradient(to bottom, #a7cfdf 0%,#23538a 100%); + /* Pick a font. + sans-serif is the Browser default. This is great because the user could change it. + Unfortunately the defaults are decades old and e.g. on Windows still use Arial in Firefox and Edge, + and this seems unlikely to change. + So we use system-ui, which is "the system's interface font". + Unfortunately on Windows *that* depends on the locale, and e.g. in Chinese it apparently + picks a font that is okay at chinese characters but fairly bad at latin ones. + So we prefer the standard Windows font Segoe. + If that's installed anywhere else that's unfortunate but not horrible because it's an okay font. + + See e.g. https://github.com/twbs/bootstrap/issues/22328 + */ + font-family: "Segoe UI", system-ui, sans-serif; } div#fmain { color: #222; - padding: 10px 40px 10px; + padding: 1em 2em; background-color: #EEEEFA; border-radius: 14px; position: relative; - margin: 15px auto 15px; + margin: 1em auto 1em; box-shadow: 0 0 5px 1px #333; - width: 85%; + width: 90%; /* This is super-cheesy, but 1270px is the maximum width of the sidebar, the content and the margins */ max-width: 1270px; } @@ -70,7 +83,7 @@ form.inline-search input[type="submit"] { div.sphinxsidebar { border-right: 1px solid #ccc; border-radius: 0px; - line-height: 150%; + line-height: 1em; font-size: smaller; margin-left: 0; float: left; @@ -98,7 +111,7 @@ div.documentwrapper { float: none; } -div.document, div.body { +div.document, div.body, div.warning { background-color: inherit; color: inherit; } @@ -112,6 +125,7 @@ div#searchbox { div.sphinxsidebar h3, div.sphinxsidebar h4 { margin-top: 1em; + font-family: inherit; } div.sphinxsidebarwrapper > h3:first-child { @@ -122,13 +136,14 @@ div.sphinxsidebarwrapper > ul > li > ul > li { margin-bottom: 0.4em; } -ul li.toctree-l1 { - line-height: 170%; +ul li, div.body li { + line-height: 2em; } form.inline-search input, div.sphinxsidebar input { - font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + /* Inputs typically have different default fonts, remove that idea */ + font-family: inherit; border: 1px solid #999999; font-size: smaller; border-radius: 3px; @@ -144,13 +159,15 @@ div.body { } div.body p { - line-height: 170%; + line-height: 2em; + text-align: left; } div.body h1, div.body h2, div.body h3, div.body h4, div.body h5, div.body h6 { margin: 0; border: 0; padding: 0.3em 0; + font-family: inherit; } div.body hr { @@ -208,12 +225,38 @@ div.body a:hover { color: #00B0E4; } -tr, code, pre { +tr, pre { background-color: inherit; } -tt, code, pre, dl > dt span ~ em, #synopsis p { - font-family: "Source Code Pro", "DejaVu Sans Mono", Menlo, "Ubuntu Mono", Consolas, Monaco, "Lucida Console", monospace, fixed; +code { + /* Make inline-code better visible */ + background-color: rgba(20,20,80, .1); + padding-left: 5px; + padding-right: 5px; +} + +tt, code, pre, dl > dt span ~ em, #synopsis p, #synopsis code, .command { + /* Pick a monospace font. + ui-monospace is the monospace version of system-ui - the system's monospace font. + Unfortunately it's barely supported anywhere (at time of writing only Safari does!), + and because monospace has the same limitations as sans-serif - Browser defaults are awful - + we hardcode a list of normal monospace fonts. + SFMono is San Francisco, Apple's font. Menlo is an older Apple one. + Consolas is a Windows font. + Ubuntu is the ubuntu monospace version, Hack is the default KDE monospace font, + Liberation is an arial-like. + + NOTE: Under no circumstances can "Source Code Pro" appear in this list for a while as it had massive bugs on macOS. + It would not appear at all when colored. + This is unfortunate because it's the default Gnome monospace font. + Instead we use Noto, which is a common monospace font that is often installed for emoji support. + */ + font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, "Ubuntu Mono", "Hack", "Noto Sans Mono", Liberation Mono, monospace; +} + +#synopsis .line { + line-height: 1em; } pre, div[class*="highlight-"] { @@ -237,8 +280,8 @@ table.docutils { border: 1px solid #ddd; min-width: 20%; border-radius: 3px; - margin-top: 10px; - margin-bottom: 10px; + margin-top: 1em; + margin-bottom: 1em; /* Make table scrollable on overflow */ display: block; overflow: auto; @@ -268,7 +311,7 @@ table.footnote, table.footnote td { } div.footer { - line-height: 150%; + line-height: 1em; margin-top: -2em; text-align: right; width: auto; @@ -291,12 +334,20 @@ div.footer { font-size: 12pt; } +dl { + margin-bottom: 1em; +} + dl.envvar, dl.describe { font-size: 11pt; - font-weight: normal !important; + font-weight: normal; } +div.sphinxsidebar ul { + margin: 1em 10px 1em 10px; +} + /* On screens that are less than 700px wide remove anything non-essential - the sidebar, the gradient background, ... */ @media screen and (max-width: 700px) { @@ -426,11 +477,11 @@ div.body .internal.reference:link { } div.sphinxsidebar a, div.footer { - color: #CCC; + color: #DDD; } - div.sphinxsidebar h3 a, div.related a, div.sphinxsidebar h3 { - color: #BBB; + div.sphinxsidebar h3 a, div.related a, div.sphinxsidebar h3, div.footer a { + color: #DDD; } .highlight { background: #000; @@ -450,7 +501,7 @@ div.body .internal.reference:link { } input { background-color: #222; - color: #BBB; + color: #DDD; } dt:target, span.highlighted { @@ -466,9 +517,6 @@ div.body .internal.reference:link { div.body a { color: #2092fa; } - div.footer a { - color: #BBB; - } /* Color based on the Name.Function (.nf) class from pygments.css. */ .command { color: #008fd7 } @@ -477,4 +525,8 @@ div.body .internal.reference:link { th, dl.field-list > dt { background-color: #121; } + + code { + background-color: rgba(200, 200, 255, .1); + } } diff --git a/doc_src/python_docs_theme/static/pygments.css b/doc_src/python_docs_theme/static/pygments.css index 2da95380a..d657ce377 100644 --- a/doc_src/python_docs_theme/static/pygments.css +++ b/doc_src/python_docs_theme/static/pygments.css @@ -67,7 +67,6 @@ --contrast: #FFFFFF; } .highlight .k { color: #507a97; font-weight: bold } /* Keyword */ - .highlight .nf { color: #009fe7 } /* Name.Function */ .highlight .nf { color: #008fd7 } /* Name.Function */ .highlight .nb { color: #209a87 } /* Name.Builtin */ .highlight .s2 { color: #9ce781 } /* Literal.String.Double */ diff --git a/doc_src/tutorial.rst b/doc_src/tutorial.rst index f66c6ccac..95befebb0 100644 --- a/doc_src/tutorial.rst +++ b/doc_src/tutorial.rst @@ -29,7 +29,7 @@ which means you are all set up and can start using fish:: This prompt that you see above is the fish default prompt: it shows your username, hostname, and working directory. - to change this prompt see :ref:`how to change your prompt ` -- to switch to fish permanently see :ref:`switch your default shell to fish `. +- to switch to fish permanently see :ref:`Default Shell `. From now on, we'll pretend your prompt is just a ``>`` to save space. @@ -361,14 +361,15 @@ You can also access ranges of elements, known as "slices": You can iterate over a list (or a slice) with a for loop:: - > for val in $PATH - echo "entry: $val" - end - entry: /usr/bin/ - entry: /bin - entry: /usr/sbin - entry: /sbin - entry: /usr/local/bin + for val in $PATH + echo "entry: $val" + end + # Will print: + # entry: /usr/bin/ + # entry: /bin + # entry: /usr/sbin + # entry: /sbin + # entry: /usr/local/bin Lists adjacent to other lists or strings are expanded as :ref:`cartesian products ` unless quoted (see :ref:`Variable expansion `):: @@ -569,13 +570,13 @@ Functions A fish function is a list of commands, which may optionally take arguments. Unlike other shells, arguments are not passed in "numbered variables" like ``$1``, but instead in a single list ``$argv``. To create a function, use the :ref:`function ` builtin:: - > function say_hello - echo Hello $argv - end - > say_hello - Hello - > say_hello everybody! - Hello everybody! + function say_hello + echo Hello $argv + end + say_hello + # prints: Hello + say_hello everybody! + # prints: Hello everybody! Unlike other shells, fish does not have aliases or special prompt syntax. Functions take their place. [#]_ @@ -583,7 +584,8 @@ Unlike other shells, fish does not have aliases or special prompt syntax. Functi You can list the names of all functions with the :ref:`functions ` builtin (note the plural!). fish starts out with a number of functions:: > functions - N_, abbr, alias, bg, cd, cdh, contains_seq, delete-or-exit, dirh, dirs, disown, down-or-search, edit_command_buffer, export, fg, fish_add_path, fish_breakpoint_prompt, fish_clipboard_copy, fish_clipboard_paste, fish_config, fish_default_key_bindings, fish_default_mode_prompt, fish_git_prompt, fish_hg_prompt, fish_hybrid_key_bindings, fish_indent, fish_is_root_user, fish_job_summary, fish_key_reader, fish_md5, fish_mode_prompt, fish_npm_helper, fish_opt, fish_print_git_action, fish_print_hg_root, fish_prompt, fish_sigtrap_handler, fish_svn_prompt, fish_title, fish_update_completions, fish_vcs_prompt, fish_vi_cursor, fish_vi_key_bindings, funced, funcsave, grep, help, history, hostname, isatty, kill, la, ll, ls, man, nextd, nextd-or-forward-word, open, popd, prevd, prevd-or-backward-word, prompt_hostname, prompt_pwd, psub, pushd, realpath, seq, setenv, suspend, trap, type, umask, up-or-search, vared, wait + N_, abbr, alias, bg, cd, cdh, contains_seq, dirh, dirs, disown, down-or-search, edit_command_buffer, export, fg, fish_add_path, fish_breakpoint_prompt, fish_clipboard_copy, fish_clipboard_paste, fish_config, fish_default_key_bindings, fish_default_mode_prompt, fish_git_prompt, fish_hg_prompt, fish_hybrid_key_bindings, fish_indent, fish_is_root_user, fish_job_summary, fish_key_reader, fish_md5, fish_mode_prompt, fish_npm_helper, fish_opt, fish_print_git_action, fish_print_hg_root, fish_prompt, fish_sigtrap_handler, fish_svn_prompt, fish_title, fish_update_completions, fish_vcs_prompt, fish_vi_cursor, fish_vi_key_bindings, funced, funcsave, grep, help, history, hostname, isatty, kill, la, ll, ls, man, nextd, open, popd, prevd, prompt_hostname, prompt_pwd, psub, pushd, realpath, seq, setenv, suspend, trap, type, umask, up-or-search, vared, wait + You can see the source for any function by passing its name to ``functions``:: @@ -602,25 +604,26 @@ Loops While loops:: - > while true + while true echo "Loop forever" end - Loop forever - Loop forever - Loop forever - ... # yes, this really will loop forever. Unless you abort it with ctrl-c. + # Prints: + # Loop forever + # Loop forever + # Loop forever + # yes, this really will loop forever. Unless you abort it with ctrl-c. For loops can be used to iterate over a list. For example, a list of files:: - > for file in *.txt + for file in *.txt cp $file $file.bak end Iterating over a list of numbers can be done with ``seq``:: - > for x in (seq 5) + for x in (seq 5) touch file_$x.txt end @@ -764,29 +767,6 @@ Now in another shell:: vim -.. _switching-to-fish: - -Switching to fish? ------------------- - -If you wish to use fish (or any other shell) as your default shell, -you need to enter your new shell's executable in two places. - -Add the shell to ``/etc/shells`` with:: - - > echo /usr/local/bin/fish | sudo tee -a /etc/shells - - -Change your default shell with:: - - > chsh -s /usr/local/bin/fish - -This assumes you installed fish to /usr/local/bin, which is the default location when you've compiled it yourself. If you installed it with a package manager, the usual location is /usr/bin/fish, but package managers typically already add it to /etc/shells. Just substitute the correct location. - -(To change it back to another shell, just substitute ``/usr/local/bin/fish`` -with ``/bin/bash``, ``/bin/tcsh`` or ``/bin/zsh`` as appropriate in the steps above.) - - Ready for more? --------------- diff --git a/fish.desktop b/fish.desktop index e01e3d699..865653724 100644 --- a/fish.desktop +++ b/fish.desktop @@ -6,6 +6,7 @@ Terminal=true # Other uses would have to replace these with the correct path. Exec=fish Name=fish +Comment=The user-friendly command line shell Icon=fish # "Shell" would be the proper category, but it's reserved so we can't use it. Categories=ConsoleOnly;System; diff --git a/po/de.po b/po/de.po index 45a8bb607..0e0e736cf 100644 --- a/po/de.po +++ b/po/de.po @@ -62163,7 +62163,7 @@ msgstr "" msgid "Check if the current directory is a git repository" msgstr "" -#: /tmp/fish/implicit/share/functions/fish_is_nth_token.fish:1 +#: /tmp/fish/implicit/share/functions/__fish_is_nth_token.fish:1 msgid "Test if current token is on Nth place" msgstr "" diff --git a/po/en.po b/po/en.po index 6ada1dd44..c2f61173a 100644 --- a/po/en.po +++ b/po/en.po @@ -62165,7 +62165,7 @@ msgstr "" msgid "Check if the current directory is a git repository" msgstr "" -#: /tmp/fish/implicit/share/functions/fish_is_nth_token.fish:1 +#: /tmp/fish/implicit/share/functions/__fish_is_nth_token.fish:1 msgid "Test if current token is on Nth place" msgstr "Test if current token is on Nth place" diff --git a/po/fr.po b/po/fr.po index 4841f42f6..37dd038b7 100644 --- a/po/fr.po +++ b/po/fr.po @@ -64769,7 +64769,7 @@ msgstr "" msgid "Check if the current directory is a git repository" msgstr "Vérifier si le dossier actuel est un dépôt git" -#: /tmp/fish/implicit/share/functions/fish_is_nth_token.fish:1 +#: /tmp/fish/implicit/share/functions/__fish_is_nth_token.fish:1 msgid "Test if current token is on Nth place" msgstr "" diff --git a/po/pl.po b/po/pl.po index 599d45115..3ed209305 100644 --- a/po/pl.po +++ b/po/pl.po @@ -61940,7 +61940,7 @@ msgstr "" msgid "Check if the current directory is a git repository" msgstr "" -#: /tmp/fish/implicit/share/functions/fish_is_nth_token.fish:1 +#: /tmp/fish/implicit/share/functions/__fish_is_nth_token.fish:1 msgid "Test if current token is on Nth place" msgstr "" diff --git a/po/pt_BR.po b/po/pt_BR.po index a7bb47975..0ccafeb70 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -18,7 +18,7 @@ msgstr "" "Project-Id-Version: fish 1.21.8\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-11-13 10:00-0300\n" -"PO-Revision-Date: 2015-10-11 20:35-0300\n" +"PO-Revision-Date: 2022-02-15 13:24+0100\n" "Last-Translator: Fábio Nogueira \n" "Language-Team: Português Brasileiro <>\n" "Language: pt_BR\n" @@ -73519,10 +73519,6 @@ msgstr "" msgid "Precede each output line with count of its occurrence" msgstr "" -#: /tmp/fish/implicit/share/completions/uniq.fish:14 -msgid "Avoid comparing fist N characters" -msgstr "" - #: /tmp/fish/implicit/share/completions/uniq.fish:16 msgid "Case insensitive comparision" msgstr "" @@ -87073,7 +87069,7 @@ msgstr "" msgid "Check if the current directory is a git repository" msgstr "" -#: /tmp/fish/implicit/share/functions/fish_is_nth_token.fish:1 +#: /tmp/fish/implicit/share/functions/__fish_is_nth_token.fish:1 msgid "Test if current token is on Nth place" msgstr "" diff --git a/po/sv.po b/po/sv.po index d74a60035..7d7d67a97 100644 --- a/po/sv.po +++ b/po/sv.po @@ -57723,8 +57723,8 @@ msgstr "" msgid "Check if the current directory is a git repository" msgstr "" -#: /tmp/fish/implicit/share/functions/fish_is_nth_token.fish:1 -#: share/functions/fish_is_nth_token.fish:1 +#: /tmp/fish/implicit/share/functions/__fish_is_nth_token.fish:1 +#: share/functions/__fish_is_nth_token.fish:1 msgid "Test if current token is on Nth place" msgstr "" diff --git a/po/zh_CN.po b/po/zh_CN.po index df0a02dd5..8109f8c89 100644 --- a/po/zh_CN.po +++ b/po/zh_CN.po @@ -61916,7 +61916,7 @@ msgstr "" msgid "Check if the current directory is a git repository" msgstr "" -#: /tmp/fish/implicit/share/functions/fish_is_nth_token.fish:1 +#: /tmp/fish/implicit/share/functions/__fish_is_nth_token.fish:1 msgid "Test if current token is on Nth place" msgstr "" diff --git a/share/completions/animate.fish b/share/completions/animate.fish index fadc47945..2aa4303ef 100644 --- a/share/completions/animate.fish +++ b/share/completions/animate.fish @@ -1,4 +1,4 @@ -complete -c animate -o alpha -d 'On, activate, off, deactivate, set, opaque, copy transparent, extract, background, or shape [option]' -xa '(animate -list alpha)' +complete -c animate -o alpha -d 'Control alpha/matte channel of an image [option]' -xa '(animate -list alpha)' complete -c animate -o authenticate -d 'Decipher image with this password [password]' complete -c animate -o backdrop -d 'Display image centered on a backdrop' complete -c animate -o channel -d 'Apply option to select image channels [type]' -xa '(animate -list channel)' @@ -12,7 +12,7 @@ complete -c animate -o depth -d 'Image depth [value]' complete -c animate -o display -d 'Display image to this X server [server]' complete -c animate -o dispose -d 'Layer disposal method [method]' -xa '(animate -list dispose)' complete -c animate -o dither -d 'Apply error diffusion to image [method]' -xa '(animate -list dither)' -complete -c animate -o filter -d 'Use this filter when resizing an image [type]' -xa '(animate -list filter)' +complete -c animate -o filter -d 'Choose filter when resizing an image [type]' -xa '(animate -list filter)' complete -c animate -o format -d 'Output formatted image characteristics ["string"]' complete -c animate -o gamma -d 'Level of gamma correction [value]' complete -c animate -o geometry -d 'Preferred size and location of the Image window [geometry]' @@ -24,7 +24,7 @@ complete -c animate -o interpolate -d 'Pixel color interpolation method [method] complete -c animate -o limit -d 'Pixel cache resource limit [type value]' -x complete -c animate -o loop -d 'Loop images then exit [iterations]' complete -c animate -o map -d 'Display image using this Standard Colormap [type]' -x -complete -c animate -o monitor -d 'Monitor progress ' +complete -c animate -o monitor -d 'Monitor progress' complete -c animate -o pause -d 'Seconds to pause before reanimating' complete -c animate -o page -d 'Size and location of an image canvas (setting) [geometry]' complete -c animate -o quantize -d 'Reduce colors in this colorspace [colorspace]' -xa '(animate -list colorspace)' @@ -34,7 +34,7 @@ complete -c animate -o remote -d 'Command execute a command in an remote display complete -c animate -o respect-parentheses -d 'Settings remain in effect until parenthesis boundary' complete -c animate -o sampling-factor -d 'Horizontal and vertical sampling factor [geometry]' complete -c animate -o seed -d 'Seed a new sequence of pseudo-random numbers [value]' -complete -c animate -o set -d 'Attribute set an image attribute [ value]' +complete -c animate -o set -d 'Attribute set an image attribute [value]' complete -c animate -o size -d 'Width and height of image [geometry]' complete -c animate -o transparent-color -d 'Transparent color [color]' -xa '(__fish_complete_convert_options color)' complete -c animate -o treedepth -d 'Color tree depth [value]' @@ -59,7 +59,7 @@ complete -c animate -o debug -d 'Display copious debugging information [events]' complete -c animate -o help -d 'Print program options' complete -c animate -o list -d 'Print a list of supported option arguments [type]' -xa '(animate -list list)' complete -c animate -o log -d 'Format of debugging information [format]' -xa '(__fish_complete_convert_options format)' -complete -c animate -o version -d 'Print version information Press any button to map or unmap the Command widget' +complete -c animate -o version -d 'Print version information' complete -c animate -o matte -d 'Store matte channel if the image has one' complete -c animate -o scenes -d 'Range image scene range' complete -c animate -o support -d 'Resize support: > 1.0 is blurry, < 1.0 is sharp [factor]' diff --git a/share/completions/ansible-playbook.fish b/share/completions/ansible-playbook.fish index a77ecc5d0..375fcfa7c 100644 --- a/share/completions/ansible-playbook.fish +++ b/share/completions/ansible-playbook.fish @@ -1,12 +1,12 @@ complete -c ansible-playbook -l ask-vault-pass -f -d "Ask for vault password" complete -c ansible-playbook -s C -l check -f -d "Just check, don't make any changes" -complete -c ansible-playbook -s D -l diff -f -d "Show the differences in files and templates; works great with --check" +complete -c ansible-playbook -s D -l diff -f -d "Show the differences in files and templates" complete -c ansible-playbook -s e -l extra-vars -r -d "Set additional variables as key=value or YAML/JSON" complete -c ansible-playbook -l flush-cache -d "Clear the fact cache" complete -c ansible-playbook -l force-handlers -d "Run handlers even if a task fails" complete -c ansible-playbook -s f -l forks -a "(seq 0 100)" -d "Number of parallel processes to use (default=5)" complete -c ansible-playbook -s h -l help -d "Shows a help message" -complete -c ansible-playbook -s i -l inventory -r -d "Specify inventory host path (default=/etc/ansible/hosts) or comma separated host list." +complete -c ansible-playbook -s i -l inventory -r -d "Specify inventory host path or comma separated host list" complete -c ansible-playbook -s l -l limit -r -d "Further limit selected hosts to an additional pattern" complete -c ansible-playbook -l list-hosts -d "List all matching hosts" complete -c ansible-playbook -l list-tags -d "List all available tags" @@ -14,13 +14,13 @@ complete -c ansible-playbook -l list-tasks -d "List all tasks that would be exec complete -c ansible-playbook -s M -l module-path -r -d "Specify path(s) to module library (default=None)" complete -c ansible-playbook -l new-vault-password-file -f -d "New vault password file for rekey" complete -c ansible-playbook -l output -f -d "Output file name for encrypt or decrypt; use - for stdout" -complete -c ansible-playbook -l skip-tags -r -d "Only run plays and tasks whose tags do not match these values" +complete -c ansible-playbook -l skip-tags -r -d "Don't run plays and tasks whose tags match these values" complete -c ansible-playbook -l start-at-task -r -d "Start the playbook at the task matching this name" complete -c ansible-playbook -l step -d "Confirm each task before running" complete -c ansible-playbook -l syntax-check -f -d "Perform a syntax check on the playbook" complete -c ansible-playbook -s t -l tags -r -f -d "Only run plays and tasks tagged with these values" complete -c ansible-playbook -l vault-password-file -d "Vault password file" -complete -c ansible-playbook -s v -l verbose -f -d "Verbose mode (-vvv for more, -vvvv to enable connection debugging)" +complete -c ansible-playbook -s v -l verbose -f -d "Verbose mode (-vv/-vvv/-vvvv for more)" complete -c ansible-playbook -l version -f -d "Display version and exit" complete -c ansible-playbook -s k -l ask-pass -f -d "Ask for connection password" complete -c ansible-playbook -l private-key -r -d "Use this file to authenticate the connection" @@ -31,7 +31,7 @@ complete -c ansible-playbook -l ssh-common-args -f -d "Specify common arguments complete -c ansible-playbook -l sftp-extra-args -f -d "Specify extra arguments to pass to sftp only" complete -c ansible-playbook -l scp-extra-args -f -d "Specify extra arguments to pass to scp only" complete -c ansible-playbook -l ssh-extra-args -f -d "Specify extra arguments to pass to ssh only" -complete -c ansible-playbook -s b -l become -f -d "Run operations with become (does not imply password prompting)" +complete -c ansible-playbook -s b -l become -f -d "Run operations with become" complete -c ansible-playbook -l become-method -r -f -a "sudo su pbrun pfexec runas doas dzdo" -d "Privilege escalation method to use (default=sudo)" complete -c ansible-playbook -l become-user -r -f -a "(__fish_complete_users)" -d "Run operations as this user (default=root)" complete -c ansible-playbook -s K -l ask-become-pass -f -d "Ask for privilege escalation password" diff --git a/share/completions/ansible.fish b/share/completions/ansible.fish index d61b0f921..d34a09b38 100644 --- a/share/completions/ansible.fish +++ b/share/completions/ansible.fish @@ -2,7 +2,7 @@ complete -c ansible -s a -l args -r -f -d "Module arguments" complete -c ansible -l ask-vault-pass -f -d "Ask for vault password" complete -c ansible -s B -l background -r -f -d "Run asynchronously, failing after X seconds" complete -c ansible -s C -l check -f -d "Just check, don't make any changes" -complete -c ansible -s D -l diff -f -d "Show the differences in files and templates; works great with --check" +complete -c ansible -s D -l diff -f -d "Show the differences in files and templates" complete -c ansible -s e -l extra-vars -r -d "Set additional variables as key=value or YAML/JSON" complete -c ansible -s f -l forks -a "(seq 0 100)" -d "Number of parallel processes to use (default=5)" complete -c ansible -s h -l help -d "Shows a help message" @@ -18,7 +18,7 @@ complete -c ansible -s P --l poll -r -d "Set the poll interval if using -B (defa complete -c ansible -l syntax-check -f -d "Perform a syntax check on the playbook" complete -c ansible -s t -l tree -f -a "(__fish_complete_directories)" -d "Log output to this directory" complete -c ansible -l vault-password-file -d "Vault password file" -complete -c ansible -s v -l verbose -f -d "Verbose mode (-vvv for more, -vvvv to enable connection debugging)" +complete -c ansible -s v -l verbose -f -d "Verbose mode (-vv/-vvv/-vvvv for more)" complete -c ansible -l version -f -d "Display version and exit" complete -c ansible -s k -l ask-pass -f -d "Ask for connection password" complete -c ansible -l private-key -r -d "Use this file to authenticate the connection" @@ -30,7 +30,7 @@ complete -c ansible -l ssh-common-args -f -d "Specify common arguments to pass t complete -c ansible -l sftp-extra-args -f -d "Specify extra arguments to pass to sftp only" complete -c ansible -l scp-extra-args -f -d "Specify extra arguments to pass to scp only" complete -c ansible -l ssh-extra-args -f -d "Specify extra arguments to pass to ssh only" -complete -c ansible -s b -l become -f -d "Run operations with become (does not imply password prompting)" +complete -c ansible -s b -l become -f -d "Run operations with become" complete -c ansible -l become-method -r -f -a "sudo su pbrun pfexec runas doas dzdo" -d "Privilege escalation method to use (default=sudo)" complete -c ansible -l become-user -r -f -a "(__fish_complete_users)" -d "Run operations as this user (default=root)" complete -c ansible -s K -l ask-become-pass -f -d "Ask for privilege escalation password" diff --git a/share/completions/ant.fish b/share/completions/ant.fish index d1977609a..2d7837fc8 100644 --- a/share/completions/ant.fish +++ b/share/completions/ant.fish @@ -62,14 +62,14 @@ complete -x -c ant -a "(__fish_complete_ant_targets (commandline -co))" # Script Options: complete -f -c ant -l help -l h -d 'print help message and ant help' -complete -f -c ant -l noconfig -d 'suppress sourcing of /etc/ant.conf, $HOME/.ant/ant.conf, and $HOME/.antrc configuration files' -complete -f -c ant -l usejikes -d 'enable use of jikes by default, unless set explicitly in configuration files' +complete -f -c ant -l noconfig -d 'suppress sourcing of configuration files' +complete -f -c ant -l usejikes -d 'enable use of jikes by default' complete -f -c ant -l execdebug -d 'print ant exec line generated by this launch script' # Options: -complete -f -c ant -o help -s h -d 'print help message and exit' -complete -f -c ant -o projecthelp -s p -d 'print project help information and exit' -complete -f -c ant -o version -d 'print the version information and exit' -complete -f -c ant -o diagnostics -d 'print information that might be helpful to diagnose or report problems and exit' +complete -f -c ant -o help -s h -d 'print help message' +complete -f -c ant -o projecthelp -s p -d 'print project help information' +complete -f -c ant -o version -d 'print the version information' +complete -f -c ant -o diagnostics -d 'print diagnostic information' complete -f -c ant -o quiet -s q -d 'be extra quiet' complete -f -c ant -o silent -s S -d 'print nothing but task outputs and build failures' complete -f -c ant -o verbose -s v -d 'be extra verbose' @@ -78,7 +78,7 @@ complete -f -c ant -o emacs -s e -d 'produce logging information without adornme complete -f -c ant -o noinput -d 'do not allow interactive input' complete -f -c ant -s D -d 'use value for given property like -D=' complete -f -c ant -o keep-going -s k -d 'execute all targets that do not depend on failed target(s)' -complete -f -c ant -o nouserlib -d 'Run ant without using the jar files from ${user.home}/.ant/lib' +complete -f -c ant -o nouserlib -d 'Run ant without using jar files from ${user.home}/.ant/lib' complete -f -c ant -o noclasspath -d 'Run ant without using CLASSPATH' complete -f -c ant -o autoproxy -d 'Java1.5+: use the OS proxy settings' complete -r -c ant -o lib -d 'specifies a path to search for jars and classes' @@ -86,8 +86,8 @@ complete -r -c ant -o logfile -s l -d 'use given file for log' complete -r -c ant -o logger -d 'the class which is to perform logging' complete -r -c ant -o listener -d 'add an instance of class as a project listener' complete -r -c ant -o buildfile -o file -s f -d 'use given buildfile' -complete -r -c ant -o propertyfile -d 'load all properties from file with -D properties taking precedence' +complete -r -c ant -o propertyfile -d 'load properties from file, -D properties takes precedence' complete -r -c ant -o inputhandler -d 'the class which will handle input requests' -complete -r -c ant -o find -s s -d '(s)earch for buildfile towards the root of the filesystem and use it' -complete -r -c ant -o nice -d 'A niceness value for the main thread: 1 (lowest) to 10 (highest); 5 is the default' +complete -r -c ant -o find -s s -d 'search for buildfile towards the root and use it' +complete -r -c ant -o nice -d 'A niceness value for the main thread' complete -r -c ant -o main -d 'override Ant\'s normal entry point' diff --git a/share/completions/apk.fish b/share/completions/apk.fish index 6a6d204f8..6759b237c 100644 --- a/share/completions/apk.fish +++ b/share/completions/apk.fish @@ -6,8 +6,8 @@ complete -f -c apk -n "__fish_seen_subcommand_from del fix version manifest" -a # Global options complete -f -c apk -s h -l help -d "Show help" -complete -x -c apk -s p -l root -d "Install packages to DIR" -complete -x -c apk -s X -l repository -d "Use packages from REPO" +complete -r -c apk -s p -l root -d "Install packages to DIR" +complete -r -c apk -s X -l repository -d "Use packages from REPO" complete -f -c apk -s q -l quiet -d "Print less information" complete -f -c apk -s v -l verbose -d "Print more information" complete -f -c apk -s i -l interactive -d "Ask confirmation for certain operations" @@ -20,18 +20,18 @@ complete -f -c apk -l force-overwrite -d "Overwrite files in other packages" complete -f -c apk -l force-refresh -d "Don't use cached files" complete -f -c apk -s U -l update-cache -d "Alias for --cache-max-age 1" complete -f -c apk -l progress -d "Show a progress bar" -complete -f -c apk -l progress-fd -d "Write progress to FD" +complete -x -c apk -l progress-fd -d "Write progress to FD" complete -f -c apk -l no-progress -d "Disable progress bar even for TTYs" complete -f -c apk -l purge -d "Delete also modified configuration files and uninstalled packages from cache" complete -f -c apk -l allow-untrusted -d "Install packages with untrusted signature or no signature" -complete -f -c apk -l wait -d "Wait for TIME seconds to get an exclusive repository lock before failing" -complete -f -c apk -l keys-dir -d "Override directory of trusted keys" -complete -f -c apk -l repositories-file -d "Override repositories file" +complete -x -c apk -l wait -d "Wait for TIME seconds to get an exclusive repository lock before failing" +complete -r -c apk -l keys-dir -d "Override directory of trusted keys" +complete -r -c apk -l repositories-file -d "Override repositories file" complete -f -c apk -l no-network -d "Don't use network" complete -f -c apk -l no-cache -d "Don't use any local cache path" -complete -f -c apk -l cache-dir -d "Override cache directory" -complete -f -c apk -l cache-max-age -d "Maximum AGE for index in cache before refresh" -complete -f -c apk -l arch -d "Use architecture with --root" +complete -r -c apk -l cache-dir -d "Override cache directory" +complete -x -c apk -l cache-max-age -d "Maximum AGE for index in cache before refresh" +complete -x -c apk -l arch -d "Use architecture with --root" complete -f -c apk -l print-arch -d "Print default architecture" # Commands @@ -82,18 +82,18 @@ complete -f -c apk -n "__fish_seen_subcommand_from fix" -l directory-permissions # Info options complete -f -c apk -n "__fish_seen_subcommand_from info" -s L -l contents -d "List included files" complete -f -c apk -n "__fish_seen_subcommand_from info" -s e -l installed -d "Check PACKAGE installed status" -complete -f -c apk -n "__fish_seen_subcommand_from info" -s W -l who-owns -d "Print who owns the file" +complete -r -c apk -n "__fish_seen_subcommand_from info" -s W -l who-owns -d "Print who owns the file" complete -f -c apk -n "__fish_seen_subcommand_from info" -s R -l depends -d "List the dependencies" complete -f -c apk -n "__fish_seen_subcommand_from info" -s P -l provides -d "List virtual packages provided" complete -f -c apk -n "__fish_seen_subcommand_from info" -s r -l rdepends -d "List reverse dependencies" complete -f -c apk -n "__fish_seen_subcommand_from info" -l replaces -d "List packages that PACKAGE might replace" -complete -f -c apk -n "__fish_seen_subcommand_from info" -s i -l install-if -d "List install_if rule" -complete -f -c apk -n "__fish_seen_subcommand_from info" -s I -l rinstall-if -d "List packages having install_if referencing PACKAGE" +complete -f -c apk -n "__fish_seen_subcommand_from info" -l install-if -d "List install_if rule" +complete -f -c apk -n "__fish_seen_subcommand_from info" -l rinstall-if -d "List packages having install_if referencing PACKAGE" complete -f -c apk -n "__fish_seen_subcommand_from info" -s w -l webpage -d "Print the URL for the upstream" complete -f -c apk -n "__fish_seen_subcommand_from info" -s s -l size -d "Show installed size" complete -f -c apk -n "__fish_seen_subcommand_from info" -s d -l description -d "Print the description" complete -f -c apk -n "__fish_seen_subcommand_from info" -l license -d "Print the license" -complete -f -c apk -n "__fish_seen_subcommand_from info" -s t -l triggers -d "Print active triggers" +complete -f -c apk -n "__fish_seen_subcommand_from info" -l triggers -d "Print active triggers" complete -f -c apk -n "__fish_seen_subcommand_from info" -s a -l all -d "Print all information" # List options @@ -119,6 +119,7 @@ complete -f -c apk -n "__fish_seen_subcommand_from upgrade" -s l -l latest -d "S complete -f -c apk -n "__fish_seen_subcommand_from upgrade" -l no-self-upgrade -d "Don't do early upgrade of the apk" complete -f -c apk -n "__fish_seen_subcommand_from upgrade" -l self-upgrade-only -d "Only do self-upgrade" complete -f -c apk -n "__fish_seen_subcommand_from upgrade" -l ignore -d "Ignore the upgrade of PACKAGE" +complete -f -c apk -n "__fish_seen_subcommand_from upgrade" -l prune -d "Prune the WORLD by removing packages which are no longer available" # Cache options complete -f -c apk -n "__fish_seen_subcommand_from cache" -s u -l upgrade -d "Prefer to upgrade package" @@ -132,8 +133,8 @@ complete -f -c apk -n "__fish_seen_subcommand_from version" -s a -l all -d "Cons complete -x -c apk -n "__fish_seen_subcommand_from version" -s l -l limit -d "Limit to packages with output matching given operand" # Index options -complete -x -c apk -n "__fish_seen_subcommand_from index" -s o -l output -d "Write the generated index to FILE" -complete -x -c apk -n "__fish_seen_subcommand_from index" -s x -l index -d "Read an existing index from INDEX" +complete -r -c apk -n "__fish_seen_subcommand_from index" -s o -l output -d "Write the generated index to FILE" +complete -r -c apk -n "__fish_seen_subcommand_from index" -s x -l index -d "Read an existing index from INDEX" complete -x -c apk -n "__fish_seen_subcommand_from index" -s d -l description -d "Add a description to the index" complete -x -c apk -n "__fish_seen_subcommand_from index" -l rewrite-arch -d "Use ARCH as architecture for all packages" complete -f -c apk -n "__fish_seen_subcommand_from index" -l no-warnings -d "Disable the warning about missing dependencies" @@ -143,7 +144,7 @@ complete -f -c apk -n "__fish_seen_subcommand_from fetch" -s L -l link -d "Creat complete -f -c apk -n "__fish_seen_subcommand_from fetch" -s R -l recursive -d "Fetch all dependencies too" complete -f -c apk -n "__fish_seen_subcommand_from fetch" -l simulate -d "Simulate the requested operation" complete -f -c apk -n "__fish_seen_subcommand_from fetch" -s s -l stdout -d "Dump the .apk to stdout" -complete -x -c apk -n "__fish_seen_subcommand_from fetch" -s o -l output -d "Write the downloaded files to DIR" +complete -r -c apk -n "__fish_seen_subcommand_from fetch" -s o -l output -d "Write the downloaded files to DIR" # Audit options complete -f -c apk -n "__fish_seen_subcommand_from audit" -l backup -d "Audit configuration files only" diff --git a/share/completions/argparse.fish b/share/completions/argparse.fish new file mode 100644 index 000000000..59fefeea9 --- /dev/null +++ b/share/completions/argparse.fish @@ -0,0 +1,72 @@ +function __fish_argparse_exclusive_args --description 'Helper function to list unused options' + set --local all_tokens (commandline --tokenize) + set --erase all_tokens[1] + set --local current_token (commandline --current-token) + + if set --local index (contains --index -- '--' $all_tokens) + set index (math $index - 1) + else + set index (count $all_tokens) + end + + set --local specifications + while test $index -gt 0 + and set -l tok $all_tokens[$index] + and not string match --quiet -- '-*' $tok + + if string match --quiet '*,*' $tok + set index (math $index - 1) + continue + end + + set -l opt (string replace --regex '=.*' '' $tok) + + if string match --quiet '*/*' $opt + set --append specifications (string split '/' $opt) + else if string match --quiet '*#*' $opt + set --append specifications (string split '#' $opt) + else + set --append specifications $opt + end + set index (math $index - 1) + end + + if string match --quiet -- '-x*' $current_token + set current_token (string replace --regex -- '^-x' '' $current_token) + end + + if test $index -gt 1 + and string match --regex --quiet -- '^(-x|--exclusive)$' $all_tokens[(math $index - 1)] + and not test -z $current_token + set --erase specifications[(count $specifications)] + end + + set --local used_options (string split -- ',' $current_token) + set --local unused_specifications + + for item in $specifications + if not contains -- $item $used_options + set --append unused_specifications $item + end + end + + string join \n $unused_specifications +end + +complete --command argparse --no-files + +complete --command argparse --short-option h --long-option help --description 'Show help' + +complete --command argparse --short-option n --long-option name --require-parameter --no-files \ + --arguments '(functions --all | string replace ", " "\n")' --description 'Use function name' +complete --command argparse --short-option x --long-option exclusive --no-files --require-parameter \ + --arguments '(__fish_append "," (__fish_argparse_exclusive_args))' \ + --description 'Specify mutually exclusive options' +complete --command argparse --short-option N --long-option min-args --no-files --require-parameter \ + --description 'Specify minimum non-option argument count' +complete --command argparse --short-option X --long-option max-args --no-files --require-parameter \ + --description 'Specify maximum non-option argument count' +complete --command argparse --short-option i --long-option ignore-unknown \ + --description 'Ignore unknown options' +complete --command argparse --short-option s --long-option stop-nonopt \ + --description 'Exit on subcommand' diff --git a/share/completions/asd.fish b/share/completions/asd.fish new file mode 100644 index 000000000..959bb71ac --- /dev/null +++ b/share/completions/asd.fish @@ -0,0 +1,3 @@ +complete -f asd +complete -c asd -n "test (__fish_number_of_cmd_args_wo_opts) = 1" \ + -a "sync unsync resync" diff --git a/share/completions/attrib.fish b/share/completions/attrib.fish new file mode 100644 index 000000000..4f461222c --- /dev/null +++ b/share/completions/attrib.fish @@ -0,0 +1,31 @@ +function __attrib_complete_args -d 'Function to generate args' + set -l current_token (commandline -tc) + + switch $current_token + case '+*' + echo -e 'r\tSet the Read-only file attribute +a\tSet the Archive file attribute +s\tSet the System file attribute +h\tSet the Hidden file attribute +i\tSet the Not Content Indexed file attribute' | awk -F '\t' "{ printf \"$current_token%s\t%s\n\", \$1, \$2 }" + case '-*' + echo -e 'r\tClear the Read-only file attribute +a\tClear the Archive file attribute +s\tClear the System file attribute +h\tClear the Hidden file attribute +i\tClear the Not Content Indexed file attribute' | awk -F '\t' "{ printf \"$current_token%s\t%s\n\", \$1, \$2 }" + end +end + +complete -c attrib -f -a '(__attrib_complete_args)' + +complete -c attrib -f -n '__fish_seen_argument -w s' -a d \ + -d 'Apply attrib and any command-line options to directories' +complete -c attrib -f -n '__fish_seen_argument -w s' -a l \ + -d 'Apply attrib and any command-line options to the Symbolic Link' + +complete -c attrib -f -a + -d 'Set the file attribute' +complete -c attrib -f -a - -d 'Clear the file attribute' +complete -c attrib -f -a /s \ + -d 'Apply to matching files in the current directory and all of its subdirectories' +complete -c attrib -f -a '/?' -d 'Show help' diff --git a/share/completions/attributes.fish b/share/completions/attributes.fish new file mode 100644 index 000000000..648182d7c --- /dev/null +++ b/share/completions/attributes.fish @@ -0,0 +1,42 @@ +function __attributes_disk_complete_args + if not __fish_seen_subcommand_from set clear + echo -e 'set\tSet the specified attribute of the disk with focus +clear\tClear the specified attribute of the disk with focus' + return + end + + echo -e 'readonly\tSpecify that the disk is read-only +noerr\tWhen an error is encountered, DiskPart continues to process commands' +end + +function __attributes_volume_complete_args + if not __fish_seen_subcommand_from set clear + echo -e 'set\tSet the specified attribute of the volume with focus +clear\tClear the specified attribute of the volume with focus' + return + end + + if not __fish_seen_subcommand_from readonly hidden nodefaultdriveletter shadowcopy + echo -e 'readonly\tSpecify that the volume is read-only +hidden\tSpecify that the volume is hidden +nodefaultdriveletter\tSpecify that the volume does not receive a drive letter by default +shadowcopy\tSpecify that the volume is a shadow copy volume' + end + + echo -e 'noerr\tWhen an error is encountered, DiskPart continues to process commands' +end + +function __attributes_complete_args -d 'Function to generate args' + if __fish_seen_subcommand_from disk + __attributes_disk_complete_args + else if __fish_seen_subcommand_from volume + __attributes_volume_complete_args + end +end + +complete -c attributes -f -a '(__attributes_complete_args)' + +complete -c attributes -f -n 'not __fish_seen_subcommand_from disk volume' -a disk \ + -d 'Display, set, or clear the attributes of a disk' +complete -c attributes -f -n 'not __fish_seen_subcommand_from dick volume' -a volume \ + -d 'Display, set, or clear the attributes of a volume' diff --git a/share/completions/aws.fish b/share/completions/aws.fish index f14013d35..c63f831d1 100644 --- a/share/completions/aws.fish +++ b/share/completions/aws.fish @@ -270,4 +270,4 @@ set -l aws_services \ workspaces \ xray -complete -c aws -n "fish_is_nth_token 1" -xa "$aws_services" +complete -c aws -n "__fish_is_nth_token 1" -xa "$aws_services" diff --git a/share/completions/basename.fish b/share/completions/basename.fish new file mode 100644 index 000000000..20aade653 --- /dev/null +++ b/share/completions/basename.fish @@ -0,0 +1,3 @@ +# author: floam 2022-01-29 +complete basename -s a -d 'work on multiple arguments' +complete basename -s s -d 'remove trailing suffix' diff --git a/share/completions/bison.fish b/share/completions/bison.fish index d7b50f891..ef2dc275d 100644 --- a/share/completions/bison.fish +++ b/share/completions/bison.fish @@ -5,19 +5,16 @@ # have been hand edited since. # -complete -c bison -s b -l file-prefix -d 'Specify a prefix to use for all bison output file names' -r - -complete -c bison -s d -d 'Write an extra output file containing macro definitions for the token type names defined in the grammar and the semantic value type YYSTYPE, as well as a few extern variable declarations' -complete -c bison -l defines -d 'The behavior of --defines is the same than -d option' -complete -c bison -s g -d 'Output a VCG definition of the LALR(1) grammar automaton com puted by Bison' -complete -c bison -l graph -d 'The behavior of --graph is the same than -g option' +complete -c bison -s b -l file-prefix -d 'Specify a prefix to use for all output file names' -r +complete -c bison -s d -l defines -d 'Generate file with macro definitions for token type names' +complete -c bison -s g -l graph -d 'Output a VCG definition of the LALR(1) grammar automaton' complete -c bison -s k -l token-table -d 'This switch causes the name' complete -c bison -s l -l no-lines -d 'Dont put any #line preprocessor commands in the parser file' -complete -c bison -s n -l no-parser -d 'Do not generate the parser code into the output; generate only declarations' +complete -c bison -s n -l no-parser -d "Generate only declarations, not parser code" complete -c bison -s o -l output -d 'Specify the name outfile for the parser file' -complete -c bison -s p -l name-prefix -d 'Rename the external symbols used in the parser so that they start with prefix instead of yy' -complete -c bison -s t -l debug -d 'In the parser file, define the macro YYDEBUG to 1 if it is not already defined, so that the debugging facilities are compiled' -complete -c bison -s v -l verbose -d 'Write an extra output file containing verbose descriptions of the parser states and what is done for each type of look-ahead token in that state' -complete -c bison -s V -l version -d 'Print the version number of bison and exit' -complete -c bison -s h -l help -d 'Print a summary of the options to bison and exit' +complete -c bison -s p -l name-prefix -d 'External symbols start with prefix instead of yy' +complete -c bison -s t -l debug -d 'Enable debugging facilities on compilation' +complete -c bison -s v -l verbose -d 'Generate file with descriptions of the parser states' +complete -c bison -s V -l version -d 'Print version number' +complete -c bison -s h -l help -d 'Print summary of the options' complete -c bison -s y -l yacc -l fixed-output-files -d 'Equivalent to -o y.tab.c' diff --git a/share/completions/bower.fish b/share/completions/bower.fish index b0dfa841f..d3a95ef8c 100644 --- a/share/completions/bower.fish +++ b/share/completions/bower.fish @@ -64,7 +64,7 @@ for k,v in data["dependencies"].items(): print(k + "\t" + v[:18])' &1 | string replace -rf '^\s+([^\s]+)\s+(.*)' '$1\t$2' | string escape) +set -l __fish_cargo_subcommands (cargo --list 2>&1 | string replace -rf '^\s+([^\s]+)\s*(.*)' '$1\t$2' | string escape) complete -c cargo -f -c cargo -n __fish_use_subcommand -a "$__fish_cargo_subcommands" complete -c cargo -x -c cargo -n '__fish_seen_subcommand_from help' -a "$__fish_cargo_subcommands" diff --git a/share/completions/cat.fish b/share/completions/cat.fish index 84698290b..4d4bbd584 100644 --- a/share/completions/cat.fish +++ b/share/completions/cat.fish @@ -15,7 +15,8 @@ else # OS X complete -c cat -s e -d "Show unprintables, end lines with \$" complete -c cat -s n -d "Enumerate lines" complete -c cat -s s -d "Squeeze away >1 blank lines" - complete -c cat -s t -d "Show unprintables; tab as '^I'" + complete -c cat -s t -d "Show unprintables; tab as ^I" complete -c cat -s u -d "Disable output buffering" complete -c cat -s v -d "Escape non-printing chars" + complete -c cat -s l -d "Set/block on F_SETLKW stdout lock" end diff --git a/share/completions/cdrecord.fish b/share/completions/cdrecord.fish index 01cd0eb85..3f7b6805e 100644 --- a/share/completions/cdrecord.fish +++ b/share/completions/cdrecord.fish @@ -2,33 +2,33 @@ # Completions for Cdrecord # -complete -c cdrecord -o version -d "Display version and exit" +complete -c cdrecord -o version -d "Display version" complete -c cdrecord -s v -d "Increment the level of general verbosity by one" complete -c cdrecord -s V -d "Increment the verbose level in respect of SCSI command transport by one" complete -c cdrecord -a "debug={1,2,3,4,5}" -d "Set the misc debug value to #" complete -c cdrecord -s d -d "Increment the misc debug level by one" -a "1 2 3 4 5" complete -c cdrecord -s s -o silent -d "Do not print out a status report for failed SCSI commands" complete -c cdrecord -o force -d "Force to continue on some errors" -complete -c cdrecord -o immed -d "Tell cdrecord to set the SCSI IMMED flag in certain commands" -complete -c cdrecord -a "minbuf={25,35,45,55,65,75,85,95}" -d "Defines the minimum drive buffer fill ratio for the experimental ATAPI wait mode intended to free the IDE bus to allow hard disk and CD/DVD writer on the same IDE cable" +complete -c cdrecord -o immed -d "Set the SCSI IMMED flag in certain commands" +complete -c cdrecord -a "minbuf={25,35,45,55,65,75,85,95}" -d "Minimum drive buffer fill ratio for the ATAPI wait mode" complete -c cdrecord -o dummy -d "Complete CD/DVD-Recorder recording process with the laser turned off" -complete -c cdrecord -o clone -d "Tells cdrecord to handle images created by readcd -clone" +complete -c cdrecord -o clone -d "Handle images created by readcd -clone" complete -c cdrecord -o dao complete -c cdrecord -o sao -d "Set SAO (Session At Once) mode, usually called Disk At Once mode" complete -c cdrecord -o tao -d "Set TAO (Track At Once) writing mode" complete -c cdrecord -o raw -d "Set RAW writing mode" complete -c cdrecord -o raw96r -d "Select Set RAW writing, the preferred raw writing mode" complete -c cdrecord -o raw96p -d "Select Set RAW writing, the less preferred raw writing mode" -complete -c cdrecord -o raw16 -d "Select Set RAW writing, the preferred raw writing mode if raw96r is not supported" +complete -c cdrecord -o raw16 -d "Select Set RAW writing, the preferred raw writing mode after raw96r" complete -c cdrecord -o multi -d "Allow multi session CDs to be made" complete -c cdrecord -o msinfo -d "Retrieve multi session info in a form suitable for mkisofs-1.10 or later" complete -c cdrecord -o toc -d "Retrieve and print out the table of content or PMA of a CD" complete -c cdrecord -o atip -d "Retrieve and print out the ATIP (absolute Time in Pre-groove) info" -complete -c cdrecord -o fix -d "The disk will only be fixated" +complete -c cdrecord -o fix -d "Only fixate disk " complete -c cdrecord -o nofix -d "Do not fixate the disk after writing the tracks" -complete -c cdrecord -o waiti -d "Wait for input to become available on standard input before trying to open the SCSI driver" -complete -c cdrecord -o load -d "Load the media and exit" -complete -c cdrecord -o lock -d "Load the media, lock the door and exit" +complete -c cdrecord -o waiti -d "Wait for standard input to become available before opening the SCSI driver" +complete -c cdrecord -o load -d "Load the media" +complete -c cdrecord -o lock -d "Load the media, lock the door" complete -c cdrecord -o eject -d "Eject disk after doing the work" complete -c cdrecord -a "speed={0,150,172,1385}" -d "Set the speed factor of the writing process to #" complete -c cdrecord -a "blank={help,all,fast,track,unreserve,trtail,unclose,session}" -d "Blank a CD-RW and exit or blank a CD-RW before writing" @@ -43,22 +43,22 @@ complete -c cdrecord -a "driver={help,mmc_cd,mmc_cd_dvd,mmc_cdr,mmc_cdr_sony,mmc # TODO: This argument accepts a comma separated list of arguments complete -c cdrecord -a "driveropts=" -d "Set driver specific options" -complete -c cdrecord -o setdropts -d "Set the driveropts specified by driveropts=option list, the speed of the drive and the dummy flag and exit" -complete -c cdrecord -o checkdrive -d "Checks if a driver for the current drive is present and exit" -complete -c cdrecord -o prcap -d "Print the drive capabilities for SCSI-3/mmc compliant drives as obtained from mode page 0x2A" -complete -c cdrecord -o inq -d "Do an inquiry for the drive, print the inquiry info and exit" +complete -c cdrecord -o setdropts -d "Set driver specific options" +complete -c cdrecord -o checkdrive -d "Checks if a driver for the current drive is present" +complete -c cdrecord -o prcap -d "Print the drive capabilities for SCSI-3/mmc compliant drives" +complete -c cdrecord -o inq -d "Do an inquiry for the drive, print the inquiry info" complete -c cdrecord -o scanbus -d "Scan all SCSI devices on all SCSI busses and print the inquiry strings" complete -c cdrecord -o reset -d "Try to reset the SCSI bus where the CD recorder is located" complete -c cdrecord -o abort -d "Try to send an abort sequence to the drive" -complete -c cdrecord -o overburn -d "Allow cdrecord to write more than the official size of a medium" +complete -c cdrecord -o overburn -d "Allow writing more than the official size of a medium" complete -c cdrecord -o ignsize -d "Ignore the known size of the medium, use for debugging only" complete -c cdrecord -o useinfo -d "Use *.inf files to overwrite audio options" -complete -c cdrecord -a "defpregap=" -d "Set the default pre-gap size for all tracks except track nr 1" -complete -c cdrecord -o packet -d "Set Packet writing mode (experimental interface)" -complete -c cdrecord -a "pktsize=" -d "Set the packet size to #, forces fixed packet mode (experimental)" -complete -c cdrecord -o noclose -d "Do not close the current track, only when in packet writing mode (experimental)" +complete -c cdrecord -a "defpregap=" -d "Set default pre-gap size for all tracks except track nr 1" +complete -c cdrecord -o packet -d "Set Packet writing mode" +complete -c cdrecord -a "pktsize=" -d "Set the packet size to #, forces fixed packet mode" +complete -c cdrecord -o noclose -d "Don't close the current track, only when in packet writing mode" complete -c cdrecord -a "mcn=" -d "Set the Media Catalog Number of the CD" -complete -c cdrecord -o text -d "Write CD-Text info based on info taken from a file that contains ascii info for the text strings" +complete -c cdrecord -o text -d "Write CD-Text info based on file containing ascii info" complete -c cdrecord -a "textfile=" -d "Write CD-Text based on info found in the binary file filename" complete -c cdrecord -a "cuefile=" -d "Take all recording related info from a CDRWIN compliant CUE sheet file" @@ -66,25 +66,25 @@ complete -c cdrecord -a "cuefile=" -d "Take all recording related info from a CD complete -c cdrecord -a "isrc=" -d "Set the International Standard Recording Number for the next track" complete -c cdrecord -a "index=" -d "Sets an index list for the next track" -complete -c cdrecord -o audio -d "All subsequent tracks are written in CD-DA audio format" -complete -c cdrecord -o swab -d "Audio data is assumed to be in byte-swapped (little-endian) order" -complete -c cdrecord -o data -d "All subsequent tracks are written in CD-ROM mode 1 (Yellow Book) format" -complete -c cdrecord -o mode2 -d "All subsequent tracks are written in CD-ROM mode 2 format" -complete -c cdrecord -o xa -d "All subsequent tracks are written in CD-ROM XA mode 2 form 1 format" -complete -c cdrecord -o xa1 -d "All subsequent tracks are written in CD-ROM XA mode 2 form 1 format" -complete -c cdrecord -o xa2 -d "All subsequent tracks are written in CD-ROM XA mode 2 form 2 format" -complete -c cdrecord -o xamix -d "All subsequent tracks are written in a way that allows a mix of CD-ROM XA mode 2 form 1/2 format" +complete -c cdrecord -o audio -d "Subsequent tracks are written in CD-DA format" +complete -c cdrecord -o swab -d "Audio data is assumed to be in byte-swapped order" +complete -c cdrecord -o data -d "Subsequent tracks are written in CD-ROM mode 1 format" +complete -c cdrecord -o mode2 -d "Subsequent tracks are written in CD-ROM mode 2 format" +complete -c cdrecord -o xa -d "Subsequent tracks are written in CD-ROM XA mode 2 form 1 format" +complete -c cdrecord -o xa1 -d "Subsequent tracks are written in CD-ROM XA mode 2 form 1 format" +complete -c cdrecord -o xa2 -d "Subsequent tracks are written in CD-ROM XA mode 2 form 2 format" +complete -c cdrecord -o xamix -d "Subsequent tracks allows a mix of CD-ROM XA mode 2 form 1/2 format" complete -c cdrecord -o cdi -d "The TOC type for the disk is set to CDI, with XA only" complete -c cdrecord -o isosize -d "Use the ISO-9660 file system size as the size of the next track" -complete -c cdrecord -o pad -d "15 sectors of zeroed data will be added to the end of this and each subsequent data track" +complete -c cdrecord -o pad -d "Add 15 sectors of zeroed data to the end of this and subsequent tracks" complete -c cdrecord -a "padsize=" -d "Set the amount of data to be appended as padding to the next track" complete -c cdrecord -o nopad -d "Do not pad the following tracks - the default" -complete -c cdrecord -o shorttrack -d "Allow all subsequent tracks to violate the Red Book track length standard (min 4 s)" -complete -c cdrecord -o noshorttrack -d "Re-enforce the Red Book track length standard (min 4 s)" +complete -c cdrecord -o shorttrack -d "Allow all subsequent tracks to violate the Red Book track length standard" +complete -c cdrecord -o noshorttrack -d "Re-enforce the Red Book track length standard" complete -c cdrecord -a "pregap=" -d "Set the pre-gap size for the next track" -complete -c cdrecord -o preemp -d "All TOC entries for subsequent audio tracks will indicate that the audio data has been sampled with 50/15 microsec pre-emphasis" -complete -c cdrecord -o nopreemp -d "All TOC entries for subsequent audio tracks will indicate that the audio data has been mastered with linear data" -complete -c cdrecord -o copy -d "All TOC entries for subsequent audio tracks of the resulting CD will indicate that the audio data has permission to be copied without limit" -complete -c cdrecord -o nocopy -d "All TOC entries for subsequent audio tracks of the resulting CD will indicate that the audio data has permission to be copied only once for personal use" -complete -c cdrecord -o scms -d "All TOC entries for subsequent audio tracks of the resulting CD will indicate that the audio data has no permission to be copied" -complete -c cdrecord -a "tsize=" -d "If the master image for the next track has been stored on a raw disk, use this option to specify the valid amount of data on this disk" +complete -c cdrecord -o preemp -d "TOC indicates that data has been sampled with 50/15 microsec pre-emphasis" +complete -c cdrecord -o nopreemp -d "TOC indicates that data has been mastered with linear data" +complete -c cdrecord -o copy -d "TOC indicates that data has permission to be copied without limit" +complete -c cdrecord -o nocopy -d "TOC indicates that data has permission to be copied only once" +complete -c cdrecord -o scms -d "TOC indicates that data has no permission to be copied" +complete -c cdrecord -a "tsize=" -d "Specify valid amount of data on raw disk for next track's master image" diff --git a/share/completions/chgrp.fish b/share/completions/chgrp.fish index 309f465e0..7e17d6a54 100644 --- a/share/completions/chgrp.fish +++ b/share/completions/chgrp.fish @@ -1,12 +1,24 @@ - -complete -c chgrp -s c -l changes -d "Output diagnostic for changed files" -complete -c chgrp -l dereference -d "Dereference symbolic links" -complete -c chgrp -s h -l no-dereference -d "Do not dereference symbolic links" -complete -c chgrp -l from -d "Change from owner/group" -complete -c chgrp -s f -l silent -d "Suppress errors" -complete -c chgrp -l reference -d "Use same owner/group as file" -r -complete -c chgrp -s R -l recursive -d "Operate recursively" -complete -c chgrp -s v -l verbose -d "Output diagnostic for every file" -complete -c chgrp -s h -l help -d "Display help and exit" -complete -c chgrp -l version -d "Display version and exit" -complete -c chgrp -d Group -a "(__fish_complete_groups)" +if chgrp --version &>/dev/null # not unix + complete -c chgrp -s c -l changes -d "Output diagnostic for changed files" + complete -c chgrp -l dereference -d "Dereference symlinks" + complete -c chgrp -s h -l no-dereference -d "Don't dereference symlinks" + complete -c chgrp -l from -d "Change from owner/group" + complete -c chgrp -s f -l silent -d "Suppress errors" + complete -c chgrp -l reference -d "Use same owner/group as file" -r + complete -c chgrp -s R -l recursive -d "Operate recursively" + complete -c chgrp -s v -l verbose -d "Output diagnostic for every file" + complete -c chgrp -l help -d "Display help and exit" + complete -c chgrp -l version -d "Display version and exit" + complete -c chgrp -d Group -a "(__fish_complete_groups)" +else # not Linux + complete -c chgrp -s h -d "Don't dereference symlinks" + complete -c chgrp -s H -d "Follow specified symlinks with -R" + complete -c chgrp -s L -d "Follow all symlinks with -R" + complete -c chgrp -s P -d "Follow no symlinks with -R" + complete -c chgrp -s f -d "Suppress errors" + complete -c chgrp -s n -d "id is numeric; avoid lookup" + complete -c chgrp -s R -d "Operate recursively" + complete -c chgrp -s v -d "Output filenames" + complete -c chgrp -s x -d "Don't traverse fs mountpoints" + complete -c chgrp -d Group -a "(__fish_complete_groups)" +end diff --git a/share/completions/chmod.fish b/share/completions/chmod.fish index 3ad274bc3..74e95299d 100644 --- a/share/completions/chmod.fish +++ b/share/completions/chmod.fish @@ -1,16 +1,19 @@ -# -# Command specific completions for the chmod command. -# These completions where generated from the commands -# man page by the make_completions.py script, but may -# have been hand edited since. -# - -complete -c chmod -s c -l changes -d 'Like verbose but report only when a change is made' -complete -c chmod -l no-preserve-root -d 'Do not treat / specially (the default)' -complete -c chmod -l preserve-root -d 'Fail to operate recursively on /' -complete -c chmod -s f -l silent -l quiet -d 'Suppress most error messages' -complete -c chmod -s v -l verbose -d 'Output a diagnostic for every file processed' -complete -c chmod -l reference -d 'Use RFILEs mode instead of MODE values' -r -complete -c chmod -s R -l recursive -d 'Change files and directories recursively' -complete -c chmod -l help -d 'Display help and exit' -complete -c chmod -l version -d 'Display version and exit' +if chmod --version &>/dev/null # gnu's not unix + complete chmod -s c -l changes -d 'Like -v but report only changes' + complete chmod -l no-preserve-root -d 'Don\'t treat / special (default)' + complete chmod -l preserve-root -d 'Fail to operate recursively on /' + complete chmod -s f -l silent -l quiet -d 'Suppress most errors' + complete chmod -s v -l verbose -d 'Prints each file processed' + complete chmod -l reference -d 'Use RFILEs mode instead of MODE values' -r + complete chmod -s R -l recursive -d 'Operate recursively' + complete chmod -l help -d 'Display help and exit' + complete chmod -l version -d 'Display version and exit' +else # guess it might be unix + complete chmod -s f -d 'Suppress errors' + complete chmod -s H -d "Follow given symlinks with -R" + complete chmod -s h -d "Don't dereference given symlinks" + complete chmod -s L -d "Follow all symlinks with -R" + complete chmod -s P -d "Follow no symlinks with -R" + complete chmod -s R -d 'Operate recursively' + complete chmod -s v -d 'Prints each file processed' +end diff --git a/share/completions/choice.fish b/share/completions/choice.fish new file mode 100644 index 000000000..f4bb425e7 --- /dev/null +++ b/share/completions/choice.fish @@ -0,0 +1,7 @@ +complete -c choice -f -a /c -d "Specify the list of choices to be created" +complete -c choice -f -a /n -d "Hide the list of choices" +complete -c choice -f -a /cs -d "Specify that the choices are case-sensitive" +complete -c choice -f -a /t -d "Specify the number of seconds" +complete -c choice -f -a /d -d "Specify the default choice" +complete -c choice -f -a /m -d "Specify a message" +complete -c choice -f -a '/?' -d "Show help" diff --git a/share/completions/chown.fish b/share/completions/chown.fish index 922e9ee4a..201d155f5 100644 --- a/share/completions/chown.fish +++ b/share/completions/chown.fish @@ -1,12 +1,25 @@ -complete -c chown -s c -l changes -d "Output diagnostic for changed files" -complete -c chown -l dereference -d "Dereference symbolic links" -complete -c chown -s h -l no-dereference -d "Do not dereference symbolic links" -complete -c chown -l from -d "Change from owner/group" -complete -c chown -s f -l silent -d "Suppress errors" -complete -c chown -l reference -d "Use same owner/group as file" -r -complete -c chown -s R -l recursive -d "Operate recursively" -complete -c chown -s v -l verbose -d "Output diagnostic for every file" -complete -c chown -s h -l help -d "Display help and exit" -complete -c chown -l version -d "Display version and exit" -complete -c chown -d Username -a "(__fish_print_users):" -complete -c chown -d Username -a "(string match -r -- '.*:' (commandline -ct))(__fish_complete_groups)" +if chown --version &>/dev/null # gee, and you is not eunichs + complete chown -s c -l changes -d "Output diagnostic for changed files" + complete chown -l dereference -d "Dereference symbolic links" + complete chown -s h -l no-dereference -d "Do not dereference symbolic links" + complete chown -l from -d "Change from owner/group" + complete chown -s f -l silent -d "Suppress errors" + complete chown -l reference -d "Use same owner/group as file" -r + complete chown -s R -l recursive -d "Operate recursively" + complete chown -s v -l verbose -d "Output diagnostic for every file" + complete chown -l help -d "Display help and exit" + complete chown -l version -d "Display version and exit" +else + complete chown -s R -d 'Operate recursively' + complete chown -s f -d "Suppress errors" + complete chown -s h -d "Do not dereference symbolic links" + complete chown -s n -d "uid/gid is numeric; avoid lookup" + complete chown -s v -d "Output filenames as modified" + complete chown -s x -d "Don't traverse fs mount points" +end + +complete chown -s H -d "Follow given symlinks with -R" +complete chown -s L -d "Follow all symlinks with -R" +complete chown -s P -d "Follow no symlinks with -R" +complete chown -d User -a "(__fish_print_users):" +complete chown -d User -a "(string match -r -- '.*:' (commandline -ct))(__fish_complete_groups)" diff --git a/share/completions/clean.fish b/share/completions/clean.fish new file mode 100644 index 000000000..b08fba20b --- /dev/null +++ b/share/completions/clean.fish @@ -0,0 +1 @@ +complete -c clean -f -a all -d "Specify that each and every sector on the disk is set to zero" diff --git a/share/completions/cleanmgr.fish b/share/completions/cleanmgr.fish new file mode 100644 index 000000000..4ebb4545a --- /dev/null +++ b/share/completions/cleanmgr.fish @@ -0,0 +1,19 @@ +function __cleanmgr_complete_args -d 'Function to generate args' + set -l previous_token (commandline -oc)[-1] + + if test "$previous_token" = /d + __fish_print_windows_drives + return + end +end + +complete -c cleanmgr -f -a '(__cleanmgr_complete_args)' + +complete -c cleanmgr -f -a /d -d 'Specify the drive' +complete -c cleanmgr -f -a /sageset \ + -d 'Display the Disk Cleanup Settings dialog box and also create a registry key' +complete -c cleanmgr -f -a /sagerun -d 'Run the specified tasks that are assigned to the n value' +complete -c cleanmgr -f -a /tuneup -d 'Run /sageset and /sagerun for the same n' +complete -c cleanmgr -f -a /lowdisk -d 'Run with the default settings' +complete -c cleanmgr -f -a /verylowdisk -d 'Run with the default settings, no user prompts' +complete -c cleanmgr -f -a '/?' -d 'Show help' diff --git a/share/completions/cmd.fish b/share/completions/cmd.fish new file mode 100644 index 000000000..ffcc16c3f --- /dev/null +++ b/share/completions/cmd.fish @@ -0,0 +1,54 @@ +function __cmd_complete_args -d 'Function to generate args' + set -l current_token (commandline -tc) + + switch $current_token + case '/t:*' + echo -e '0\tBlack +1\tBlue +2\tGreen +3\tAqua +4\tRed +5\tPurple +6\tYellow +7\tWhite +8\tGray +9\tLight blue +A\tLight green +B\tLight aqua +C\tLight red +D\tLight purple +E\tLight yellow +F\tBright white' | awk -F '\t' "{ printf \"$current_token%s\t%s\n\", \$1, \$2 }" + case '/e:*' + echo -e 'on\tEnable command extensions +off\tDisable command extensions' | awk -F '\t' "{ printf \"$current_token%s\t%s\n\", \$1, \$2 }" + case '/f:*' + echo -e 'on\tEnable file and directory name completion +off\tDisable file and directory name completion' | awk -F '\t' "{ printf \"$current_token%s\t%s\n\", \$1, \$2 }" + case '/v:*' + echo -e 'on\tEnable delayed environment variable expansion +off\tDisable delayed environment variable expansion' | awk -F '\t' "{ printf \"$current_token%s\t%s\n\", \$1, \$2 }" + end +end + +complete -c cmd -f -a '(__cmd_complete_args)' + +complete -c cmd -f -n 'not __fish_seen_argument -w c -w k' -a /c \ + -d 'Carry out the command specified by string and then stop' +complete -c cmd -f -n 'not __fish_seen_argument -w c -w k' -a /k \ + -d 'Carry out the command specified by string and continue' + +complete -c cmd -f -a /s -d 'Modify the treatment of string after /c or /k' +complete -c cmd -f -a /q -d 'Turn the echo off' +complete -c cmd -f -a /d -d 'Disable execution of AutoRun commands' + +complete -c cmd -f -n 'not __fish_seen_argument -w a -w u' -a /a \ + -d 'Format internal command output as ANSI' +complete -c cmd -f -n 'not __fish_seen_argument -w a -w u' -a /u \ + -d 'Format internal command output as Unicode' + +complete -c cmd -f -a /t -d 'Set the background and foreground color' +complete -c cmd -f -a /e -d 'Manage command extensions' +complete -c cmd -f -a /f -d 'Manage file and directory name completion' +complete -c cmd -f -a /v -d 'Manage delayed environment variable expansion' +complete -c cmd -f -a '/?' -d 'Show help' diff --git a/share/completions/cmdkey.fish b/share/completions/cmdkey.fish new file mode 100644 index 000000000..e9abe1a6c --- /dev/null +++ b/share/completions/cmdkey.fish @@ -0,0 +1,34 @@ +function __cmdkey_complete_args -d 'Function to generate args' + set -l current_token (commandline -tc) + set -l previous_token (commandline -oc)[-1] + + switch $current_token + case '/user:*' + __fish_print_windows_users | awk "{ printf \"%s%s\n\", \"$current_token\", \$0 }" + case '*' + if test "$previous_token" = /delete + echo -e '/ras\tDelete remote access entry' + return + end + end +end + +complete -c cmdkey -f -a '(__cmdkey_complete_args)' + +complete -c cmdkey -f -n "not __fish_seen_argument -w add: -w generic:" -a /add: \ + -d 'Add a user name and password' +complete -c cmdkey -f -n "not __fish_seen_argument -w add: -w generic:" -a /generic: \ + -d 'Add generic credentials' + +complete -c cmdkey -f -n "not __fish_seen_argument -w smartcard -w user:" -a /smartcard \ + -d 'Retrieve the credential' +complete -c cmdkey -f -n "not __fish_seen_argument -w smartcard -w user:" -a /user: \ + -d 'Specify the user or account name' + +complete -c cmdkey -f -n "__fish_seen_argument -w user:" -a /pass: -d 'Specify the password' + +complete -c cmdkey -f -a /delete: -d 'Specify the user or account name' +complete -c cmdkey -f -a /delete -d 'Specify the user or account name' + +complete -c cmdkey -f -a /list: -d 'Display the list of stored user names and credentials' +complete -c cmdkey -f -a '/?' -d 'Show help' diff --git a/share/completions/color.fish b/share/completions/color.fish index a8e192fe9..7b4d4185f 100644 --- a/share/completions/color.fish +++ b/share/completions/color.fish @@ -1,10 +1,10 @@ function __color_generate_args --description 'Function to generate args' - set --local current_token (commandline --current-token --cut-at-cursor) - switch $current_token - case '/*' - echo -e '/?\tShow help' - case '*' - echo -e '0\tBlack + set --local current_token (commandline --current-token --cut-at-cursor) + switch $current_token + case '/*' + echo -e '/?\tShow help' + case '*' + echo -e '0\tBlack 1\tBlue 2\tGreen 3\tAqua @@ -20,7 +20,7 @@ C\tLight red D\tLight purple E\tLight yellow F\tBright white' | awk -F '\t' "{ printf \"$current_token%s\t%s\n\", \$1, \$2 }" - end + end end complete --command color --no-files --arguments '(__color_generate_args)' diff --git a/share/completions/commandline.fish b/share/completions/commandline.fish index 245a45ec8..716016b2f 100644 --- a/share/completions/commandline.fish +++ b/share/completions/commandline.fish @@ -19,6 +19,7 @@ complete -c commandline -s C -l cursor -d "Set/get cursor position, not buffer c complete -c commandline -s L -l line -d "Print the line that the cursor is on" complete -c commandline -s S -l search-mode -d "Return true if performing a history search" complete -c commandline -s P -l paging-mode -d "Return true if showing pager content" +complete -c commandline -l paging-full-mode -d "Return true if pager is showing all content" complete -c commandline -l is-valid -d "Return true if the command line is syntactically valid and complete" diff --git a/share/completions/comp.fish b/share/completions/comp.fish new file mode 100644 index 000000000..c2e9adddb --- /dev/null +++ b/share/completions/comp.fish @@ -0,0 +1,8 @@ +complete -c comp -f -a /d -d 'Display differences in decimal format' +complete -c comp -f -a /a -d 'Display differences as characters' +complete -c comp -f -a /l -d 'Displays the number of the line where a difference occurs' +complete -c comp -f -a /n -d 'Compare only the number of lines that are specified for each file' +complete -c comp -f -a /c -d 'Perform a comparison that is not case-sensitive' +complete -c comp -f -a /off -d 'Process files with the offline attribute set' +complete -c comp -f -a /offline -d 'Process files with the offline attribute set' +complete -c comp -f -a '/?' -d 'Show help' diff --git a/share/completions/compare.fish b/share/completions/compare.fish index 4b87f43bd..2e702d3a9 100644 --- a/share/completions/compare.fish +++ b/share/completions/compare.fish @@ -1,4 +1,4 @@ -complete -c compare -o alpha -d 'On, activate, off, deactivate, set, opaque, copy transparent, extract, background, or shape [option]' -xa '(compare -list alpha)' +complete -c compare -o alpha -d 'Control alpha/matte channel of an image [option]' -xa '(compare -list alpha)' complete -c compare -o authenticate -d 'Decipher image with this password [password]' complete -c compare -o channel -d 'Apply option to select image channels [type]' -xa '(compare -list channel)' complete -c compare -o colorspace -d 'Alternate image colorspace [type]' -xa '(compare -list colorspace)' @@ -19,7 +19,7 @@ complete -c compare -o interlace -d 'Type of image interlacing scheme [type]' -x complete -c compare -o limit -d 'Pixel cache resource limit [type value]' -x complete -c compare -o lowlight-color -d 'De-emphasize pixel differences with this color [color]' -xa '(__fish_complete_convert_options color)' complete -c compare -o metric -d 'Measure differences between images with this metric [type]' -xa '(compare -list metric)' -complete -c compare -o monitor -d 'Monitor progress ' +complete -c compare -o monitor -d 'Monitor progress' complete -c compare -o passphrase -d 'Get the passphrase from this file [filename]' -r complete -c compare -o profile -d 'Add, delete, or apply an image profile [filename]' -r complete -c compare -o quality -d 'JPEG/MIFF/PNG compression level [value]' @@ -29,7 +29,7 @@ complete -c compare -o regard-warnings -d 'Pay attention to warning messages' complete -c compare -o respect-parentheses -d 'Settings remain in effect until parenthesis boundary' complete -c compare -o sampling-factor -d 'Horizontal and vertical sampling factor [geometry]' complete -c compare -o seed -d 'Seed a new sequence of pseudo-random numbers [value]' -complete -c compare -o set -d 'Attribute set an image attribute [ value]' +complete -c compare -o set -d 'Attribute set an image attribute [value]' complete -c compare -o size -d 'Width and height of image [geometry]' complete -c compare -o subimage-search -d 'Search for subimage' complete -c compare -o transparent-color -d 'Transparent color [color]' -xa '(__fish_complete_convert_options color)' diff --git a/share/completions/complete.fish b/share/completions/complete.fish index 709615c28..ed6a6a1cb 100644 --- a/share/completions/complete.fish +++ b/share/completions/complete.fish @@ -1,5 +1,6 @@ # Completions for complete +complete -c complete -xa '(__fish_complete_command)' complete -c complete -s c -l command -d "Command to add completion to" -xa '(__fish_complete_command)' complete -c complete -s p -l path -d "Path to add completion to" -r complete -c complete -s s -l short-option -d "POSIX-style short option to complete" -x diff --git a/share/completions/composite.fish b/share/completions/composite.fish index ce972cbae..b4fede6d1 100644 --- a/share/completions/composite.fish +++ b/share/completions/composite.fish @@ -1,5 +1,5 @@ complete -c composite -o affine -d 'Affine transform matrix [matrix]' -complete -c composite -o alpha -d 'On, activate, off, deactivate, set, opaque, copy transparent, extract, background, or shape [option]' -xa '(convert -list alpha)' +complete -c composite -o alpha -d 'Control alpha/matte channel of an image [option]' -xa '(convert -list alpha)' complete -c composite -o authenticate -d 'Decipher image with this password [password]' complete -c composite -o blue-primary -d 'Chromaticity blue primary point [point]' complete -c composite -o channel -d 'Apply option to select image channels [type]' -xa '(convert -list channel)' @@ -24,7 +24,7 @@ complete -c composite -o interlace -d 'Type of image interlacing scheme [type]' complete -c composite -o interpolate -d 'Pixel color interpolation method [method]' -xa '(convert -list interpolate)' complete -c composite -o label -d 'Assign a label to an image [string]' complete -c composite -o limit -d 'Pixel cache resource limit [type value]' -x -complete -c composite -o monitor -d 'Monitor progress ' +complete -c composite -o monitor -d 'Monitor progress' complete -c composite -o page -d 'Size and location of an image canvas (setting) [geometry]' complete -c composite -o pointsize -d 'Font point size [value]' complete -c composite -o quality -d 'JPEG/MIFF/PNG compression level [value]' @@ -50,9 +50,9 @@ complete -c composite -o border -d 'Surround image with a border of color [geome complete -c composite -o bordercolor -d 'Border color [color]' -xa '(__fish_complete_convert_options color)' complete -c composite -o colors -d 'Preferred number of colors in the image [value]' complete -c composite -o decipher -d 'Convert cipher pixels to plain pixels [filename]' -r -complete -c composite -o displace -d 'Shift lookup according to a relative displacement map [geometry]' +complete -c composite -o displace -d 'Shift image pixels defined by a displacement map [geometry]' complete -c composite -o dissolve -d 'Dissolve the two images a given percent [value]' -complete -c composite -o distort -d 'Shift lookup according to a absolute distortion map [geometry]' +complete -c composite -o distort -d 'Shift lookup based on a absolute distortion map [geometry]' complete -c composite -o encipher -d 'Convert plain pixels to cipher pixels [filename]' -r complete -c composite -o extract -d 'Extract area from image [geometry]' complete -c composite -o geometry -d 'Location of the composite image [geometry]' diff --git a/share/completions/conda.fish b/share/completions/conda.fish index d89e87a9c..8fbb8dca7 100644 --- a/share/completions/conda.fish +++ b/share/completions/conda.fish @@ -23,7 +23,7 @@ end # Complete for the first argument only function __fish_conda_top - complete -c conda -n "test (count (commandline -opc)) -eq 1" $argv + complete -c conda -n __fish_is_first_token $argv end function __fish_conda_config_keys diff --git a/share/completions/conjure.fish b/share/completions/conjure.fish index 46954e08c..a78657d83 100644 --- a/share/completions/conjure.fish +++ b/share/completions/conjure.fish @@ -1,4 +1,4 @@ -complete -c conjure -o monitor -d 'Monitor progress ' +complete -c conjure -o monitor -d 'Monitor progress' complete -c conjure -o quiet -d 'Suppress all warning messages' complete -c conjure -o regard-warnings -d 'Pay attention to warning messages' complete -c conjure -o seed -d 'Seed a new sequence of pseudo-random numbers [value]' diff --git a/share/completions/convert.fish b/share/completions/convert.fish index 5e19772af..fe7873159 100644 --- a/share/completions/convert.fish +++ b/share/completions/convert.fish @@ -1,7 +1,7 @@ complete -c convert -o adjoin -d 'Join images into a single multi-image file' complete -c convert -o affine -d 'Affine transform matrix [matrix]' -complete -c convert -o alpha -d 'Activate, deactivate, reset, or set the alpha channel [option]' -xa '(convert -list alpha)' -complete -c convert -o antialias -d 'Remove pixel-aliasing ' +complete -c convert -o alpha -d 'Control alpha/matte channel of an image [option]' -xa '(convert -list alpha)' +complete -c convert -o antialias -d 'Remove pixel-aliasing' complete -c convert -o authenticate -d 'Decipher image with this password [password]' complete -c convert -o attenuate -d 'Lessen (or intensify) when adding noise to an image [value]' complete -c convert -o background -d 'Background color [color]' -xa '(__fish_complete_convert_options color)' @@ -45,7 +45,7 @@ complete -c convert -o limit -d 'Pixel cache resource limit [type value]' -x complete -c convert -o loop -d 'Add Netscape loop extension to your GIF animation [iterations]' complete -c convert -o mask -d 'Associate a mask with the image [filename]' -r complete -c convert -o mattecolor -d 'Frame color [color]' -xa '(__fish_complete_convert_options color)' -complete -c convert -o monitor -d 'Monitor progress ' +complete -c convert -o monitor -d 'Monitor progress' complete -c convert -o orient -d 'Image orientation [type]' -xa '(convert -list orientation)' complete -c convert -o page -d 'Size and location of an image canvas (setting) [geometry]' complete -c convert -o ping -d 'Efficiently determine image attributes' @@ -80,7 +80,7 @@ complete -c convert -o virtual-pixel -d 'Virtual pixel access method [method]' - complete -c convert -o weight -d 'Render text with this font weight [type]' -x complete -c convert -o white-point -d 'Chromaticity white point [point]' complete -c convert -o adaptive-blur -d 'Adaptively blur pixels; decrease effect near edges [geometry]' -complete -c convert -o adaptive-resize -d 'Adaptively resize image using \'mesh\' interpolation [geometry]' +complete -c convert -o adaptive-resize -d "Adaptively resize image using 'mesh' interpolation [geometry]" complete -c convert -o adaptive-sharpen -d 'Adaptively sharpen pixels; increase effect near edges [geometry]' complete -c convert -o annotate -d 'Annotate the image with text [geometry text]' complete -c convert -o auto-gamma -d 'Automagically adjust gamma level of image' @@ -115,7 +115,7 @@ complete -c convert -o encipher -d 'Convert plain pixels to cipher pixels [filen complete -c convert -o emboss -d 'Emboss an image [radius]' complete -c convert -o enhance -d 'Apply a digital filter to enhance a noisy image' complete -c convert -o equalize -d 'Perform histogram equalization to an image' -complete -c convert -o evaluate -d 'Evaluate an arithmetic, relational, or logical expression [operator value]' +complete -c convert -o evaluate -d 'Alter channel pixels based on expression [operator]' complete -c convert -o extent -d 'Set the image size [geometry]' complete -c convert -o extract -d 'Extract area from image [geometry]' complete -c convert -o fft -d 'Implements the discrete Fourier transform (DFT)' @@ -173,13 +173,13 @@ complete -c convert -o shadow -d 'Simulate an image shadow [geometry]' complete -c convert -o sharpen -d 'Sharpen the image [geometry]' complete -c convert -o shave -d 'Shave pixels from the image edges [geometry]' complete -c convert -o shear -d 'Slide one edge of the image along the X or Y axis [geometry]' -complete -c convert -o sigmoidal-contrast -d 'Increase the contrast without saturating highlights or shadows [geometry]' +complete -c convert -o sigmoidal-contrast -d 'Lightness rescaling using sigmoidal contrast enhancement [geometry]' complete -c convert -o sketch -d 'Simulate a pencil sketch [geometry]' complete -c convert -o solarize -d 'Negate all pixels above the threshold level [threshold]' complete -c convert -o sparse-color -d 'Args fill in a image based on a few color points [method]' -xa '(convert -list sparse-color)' complete -c convert -o splice -d 'Splice the background color into the image [geometry]' complete -c convert -o spread -d 'Displace image pixels by a random amount [radius]' -complete -c convert -o statistic -d 'Replace each pixel with corresponding statistic from the neighborhood [type geometry]' -xa '(convert -list statistic)' +complete -c convert -o statistic -d 'Replace pixels with statistic from the neighborhood [type geometry]' -xa '(convert -list statistic)' complete -c convert -o strip -d 'Strip image of all profiles and comments' complete -c convert -o swirl -d 'Swirl image pixels about the center [degrees]' complete -c convert -o threshold -d 'Threshold the image [value]' @@ -201,10 +201,10 @@ complete -c convert -o append -d 'Append an image sequence' complete -c convert -o clut -d 'Apply a color lookup table to the image' complete -c convert -o coalesce -d 'Merge a sequence of images' complete -c convert -o combine -d 'Combine a sequence of images' -complete -c convert -o composite -d 'Composite image ' +complete -c convert -o composite -d 'Composite image' complete -c convert -o crop -d 'Cut out a rectangular region of the image [geometry]' complete -c convert -o deconstruct -d 'Break down an image sequence into constituent parts' -complete -c convert -o evaluate-sequence -d 'Evaluate an arithmetic, relational, or logical expression [operator]' +complete -c convert -o evaluate-sequence -d 'Alter channel pixels based on expression [operator]' complete -c convert -o flatten -d 'Flatten a sequence of images' complete -c convert -o fx -d 'Apply mathematical expression to an image channel(s) [expression]' complete -c convert -o hald-clut -d 'Apply a Hald color lookup table to the image' diff --git a/share/completions/cp.fish b/share/completions/cp.fish index 7c3cb219a..42e9e5c27 100644 --- a/share/completions/cp.fish +++ b/share/completions/cp.fish @@ -31,7 +31,7 @@ else # BSD/macOS set -l uname (uname -s) # Solaris: cp [-R | r [H | L | P ]] [-fi ] [-p ] # openbsd: cp [-R | [H | L | P ]] [-fi ] [-pv ] - # macos: cp [-R | [H | L | P ]] [-fin] [-pva cX ] # -c: clone -X: copy xattrs + # macos: cp [-R | [H | L | P ]] [-fin] [-pvalxscX ] # -c: clone -X: copy xattrs # netbsd: cp [-R | [H | L | P ]] [-fi ] [-pval N] # -l: hard link instead of copy -N: don't copy file flags # dragonfly: cp [-R | [H | L | P ]] [-fin] [-pvalx ] # -x: don't traverse mount points # freebsd: cp [-R | [H | L | P ]] [-fin] [-pvalxs ] # -s: symlink instead of copy @@ -62,7 +62,6 @@ else # BSD/macOS if test "$uname" = Darwin complete -c cp -s c -d "Clone using clonefile(2)" complete -c cp -s X -d "Omit xattrs, resource forks" - exit 0 end complete -c cp -s l -d "Hard link instead of copying" if test "$uname" = NetBSD @@ -70,7 +69,7 @@ else # BSD/macOS exit 0 end complete -c cp -s x -d "Don't traverse mount points" - if test "$uname" = FreeBSD + if test "$uname" = FreeBSD -o "$uname" = Darwin complete -c cp -s s -d "Symlink instead of copying" end end diff --git a/share/completions/csharp.fish b/share/completions/csharp.fish new file mode 100644 index 000000000..a32361315 --- /dev/null +++ b/share/completions/csharp.fish @@ -0,0 +1,4 @@ +complete -c csharp -l attach -f -r -a '(ps -A | awk \'NR > 1 { printf "%s\t%s\n", $1, $4 }\')' -d +'Inject into other processes' +complete -c csharp -s e -f -r -d 'Specify expression to execute' +complete -c csharp -s s -r -d 'Use file to execute' diff --git a/share/completions/cut.fish b/share/completions/cut.fish index 0d92280a2..21f23682b 100644 --- a/share/completions/cut.fish +++ b/share/completions/cut.fish @@ -1,11 +1,21 @@ -complete -c cut -s b -l bytes -x -d "Output byte range" -complete -c cut -s c -l characters -x -d "Output character range" -complete -c cut -s d -l delimiter -x -d "Select field delimiter" -complete -c cut -s f -l fields -x -d "Select fields" -complete -c cut -s n -d "Don't split multi byte characters" -complete -c cut -l complement -d "complement the set of selected bytes, characters or fields" -complete -c cut -s s -l only-delimited -d "Do not print lines without delimiter" -complete -c cut -l output-delimiter -x -d "Select output delimiter" -complete -c cut -s z -l zero-terminated -d "line delimiter is NUL, not newline" -complete -c cut -l help -d "Display help and exit" -complete -c cut -l version -d "Display version and exit" +if cut --version &>/dev/null + complete -c cut -s b -l bytes -x -d "Select byte positions" + complete -c cut -s c -l characters -x -d "Select characters" + complete -c cut -s d -l delimiter -x -d "Select field delimiter" + complete -c cut -s f -l fields -x -d "Select fields" + complete -c cut -s n -d "Don't split multi-byte characters" + complete -c cut -l complement -d "complement the set of selected bytes, characters or fields" + complete -c cut -s s -l only-delimited -d "Suppress lines without delimiter" + complete -c cut -l output-delimiter -x -d "Select output delimiter" + complete -c cut -s z -l zero-terminated -d "line delimiter is NUL, not newline" + complete -c cut -l help -d "Display help and exit" + complete -c cut -l version -d "Display version and exit" +else + complete -c cut -s b -x -d "Select byte positions" + complete -c cut -s c -x -d "Output character range" + complete -c cut -s d -x -d "Delimiter instead of \t to use" + complete -c cut -s f -x -d "Select fields" + complete -c cut -s n -d "Don't split multi-byte characters" + complete -c cut -s s -d "Supress lines without delimiter" + complete -c cut -s w -d "Use whitespace as delimiter" +end diff --git a/share/completions/cygport.fish b/share/completions/cygport.fish index 7dd60dba8..5ca10b351 100644 --- a/share/completions/cygport.fish +++ b/share/completions/cygport.fish @@ -5,28 +5,28 @@ complete -c cygport -s 8 -l 64 -d "Build for 64-bit Cygwin" complete -c cygport -l debug -d "Enable debugging messages" # Cygport file -complete -c cygport -n "fish_is_nth_token 1" -f -a '*.cygport' -d "Cygport file" +complete -c cygport -n "__fish_is_nth_token 1" -f -a '*.cygport' -d "Cygport file" # Commands -complete -c cygport -n 'not fish_is_nth_token 1' -f -a 'downloadall fetchall wgetall getall' -d "Download all sources" -complete -c cygport -n 'not fish_is_nth_token 1' -f -a 'download fetch wget get' -d "Download missing sources" -complete -c cygport -n 'not fish_is_nth_token 1' -f -a 'prep unpack' -d "Prepare source directory" -complete -c cygport -n 'not fish_is_nth_token 1' -f -a 'compile build make' -d "Build software" -complete -c cygport -n 'not fish_is_nth_token 1' -f -a 'check test' -d "Run test suite" -complete -c cygport -n 'not fish_is_nth_token 1' -f -a 'inst install' -d "Install into DESTDIR and run post-installation steps" -complete -c cygport -n 'not fish_is_nth_token 1' -f -a postinst -d "Run post-installation steps" -complete -c cygport -n 'not fish_is_nth_token 1' -f -a list -d "List package files" -complete -c cygport -n 'not fish_is_nth_token 1' -f -a 'listdebug listdbg' -d "List debug package files" -complete -c cygport -n 'not fish_is_nth_token 1' -f -a dep -d "Show dependencies" -complete -c cygport -n 'not fish_is_nth_token 1' -f -a info -d "Show packaging info" -complete -c cygport -n 'not fish_is_nth_token 1' -f -a 'homepage web www' -d "Show project homepage URL" -complete -c cygport -n 'not fish_is_nth_token 1' -f -a 'package-test pkg-test' -d "Create packages, marked as test" -complete -c cygport -n 'not fish_is_nth_token 1' -f -a 'package pkg' -d "Create packages" -complete -c cygport -n 'not fish_is_nth_token 1' -f -a 'diff mkdiff mkpatch' -d "Create source patches" -complete -c cygport -n 'not fish_is_nth_token 1' -f -a 'upload up' -d "Upload finished packages" -complete -c cygport -n 'not fish_is_nth_token 1' -f -a stage -d "Upload packages without marking !ready" -complete -c cygport -n 'not fish_is_nth_token 1' -f -a announce -d "Send announcement email" -complete -c cygport -n 'not fish_is_nth_token 1' -f -a 'clean finish' -d "Delete working directory" -complete -c cygport -n 'not fish_is_nth_token 1' -f -a 'almostall all' -d "Same as prep build inst pkg" -complete -c cygport -n 'not fish_is_nth_token 1' -f -a help -d "Show help" -complete -c cygport -n 'not fish_is_nth_token 1' -f -a version -d "Show version" +complete -c cygport -n 'not __fish_is_nth_token 1' -f -a 'downloadall fetchall wgetall getall' -d "Download all sources" +complete -c cygport -n 'not __fish_is_nth_token 1' -f -a 'download fetch wget get' -d "Download missing sources" +complete -c cygport -n 'not __fish_is_nth_token 1' -f -a 'prep unpack' -d "Prepare source directory" +complete -c cygport -n 'not __fish_is_nth_token 1' -f -a 'compile build make' -d "Build software" +complete -c cygport -n 'not __fish_is_nth_token 1' -f -a 'check test' -d "Run test suite" +complete -c cygport -n 'not __fish_is_nth_token 1' -f -a 'inst install' -d "Install into DESTDIR and run post-installation steps" +complete -c cygport -n 'not __fish_is_nth_token 1' -f -a postinst -d "Run post-installation steps" +complete -c cygport -n 'not __fish_is_nth_token 1' -f -a list -d "List package files" +complete -c cygport -n 'not __fish_is_nth_token 1' -f -a 'listdebug listdbg' -d "List debug package files" +complete -c cygport -n 'not __fish_is_nth_token 1' -f -a dep -d "Show dependencies" +complete -c cygport -n 'not __fish_is_nth_token 1' -f -a info -d "Show packaging info" +complete -c cygport -n 'not __fish_is_nth_token 1' -f -a 'homepage web www' -d "Show project homepage URL" +complete -c cygport -n 'not __fish_is_nth_token 1' -f -a 'package-test pkg-test' -d "Create packages, marked as test" +complete -c cygport -n 'not __fish_is_nth_token 1' -f -a 'package pkg' -d "Create packages" +complete -c cygport -n 'not __fish_is_nth_token 1' -f -a 'diff mkdiff mkpatch' -d "Create source patches" +complete -c cygport -n 'not __fish_is_nth_token 1' -f -a 'upload up' -d "Upload finished packages" +complete -c cygport -n 'not __fish_is_nth_token 1' -f -a stage -d "Upload packages without marking !ready" +complete -c cygport -n 'not __fish_is_nth_token 1' -f -a announce -d "Send announcement email" +complete -c cygport -n 'not __fish_is_nth_token 1' -f -a 'clean finish' -d "Delete working directory" +complete -c cygport -n 'not __fish_is_nth_token 1' -f -a 'almostall all' -d "Same as prep build inst pkg" +complete -c cygport -n 'not __fish_is_nth_token 1' -f -a help -d "Show help" +complete -c cygport -n 'not __fish_is_nth_token 1' -f -a version -d "Show version" diff --git a/share/completions/df.fish b/share/completions/df.fish index 1f77d036f..51ad6e281 100644 --- a/share/completions/df.fish +++ b/share/completions/df.fish @@ -33,6 +33,6 @@ else complete -c df -s a -d "Show all file systems" complete -c df -s g -d "Show sizes in gigabytes" complete -c df -s m -d "Show sizes in megabytes" - complete -c df -s n -d "Print out the previously obtained statistics from the file systems" + complete -c df -s n -d "Use cached statistics" end diff --git a/share/completions/display.fish b/share/completions/display.fish index 8a764dd2b..7b182ac25 100644 --- a/share/completions/display.fish +++ b/share/completions/display.fish @@ -1,5 +1,5 @@ -complete -c display -o alpha -d 'On, activate, off, deactivate, set, opaque, copy transparent, extract, background, or shape [option]' -xa '(display -list alpha)' -complete -c display -o antialias -d 'Remove pixel-aliasing ' +complete -c display -o alpha -d 'Control alpha/matte channel of an image [option]' -xa '(display -list alpha)' +complete -c display -o antialias -d 'Remove pixel-aliasing' complete -c display -o authenticate -d 'Decipher image with this password [password]' complete -c display -o backdrop -d 'Display image centered on a backdrop' complete -c display -o channel -d 'Apply option to select image channels [type]' -xa '(display -list channel)' @@ -27,7 +27,7 @@ complete -c display -o label -d 'Assign a label to an image [string]' complete -c display -o limit -d 'Pixel cache resource limit [type value]' -x complete -c display -o loop -d 'Loop images then exit [iterations]' complete -c display -o map -d 'Display image using this Standard Colormap [type]' -x -complete -c display -o monitor -d 'Monitor progress ' +complete -c display -o monitor -d 'Monitor progress' complete -c display -o page -d 'Size and location of an image canvas [geometry]' complete -c display -o profile -d 'Add, delete, or apply an image profile [filename]' -r complete -c display -o quality -d 'JPEG/MIFF/PNG compression level [value]' @@ -41,7 +41,7 @@ complete -c display -o sampling-factor -d 'Horizontal and vertical sampling fact complete -c display -o seed -d 'Seed a new sequence of pseudo-random numbers [value]' complete -c display -o set -d 'Set an image property [property value]' complete -c display -o size -d 'Width and height of image [geometry]' -complete -c display -o texture -d 'Name of texture to tile onto the image background [filename]' -r +complete -c display -o texture -d 'Texture name to tile onto the image background [filename]' -r complete -c display -o transparent-color -d 'Transparent color [color]' -xa '(__fish_complete_convert_options color)' complete -c display -o treedepth -d 'Color tree depth [value]' complete -c display -o update -d 'Seconds detect when image file is modified and redisplay' @@ -51,7 +51,7 @@ complete -c display -o virtual-pixel -d 'Virtual pixel access method [method]' - complete -c display -o window -d 'Display image to background of this window [id]' -xa 'root (__fish_print_xwindows)' complete -c display -o window-group -d 'Exit program when this window id is destroyed [id]' complete -c display -o write -d 'Write image to a file [filename]' -r -complete -c display -o auto-orient -d 'Automagically orient image' +complete -c display -o auto-orient -d 'Automagically orient (rotate) image' complete -c display -o border -d 'Surround image with a border of color [geometry]' complete -c display -o clip -d 'Clip along the first path from the 8BIM profile' complete -c display -o clip-path -d 'Clip along a named path from the 8BIM profile [id]' diff --git a/share/completions/dnf.fish b/share/completions/dnf.fish index aaae9d742..2f5bd879c 100644 --- a/share/completions/dnf.fish +++ b/share/completions/dnf.fish @@ -160,6 +160,22 @@ complete -c dnf -n "__fish_seen_subcommand_from module; and __fish_seen_subcomma complete -c dnf -n "__fish_seen_subcommand_from module" -xa info -d "Print module information" complete -c dnf -n "__fish_seen_subcommand_from module; and __fish_seen_subcommand_from info" -l profile -d "Print module profiles information" +# Offline-distrosync +complete -c dnf -n __fish_use_subcommand -xa offline-distrosync -d "Synchronizes packages to match the latest" +complete -c dnf -n "__fish_seen_subcommand_from offline-distrosync" -xa download -d "Download updates for offline upgrade" +complete -c dnf -n "__fish_seen_subcommand_from offline-distrosync" -xa clean -d "Remove cached packages" +complete -c dnf -n "__fish_seen_subcommand_from offline-distrosync" -xa reboot -d "Reboot and install packages" +complete -c dnf -n "__fish_seen_subcommand_from offline-distrosync" -xa upgrade -d "Install cached packages without reboot" +complete -c dnf -n "__fish_seen_subcommand_from offline-distrosync" -xa log -d "Show logs of upgrade attempts" + +# Offline-upgrade +complete -c dnf -n __fish_use_subcommand -xa offline-upgrade -d "Prepare offline upgrade of the system" +complete -c dnf -n "__fish_seen_subcommand_from offline-upgrade" -xa download -d "Download updates for offline upgrade" +complete -c dnf -n "__fish_seen_subcommand_from offline-upgrade" -xa clean -d "Remove cached packages" +complete -c dnf -n "__fish_seen_subcommand_from offline-upgrade" -xa reboot -d "Reboot and install packages" +complete -c dnf -n "__fish_seen_subcommand_from offline-upgrade" -xa upgrade -d "Install cached packages without reboot" +complete -c dnf -n "__fish_seen_subcommand_from offline-upgrade" -xa log -d "Show logs of upgrade attempts" + # Provides complete -c dnf -n __fish_use_subcommand -xa provides -d "Finds packages providing the given command" @@ -217,6 +233,14 @@ complete -c dnf -n "__fish_seen_subcommand_from repoquery" -l alldeps complete -c dnf -n "__fish_seen_subcommand_from repoquery" -l exactdeps complete -c dnf -n "__fish_seen_subcommand_from repoquery" -l srpm +# System-upgrade +complete -c dnf -n __fish_use_subcommand -xa system-upgrade -d "Prepare major version upgrade of the system" +complete -c dnf -n "__fish_seen_subcommand_from system-upgrade" -xa download -d "Download updates for offline upgrade" +complete -c dnf -n "__fish_seen_subcommand_from system-upgrade" -xa clean -d "Remove cached packages" +complete -c dnf -n "__fish_seen_subcommand_from system-upgrade" -xa reboot -d "Reboot and install packages" +complete -c dnf -n "__fish_seen_subcommand_from system-upgrade" -xa upgrade -d "Install cached packages without reboot" +complete -c dnf -n "__fish_seen_subcommand_from system-upgrade" -xa log -d "Show logs of upgrade attempts" + # Query options complete -c dnf -n "__fish_seen_subcommand_from repoquery" -s i -l info -d "Show detailed information about the package" complete -c dnf -n "__fish_seen_subcommand_from repoquery" -s l -l list -d "Show the list of files in the package" diff --git a/share/completions/dscacheutil.fish b/share/completions/dscacheutil.fish new file mode 100644 index 000000000..72462c565 --- /dev/null +++ b/share/completions/dscacheutil.fish @@ -0,0 +1,27 @@ +# dscacheutil +complete -c dscacheutil -f -d 'Directory Service cache utility' +complete -c dscacheutil -s h -d 'lists options' -f -n '[ (commandline -opc | count) -le 1 ]' +complete -c dscacheutil -s q -d 'initiate query' -f -x -n '[ (commandline -opc | count) -le 1 ] || contains -- -a (commandline -opc) || contains -- -q (commandline -opc) && [ (commandline -opc | count) -lt 3 ]' -a " +group\t'name or gid' +host\t'name or ip address' +mount\t'name' +protocol\t'name or number' +rpc\t'name or number' +service\t'name or port' +user\t'name or uid' +" +complete -c dscacheutil -s a -d '-q: specific key & value' -f -n 'contains -- -q (commandline -opc)' +complete -c dscacheutil -o cachedump -d 'dump cache overview' -f -n '[ (commandline -opc | count) -le 1 ]' +complete -c dscacheutil -o buckets -d 'show hash buckets' -f -n 'contains -- -cachedump (commandline -opc)' +complete -c dscacheutil -o entries -d '-cachedump: cache entries' -f -n 'contains -- -cachedump (commandline -opc)' -a " +group\t'name or gid' +host\t'name or ip address' +mount\t'name' +protocol\t'name or number' +rpc\t'name or number' +service\t'name or port' +user\t'name or uid' +" +complete -c dscacheutil -o configuration -d 'print current config' -f -n '[ (commandline -opc | count) -le 1 ]' +complete -c dscacheutil -o statistics -d 'prints cache stats' -f -n '[ (commandline -opc | count) -le 1 ]' +complete -c dscacheutil -o flushcache -d 'reset cache (DNS )' -f -k -n '[ (commandline -opc | count) -le 1 ]' diff --git a/share/completions/duply.fish b/share/completions/duply.fish index 81c894d64..97495e0cf 100644 --- a/share/completions/duply.fish +++ b/share/completions/duply.fish @@ -1,24 +1,24 @@ # First parameter is the profile name, or 'usage' -complete -c duply -f -n "fish_is_nth_token 1" -a '(set -l files /etc/duply/* ~/.duply/*; string replace -r ".*/" "" -- $files)' -d Profile +complete -c duply -f -n "__fish_is_nth_token 1" -a '(set -l files /etc/duply/* ~/.duply/*; string replace -r ".*/" "" -- $files)' -d Profile complete --command duply --no-files --arguments usage -d 'Get usage help text' # Second parameter is a duply command -complete --command duply --no-files --condition 'not fish_is_nth_token 1' --arguments create -d 'Creates a configuration profile' -complete --command duply --no-files --condition 'not fish_is_nth_token 1' --arguments backup -d 'Backup with pre/post script execution' -complete --command duply --no-files --condition 'not fish_is_nth_token 1' --arguments bkp -d 'Backup without executing pre/post scripts' -complete --command duply --no-files --condition 'not fish_is_nth_token 1' --arguments pre -d 'Execute /pre script' -complete --command duply --no-files --condition 'not fish_is_nth_token 1' --arguments post -d 'Execute /post script' -complete --command duply --no-files --condition 'not fish_is_nth_token 1' --arguments full -d 'Force full backup' -complete --command duply --no-files --condition 'not fish_is_nth_token 1' --arguments incr -d 'Force incremental backup' -complete --command duply --no-files --condition 'not fish_is_nth_token 1' --arguments list -d 'List all files in backup (as it was at , default: now)' -complete --command duply --no-files --condition 'not fish_is_nth_token 1' --arguments status -d 'Prints backup sets and chains currently in repository' -complete --command duply --no-files --condition 'not fish_is_nth_token 1' --arguments verify -d 'List files changed since latest backup' -complete --command duply --no-files --condition 'not fish_is_nth_token 1' --arguments purge -d 'Shows outdated backup archives [--force, delete these files]' -complete --command duply --no-files --condition 'not fish_is_nth_token 1' --arguments purge-full -d 'Shows outdated backups [--force, delete these files]' -complete --command duply --no-files --condition 'not fish_is_nth_token 1' --arguments cleanup -d 'Shows broken backup archives [--force, delete these files]' -complete --command duply --no-files --condition 'not fish_is_nth_token 1' --arguments restore -d 'Restore the backup to [as it was at ]' -complete --command duply --no-files --condition 'not fish_is_nth_token 1' --arguments fetch -d 'Restore single file/folder from backup [as it was at ]' +complete --command duply --no-files --condition 'not __fish_is_nth_token 1' --arguments create -d 'Creates a configuration profile' +complete --command duply --no-files --condition 'not __fish_is_nth_token 1' --arguments backup -d 'Backup with pre/post script execution' +complete --command duply --no-files --condition 'not __fish_is_nth_token 1' --arguments bkp -d 'Backup without executing pre/post scripts' +complete --command duply --no-files --condition 'not __fish_is_nth_token 1' --arguments pre -d 'Execute /pre script' +complete --command duply --no-files --condition 'not __fish_is_nth_token 1' --arguments post -d 'Execute /post script' +complete --command duply --no-files --condition 'not __fish_is_nth_token 1' --arguments full -d 'Force full backup' +complete --command duply --no-files --condition 'not __fish_is_nth_token 1' --arguments incr -d 'Force incremental backup' +complete --command duply --no-files --condition 'not __fish_is_nth_token 1' --arguments list -d 'List all files in backup (as it was at , default: now)' +complete --command duply --no-files --condition 'not __fish_is_nth_token 1' --arguments status -d 'Prints backup sets and chains currently in repository' +complete --command duply --no-files --condition 'not __fish_is_nth_token 1' --arguments verify -d 'List files changed since latest backup' +complete --command duply --no-files --condition 'not __fish_is_nth_token 1' --arguments purge -d 'Shows outdated backup archives [--force, delete these files]' +complete --command duply --no-files --condition 'not __fish_is_nth_token 1' --arguments purge-full -d 'Shows outdated backups [--force, delete these files]' +complete --command duply --no-files --condition 'not __fish_is_nth_token 1' --arguments cleanup -d 'Shows broken backup archives [--force, delete these files]' +complete --command duply --no-files --condition 'not __fish_is_nth_token 1' --arguments restore -d 'Restore the backup to [as it was at ]' +complete --command duply --no-files --condition 'not __fish_is_nth_token 1' --arguments fetch -d 'Restore single file/folder from backup [as it was at ]' # Options complete --command duply --no-files --long-option force -d 'Really execute the commands: purge, purge-full, cleanup' diff --git a/share/completions/entr.fish b/share/completions/entr.fish index 4d70b65a0..ca020a476 100644 --- a/share/completions/entr.fish +++ b/share/completions/entr.fish @@ -1,5 +1,5 @@ -complete -c entr -s r -d 'Launches the utility at startup and reloads it if one of the source files change' +complete -c entr -s r -d 'Launch utility at startup and reload on file change' complete -c entr -s c -d 'Clears the screen before running the utility' -complete -c entr -s h -l help -d 'Display help and exit' +complete -c entr -s h -l help -d 'Display help' complete -c entr -s v -l version -d 'Output version information' complete -c entr -x -a '(__fish_complete_subcommand)' diff --git a/share/completions/env.fish b/share/completions/env.fish index ef7284bcc..087c5d9d5 100644 --- a/share/completions/env.fish +++ b/share/completions/env.fish @@ -1,6 +1,15 @@ -function __fish_env_remaining_args - argparse -s s/ignore-environment u/unset= h-help v-version -- (commandline -opc) (commandline -ct) 2>/dev/null - or return 1 +if env --version &>/dev/null + set -l is_gnu --is-gnu +end + +function __fish_env_remaining_args -V is_gnu + if set -q is_gnu[1] + argparse -s i/ignore-environment u/unset= help version -- (commandline -opc) (commandline -ct) 2>/dev/null + or return 1 + else + argparse -s 0 i P= S= u= v -- (commandline -opc) (commandline -ct) 2>/dev/null + or return 1 + end # argv[1] is `env` or an alias. set -e argv[1] @@ -28,10 +37,20 @@ function __fish_complete_env_subcommand end complete -c env -a "(__fish_complete_env_subcommand)" - -# complete VAR= only if the cursor is left of the =, otherwise complete the file right of the = complete -c env -n 'not __fish_env_remaining_args; and not string match -eq = -- (commandline -ct)' -a "(set -n)=" -f -d "Redefine variable" -complete -c env -n 'not __fish_env_remaining_args' -s i -l ignore-environment -d "Start with an empty environment" -complete -c env -n 'not __fish_env_remaining_args' -s u -l unset -d "Remove variable from the environment" -x -a "(set -n)" -complete -c env -n 'not __fish_env_remaining_args' -l help -d "Display help and exit" -complete -c env -n 'not __fish_env_remaining_args' -l version -d "Display version and exit" + +if set -q is_gnu + # complete VAR= only if the cursor is left of the =, otherwise complete the file right of the = + complete -c env -n 'not __fish_env_remaining_args' -s i -l ignore-environment -d "Start with an empty environment" + complete -c env -n 'not __fish_env_remaining_args' -s u -l unset -d "Unset environment variable" -x -a "(set -n)" + complete -c env -n 'not __fish_env_remaining_args' -l help -d "Display help and exit" + complete -c env -n 'not __fish_env_remaining_args' -l version -d "Display version and exit" +else + # complete VAR= only if the cursor is left of the =, otherwise complete the file right of the = + complete -c env -n 'not __fish_env_remaining_args' -s 0 -d "End output lines with NUL" + complete -c env -n 'not __fish_env_remaining_args' -s i -d "Start with empty environment" + complete -c env -n 'not __fish_env_remaining_args' -s P -d "Provide an alternate PATH" + complete -c env -n 'not __fish_env_remaining_args' -s S -d "Split argument into args on ' '" + complete -c env -n 'not __fish_env_remaining_args' -s u -d "Unset environment variable" -x -a "(set -n)" + complete -c env -n 'not __fish_env_remaining_args' -s v -d "Verbose output on processing" +end diff --git a/share/completions/findstr.fish b/share/completions/findstr.fish index 47892995a..c4144e2ef 100644 --- a/share/completions/findstr.fish +++ b/share/completions/findstr.fish @@ -1,8 +1,8 @@ function __findstr_generate_args --description 'Function to generate args' - set --local current_token (commandline --current-token --cut-at-cursor) - switch $current_token - case '/a:*' - echo -e '0\tBlack + set --local current_token (commandline --current-token --cut-at-cursor) + switch $current_token + case '/a:*' + echo -e '0\tBlack 1\tBlue 2\tGreen 3\tAqua @@ -18,8 +18,8 @@ C\tLight red D\tLight purple E\tLight yellow F\tBright white' | awk -F '\t' "{ printf \"$current_token%s\t%s\n\", \$1, \$2 }" - case '*' - echo -e '/b\tMatch at the beginning of the line + case '*' + echo -e '/b\tMatch at the beginning of the line /e\tMatch at the end of the line /l\tUse literal strings /r\tUse regular expressions @@ -39,7 +39,7 @@ F\tBright white' | awk -F '\t' "{ printf \"$current_token%s\t%s\n\", \$1, \$2 }" /d:\tSpecify the search list of directories /a:\tUse color attributes with two hexadecimal digits /?\tShow help' - end + end end complete --command findstr --no-files --arguments '(__findstr_generate_args)' diff --git a/share/completions/fish_opt.fish b/share/completions/fish_opt.fish index ef161709e..e2d317ad8 100644 --- a/share/completions/fish_opt.fish +++ b/share/completions/fish_opt.fish @@ -8,5 +8,5 @@ complete --command fish_opt --short-option s --long-option short --no-files --re complete --command fish_opt --short-option l --long-option long --no-files --require-parameter --description 'Specify long option' complete --command fish_opt --long-option longonly --description 'Use only long option' complete --command fish_opt --short-option o --long-option optional-val -n $CONDITION --description 'Don\'t require value' -complete --command fish_opt --short-option r --long-option required-val -n $CONDITION --description 'Require value' +complete --command fish_opt --short-option r --long-option required-val -n $CONDITION --description 'Require value' complete --command fish_opt --long-option multiple-vals --description 'Store all values' diff --git a/share/completions/forfiles.fish b/share/completions/forfiles.fish new file mode 100644 index 000000000..b66e85501 --- /dev/null +++ b/share/completions/forfiles.fish @@ -0,0 +1,7 @@ +complete -c forfiles -f -a /P -d 'Specify the path from which to start the search' +complete -c forfiles -f -a /M -d 'Search files according to the specified search mask' +complete -c forfiles -f -a /S -d 'Instruct the forfiles command to search in subdirectories recursively' +complete -c forfiles -f -a /C -d 'Run the specified command on each file' +complete -c forfiles -f -a /D \ + -d 'Select files with a last modified date within the specified time frame' +complete -c forfiles -f -a '/?' -d 'Show help' diff --git a/share/completions/gacutil.fish b/share/completions/gacutil.fish new file mode 100644 index 000000000..0abb5a233 --- /dev/null +++ b/share/completions/gacutil.fish @@ -0,0 +1,25 @@ +set -l COMMANDS -s i -o il -s u -o ul -o us -s l + +complete -c gacutil -s '?' -d 'Show help' + +complete -c gacutil -s i -c "! __fish_seen_argument $COMMANDS" \ + -d 'Install an assembly into the global assembly cache' +complete -c gacutil -o il -c "! __fish_seen_argument $COMMANDS" \ + -d 'Install one or more assemblies into the global assembly cache' +complete -c gacutil -s u -c "! __fish_seen_argument $COMMANDS" \ + -d 'Uninstall an assembly from the global assembly cache' +complete -c gacutil -o ul -c "! __fish_seen_argument $COMMANDS" \ + -d 'Uninstall one or more assemblies from the global assembly cache' +complete -c gacutil -o us -c "! __fish_seen_argument $COMMANDS" \ + -d 'Uninstall an assembly using the specifed assembly\'s full name' +complete -c gacutil -s l -c "! __fish_seen_argument $COMMANDS" \ + -d 'List the contents of the global assembly cache' + +complete -c gacutil -o package -c '__fish_seen_argument $COMMANDS' \ + -d 'Create a directory in prefix/lib/mono' +complete -c gacutil -o gacdir -c "__fish_seen_argument $COMMANDS" \ + -d 'Use the GACs base directory' +complete -c gacutil -o root -c "__fish_seen_argument $COMMANDS" \ + -d 'Integrate with automake tools or packaging tools that require a prefix directory to be specified' +complete -c gacutil -o check_refs -c '__fish_seen_argument -s i -o il' \ + -d 'Check the assembly being installed into the GAC does not reference any non strong named assemblies' diff --git a/share/completions/gcc.fish b/share/completions/gcc.fish index f7e2e9ee7..414b27c2b 100644 --- a/share/completions/gcc.fish +++ b/share/completions/gcc.fish @@ -502,8 +502,8 @@ complete -c gcc -o Xlinker -d 'Pass option as an option to the linker' complete -c gcc -s u -d 'Pretend the symbol symbol is undefined, to force linking of library modules to define it' complete -c gcc -o Idir -d 'Add the directory dir to the head of the list of directories to be searched for header files' complete -c gcc -o iquotedir -d 'Add the directory dir to the head of the list of directories to be searched for header files only for the case of #include "file"; they are not searched for #include , otherwise just like -I' -complete -c gcc -o Ldir -d 'Add directory dir to the list of directories to be searched for -l' -complete -c gcc -o Bprefix -d 'This option specifies where to find the executables, libraries, include files, and data files of the compiler itself' +complete -c gcc -o L -d 'Add directory dir to the list of directories to be searched for -l' +complete -c gcc -o B -d 'This option specifies where to find the executables, libraries, include files, and data files of the compiler itself' complete -c gcc -o specs -r -d 'Process file after the compiler reads in the standard specs file, in order to override the defaults that the gcc driver program uses when determining what switches to pass to cc1, cc1plus, as, ld, etc' complete -c gcc -l sysroot -x -a '(__fish_complete_directories)' -d 'Use dir as the logical root directory for headers and libraries' complete -c gcc -o I- -d 'This option has been deprecated' @@ -513,10 +513,6 @@ complete -c gcc -o EL -d 'Compile code for little endian mode' complete -c gcc -o EB -d 'Compile code for big endian mode' complete -c gcc -o mmangle-cpu -d 'Prepend the name of the cpu to all public symbol names' complete -c gcc -o mcpu -d 'Compile code for ARC variant cpu' -x -complete -c gcc -o mtext -d 'Put functions, data, and readonly data in text-section, data-section, and readonly-data-section respectively by default' -complete -c gcc -o mdata -d 'Put functions, data, and readonly data in text-section, data-section, and readonly-data-section respectively by default' -complete -c gcc -o mrodata -d 'Put functions, data, and readonly data in text-section, data-section, and readonly-data-section respectively by default' -complete -c gcc -o section -d 'Put functions, data, and readonly data in text-section, data-section, and readonly-data-section respectively by default' complete -c gcc -o mabi -d 'Generate code for the specified ABI' -x complete -c gcc -o mapcs-frame -d 'Generate a stack frame that is compliant with the ARM Procedure Call Standard for all functions, even if this is not strictly necessary for correct execution of the code' complete -c gcc -o mapcs -d 'This is a synonym for -mapcs-frame' @@ -529,7 +525,7 @@ complete -c gcc -o mlittle-endian -d 'Generate code for a processor running in l complete -c gcc -o mbig-endian -d 'Generate code for a processor running in big-endian mode; the default is to compile code for a little-endian processor' complete -c gcc -o mwords-little-endian -d 'This option only applies when generating code for big-endian processors' complete -c gcc -o mcpu -d 'This specifies the name of the target ARM processor' -x -complete -c gcc -o mtune -d 'This option is very similar to the -mcpu= option, except that instead of specifying the actual target processor type, and hence restricting which instructions can be used, it specifies that GCC should tune the performance of the code as if the target were of the type specified in this option, but still choosing the instructions that it will generate based on the cpu specified by a -mcpu= option' -x +complete -c gcc -o mtune -d 'Tune output for this cpu without restricting the instructions to it' complete -c gcc -o march -d 'This specifies the name of the target ARM architecture' -x complete -c gcc -o mfpu -x -d 'This specifies what floating point hardware (or hardware emulation) is available on the target' complete -c gcc -o mfpe -x -d 'This specifies what floating point hardware (or hardware emulation) is available on the target' diff --git a/share/completions/gendarme.fish b/share/completions/gendarme.fish new file mode 100644 index 000000000..44b6a8007 --- /dev/null +++ b/share/completions/gendarme.fish @@ -0,0 +1,17 @@ +complete -c gendarme -l version -d 'Show version' + +complete -c gendarme -l config -r -d 'Use config file' +complete -c gendarme -l set -x -d 'Use rule set from config file' +complete -c gendarme -l xml -r -d 'Convert stdout to XML and redirect to file' +complete -c gendarme -l html -r -d 'Convert stdout to HTML and redirect to file' +complete -c gendarme -l console -d 'Show the defects on stdout' +complete -c gendarme -l ignore -r -d 'Exclude the defects from file' +complete -c gendarme -l limit -x -d 'Specify defect limit' +complete -c gendarme -l severity -x \ + -a 'all audit audit+ low low+ low- medium medium+ medium- high high+ high- critical critical-' \ + -d 'Filter the reported defects to include the specified severity levels' +complete -c gendarme -l confidence -x \ + -a 'all low low+ normal normal+ normal- high high+ high- total total-' \ + -d 'Filter the reported defects to include the specified confidence levels' +complete -c gendarme -l quiet -d 'Discard stdout' +complete -c gendarme -s v -l verbose -d 'Show more messages' diff --git a/share/completions/git.fish b/share/completions/git.fish index a9fe99d63..0fa768d4f 100644 --- a/share/completions/git.fish +++ b/share/completions/git.fish @@ -58,6 +58,11 @@ function __fish_git_branches | string replace -r '^refs/remotes/(.*)$' '$1\tRemote Branch' end +function __fish_git_submodules + __fish_git submodule 2>/dev/null \ + | string replace -r '^.[^ ]+ ([^ ]+).*$' '$1' +end + function __fish_git_local_branches __fish_git for-each-ref --format='%(refname:strip=2)' refs/heads/ 2>/dev/null \ | string replace -rf '.*' '$0\tLocal Branch' @@ -576,7 +581,7 @@ function __fish_git_config_keys # Print already defined config values first # Config keys may span multiple lines, so parse using null char # With -z, key and value are separated by space, not "=" - git config -lz | while read -lz key value + __fish_git config -lz | while read -lz key value # Print only first line of value(with an ellipsis) if multiline printf '%s\t%s\n' $key (string replace \n …\n -- $value)[1] end @@ -798,6 +803,10 @@ format:\tSpecify which information to show" end end +function __fish_git_is_rebasing + test -e (__fish_git rev-parse --absolute-git-dir)/rebase-merge +end + # general options complete -f -c git -l help -d 'Display the manual of a git command' complete -f -c git -n __fish_git_needs_command -l version -d 'Display version' @@ -898,6 +907,7 @@ complete -f -c git -n '__fish_git_using_command fetch' -s v -l verbose -d 'Be ve complete -f -c git -n '__fish_git_using_command fetch' -s a -l append -d 'Append ref names and object names' # TODO --upload-pack complete -f -c git -n '__fish_git_using_command fetch' -s f -l force -d 'Force update of local branches' +complete -f -c git -n '__fish_git_using_command fetch' -s p -l prune -d 'Remove remote-tracking references that no longer exist on the remote' # TODO other options #### filter-branch @@ -947,10 +957,11 @@ complete -f -c git -n "__fish_git_using_command remote; and __fish_seen_subcomma ### show complete -f -c git -n __fish_git_needs_command -a show -d 'Shows the last commit of a branch' -complete -f -c git -n '__fish_git_using_command show' -a '(__fish_git_branches)' -complete -f -c git -n '__fish_git_using_command show' -ka '(__fish_git_tags)' -d Tag -complete -f -c git -n '__fish_git_using_command show' -ka '(__fish_git_commits)' -complete -f -c git -n __fish_git_needs_rev_files -xa '(__fish_git_complete_rev_files)' +complete -f -c git -n '__fish_git_using_command show; and not contains -- -- (commandline -opc)' -a '(__fish_git_branches)' +complete -f -c git -n '__fish_git_using_command show; and not contains -- -- (commandline -opc)' -ka '(__fish_git_tags)' -d Tag +complete -f -c git -n '__fish_git_using_command show; and not contains -- -- (commandline -opc)' -ka '(__fish_git_commits)' +complete -f -c git -n '__fish_git_needs_rev_files; and not contains -- -- (commandline -opc)' -xa '(__fish_git_complete_rev_files)' +complete -F -c git -n '__fish_git_using_command show; and contains -- -- (commandline -opc)' complete -f -c git -n '__fish_git_using_command show' -l format -d 'Pretty-print the contents of the commit logs in a given format' -a '(__fish_git_show_opt format)' complete -f -c git -n '__fish_git_using_command show' -l abbrev-commit -d 'Show only a partial hexadecimal commit object name' complete -f -c git -n '__fish_git_using_command show' -l no-abbrev-commit -d 'Show the full 40-byte hexadecimal commit object name' @@ -980,6 +991,7 @@ complete -c git -n '__fish_git_using_command add' -s u -l update -d 'Only match complete -c git -n '__fish_git_using_command add' -s A -l all -d 'Match files both in working tree and index' complete -c git -n '__fish_git_using_command add' -s N -l intent-to-add -d 'Record only the fact that the path will be added later' complete -c git -n '__fish_git_using_command add' -l refresh -d "Don't add the file(s), but only refresh their stat" +complete -c git -n '__fish_git_using_command add' -l chmod -xa "-x\t'Track file as non-executable' +x\t'Track file as executable'" complete -c git -n '__fish_git_using_command add' -l ignore-errors -d 'Ignore errors' complete -c git -n '__fish_git_using_command add' -l ignore-missing -d 'Check if any of the given files would be ignored' # Renames also show up as untracked + deleted, and to get git to show it as a rename _both_ need to be added. @@ -1033,6 +1045,8 @@ complete -f -c git -n '__fish_git_using_command checkout' -s b -d 'Create a new complete -f -c git -n '__fish_git_using_command checkout' -s t -l track -d 'Track a new branch' complete -f -c git -n '__fish_git_using_command checkout' -l theirs -d 'Keep staged changes' complete -f -c git -n '__fish_git_using_command checkout' -l ours -d 'Keep unmerged changes' +complete -f -c git -n '__fish_git_using_command checkout' -l recurse-submodules -d 'Update the work trees of submodules' +complete -f -c git -n '__fish_git_using_command checkout' -l no-recurse-submodules -d 'Do not update the work trees of submodules' # TODO options ### apply @@ -1236,7 +1250,7 @@ complete -c git -n '__fish_git_using_command diff' -l cached -d 'Show diff of ch complete -c git -n '__fish_git_using_command diff' -l staged -d 'Show diff of changes in the index' complete -c git -n '__fish_git_using_command diff' -l no-index -d 'Compare two paths on the filesystem' complete -c git -n '__fish_git_using_command diff' -l exit-code -d 'Exit with 1 if there were differences or 0 if no differences' -complete -c git -n '__fish_git_using_command diff' -s q -l quiet -d 'Disable all output of the program, implies --exit-code' +complete -c git -n '__fish_git_using_command diff' -l quiet -d 'Disable all output of the program, implies --exit-code' complete -c git -n '__fish_git_using_command diff' -s 1 -l base -d 'Compare the working tree with the "base" version' complete -c git -n '__fish_git_using_command diff' -s 2 -l ours -d 'Compare the working tree with the "our branch"' complete -c git -n '__fish_git_using_command diff' -s 3 -l theirs -d 'Compare the working tree with the "their branch"' @@ -1625,6 +1639,7 @@ complete -f -c git -n '__fish_git_using_command pull' -s a -l append -d 'Append complete -f -c git -n '__fish_git_using_command pull' -s f -l force -d 'Force update of local branches' complete -f -c git -n '__fish_git_using_command pull' -s k -l keep -d 'Keep downloaded pack' complete -f -c git -n '__fish_git_using_command pull' -l no-tags -d 'Disable automatic tag following' +complete -f -c git -n '__fish_git_using_command pull' -s p -l prune -d 'Remove remote-tracking references that no longer exist on the remote' # TODO --upload-pack complete -f -c git -n '__fish_git_using_command pull' -l progress -d 'Force progress status' complete -f -c git -n '__fish_git_using_command pull; and not __fish_git_branch_for_remote' -a '(__fish_git_remotes)' -d 'Remote alias' @@ -1667,7 +1682,9 @@ complete -f -c git -n '__fish_git_using_command range-diff' -l no-dual-color -d ### push complete -f -c git -n __fish_git_needs_command -a push -d 'Update remote refs along with associated objects' complete -f -c git -n '__fish_git_using_command push; and not __fish_git_branch_for_remote' -a '(__fish_git_remotes)' -d 'Remote alias' -complete -f -c git -n '__fish_git_using_command push; and __fish_git_branch_for_remote' -a '(__fish_git_branches)' +complete -f -c git -n '__fish_git_using_command push; and __fish_git_branch_for_remote' -ka '(__fish_git_tags)' -d Tag +complete -f -c git -n '__fish_git_using_command push; and __fish_git_branch_for_remote' -ka '(__fish_git_branches)' +complete -f -c git -n '__fish_git_using_command push; and __fish_git_branch_for_remote' -ka '(__fish_git_heads)' # The "refspec" here is an optional "+" to signify a force-push complete -f -c git -n '__fish_git_using_command push; and __fish_git_branch_for_remote; and string match -q "+*" -- (commandline -ct)' -a '+(__fish_git_branches | string replace -r \t".*" "")' -d 'Force-push branch' # git push REMOTE :BRANCH deletes BRANCH on remote REMOTE @@ -1698,10 +1715,11 @@ complete -f -c git -n '__fish_git_using_command rebase' -a '(__fish_git_branches complete -f -c git -n '__fish_git_using_command rebase' -a '(__fish_git_heads)' -d Head complete -f -c git -n '__fish_git_using_command rebase' -a '(__fish_git_recent_commits)' complete -f -c git -n '__fish_git_using_command rebase' -a '(__fish_git_tags)' -d Tag -complete -f -c git -n '__fish_git_using_command rebase' -l continue -d 'Restart the rebasing process' -complete -f -c git -n '__fish_git_using_command rebase' -l abort -d 'Abort the rebase operation' +complete -f -c git -n '__fish_git_using_command rebase; and __fish_git_is_rebasing' -l continue -d 'Restart the rebasing process' +complete -f -c git -n '__fish_git_using_command rebase; and __fish_git_is_rebasing' -l abort -d 'Abort the rebase operation' +complete -f -c git -n '__fish_git_using_command rebase; and __fish_git_is_rebasing' -l edit-todo -d 'Edit the todo list' complete -f -c git -n '__fish_git_using_command rebase' -l keep-empty -d "Keep the commits that don't change anything" -complete -f -c git -n '__fish_git_using_command rebase' -l skip -d 'Restart the rebasing process by skipping the current patch' +complete -f -c git -n '__fish_git_using_command rebase; and __fish_git_is_rebasing' -l skip -d 'Restart the rebasing process by skipping the current patch' complete -f -c git -n '__fish_git_using_command rebase' -s m -l merge -d 'Use merging strategies to rebase' complete -f -c git -n '__fish_git_using_command rebase' -s q -l quiet -d 'Be quiet' complete -f -c git -n '__fish_git_using_command rebase' -s v -l verbose -d 'Be verbose' @@ -1942,15 +1960,19 @@ complete -f -c git -n '__fish_git_using_command format-patch' -l no-numbered -s ## git submodule -set -l submodulecommands add status init update summary foreach sync +set -l submodulecommands add status init deinit update set-branch set-url summary foreach sync absorbgitdirs complete -f -c git -n __fish_git_needs_command -a submodule -d 'Initialize, update or inspect submodules' complete -f -c git -n "__fish_git_using_command submodule; and not __fish_seen_subcommand_from $submodulecommands" -a add -d 'Add a submodule' complete -f -c git -n "__fish_git_using_command submodule; and not __fish_seen_subcommand_from $submodulecommands" -a status -d 'Show submodule status' complete -f -c git -n "__fish_git_using_command submodule; and not __fish_seen_subcommand_from $submodulecommands" -a init -d 'Initialize all submodules' +complete -f -c git -n "__fish_git_using_command submodule; and not __fish_seen_subcommand_from $submodulecommands" -a deinit -d 'Unregister the given submodules' complete -f -c git -n "__fish_git_using_command submodule; and not __fish_seen_subcommand_from $submodulecommands" -a update -d 'Update all submodules' +complete -x -c git -n "__fish_git_using_command submodule; and not __fish_seen_subcommand_from $submodulecommands" -a set-branch -d 'Sets the default remote tracking branch for the submodule' +complete -f -c git -n "__fish_git_using_command submodule; and not __fish_seen_subcommand_from $submodulecommands" -a set-url -d 'Sets the URL of the specified submodule' complete -f -c git -n "__fish_git_using_command submodule; and not __fish_seen_subcommand_from $submodulecommands" -a summary -d 'Show commit summary' complete -f -c git -n "__fish_git_using_command submodule; and not __fish_seen_subcommand_from $submodulecommands" -a foreach -d 'Run command on each submodule' complete -f -c git -n "__fish_git_using_command submodule; and not __fish_seen_subcommand_from $submodulecommands" -a sync -d 'Sync submodules\' URL with .gitmodules' +complete -f -c git -n "__fish_git_using_command submodule; and not __fish_seen_subcommand_from $submodulecommands" -a absorbgitdirs -d 'Move submodule\'s git directory to current .git/module directory' complete -f -c git -n "__fish_git_using_command submodule; and not __fish_seen_subcommand_from $submodulecommands" -s q -l quiet -d "Only print error messages" complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subcommand_from update' -l init -d "Initialize all submodules" complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subcommand_from update' -l checkout -d "Checkout the superproject's commit on a detached HEAD in the submodule" @@ -1961,7 +1983,12 @@ complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subco complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subcommand_from update' -l force -d "Discard local changes when switching to a different commit & always run checkout" complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subcommand_from add' -l force -d "Also add ignored submodule path" complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subcommand_from deinit' -l force -d "Remove even with local changes" +complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subcommand_from deinit' -l all -d "Remove all submodules" +complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subcommand_from deinit; and not contains -- -- (commandline -opc)' -a '(__fish_git_submodules)' -d Submodule +complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subcommand_from set-branch' -s b -l branch -d "Specify the branch to use" +complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subcommand_from set-branch' -s d -l default -d "Use default branch of the submodule" complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subcommand_from status summary' -l cached -d "Use the commit stored in the index" +complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subcommand_from status; and not contains -- -- (commandline -opc)' -a '(__fish_git_submodules)' -d Submodule complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subcommand_from summary' -l files -d "Compare the commit in the index with submodule HEAD" complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subcommand_from foreach update status' -l recursive -d "Traverse submodules recursively" complete -f -c git -n '__fish_git_using_command submodule; and __fish_seen_subcommand_from foreach' -a "(__fish_complete_subcommand --fcs-skip=3)" @@ -2076,9 +2103,8 @@ complete -F -c git -n '__fish_git_using_command config' -s f -l file -d 'Read co complete -F -c git -n '__fish_git_using_command config' -l blob -d 'Read config from blob' -r # If no argument is specified, it's as if --get was used -# Use -k with `__fish_git_config_keys` so that user defined valeus are shown first -complete -c git -n '__fish_git_using_command config; and fish_is_nth_token 3' -kfa '(__fish_git_config_keys)' -complete -f -c git -n '__fish_git_using_command config; and __fish_is_first_arg' -l get -d 'Get config with name' -kra '(__fish_git_config_keys)' +# Use -k with `__fish_git_config_keys` so that user defined values are shown first +complete -c git -n '__fish_git_using_command config; and __fish_is_nth_token 2' -kfa '(__fish_git_config_keys)' complete -f -c git -n '__fish_git_using_command config' -l get -d 'Get config with name' -kra '(__fish_git_config_keys)' complete -f -c git -n '__fish_git_using_command config' -l get-all -d 'Get all values matching key' -ka '(__fish_git_config_keys)' complete -f -c git -n '__fish_git_using_command config' -l get-urlmatch -d 'Get value specific for the section url' -r diff --git a/share/completions/gnome-extensions.fish b/share/completions/gnome-extensions.fish new file mode 100644 index 000000000..fcddf3390 --- /dev/null +++ b/share/completions/gnome-extensions.fish @@ -0,0 +1,80 @@ +# Fish completion for gnome-extensions + +function __fish_gnome-extensions_complete_all_extensions + gnome-extensions list +end + +function __fish_gnome-extensions_complete_enabled_extensions + gnome-extensions list --enabled +end + +function __fish_gnome-extensions_complete_disabled_extensions + gnome-extensions list --disabled +end + +function __fish_gnome-extensions_complete_enabled_extensions_with_preferences + gnome-extensions list --enabled --prefs | sort +end + +function __fish_gnome-extensions_complete_disabled_extensions_with_preferences + gnome-extensions list --disabled --prefs | sort +end + +set -l commands_with_quiet enable disable reset uninstall list info show prefs create pack install +set -l commands help version $commands_with_quiet +set -l commands_without_help version $commands_with_quiet + +complete -f -c gnome-extensions + +complete -c gnome-extensions -n "not __fish_seen_subcommand_from $commands" -a "help" -d "Print help" +complete -c gnome-extensions -n "not __fish_seen_subcommand_from $commands" -a "version" -d "Print version" +complete -c gnome-extensions -n "not __fish_seen_subcommand_from $commands" -a "enable" -d "Enable extension" +complete -c gnome-extensions -n "not __fish_seen_subcommand_from $commands" -a "disable" -d "Disable extension" +complete -c gnome-extensions -n "not __fish_seen_subcommand_from $commands" -a "reset" -d "Reset extension" +complete -c gnome-extensions -n "not __fish_seen_subcommand_from $commands" -a "uninstall" -d "Uninstall extension" +complete -c gnome-extensions -n "not __fish_seen_subcommand_from $commands" -a "list" -d "List extensions" +complete -c gnome-extensions -n "not __fish_seen_subcommand_from $commands" -a "info show" -d "Show extension info" +complete -c gnome-extensions -n "not __fish_seen_subcommand_from $commands" -a "prefs" -d "Open extension preferences" +complete -c gnome-extensions -n "not __fish_seen_subcommand_from $commands" -a "create" -d "Create extension" +complete -c gnome-extensions -n "not __fish_seen_subcommand_from $commands" -a "pack" -d "Package extension" +complete -c gnome-extensions -n "not __fish_seen_subcommand_from $commands" -a "install" -d "Install extension bundle" + +complete -c gnome-extensions -n "__fish_seen_subcommand_from help && not __fish_seen_subcommand_from $commands_without_help" -a "$commands" +complete -c gnome-extensions -n "__fish_seen_subcommand_from enable && not __fish_seen_subcommand_from (__fish_gnome-extensions_complete_disabled_extensions)" -a "(__fish_gnome-extensions_complete_disabled_extensions)" +complete -c gnome-extensions -n "__fish_seen_subcommand_from disable && not __fish_seen_subcommand_from (__fish_gnome-extensions_complete_enabled_extensions)" -a "(__fish_gnome-extensions_complete_enabled_extensions)" +complete -c gnome-extensions -n "__fish_seen_subcommand_from reset && not __fish_seen_subcommand_from (__fish_gnome-extensions_complete_all_extensions)" -a "(__fish_gnome-extensions_complete_all_extensions)" +complete -c gnome-extensions -n "__fish_seen_subcommand_from uninstall && not __fish_seen_subcommand_from (__fish_gnome-extensions_complete_all_extensions)" -a "(__fish_gnome-extensions_complete_all_extensions)" + +complete -c gnome-extensions -n "__fish_seen_subcommand_from list" -l user -d "Show user-installed extensions" +complete -c gnome-extensions -n "__fish_seen_subcommand_from list" -l system -d "Show system-installed extensions" +complete -c gnome-extensions -n "__fish_seen_subcommand_from list" -l enabled -d "Show enabled extensions" +complete -c gnome-extensions -n "__fish_seen_subcommand_from list" -l disabled -d "Show disabled extensions" +complete -c gnome-extensions -n "__fish_seen_subcommand_from list" -l prefs -d "Show extensions with preferences" +complete -c gnome-extensions -n "__fish_seen_subcommand_from list" -l updates -d "Show extensions with updates" +complete -c gnome-extensions -n "__fish_seen_subcommand_from list" -s d -l details -d "Print extension details" + +complete -c gnome-extensions -n "__fish_seen_subcommand_from info show && not __fish_seen_subcommand_from (__fish_gnome-extensions_complete_enabled_extensions)" -a "(__fish_gnome-extensions_complete_enabled_extensions)" -d "Enabled" +complete -c gnome-extensions -n "__fish_seen_subcommand_from info show && not __fish_seen_subcommand_from (__fish_gnome-extensions_complete_disabled_extensions)" -a "(__fish_gnome-extensions_complete_disabled_extensions)" -d "Disabled" + +complete --keep-order -c gnome-extensions -n "__fish_seen_subcommand_from prefs && not __fish_seen_subcommand_from (__fish_gnome-extensions_complete_disabled_extensions_with_preferences) (__fish_gnome-extensions_complete_enabled_extensions_with_preferences)" -a "(__fish_gnome-extensions_complete_disabled_extensions_with_preferences)" -d "Disabled" +complete --keep-order -c gnome-extensions -n "__fish_seen_subcommand_from prefs && not __fish_seen_subcommand_from (__fish_gnome-extensions_complete_disabled_extensions_with_preferences) (__fish_gnome-extensions_complete_enabled_extensions_with_preferences)" -a "(__fish_gnome-extensions_complete_enabled_extensions_with_preferences)" -d "Enabled" + +complete -x -c gnome-extensions -n "__fish_seen_subcommand_from create && not __fish_seen_argument -l uuid" -l uuid -d "The unique identifier of the new extension" +complete -x -c gnome-extensions -n "__fish_seen_subcommand_from create && not __fish_seen_argument -l name" -l name -d "The user-visible name of the new extension" +complete -x -c gnome-extensions -n "__fish_seen_subcommand_from create && not __fish_seen_argument -l description" -l description -d "A short description of what the extension does" +complete -x -c gnome-extensions -n "__fish_seen_subcommand_from create && not __fish_seen_argument -l template" -l template -d "The template to use for the new extension" +complete -c gnome-extensions -n "__fish_seen_subcommand_from create && not __fish_seen_argument -s i -l interactive" -s i -l interactive -d "Enter extension information interactively" + +complete -x -c gnome-extensions -n "__fish_seen_subcommand_from pack && not __fish_seen_argument -l extra-source" -l extra-source -d "Additional source to include in the bundle" +complete -x -c gnome-extensions -n "__fish_seen_subcommand_from pack && not __fish_seen_argument -l schema" -l schema -d "A GSettings schema that should be included" +complete -x -c gnome-extensions -n "__fish_seen_subcommand_from pack && not __fish_seen_argument -l podir" -l podir -d "The directory where translations are found" +complete -x -c gnome-extensions -n "__fish_seen_subcommand_from pack && not __fish_seen_argument -l gettext-domain" -l gettext-domain -d "The gettext domain to use for translations" +complete -c gnome-extensions -n "__fish_seen_subcommand_from pack && not __fish_seen_argument -s f -l force" -s f -l force -d "Overwrite an existing pack" +complete -c gnome-extensions -n "__fish_seen_subcommand_from pack && not __fish_seen_argument -s o -l out-dir" -s o -l out-dir -d "The directory where the pack should be created" +complete -c gnome-extensions -n "__fish_seen_subcommand_from pack" -a "(__fish_complete_directories)" -d "Source directory" + +complete -c gnome-extensions -n "__fish_seen_subcommand_from install && not __fish_seen_argument -s f" -s f -l force -d "Overwrite an existing extension" +complete -F -c gnome-extensions -n "__fish_seen_subcommand_from install" -d "Extension bundle" + +complete -c gnome-extensions -n "__fish_seen_subcommand_from $commands_with_quiet" -s q -l quiet -d "Do not print error messages" + diff --git a/share/completions/gradle.fish b/share/completions/gradle.fish index 46cec347f..da0d8e1f7 100644 --- a/share/completions/gradle.fish +++ b/share/completions/gradle.fish @@ -54,7 +54,7 @@ function __fish_gradle_get_task_completion set -l gradle_cache_file (__fish_gradle_create_completion_cache_file "{$PWD}-tasks") if not test -f "$gradle_cache_file" -a -s "$gradle_cache_file" - command gradle -q tasks --all 2>/dev/null | string match --regex '^[a-z][A-z:]+.*' | string replace ' - ' \t >"$gradle_cache_file" + command gradle -q tasks --all 2>/dev/null | string match --regex '^(?!-)[A-Za-z0-9:-]+(?: - .*)?$' | string replace ' - ' \t >"$gradle_cache_file" end # return possible tasks diff --git a/share/completions/helm.fish b/share/completions/helm.fish index 90e009a64..4d6f7977b 100644 --- a/share/completions/helm.fish +++ b/share/completions/helm.fish @@ -1,287 +1 @@ -# helm - is a tool for managing Kubernetes charts. Charts are packages -# of pre-configured Kubernetes resources. -# See: https://github.com/kubernetes/helm - -function __helm_using_command - set -l cmd (commandline -poc) - set -l found - - test (count $cmd) -gt (count $argv) - or return 1 - - set -e cmd[1] - - for i in $argv - contains -- $i $cmd - and set found $found $i - end - - test "$argv" = "$found" -end - -function __helm_seen_any_subcommand_from -a cmd - __fish_seen_subcommand_from (__helm_subcommands $cmd | string replace -r '\t.*$' '') -end - -function __helm_subcommands -a cmd - switch $cmd - case '' - echo create\t'Create a new chart with the given name' - echo delete\t'Delete the release from Kubernetes' - echo dependency\t"Manage a chart's dependencies" - echo fetch\t'Download a chart from a repository' - echo get\t'Download a named release' - echo history\t'Fetch release history' - echo home\t'Display the location of HELM_HOME' - echo init\t'Initialize Helm on both client and server' - echo inspect\t'Inspect a chart' - echo install\t'Install a chart archive' - echo lint\t'Examine a chart for possible issues' - echo list\t'List releases' - echo package\t'Package a chart directory into a chart archive' - echo repo\t'Operate on chart repositories' - echo rollback\t'Roll back a release to a previous revision' - echo search\t'Search for a keyword in charts' - echo serve\t'Start a local http web server' - echo status\t'Display the status of the named release' - echo upgrade\t'Upgrade a release' - echo verify\t'Verify that a chart has been signed and is valid' - echo version\t'Print the client/server version information' - case dependency - echo build\t'Rebuild the charts/ directory' - echo list\t'List the dependencies for the given chart' - echo update\t'Update charts/' - case get - echo hooks\t'Download all hooks for a named release' - echo manifest\t'Download the manifest for a named release' - echo values\t'Download the values file for a named release' - case inspect - echo chart\t'Show inspect chart' - echo values\t'Show inspect values' - case repo - echo add\t'Add a chart repository' - echo index\t'Generate an index file' - echo list\t'List chart repositories' - echo remove\t'Remove a chart repository' - echo update\t'Update information on available charts' - end -end - -function __helm_kube_contexts - kubectl config get-contexts -o name 2>/dev/null -end - -function __helm_kube_namespaces - kubectl get namespaces -o name | string replace namespace/ '' -end - -function __helm_releases - helm ls --short 2>/dev/null -end - -function __helm_release_completions - helm ls 2>/dev/null | awk 'NR >= 2 { print $1"\tRelease of "$NF }' -end - -function __helm_release_revisions - set -l cmd (commandline -poc) - - for pair in (helm ls | awk 'NR >= 2 { print $1" "$2 }') - echo $pair | read -l release revision - - if contains $release $cmd - seq 1 $revision - return - end - end -end - -function __helm_repositories - helm repo list | awk 'NR >= 2 { print $1 }' -end - -function __helm_charts - helm search | awk 'NR >= 2 && !/^local\// { print $1 }' -end - -function __helm_chart_versions - set -l cmd (commandline -poc) - - for pair in (helm search -l | awk 'NR >= 2 { print $1" "$2 }') - echo $pair | read -l chart version - - if contains $chart $cmd - echo $version - end - end -end - -# -# Global Flags -# -complete -c helm -l debug -f -d 'Enable verbose output' -complete -c helm -l home -r -d 'Location of your Helm config' -complete -c helm -l host -x -d 'Address of tiller' -complete -c helm -l kube-context -x -a '(__helm_kube_contexts)' -d 'Name of the kubeconfig context to use' -complete -c helm -s h -l help -f -d 'More information about a command' - -# -# Commands -# - -# helm [command] -complete -c helm -n 'not __helm_seen_any_subcommand_from ""' -x -a '(__helm_subcommands "")' - -# helm create NAME [flags] -complete -c helm -n '__helm_using_command create' -s p -l starter -x -d 'The named Helm starter scaffold' - -# helm delete [flags] RELEASE [...] -complete -c helm -n '__helm_using_command delete' -f -a '(__helm_release_completions)' -d Release - -complete -c helm -n '__helm_using_command delete' -l dry-run -f -d 'Simulate a delete' -complete -c helm -n '__helm_using_command delete' -l no-hooks -f -d 'Prevent hooks from running during deletion' -complete -c helm -n '__helm_using_command delete' -l purge -f -d 'Remove the release from the store' - -# helm dependency [command] -complete -c helm -n '__helm_using_command dependency; and not __helm_seen_any_subcommand_from dependency' -x -a '(__helm_subcommands dependency)' - -# helm dependency build [flags] CHART -complete -c helm -n '__helm_using_command dependency build' -l keyring -r -d 'Keyring containing public keys' -complete -c helm -n '__helm_using_command dependency build' -l verify -f -d 'Verify the packages against signatures' - -# helm dependency update [flags] CHART -complete -c helm -n '__helm_using_command dependency update' -l keyring -r -d 'Keyring containing public keys' -complete -c helm -n '__helm_using_command dependency update' -l verify -f -d 'Verify the packages against signatures' - -# helm fetch [flags] [chart URL | repo/chartname] [...] -complete -c helm -n '__helm_using_command fetch; and not __fish_seen_subcommand_from (__helm_charts)' -f -a '(__helm_charts)' -d Chart - -complete -c helm -n '__helm_using_command fetch' -s d -l destination -r -d 'Location to write the chart' -complete -c helm -n '__helm_using_command fetch' -l keyring -r -d 'Keyring containing public keys' -complete -c helm -n '__helm_using_command fetch' -l prov -f -d 'Fetch the provenance file' -complete -c helm -n '__helm_using_command fetch' -l untar -f -d 'Will untar the chart after downloading it' -complete -c helm -n '__helm_using_command fetch --untar' -l untardir -r -d 'Directory into which the chart is expanded' -complete -c helm -n '__helm_using_command fetch' -l verify -f -d 'Verify the package against its signature' -complete -c helm -n '__helm_using_command fetch' -l version -x -a '(__helm_chart_versions)' -d 'Chart version' - -# helm get [command] -complete -c helm -n '__helm_using_command get; and not __helm_seen_any_subcommand_from get' -f -a '(__helm_subcommands get)' - -# helm get [flags] RELEASE -complete -c helm -n '__helm_using_command get' -f -a '(__helm_release_completions)' -d Release - -complete -c helm -n '__helm_using_command get' -l revision -x -a '(__helm_release_revisions)' -d Revision - -# helm get values [flags] RELEASE -complete -c helm -n '__helm_using_command get values' -s a -l all -f -d 'Dump all (computed) values' - -# helm history [flags] RELEASE -complete -c helm -n '__helm_using_command history' -f -a '(__helm_release_completions)' -d Release - -complete -c helm -n '__helm_using_command history' -l max -x -d 'Maximum number of revision to include in history' - -# helm init [flags] -complete -c helm -n '__helm_using_command init' -l canary-image -f -d 'Use the canary tiller image' -complete -c helm -n '__helm_using_command init' -s c -l client-only -f -d 'Do not install tiller' -complete -c helm -n '__helm_using_command init' -l dry-run -f -d 'Do not install local or remote' -complete -c helm -n '__helm_using_command init' -s i -l tiller-image -x -d 'Override tiller image' - -# helm inspect [command] -complete -c helm -n '__helm_using_command inspect; and not __helm_seen_any_subcommand_from inspect' -f -a '(__helm_subcommands inspect)' - -# helm inspect [CHART] [flags] -complete -c helm -n '__helm_using_command inspect; and not __fish_seen_subcommand_from (__helm_charts)' -a '(__helm_charts)' -d Chart - -complete -c helm -n '__helm_using_command inspect' -l keyring -r -d 'Keyring containing public verification keys' -complete -c helm -n '__helm_using_command inspect' -l verify -f -d 'Verify the provenance data for this chart' -complete -c helm -n '__helm_using_command inspect' -l version -x -a '(__helm_chart_versions)' -d 'Chart version' - -# helm install [CHART] [flags] -complete -c helm -n '__helm_using_command install; and not __fish_seen_subcommand_from (__helm_charts)' -a '(__helm_charts)' -d Chart - -complete -c helm -n '__helm_using_command install' -l dry-run -f -d 'Simulate an install' -complete -c helm -n '__helm_using_command install' -l keyring -r -d 'Keyring containing public verification keys' -complete -c helm -n '__helm_using_command install' -s n -l name -x -d 'Release name' -complete -c helm -n '__helm_using_command install' -l name-template -r -d 'Specify template used to name the release' -complete -c helm -n '__helm_using_command install' -l namespace -x -a '(__helm_kube_namespaces)' -d Namespace -complete -c helm -n '__helm_using_command install' -l no-hooks -f -d 'Prevent hooks from running during install' -complete -c helm -n '__helm_using_command install' -l replace -f -d 'Re-use the given name if already used' -complete -c helm -n '__helm_using_command install' -l set -x -d 'Set values on the command line' -complete -c helm -n '__helm_using_command install' -s f -l values -r -d 'Specify values in a YAML file' -complete -c helm -n '__helm_using_command install' -l verify -f -d 'Verify the package before installing it' -complete -c helm -n '__helm_using_command install' -l version -x -a '(__helm_chart_versions)' -d 'Chart version' - -# helm lint [flags] PATH -complete -c helm -n '__helm_using_command lint' -l strict -f -d 'Fail on lint warnings' - -# helm list [flags] [FILTER] -complete -c helm -n '__helm_using_command list' -l all -f -d 'Show all releases' -complete -c helm -n '__helm_using_command list' -s d -l date -f -d 'Sort by release date' -complete -c helm -n '__helm_using_command list' -l deleted -f -d 'Show deleted releases' -complete -c helm -n '__helm_using_command list' -l deleting -f -d 'Show releases that are currently being deleted' -complete -c helm -n '__helm_using_command list' -l deployed -f -d 'Show deployed releases' -complete -c helm -n '__helm_using_command list' -l failed -f -d 'Show failed releases' -complete -c helm -n '__helm_using_command list' -s m -l max -x -d 'Maximum number of releases to fetch' -complete -c helm -n '__helm_using_command list' -s o -l offset -x -a '(__helm_release_completions)' -d 'Next release name in the list' -complete -c helm -n '__helm_using_command list' -s r -l reverse -f -d 'Reverse the sort order' -complete -c helm -n '__helm_using_command list' -s q -l short -f -d 'Output short listing format' - -# helm package [flags] [CHART_PATH] [...] -complete -c helm -n '__helm_using_command package' -l key -x -d 'Name of the key to use when signing' -complete -c helm -n '__helm_using_command package' -l keyring -r -d 'Keyring containing public keys' -complete -c helm -n '__helm_using_command package' -l save -f -d 'Save packaged chart to local chart repository' -complete -c helm -n '__helm_using_command package' -l sign -f -d 'Use a PGP private key to sign this package' - -# helm repo [command] -complete -c helm -n '__helm_using_command repo; and not __helm_seen_any_subcommand_from repo' -f -a '(__helm_subcommands repo)' - -# helm repo add [flags] [NAME] [URL] -complete -c helm -n '__helm_using_command repo add' -l no-update -f -d 'Raise error if repo is already registered' - -# helm repo index [flags] [DIR] -complete -c helm -n '__helm_using_command repo index' -l merge -x -d 'Merge the generated index into the given index' -complete -c helm -n '__helm_using_command repo index' -l url -x -d 'URL of chart repository' - -# helm repo remove [flags] [NAME] -complete -c helm -n '__helm_using_command repo remove' -f -a '(__helm_repositories)' -d Repository - -# helm rollback [RELEASE] [REVISION] [flags] -complete -c helm -n '__helm_using_command rollback; and not __fish_seen_subcommand_from (__helm_releases)' -f -a '(__helm_release_completions)' -d Release -complete -c helm -n '__helm_using_command rollback' -f -a '(__helm_release_revisions)' -d Revision - -complete -c helm -n '__helm_using_command rollback' -l dry-run -f -d 'Simulate a rollback' -complete -c helm -n '__helm_using_command rollback' -l no-hooks -f -d 'Prevent hooks from running during rollback' - -# helm search [keyword] [flags] -complete -c helm -n '__helm_using_command search' -s r -l regexp -f -d 'Use regular expressions for searching' -complete -c helm -n '__helm_using_command search' -s l -l versions -f -d 'Show the long listing' - -# helm serve [flags] -complete -c helm -n '__helm_using_command serve' -l address -x -d 'Address to listen on' -complete -c helm -n '__helm_using_command serve' -l repo-path -r -d 'Path from which to serve charts' - -# helm status [flags] RELEASE -complete -c helm -n '__helm_using_command status' -f -a '(__helm_release_completions)' -d Release - -complete -c helm -n '__helm_using_command status' -l revision -x -a '(__helm_release_revisions)' -d Revision - -# helm upgrade [RELEASE] [CHART] [flags] -complete -c helm -n '__helm_using_command upgrade; and not __fish_seen_subcommand_from (__helm_releases)' -f -a '(__helm_release_completions)' -d Release -complete -c helm -n '__helm_using_command upgrade; and __fish_seen_subcommand_from (__helm_releases); and not __fish_seen_subcommand_from (__helm_charts)' -a '(__helm_charts)' -d Chart - -complete -c helm -n '__helm_using_command upgrade' -l dry-run -f -d 'Simulate an upgrade' -complete -c helm -n '__helm_using_command upgrade' -s i -l install -f -d "Run an install if the release don't exists" -complete -c helm -n '__helm_using_command upgrade' -l keyring -r -d 'Keyring containing public keys' -complete -c helm -n '__helm_using_command upgrade' -l namespace -x -a '(__helm_kube_namespaces)' -d Namespace -complete -c helm -n '__helm_using_command upgrade' -l no-hooks -f -d 'Disable pre/post upgrade hooks' -complete -c helm -n '__helm_using_command upgrade' -l set -x -d 'Set values on the command line' -complete -c helm -n '__helm_using_command upgrade' -s f -l values -r -d 'Specify values in a YAML file' -complete -c helm -n '__helm_using_command upgrade' -l verify -f -d 'Verify the provenance of the chart before upgrading' -complete -c helm -n '__helm_using_command upgrade' -l version -x -a '(__helm_chart_versions)' -d 'Chart version' - -# helm verify [flags] PATH -complete -c helm -n '__helm_using_command verify' -l keyring -r -d 'Keyring containing public keys' - -# helm version [flags] -complete -c helm -n '__helm_using_command version' -s c -l client -f -d 'Show the client version' -complete -c helm -n '__helm_using_command version' -s s -l server -f -d 'Show the server version' +helm completion fish | source diff --git a/share/completions/history.fish b/share/completions/history.fish index 227544cd1..6b58ec411 100644 --- a/share/completions/history.fish +++ b/share/completions/history.fish @@ -4,23 +4,23 @@ set -l __fish_history_all_commands search delete save merge clear clear-session complete -c history -s h -l help -d "Display help and exit" # Note that these options are only valid with the "search" and "delete" subcommands. -complete -c history -n '__fish_seen_subcommand_from search delete' \ +complete -c history -n '__fish_seen_subcommand_from search delete; or not __fish_seen_subcommand_from $__fish_history_all_commands' \ -s p -l prefix -d "Match items beginning with the string" -complete -c history -n '__fish_seen_subcommand_from search delete' \ +complete -c history -n '__fish_seen_subcommand_from search delete; or not __fish_seen_subcommand_from $__fish_history_all_commands' \ -s c -l contains -d "Match items containing the string" -complete -c history -n '__fish_seen_subcommand_from search delete' \ +complete -c history -n '__fish_seen_subcommand_from search delete; or not __fish_seen_subcommand_from $__fish_history_all_commands' \ -s e -l exact -d "Match items identical to the string" -complete -c history -n '__fish_seen_subcommand_from search delete' \ +complete -c history -n '__fish_seen_subcommand_from search delete; or not __fish_seen_subcommand_from $__fish_history_all_commands' \ -s t -l show-time -d "Output with timestamps" -complete -c history -n '__fish_seen_subcommand_from search delete' \ +complete -c history -n '__fish_seen_subcommand_from search delete; or not __fish_seen_subcommand_from $__fish_history_all_commands' \ -s C -l case-sensitive -d "Match items in a case-sensitive manner" # Note that these options are only valid with the "search" subcommand. -complete -c history -n '__fish_seen_subcommand_from search' \ +complete -c history -n '__fish_seen_subcommand_from search; or not __fish_seen_subcommand_from $__fish_history_all_commands' \ -s n -l max -d "Limit output to the first 'n' matches" -x -complete -c history -n '__fish_seen_subcommand_from search' \ +complete -c history -n '__fish_seen_subcommand_from search; or not __fish_seen_subcommand_from $__fish_history_all_commands' \ -s z -l null -d "Terminate entries with NUL character" -complete -c history -n '__fish_seen_subcommand_from search' \ +complete -c history -n '__fish_seen_subcommand_from search; or not __fish_seen_subcommand_from $__fish_history_all_commands' \ -s R -l reverse -d "Output the oldest results first" -x # We don't include a completion for the "save" subcommand because it should not be used diff --git a/share/completions/id.fish b/share/completions/id.fish index e32e9ecb7..c63914b29 100644 --- a/share/completions/id.fish +++ b/share/completions/id.fish @@ -1,7 +1,32 @@ -complete -c id -s g -l group -d "Print effective group id" -complete -c id -s G -l groups -d "Print all group ids" -complete -c id -s n -l name -d "Print name, not number" -complete -c id -s r -l real -d "Print real ID, not effective" -complete -c id -s u -l user -d "Print effective user ID" -complete -c id -l help -d "Display help and exit" -complete -c id -l version -d "Display version and exit" +complete id -xa "(__fish_complete_users)" + +if string match -eq 'GNU coreutils' (id --version 2>&1) + complete id -s Z -l context -d "Print security context" + complete id -s z -l zero -d "Delimit entries with NUL" + complete id -s n -l name -d "Print name, not number" + complete id -s g -l group -d "Print effective group id" + complete id -s G -l groups -d "Print all group ids" + complete id -s r -l real -d "Print real ID, not effective" + complete id -s u -l user -d "Print effective user ID" + complete id -l help -d "Display help and exit" + complete id -l version -d "Display version and exit" +else + # macOS id shell_cmds-240.100.15 + # id [user] + # id -A + # id -F [user] + # id -G [-n] [user] + # id -P [user] + # id -g [-nr] [user] + # id -p [user] + # id -u [-nr] [user] + complete id -s A -d "Print process audit ID" + complete id -s F -d "Print full name of the user" + complete id -s G -d "Print all group ids" + complete id -s P -d "Print as passwd file entry" + complete id -s g -d "Print effective group id" + complete id -s n -d "Print name, not number" + complete id -s p -d "Human-readable output" + complete id -s r -d "Print real ID, not effective" + complete id -s u -d "Print effective user ID" +end diff --git a/share/completions/identify.fish b/share/completions/identify.fish index f4ae7c5e7..c3806d871 100644 --- a/share/completions/identify.fish +++ b/share/completions/identify.fish @@ -1,4 +1,4 @@ -complete -c identify -o antialias -d 'Remove pixel-aliasing ' +complete -c identify -o antialias -d 'Remove pixel-aliasing' complete -c identify -o authenticate -d 'Decrypt image with this password [value]' complete -c identify -o channel -d 'Apply option to select image channels [type]' -xa '(identify -list channel)' complete -c identify -o crop -d 'Cut out a rectangular region of the image [geometry]' @@ -6,21 +6,21 @@ complete -c identify -o define -d 'Define one or more image format options [form complete -c identify -o density -d 'Horizontal and vertical density of the image [geometry]' complete -c identify -o depth -d 'Image depth [value]' complete -c identify -o extract -d 'Extract area from image [geometry]' -complete -c identify -o features -d 'Display image features (e.g. contrast, correlation) [distance]' +complete -c identify -o features -d 'Display image features [distance]' complete -c identify -o format -d 'Output formatted image characteristics ["string"]' complete -c identify -o fuzz -d 'Colors within this distance are considered equal [distance]' complete -c identify -o interlace -d 'Type of image interlacing scheme [type]' -xa '(identify -list interlace)' complete -c identify -o interpolate -d 'Pixel color interpolation method [method]' -xa '(identify -list interpolate)' complete -c identify -o limit -d 'Pixel cache resource limit [type value]' -x -complete -c identify -o list -d 'Color, Configure, Delegate, Format, Magic, Module, Resource, or Type [type]' -xa '(identify -list list)' +complete -c identify -o list -d 'Print a list of supported option arguments [type]' -xa '(identify -list list)' complete -c identify -o matte -d 'Store matte channel if the image has one' -complete -c identify -o monitor -d 'Monitor progress ' +complete -c identify -o monitor -d 'Monitor progress' complete -c identify -o ping -d 'Efficiently determine image attributes' complete -c identify -o quiet -d 'Suppress all warning messages' complete -c identify -o regard-warnings -d 'Pay attention to warning messages' complete -c identify -o sampling-factor -d 'Horizontal and vertical sampling factor [geometry]' complete -c identify -o seed -d 'Seed a new sequence of pseudo-random numbers [value]' -complete -c identify -o set -d 'Attribute set an image attribute [ value]' +complete -c identify -o set -d 'Attribute set an image attribute [value]' complete -c identify -o size -d 'Width and height of image [geometry]' complete -c identify -o strip -d 'Strip image of all profiles and comments' complete -c identify -o unique -d 'Display the number of unique colors in the image' diff --git a/share/completions/ikdasm.fish b/share/completions/ikdasm.fish new file mode 100644 index 000000000..76c6dec4b --- /dev/null +++ b/share/completions/ikdasm.fish @@ -0,0 +1,8 @@ +complete -c ikdasm -o help -d 'Show help' + +complete -c ikdasm -o out -r -d 'Redirect stdout to file' +complete -c ikdasm -o assembly -d 'Include Assembly table contents' +complete -c ikdasm -o assemblyref -d 'Include AssemblyRef table contents' +complete -c ikdasm -o moduleref -d 'Include ModuleRef table contents' +complete -c ikdasm -o exported -d 'Include ExportedType table contents' +complete -c ikdasm -o customattr -d 'Include CustomAttribute table contents' diff --git a/share/completions/ilasm.fish b/share/completions/ilasm.fish new file mode 100644 index 000000000..f23c2743c --- /dev/null +++ b/share/completions/ilasm.fish @@ -0,0 +1,10 @@ +complete -c ilasm -l help -d 'Show help and exit' +complete -c ilasm -l version -d 'Show version and exit' + +complete -c ilasm -o 'output:' -r -d 'Specify the output file name' +complete -c ilasm -o exe -d 'Generate an exe' +complete -c ilasm -o scan_only -d 'Just scan the IL code and display tokens' +complete -c ilasm -o show_tokens -d 'Show tokens as they are parsed' +complete -c ilasm -o show_method_def -d 'Display method information when a method is defined' +complete -c ilasm -o show_method_ref -d 'Display method information when a method is referenced' +complete -c ilasm -o 'key:' -d 'Strongname (sign) the output assembly using the key pair' diff --git a/share/completions/import.fish b/share/completions/import.fish index bb12ab76c..d34398631 100644 --- a/share/completions/import.fish +++ b/share/completions/import.fish @@ -24,7 +24,7 @@ complete -c import -o interlace -d 'None, Line, Plane, or Partition [type]' -xa complete -c import -o interpolate -d 'Pixel color interpolation method [method]' -xa '(import -list interpolate)' complete -c import -o label -d 'Assign a label to an image [string]' complete -c import -o limit -d 'Area, Disk, Map, or Memory resource limit [type value]' -x -complete -c import -o monitor -d 'Monitor progress ' +complete -c import -o monitor -d 'Monitor progress' complete -c import -o page -d 'Size and location of an image canvas [geometry]' complete -c import -o pause -d 'Seconds delay between snapshots [value]' complete -c import -o pointsize -d 'Font point size [value]' diff --git a/share/completions/isatty.fish b/share/completions/isatty.fish new file mode 100644 index 000000000..2ee644b0f --- /dev/null +++ b/share/completions/isatty.fish @@ -0,0 +1 @@ +complete -c isatty -x -k -a "stdin stdout stderr" diff --git a/share/completions/killall.fish b/share/completions/killall.fish index 217827298..679e4f0b6 100644 --- a/share/completions/killall.fish +++ b/share/completions/killall.fish @@ -13,7 +13,7 @@ for i in $__kill_signals set -q numname[2] and set -l name $numname[2] complete -c killall -o $number -d $name - complete -c killall -o $name + complete -c killall -o $name -d $name # The `-s` flag doesn't work in OS X test "$OS" != Darwin and complete -c killall -s s -x -a "$number $name" @@ -30,17 +30,17 @@ if killall --version >/dev/null 2>/dev/null # GNU complete -c killall -s w -l wait -d 'Wait for all killed processes to die' complete -c killall -s v -l version -d 'Print version' else # probably BSD - complete -c killall -s v -d 'Be more verbose about what will be done' - complete -c killall -s e -d 'Use effective UID instead of the real UID for matching processes specified with the -u option' - complete -c killall -s help -d 'Print help and exit' - complete -c killall -s l -d 'List names of available signals and exit' - complete -c killall -s m -d 'Case sensitive argument match for processed' - complete -c killall -s s -d 'Simulate, but do not send any signals' - complete -c killall -s d -d "Print detailed info. Doesn't send signals" - complete -c killall -s u -x -a "(__fish_complete_users)" -d 'Kill only processes the specified user owns. Command names are optional' + complete -c killall -s v -d 'Print what is done' + complete -c killall -s e -d 'Use effective UID instead of the real UID for -u' + complete -c killall -s help + complete -c killall -s l -d 'List names of available signals' + complete -c killall -s m -d 'Case sensitive process matching' + complete -c killall -s s -d "Simulate, send no signals" + complete -c killall -s d -d "Simulate & summarize, send no signals" + complete -c killall -s u -x -a "(__fish_complete_users)" -d "kill given user's processes" complete -c killall -s -u -l user -x -a "(__fish_complete_users)" - complete -c killall -s t -d 'Limit to processes running on specified TTY' + complete -c killall -s t -d 'Limit to processes on specified TTY' complete -c killall -s t -xa "(ps a -o tty | sed 1d | uniq)" - complete -c killall -s c -x -d 'Limit to processes matching specified PROCNAME' - complete -c killall -s z -d 'Do not skip zombies' + complete -c killall -s c -x -d 'Limit to processes matching pattern' + complete -c killall -s z -d "Don't skip zombies" end diff --git a/share/completions/kubectl.fish b/share/completions/kubectl.fish new file mode 100644 index 000000000..75ae15557 --- /dev/null +++ b/share/completions/kubectl.fish @@ -0,0 +1 @@ +kubectl completion fish | source diff --git a/share/completions/latexmk.fish b/share/completions/latexmk.fish index ac1dc5eeb..d8b4b7874 100644 --- a/share/completions/latexmk.fish +++ b/share/completions/latexmk.fish @@ -6,25 +6,25 @@ complete -c latexmk -o bm -x -d 'Print message across the page when converting t complete -c latexmk -o bi -x -d 'Set contrast or intensity of banner' complete -c latexmk -o bs -x -d 'Set scale for banner' complete -c latexmk -o commands -d 'list commands used by latexmk for processing files' -complete -c latexmk -o c -d 'clean up (remove) all nonessential files, except dvi, ps and pdf files' -complete -c latexmk -o C -o CA -d 'clean up (remove) all nonessential files' -complete -c latexmk -o CF -d 'Remove file of database of file information before doing other actions' +complete -c latexmk -o c -d 'Delete all nonessential files, except dvi, ps and pdf files' +complete -c latexmk -o C -o CA -d 'Delete all nonessential files' +complete -c latexmk -o CF -d 'Delete database file information file before other actions' complete -c latexmk -o cd -d 'Change to directory of source file when processing it' -complete -c latexmk -o cd- -d 'Do NOT change to directory of source file when processing it' +complete -c latexmk -o cd- -d "Don't change to directory of source file when processing it" complete -c latexmk -o dependents -o -deps -d 'Show list of dependent files after processing' complete -c latexmk -o dependents- -o -deps- -d 'Do not show list of dependent files' -complete -c latexmk -o deps-out= -r -d 'Set name of output file for dependency list, and turn on showing of dependency list' +complete -c latexmk -o deps-out= -r -d 'Set dependency list file name, show dependency list' complete -c latexmk -o dF -x -d 'Filter to apply to dvi file' complete -c latexmk -o dvi -d 'generate dvi' complete -c latexmk -o dvi- -d 'turn off required dvi' -complete -c latexmk -o e -x -d 'Execute specified Perl code (as part of latexmk start-up code)' +complete -c latexmk -o e -x -d 'Execute specified Perl code on start-up' complete -c latexmk -o f -d 'force continued processing past errors' complete -c latexmk -o f- -d 'turn off forced continuing processing past errors' complete -c latexmk -o gg -d 'Super go mode: clean out generated files before processing' complete -c latexmk -o g -d 'process regardless of file timestamps' complete -c latexmk -o g- -d 'Turn off -g' complete -c latexmk -o h -o help -d 'print help' -complete -c latexmk -o jobname= -x -d 'set basename of output file(s) to STRING' +complete -c latexmk -o jobname= -x -d 'set basename of output files to STRING' complete -c latexmk -o l -d 'force landscape mode' complete -c latexmk -o l- -d 'turn off -l' complete -c latexmk -o latex= -d 'set program used for latex' -xa '(__fish_complete_command)' diff --git a/share/completions/ln.fish b/share/completions/ln.fish index a8c79e1dc..806346ba9 100644 --- a/share/completions/ln.fish +++ b/share/completions/ln.fish @@ -1,4 +1,3 @@ -complete -c ln -s s -l symbolic -d 'Make symbolic links instead of hard links' complete -c ln -l backup -d 'Make a backup of each existing destination file' -a "none off numbered t existing nil simple never" complete -c ln -s b -d 'Make a backup of each existing destination file' complete -c ln -s d -l directory -d 'Allow superuser to attempt to hard link directories' @@ -7,6 +6,8 @@ complete -c ln -s i -l interactive -d 'Prompt whether to remove destinations' complete -c ln -s L -l logical -d 'Dereference TARGETs that are symbolic links' complete -c ln -s n -l no-dereference -d 'Treat symlink to directory as if it were a file' complete -c ln -s P -l physical -d 'Make hard links directly to symbolic links' +complete -c ln -s r -l relative -d 'With -s, create links relative to link location' +complete -c ln -s s -l symbolic -d 'Make symbolic links instead of hard links' complete -c ln -s S -l suffix -d 'Override the usual ~ backup suffix' complete -c ln -s t -l target-directory -d 'Specify the DIRECTORY in which to create the links' -a '(__fish_complete_directories)' complete -c ln -s T -l no-target-directory -d 'Treat LINK_NAME as a normal file' diff --git a/share/completions/lpadmin.fish b/share/completions/lpadmin.fish index 6e9d83c52..c70ba55ce 100644 --- a/share/completions/lpadmin.fish +++ b/share/completions/lpadmin.fish @@ -2,30 +2,30 @@ complete -c lpadmin -s c -d 'Adds the named printer to class' -x complete -c lpadmin -s i -d 'Sets a System V style interface script for the printer' -x complete -c lpadmin -s m -d 'Sets a standard System V interface script or PPD file ' -x complete -c lpadmin -s R -d 'Deletes the named option from printer' -xa '(__fish_print_lpr_options)' -complete -c lpadmin -s r -d 'Removes the named printer from class. If the resulting class becomes empty it is removed' -x +complete -c lpadmin -s r -d 'Removes the named printer from class' -x complete -c lpadmin -s v -d 'Sets the device-uri attribute of the printer queue' -r complete -c lpadmin -s D -d 'Provides a textual description of the destination' -x complete -c lpadmin -s E -d 'Enables the destination and accepts jobs' complete -c lpadmin -s L -d 'Provides a textual location of the destination' -x -complete -c lpadmin -s P -d 'Specifies a PostScript Printer Description file to use with the printer' -k -xa "(__fish_complete_suffix .ppd; __fish_complete_suffix .ppd.gz)" -complete -c lpadmin -s o -xa cupsIPPSupplies=true -d 'Specifies whether IPP supply level values should be reported' -complete -c lpadmin -s o -xa cupsIPPSupplies=false -d 'Specifies whether IPP supply level values should be reported' -complete -c lpadmin -s o -xa cupsSNMPSupplies=true -d 'Specifies whether SNMP supply level (RFC 3805) values should be reported' -complete -c lpadmin -s o -xa cupsSNMPSupplies=false -d 'Specifies whether SNMP supply level (RFC 3805) values should be reported' -complete -c lpadmin -s o -xa job-k-limit= -d 'Sets the kilobyte limit for per-user quotas. The value is an integer number of kilobytes (1024)' +complete -c lpadmin -s P -d 'Specify a PDD file to use with the printer' -k -xa "(__fish_complete_suffix .ppd; __fish_complete_suffix .ppd.gz)" +complete -c lpadmin -s o -xa cupsIPPSupplies=true -d 'Specify if IPP supply level values should be reported' +complete -c lpadmin -s o -xa cupsIPPSupplies=false -d 'Specify if IPP supply level values should be reported' +complete -c lpadmin -s o -xa cupsSNMPSupplies=true -d 'Specify if SNMP supply level values should be reported' +complete -c lpadmin -s o -xa cupsSNMPSupplies=false -d 'Specify if SNMP supply level values should be reported' +complete -c lpadmin -s o -xa job-k-limit= -d 'Sets the kilobyte limit for per-user quotas' complete -c lpadmin -s o -xa job-page-limit= -d 'Sets the page limit for per-user quotas (int) ' complete -c lpadmin -s o -xa job-quota-period= -d 'Sets the accounting period for per-user quotas (sec)' complete -c lpadmin -s o -xa job-sheets-default= -d 'Sets the default banner page(s) to use for print jobs' complete -c lpadmin -s o -d 'Sets a PPD option for the printer' -xa '(__fish_complete_lpr_option)' #complete -c lpadmin -s o -d 'Sets a default server-side option for the destination' -xa '(__fish_complete_lpr_option | sed "s/=/-default=/")' complete -c lpadmin -s o -d 'Sets the binary communications program to use when printing' -xa 'port-monitor=none port-monitor=bcp port-monitor=tbcp' -complete -c lpadmin -s o -d 'Sets the error policy to be used when the printer backend is unable to send the job to the printer. ' -xa 'printer-error-policy=abort-job printer-error-policy=retry-job printer-error-policy=retry-current-job printer-error-policy=stop-printer' -complete -c lpadmin -s o -xa printer-is-shared=true -d 'Sets the destination to shared/published or unshared/unpublished' -complete -c lpadmin -s o -xa printer-is-shared=false -d 'Sets the destination to shared/published or unshared/unpublished' -complete -c lpadmin -s o -d 'Sets the IPP operation policy associated with the destination' -xa "printer-policy=(test -r /etc/cups/cupsd.conf; and string replace -r --filter '' '$1' < /etc/cups/cupsd.conf)" +complete -c lpadmin -s o -d "Set error policy if printer backend can't send job" -xa 'printer-error-policy=abort-job printer-error-policy=retry-job printer-error-policy=retry-current-job printer-error-policy=stop-printer' +complete -c lpadmin -s o -xa printer-is-shared=true -d 'Sets destination to shared/published or unshared/unpublished' +complete -c lpadmin -s o -xa printer-is-shared=false -d 'Sets destination to shared/published or unshared/unpublished' +complete -c lpadmin -s o -d 'Set IPP operation policy associated with destination' -xa "printer-policy=(test -r /etc/cups/cupsd.conf; and string replace -r --filter '' '$1' < /etc/cups/cupsd.conf)" -complete -c lpadmin -s u -xa 'allow:all allow:none (__fish_complete_list , __fish_complete_users allow:)' -d 'Sets user-level access control on a destination. Names starting with "@" are interpreted as UNIX group' -complete -c lpadmin -s u -xa '(__fish_complete_list , __fish_complete_groups allow: @)' -d 'Sets user-level access control on a destination. Names starting with "@" are interpreted as UNIX group' -complete -c lpadmin -s u -xa 'deny:all deny:none (__fish_complete_list , __fish_complete_users deny:)' -d 'Sets user-level access control on a destination. Names starting with "@" are interpreted as UNIX group' -complete -c lpadmin -s u -xa '(__fish_complete_list , __fish_complete_groups deny: @)' -d 'Sets user-level access control on a destination. Names starting with "@" are interpreted as UNIX group' +complete -c lpadmin -s u -xa 'allow:all allow:none (__fish_complete_list , __fish_complete_users allow:)' -d 'Sets user-level access control on a destination' +complete -c lpadmin -s u -xa '(__fish_complete_list , __fish_complete_groups allow: @)' -d 'Sets user-level access control on a destination' +complete -c lpadmin -s u -xa 'deny:all deny:none (__fish_complete_list , __fish_complete_users deny:)' -d 'Sets user-level access control on a destination' +complete -c lpadmin -s u -xa '(__fish_complete_list , __fish_complete_groups deny: @)' -d 'Sets user-level access control on a destination' diff --git a/share/completions/lpstat.fish b/share/completions/lpstat.fish index 3a1effd2a..54b8479c2 100644 --- a/share/completions/lpstat.fish +++ b/share/completions/lpstat.fish @@ -1,15 +1,15 @@ __fish_complete_lpr lpstat -complete -c lpstat -s H -d 'Show the server hostname and port' -complete -c lpstat -s R -d 'Shows the ranking of print jobs' -complete -c lpstat -s W -d 'Specifies which jobs to show' -xa 'completed not-completed' -complete -c lpstat -s a -d 'Shows the accepting state of selected printer queues' -xa '(__fish_print_lpr_printers)' -complete -c lpstat -s c -x -d 'Shows the printer classes and the printers that belong to them. If no classes are specified then all classes are listed' +complete -c lpstat -s H -d 'Show server hostname and port' +complete -c lpstat -s R -d 'Shows ranking of print jobs' +complete -c lpstat -s W -d 'Specify which jobs to show' -xa 'completed not-completed' +complete -c lpstat -s a -d 'Shows accepting state of selected printer queues' -xa '(__fish_print_lpr_printers)' +complete -c lpstat -s c -x -d 'Shows printer classes and the printers that belong to them' complete -c lpstat -s d -d 'Shows the current default destination' -complete -c lpstat -s l -d 'Shows a long listing of printers, classes, or jobs' -complete -c lpstat -s o -d 'Shows the jobs queue on the specified destinations' -xa '(__fish_print_lpr_printers)' -complete -c lpstat -s p -d 'Shows the printers and whether or not they are enabled for printing' -xa '(__fish_print_lpr_printers)' +complete -c lpstat -s l -d 'Shows list of printers, classes, or jobs' +complete -c lpstat -s o -d 'Shows jobs queue on the specified destinations' -xa '(__fish_print_lpr_printers)' +complete -c lpstat -s p -d 'Shows printers and if they are enabled for printing' -xa '(__fish_print_lpr_printers)' complete -c lpstat -s r -d 'Shows whether the CUPS server is running' -complete -c lpstat -s s -d 'Shows a status summary, including the default destination' +complete -c lpstat -s s -d 'Shows a status summary, including default destination' complete -c lpstat -s t -d 'Shows all status information' complete -c lpstat -s u -d 'Shows a list of print jobs queued by the specified users' -xa '(__fish_complete_users)' -complete -c lpstat -s v -d 'Shows the printers and what device they are attached to' -xa '(__fish_print_lpr_printers)' +complete -c lpstat -s v -d 'Shows printers and what device they are attached to' -xa '(__fish_print_lpr_printers)' diff --git a/share/completions/matlab.fish b/share/completions/matlab.fish new file mode 100644 index 000000000..cec5285ee --- /dev/null +++ b/share/completions/matlab.fish @@ -0,0 +1,54 @@ +# Completion for: MATLAB R2021b +function __fish_matlabcheck_no_desktop_nodesktop_opts + not __fish_seen_argument --old desktop --old nodesktop + return $status +end + +function __fish_matlabcheck_no_batch_r_opts + not __fish_seen_argument --old batch --short r + return $status +end + +complete -c matlab -s h -l help -d 'Show help' + +# Mode options +complete -c matlab -o desktop -n __fish_matlabcheck_no_desktop_nodesktop_opts -d 'Start without a controlling terminal' +complete -c matlab -o nodesktop -n __fish_matlabcheck_no_desktop_nodesktop_opts -d 'Run the JVM software without opening the desktop' +complete -c matlab -o nojvm -d 'Start without the JVM software' + +# Display options +complete -c matlab -o noFigureWindows -d 'Disable the display of figure windows' +complete -c matlab -o nosplash -d 'Don\'t display the splash screen during startup' +complete -c matlab -o nodisplay -d 'Start the JVM software without starting desktop' +complete -c matlab -o display -x -d 'Send X commands to X Window Server display xDisp' + +# Set initial working folder +complete -c matlab -o sd -r -d 'Set the folder' +complete -c matlab -o useStartupFolderPref -d 'Change the folder to the Initial working folder preference' + +# Debugging options +complete -c matlab -o logfile -r -a '(__fish_complete_suffix .log)' -d 'Copy Command Window output into filename' +complete -c matlab -s n -d 'Display the environment variables/arguments passed to the executable' +complete -c matlab -s e -d 'Display all environment variables and their values to standard output' +complete -c matlab -s Dgdb -x -d 'Start in debug mode' +complete -c matlab -s Dlldb -x -d 'Start in debug mode' +complete -c matlab -s Ddbx -x -d 'Start in debug mode' +complete -c matlab -o jdb -x -d 'Enable use of the Java debugger' +complete -c matlab -o debug -d 'Display information for debugging X-based problems' + +# Execute MATLAB script or function +complete -c matlab -o batch -x -n __fish_matlabcheck_no_batch_r_opts -d 'Execute script, statement, or function non-interactively' +complete -c matlab -s r -x -n __fish_matlabcheck_no_batch_r_opts -d 'Execute the statement' + +# Use single computational thread +complete -c matlab -o singleCompThread -d 'Limit to a single computational thread' + +# Disable searching custom Java class path +complete -c matlab -o nouserjavapath -d 'Disable use of javaclasspath.txt and javalibrarypath.txt files' + +# OpenGL library options +complete -c matlab -o softwareopengl -d 'Force to start with software OpenGL libraries' +complete -c matlab -o nosoftwareopengl -d 'Disable auto-selection of OpenGL software' + +# Specify license file +complete -c matlab -s c -r -d 'Use the specified license file' diff --git a/share/completions/mdfind.fish b/share/completions/mdfind.fish index b5598621f..9b9f86794 100644 --- a/share/completions/mdfind.fish +++ b/share/completions/mdfind.fish @@ -1,12 +1,13 @@ # completion for mdfind (macOS) -complete -c mdfind -o attr -x -d 'Fetches the value of the specified attribute' -complete -c mdfind -o count -f -d 'Query only reports matching items count' -complete -c mdfind -o onlyin -x -a '(__fish_complete_directories (commandline -ct))' -d 'Search only within given directory' -complete -c mdfind -o live -f -d 'Query should stay active' -complete -c mdfind -o name -x -d 'Search on file name only' -complete -c mdfind -o reprint -f -d 'Reprint results on live update' -complete -c mdfind -s s -x -d 'Show contents of smart folder' -complete -c mdfind -s 0 -f -d 'Use NUL (\0) as a path separator, for use with xargs -0' -complete -c mdfind -o literal -f -d 'Force the provided query string to be taken as a literal' -complete -c mdfind -o interpret -f -d 'Interprete query string as Spotlight query' +complete mdfind -d "find files matching given query" +complete mdfind -o attr -x -d 'Show given attribute' +complete mdfind -o count -f -d 'Print number of matches' +complete mdfind -o onlyin -x -a '(__fish_complete_directories (commandline -ct))' -d 'Search within directory' +complete mdfind -o live -f -d 'Query should stay active' +complete mdfind -o name -x -d 'Search on file name only' +complete mdfind -o reprint -f -d 'Reprint -live results' +complete mdfind -s s -x -d 'List a smart folder' +complete mdfind -s 0 -f -d 'NUL path separators' +complete mdfind -o literal -f -d 'Literal metadata query' +complete mdfind -o interpret -f -d 'Spotlight-like search' diff --git a/share/completions/meson.fish b/share/completions/meson.fish index abce460d2..9a3fe94de 100644 --- a/share/completions/meson.fish +++ b/share/completions/meson.fish @@ -49,4 +49,4 @@ complete -c meson -l cross-file -r -d "File describing cross-compilation environ complete -c meson -l wrap-mode -xa 'WrapMode.{default,nofallback,nodownload,forcefallback}' -d "Special wrap mode to use" # final parameter -complete -c meson -n "fish_is_nth_token 1" -xa '(__fish_complete_directories)' +complete -c meson -n "__fish_is_nth_token 1" -xa '(__fish_complete_directories)' diff --git a/share/completions/mkbundle.fish b/share/completions/mkbundle.fish new file mode 100644 index 000000000..ee49aeac7 --- /dev/null +++ b/share/completions/mkbundle.fish @@ -0,0 +1,56 @@ +function __fish_mkbundle_cross_args + mkbundle --list-targets | awk -F ' - ' '/^Targets available/ { exit } !/^Available targets/ { printf "%s\t%s\n", gensub(/^\t/, "", 1, $1), $2 }' +end + +# Options +complete -c mkbundle -l config -r -d 'Bundle DLLMAP Mono config file' +complete -c mkbundle -l config-dir -r -d 'Use MONO_CFG_DIR environment variable as config dir' +complete -c mkbundle -n 'not __fish_seen_argument -l sdk -l cross' -l cross -x -a '(__fish_mkbundle_cross_args)' \ + -d 'Create bundle for the specified target platform' +complete -c mkbundle -l deps \ + -d 'Bundle all of the referenced assemblies for the assemblies listed on the command line option' +complete -c mkbundle -l env -x -d 'Specify value for the environment variable' +complete -c mkbundle -l fetch-target -x \ + -d 'Download a precompiled runtime for the specified target from the Mono distribution site' +complete -c mkbundle -l i18n -x -d 'Use encoding tables to ship with the executable' +complete -c mkbundle -s L -r -d 'Use path for look for assemblies' +complete -c mkbundle -l library -r -d 'Embed the dynamic library file' +complete -c mkbundle -l lists-targets -d 'Show all of the available remote cross compilation targets' +complete -c mkbundle -l local-targets -d 'Show all of the available local cross compilation targets' +complete -c mkbundle -l cil-strip -r -d 'Use a CIL stripper that mkbundle will use if able to' +complete -c mkbundle -l in-tree -r \ + -d 'Use mkbundle with a mono source repository from which to pull the necessary headers for compilation' +complete -c mkbundle -l managed-linker -r \ + -d 'Use mkbundle access to a managed linker to preprocess the assemblies' +complete -c mkbundle -l machine-config -r \ + -d 'Use the given FILE as the machine.config file for the generated application' +complete -c mkbundle -l no-config \ + -d 'Prevent mkbundle from automatically bundling a config file' +complete -c mkbundle -l nodeps \ + -d 'Exclude all the assemblies but those were specified on the command line' +complete -c mkbundle -s o -r -d 'Use output file name' +complete -c mkbundle -l options -r -d 'Specify configuration options to the Mono runtime' +complete -c mkbundle -n 'not __fish_seen_argument -l sdk -l cross' -l sdk -r \ + -d 'Use a path from which mkbundle will resolve the Mono SDK from' +complete -c mkbundle -l target-server -r -d 'Use a different server to provide cross-compiled runtimes' +complete -c mkbundle -l mono-api-struct-path -r \ + -d 'Use file with the definition of the BundleMonoAPI structure' + +# Old embedding options +complete -c mkbundle -s c -d 'Produce the stub file, do not compile the resulting stub' +complete -c mkbundle -o oo -r \ + -d 'Specify the name to be used for the helper object file that contains the bundle' +complete -c mkbundle -l keeptemp \ + -d 'Prevent mkbundle from deleting temporary files that it uses to produce the bundle' +complete -c mkbundle -l nomain -d 'Generate the host stub without a main() function' +complete -c mkbundle -l static -d 'Statically link to mono and glib' +complete -c mkbundle -s z -d 'Compress the assemblies before embedding' + +# AOT options +complete -c mkbundle -l aot-runtime -r \ + -d 'Use the path to the mono runtime to use for AOTing assemblies' +complete -c mkbundle -l aot-dedup \ + -d 'Deduplicate AOT\'ed methods based on a unique mangling of method names' +complete -c mkbundle -l aot-mode -x \ + -a 'full\t"Generate the necessary stubs to not require runtime code generation" llvmonly\t"Do the same, but force all codegen to go through the llvm backend"' \ + -d 'Specifiy AOT mode' diff --git a/share/completions/mocp.fish b/share/completions/mocp.fish index ef1493563..321a9bf01 100644 --- a/share/completions/mocp.fish +++ b/share/completions/mocp.fish @@ -1,32 +1,32 @@ -complete -c mocp -s V -l version -d "Print program version and exit" -complete -c mocp -s h -l help -d "Print usage and exit" +complete -c mocp -s V -l version -d "Print program version" +complete -c mocp -s h -l help -d "Print usage" complete -c mocp -s D -l debug -d "Turn on logging to a file" complete -c mocp -s S -l server -d "Run only the server" complete -c mocp -s F -l foreground -d "Run server in foreground, log to stdout" complete -c mocp -s R -l sound-driver -d "Use the specified sound driver" -xa 'oss alsa jack null' complete -c mocp -s m -l music-dir -r -d "Start in MusicDir" -complete -c mocp -s a -l append -r -d "Append the files/directories/playlists passed in the command line to playlist and exit" -complete -c mocp -s q -l enqueue -r -d "Add the files given on command line to the queue" -complete -c mocp -s c -l clear -d "Clear the playlist and exit" +complete -c mocp -s a -l append -r -d "Append the files/directories/playlists to playlist" +complete -c mocp -s q -l enqueue -r -d "Add files to the queue" +complete -c mocp -s c -l clear -d "Clear the playlist" complete -c mocp -s p -l play -r -d "Start playing from the first item on the playlist" -complete -c mocp -s l -l playit -r -d "Play files given on command line without modifying the playlist" +complete -c mocp -s l -l playit -r -d "Play files without modifying the playlist" complete -c mocp -s s -l stop -d "Stop playing" complete -c mocp -s f -l next -d "Play next song" complete -c mocp -s r -l previous -d "Play previous song" complete -c mocp -s x -l exit -d "Shutdown the server" -complete -c mocp -s T -l theme -r -d "Use selected theme file (read from ~/.moc/themes if the path is not absolute" -complete -c mocp -s C -l config -r -d "Use the specified config file instead of the default" +complete -c mocp -s T -l theme -r -d "Use selected theme file" +complete -c mocp -s C -l config -r -d "Use config file instead of the default" complete -c mocp -s O -l set-option -r -d "NAME=VALUE Override configuration option NAME with VALUE" -complete -c mocp -s M -l moc-dir -r -d "Use the specified MOC directory instead of the default" +complete -c mocp -s M -l moc-dir -r -d "Use MOC directory instead of the default" complete -c mocp -s P -l pause -d Pause complete -c mocp -s U -l unpause -d Unpause complete -c mocp -s G -l toggle-pause -d "Toggle between play/pause" complete -c mocp -s v -l volume -d "(+/-)LEVEL Adjust PCM volume" -xa '+ -' complete -c mocp -s y -l sync -d "Synchronize the playlist with other clients" -complete -c mocp -s n -l nosync -d "Don't synchronize the playlist with other client's" +complete -c mocp -s n -l nosync -d "Don't synchronize the playlist with other clients" complete -c mocp -s A -l ascii -d "Use ASCII characters to draw lines" -complete -c mocp -s i -l info -d "Print the information about the currently played file" -complete -c mocp -s Q -l format -rf -d "Print the formatted information about the currently played file" +complete -c mocp -s i -l info -d "Print information about the currently played file" +complete -c mocp -s Q -l format -rf -d "Print formatted information about currently played file" complete -c mocp -s e -l recursively -d "Alias for -a" complete -c mocp -s k -l seek -rf -d "Seek by N seconds (can be negative)" complete -c mocp -s j -l jump -rf -d "N{%,s} Jump to some position of the current track" diff --git a/share/completions/mogrify.fish b/share/completions/mogrify.fish index aec69c942..458c76f43 100644 --- a/share/completions/mogrify.fish +++ b/share/completions/mogrify.fish @@ -1,6 +1,6 @@ complete -c mogrify -o adjoin -d 'Join images into a single multi-image file' complete -c mogrify -o affine -d 'Affine transform matrix [matrix]' -complete -c mogrify -o antialias -d 'Remove pixel-aliasing ' +complete -c mogrify -o antialias -d 'Remove pixel-aliasing' complete -c mogrify -o authenticate -d 'Decrypt image with this password [value]' complete -c mogrify -o background -d 'Background color [color]' -xa '(__fish_complete_convert_options color)' complete -c mogrify -o bias -d 'Add bias when convolving an image [value]' @@ -47,7 +47,7 @@ complete -c mogrify -o loop -d 'Add Netscape loop extension to your GIF animatio complete -c mogrify -o mask -d 'Associate a mask with the image [filename]' -r complete -c mogrify -o matte -d 'Store matte channel if the image has one' complete -c mogrify -o mattecolor -d 'Frame color [color]' -xa '(__fish_complete_convert_options color)' -complete -c mogrify -o monitor -d 'Monitor progress ' +complete -c mogrify -o monitor -d 'Monitor progress' complete -c mogrify -o morphology -d 'Apply a morphology method to the image [method kernel]' -xa '(mogrify -list morphology)' complete -c mogrify -o orient -d 'Image orientation [type]' -xa '(mogrify -list orientation)' complete -c mogrify -o origin -d 'Image origin [geometry]' @@ -83,10 +83,10 @@ complete -c mogrify -o virtual-pixel -d 'Virtual pixel access method [method]' - complete -c mogrify -o weight -d 'Render text with this font weight [type]' -x complete -c mogrify -o white-point -d 'Chromaticity white point [point]' complete -c mogrify -o adaptive-blur -d 'Adaptively blur pixels; decrease effect near edges [geometry]' -complete -c mogrify -o adaptive-resize -d 'Adaptively resize image with data dependent triangulation [geometry]' +complete -c mogrify -o adaptive-resize -d "Adaptively resize image using 'mesh' interpolation [geometry]" complete -c mogrify -o adaptive-sharpen -d 'Adaptively sharpen pixels; increase effect near edges [geometry]' complete -c mogrify -o annotate -d 'Annotate the image with text [geometry text]' -complete -c mogrify -o auto-orient -d 'Automatically orient image' +complete -c mogrify -o auto-orient -d 'Automatically orient (rotate) image' complete -c mogrify -o black-threshold -d 'Force all pixels below the threshold into black [value]' complete -c mogrify -o blur -d 'Reduce image noise and reduce detail levels [geometry]' complete -c mogrify -o border -d 'Surround image with a border of color [geometry]' @@ -107,7 +107,7 @@ complete -c mogrify -o edge -d 'Apply a filter to detect edges in the image [rad complete -c mogrify -o emboss -d 'Emboss an image [radius]' complete -c mogrify -o enhance -d 'Apply a digital filter to enhance a noisy image' complete -c mogrify -o equalize -d 'Perform histogram equalization to an image' -complete -c mogrify -o evaluate -d 'Evaluate an arithmetic, relational, or logical expression [operator value]' +complete -c mogrify -o evaluate -d 'Alter channel pixels based on expression [operator]' complete -c mogrify -o extent -d 'Set the image size [geometry]' complete -c mogrify -o extract -d 'Extract area from image [geometry]' complete -c mogrify -o fft -d 'Implements the discrete Fourier transform (DFT)' @@ -168,7 +168,7 @@ complete -c mogrify -o sketch -d 'Simulate a pencil sketch [geometry]' complete -c mogrify -o solarize -d 'Negate all pixels above the threshold level [threshold]' complete -c mogrify -o splice -d 'Splice the background color into the image [geometry]' complete -c mogrify -o spread -d 'Displace image pixels by a random amount [amount]' -complete -c mogrify -o statistic -d 'Replace each pixel with corresponding statistic from the neighborhood [type geometry]' -xa '(mogrify -list statistic)' +complete -c mogrify -o statistic -d 'Replace pixels with statistic from the neighborhood [type geometry]' -xa '(mogrify -list statistic)' complete -c mogrify -o strip -d 'Strip image of all profiles and comments' complete -c mogrify -o swirl -d 'Swirl image pixels about the center [degrees]' complete -c mogrify -o threshold -d 'Threshold the image [value]' @@ -187,14 +187,14 @@ complete -c mogrify -o vignette -d 'Soften the edges of the image in vignette st complete -c mogrify -o wave -d 'Alter an image along a sine wave [geometry]' complete -c mogrify -o white-threshold -d 'Force all pixels above the threshold into white [value]' complete -c mogrify -o affinity -d 'Transform image colors to match this set of colors [filename]' -r -complete -c mogrify -o append -d 'Append an image sequence top to botto (use +append for left to right)' +complete -c mogrify -o append -d 'Append an image sequence' complete -c mogrify -o clut -d 'Apply a color lookup table to the image' complete -c mogrify -o coalesce -d 'Merge a sequence of images' complete -c mogrify -o combine -d 'Combine a sequence of images' -complete -c mogrify -o composite -d 'Composite image ' +complete -c mogrify -o composite -d 'Composite image' complete -c mogrify -o crop -d 'Cut out a rectangular region of the image [geometry]' complete -c mogrify -o deconstruct -d 'Break down an image sequence into constituent parts' -complete -c mogrify -o evaluate-sequence -d 'Evaluate an arithmetic, relational, or logical expression [operator]' +complete -c mogrify -o evaluate-sequence -d 'Alter channel pixels based on expression [operator]' complete -c mogrify -o fx -d 'Apply mathematical expression to an image channel(s) [expression]' complete -c mogrify -o hald-clut -d 'Apply a Hald color lookup table to the image' complete -c mogrify -o morph -d 'Morph an image sequence [value]' diff --git a/share/completions/mono.fish b/share/completions/mono.fish index 5463d571d..824bd3931 100644 --- a/share/completions/mono.fish +++ b/share/completions/mono.fish @@ -1,29 +1,153 @@ -complete -c mono -s h -l help -d 'Show help and exit' -complete -c mono -s V -l version -a number -f -d 'Show version and exit' +# Runtime options +complete -c mono -s h -l help -d 'Show help' +complete -c mono -s V -l version -a number -f -d 'Show version' -complete -c mono -l aot -a 'asmonly bind-to-runtime-version data-outfile direct-icalls - direct-pinvoke dwarfdebug full hybrid llvm llvmonly llvmopts llvmllc mcpu dedup-include - info interp depfile ld-flags llvm-path msym-dir mtriple nimt-trampolines ngsharedvt-trampolines - nodebug no-direct-calls nrgctx-trampolines nrgctx-fetch-trampolines ntrampolines outfile - print-skipped-methods profile profile-only readonly-value save-temps,keep-temps soft-debug - static stats temp-path threads tool-prefix verbose write-symbols,no-write-symbols no-opt' \ +complete -c mono -l aot -a '(__fish_append , \\ + asmonly\t"Instruct the AOT compiler to output assembly code instead of an object file" \\ + bind-to-runtime-version\t"Force the generated AOT files to be bound to the runtime version of the compiling Mono" \\ + data-outfile\t"Instruct the AOT code generator to output certain data constructs into a separate file" \\ + direct-icalls\t"Invoke icalls directly instead of going through the operating system symbol lookup operation" \\ + direct-pinvoke\t"Invoke PInvoke methods directly instead of going through the operating system symbol lookup operation" \\ + dwarfdebug\t"Instruct the AOT compiler to emit DWARF debugging information" \\ + full\t"Create binaries which can be used with the --full-aot option" \\ + hybrid\t"Create binaries which can be used with the --hybrid-aot option" \\ + llvm\t"Perform AOT with the LLVM backend instead of the Mono backend where possible" \\ + llvmonly\t"Perform AOT with the LLVM backend exclusively and the Mono backend will not be used" \\ + llvmopts\t"Specify flags to the built-in set of flags passed to the LLVM optimizer" \\ + llvmllc\t"Specify flags to the built-in set of flags passed to the LLVM static compiler (llc)" \\ + mcpu\t"Allow AOT mode to use all instructions current CPU supports" \\ + dedup-include\t"Pass compilation where we compile the methods that we had previously skipped" \\ + info\t"Print the architecture the AOT in this copy of Mono targets and quit" \\ + interp\t"Generate all required wrappers, so that it is possible to run --interpreter without any code generation at runtime" \\ + depfile\t"Output a gcc -M style dependency file" \\ + ld-flags\t"Specify flags to pass to the C linker (if the current AOT mode calls for invoking it)" \\ + llvm-path\t"Same for the llvm tools \\\'opt\\\' and \\\'llc\\\'" \\ + msym-dir\t"Instruct the AOT compiler to generate offline sequence points .msym files" \\ + mtriple\t"Use the GNU style target triple to determine some code generation options" \\ + nimt-trampolines\t"Precreate IMT trampolines in the AOT image" \\ + ngsharedvt-trampolines\t"Precreate value type generic sharing trampolines in the AOT image" \\ + nodebug\t"Instruct the AOT compiler to not output any debugging information" \\ + no-direct-calls\t"Prevent the AOT compiler from generating a direct calls to a method" \\ + nrgctx-trampolines\t"Precreate generic sharing trampolines in the AOT image" \\ + nrgctx-fetch-trampolines\t"Precreate generic sharing fetch trampolines in the AOT image" \\ + ntrampolines\t"Precreate method trampolines in the AOT image" \\ + outfile\t"Instruct the AOT compiler to save the output to the specified file" \\ + print-skipped-methods\t"Output the skipped methods to the console" \\ + profile\t"Specify a file to use for profile-guided optimization" \\ + profile-only\t"" \\ + readonly-value\t"Override the value of a static readonly field" \\ + save-temps,keep-temps\t"Instruct the AOT compiler to keep temporary files" \\ + soft-debug\t"Instruct the compiler to generate sequence point checks" \\ + static\t"Create an ELF object file (.o) or .s file which can be statically linked into an executable when embedding the mono runtime" \\ + stats\t"Print various stats collected during AOT compilation" \\ + temp-path\t"Specify path to store temporary files created during AOT compilation" \\ + threads\t"Use multiple threads when compiling the methods" \\ + tool-prefix\t"Prepend to the name of tools ran by the AOT compiler" \\ + verbose\t"Print additional information about type loading failures" \\ + write-symbols,no-write-symbols\t"Instruct the AOT compiler to emit (or not emit) debug symbol information" \\ + no-opt\t"Instruct the AOT compiler tot no call opt when compiling with LLVM")' \ -f -d 'Precompile CIL code to native code' -complete -c mono -l debug -a 'casts mdb-optimizations gdb' -f -d 'Use debug mode' -complete -c mono -l debugger-agent -a 'address loglevel logfile server setpgid suspend - transport' -f -d 'Use debugger agent' -complete -c mono -l profile -d 'Use profiler module' -complete -c mono -l trace -d 'Trace expression' -complete -c mono -l jitmap -d 'Generate JIT method map in /tmp/perf-PID.map' -complete -c mono -l config -F -r -d 'Use config' -complete -c mono -s v -l verbose -d 'Increase verbosity level' -complete -c mono -l runtime -f -d 'Use runtime version' -complete -c mono -l optimize -a 'abcrem all aot branch cfold cmov deadce consprop copyprop - fcmov float32 gshared inline intrins linears leaf loop peephole precomp sched shared - sse2 tailc' -f -d 'Use optimizations' -complete -c mono -l attach -a disable -f -d 'Specify attach agent options' -complete -c mono -l llvm -d 'Use LLVM' -complete -c mono -l nollvm -d 'Don\'t use LLVM' -complete -c mono -l gc -a 'sgen boehm' -f -d 'Specify garbage collector' -complete -c mono -l handlers -d 'Use custom handlers' -complete -c mono -l aot-path -f -d 'Add directories for AOT image search' +complete -c mono -l aot-path -d 'Show additional directories to search for AOT images' +complete -c mono -l apply-bindings \ + -d 'Apply the assembly bindings from the specified configuration file when running the AOT compiler' +complete -c mono -l assembly-loader \ + -a 'strict\t"Check that the public key token, culture and version of a candidate assembly matches the requested strong name" legacy\t"Allow candidate as long as the name matches"' \ + -f -d 'Use assembly loader mode' +complete -c mono -l attach -a disable -f -d 'Disable the attach functionality' +complete -c mono -l config -d 'Read configuration from file instead of using default one' + +complete -c mono -l debugger-agent -a '(__fish_append , \\ + address\t"Specify the IP address where your debugger client is listening to" \\ + loglevel\t"Specify the diagnostics log level for" \\ + logfile\t"Instruct the AOT code generator to output certain data constructs into a separate file" \\ + server\t"Specify the file where the log will be stored, it defaults to standard output" \\ + setpgid\t"If set to yes, Mono will call setpgid(0, 0) on startup" \\ + suspend\t"Suspend the vm on startup until it connects successfully to a debugger front end" \\ + transport\t"Specify the transport that the debugger will use to communicate")' \ + -f -d 'Use a debugging agent inside the Mono runtime and connect it to a client user interface' + +complete -c mono -l desktop \ + -d 'Configure the virtual machine to be better suited for desktop applications' +complete -c mono -l full-aot \ + -d 'Prevent from generation any code at runtime and depend exclusively on the code generated from using mono --aot=full previously' +complete -c mono -l full-aot-interp \ + -d 'Same as --full-aot with fallback to the interpreter' +complete -c mono -l gc -a 'boehm\tBoehm sgen\tSGen' -f -d 'Use the Garbage Collector engine' +complete -c mono -l gc-debug -f -d 'Specify MONO_GC_DEBUG environment variable value' +complete -c mono -l gc-params -f -d 'Specify MONO_GC_PARAMS environment variable value' +test "$(uname)" = Darwin && complete -c mono -l arch -a '32\t"32 bit" 64\t"64 bit"' -f \ + -d 'Use the bitness of the Mono binary used, if available' +complete -c mono -l interpreter -d 'Use Mono interpreter to execute a given assembly' +complete -c mono -l hybrid-aot -d 'Run assemblies that have been stripped of IL' +complete -c mono -l llvm -d 'Use the LLVM optimization and code generation engine to JIT or AOT compile' +complete -c mono -l ffast-math -d 'Use Mono and LLVM aggressive floating point optimizations' + +complete -c mono -s o -l optimize -a '(__fish_append , \\ + abcrem\t"Array bound checks removal" \\ + all\t"Turn on all optimizations" \\ + aot\t"Usage of Ahead Of Time compiled code" \\ + branch\t"Branch optimizations" \\ + cfold\t"Constant folding" \\ + cmov\t"Conditional moves [arch-dependency]" \\ + deadce\t"Dead code elimination" \\ + consprop\t"Constant propagation" \\ + copyprop\t"Copy propagation" \\ + fcmov\t"Fast x86 FP compares [arch-dependency]" \\ + float32\t"Perform 32-bit float arithmetic using 32-bit operations" \\ + gshared\t"Enable generic code sharing" \\ + inline\t"Inline method calls" \\ + intrins\t"Intrinsic method implementations" \\ + linears\t"Linear scan global reg allocation" \\ + leaf\t"Leaf procedures optimizations" \\ + loop\t"Loop related optimizations" \\ + peephole\t"Peephole postpass" \\ + precomp\t"Precompile all methods before executing Main" \\ + sched\t"Instruction scheduling" \\ + shared\t"Emit per-domain code" \\ + sse2\t"SSE2 instructions on x86 [arch-dependency]" \\ + tailc\t"Tail recursion and tail calls" \\ + transport\t"Specify the transport that the debugger will use to communicate")' \ + -f -d 'Use optimizations' + +complete -c mono -l response -d 'Use a response file' +complete -c mono -l runtime -a '(mono --version)' -f -d 'Use Mono version' +complete -c mono -l server -d 'Optimize the virtual machine to be better suited for server operations' +complete -c mono -l use-map-jit -d 'Generate code using MAP_JIT on MacOS' +complete -c mono -l verify-all \ + -d 'Verify mscorlib and assemblies in the global assembly cache for valid IL, and all user code for IL verifiability' + +# Development options +complete -c mono -l debug -a '(__fish_append , \\ + casts\t"Produce a detailed error when throwing a InvalidCastException" \\ + mdb-optimizations\t"Disable some JIT optimizations which are usually only disabled when running inside the debugger" \\ + gdb\t"Generate and register debugging information with gdb")' \ + -f -d 'Use the debugging mode in the runtime' + +complete -c mono -l profile -f -d 'Use a profiler module with the given arguments' +complete -c mono -l trace -f -d 'Show method names as they are invoked' +complete -c mono -l no-x86-stack-align -d 'Don\'t align stack frames on the x86 architecture' +complete -c mono -l jitmap -d 'Generate a JIT method map in a /tmp/perf-PID.map file' + +# JIT maintainer options +complete -c mono -l bisect -f -d 'This flag is used by the automatic optimization bug bisector' +complete -c mono -l break -x \ + -d 'Insert a breakpoint before the method whose name is \'method\' (namespace.class:methodname)' +complete -c mono -l breakonex -d 'Use a breakpoint on exceptions' +complete -c mono -l compile -x -d 'Compile a method (namespace.name:methodname)' +complete -c mono -l compile-all -d 'Compile all the methods in an assembly' +complete -c mono -l graph \ + -a 'cfg\t"Control Flow Graph (CFG)" + dtree\t"Dominator Tree" code\t"CFG showing code" + ssa\t"CFG showing code after SSA translation" + optcode\t"CFG showing code after IR optimizations"' \ + -x -d 'Generate a postscript file with a graph with the details about the specified method' +complete -c mono -l ncompile \ + -d 'Instruct the runtime on the number of times that the method(-s) specified by --compile/--compile-all to be compiled' +complete -c mono -l stats \ + -d 'Display information about the work done by the runtime during the execution of an application' +complete -c mono -l wapi \ + -a 'hps\t"Delete the global semaphore" + semdel\t"List the currently used handles"' \ + -x -d 'Perform maintenance of the process shared data' +complete -c mono -s v -l verbose -d 'Show more messages' diff --git a/share/completions/monodis.fish b/share/completions/monodis.fish new file mode 100644 index 000000000..064beae03 --- /dev/null +++ b/share/completions/monodis.fish @@ -0,0 +1,45 @@ +# Options +complete -c monodis -s h -l help -d 'Show help' + +complete -c monodis -l output -r -d 'Redirect stdout to file' +complete -c monodis -l mscorlib -d 'Use \'mscorlib\' as the assembly name for non-corlib assemblies' +complete -c monodis -l show-method-tokens -d 'Show tokens for disassembled methods' +complete -c monodis -l show-tokens -d 'Show tokens for strings, types, methods, fields, ...' + +# Options to display metadata tables +complete -c monodis -l assembly -d 'Include Assembly table contents' +complete -c monodis -l assemblyref -d 'Include AssemblyRef table contents' +complete -c monodis -l classlayout -d 'Include ClassLayout table contents' +complete -c monodis -l constant -d 'Include Constant table contents' +complete -c monodis -l customattr -d 'Include CustomAttribute table contents' +complete -c monodis -l declsec -d 'Include DeclSec table contents' +complete -c monodis -l event -d 'Include Event table contents' +complete -c monodis -l exported -d 'Include ExportedType table contents' +complete -c monodis -l fields -d 'Include Field table contents' +complete -c monodis -l file -d 'Include File table contents' +complete -c monodis -l forward-decls -d 'Include forward declarations for classes' +complete -c monodis -l genericpar -d 'Include GenericParam table contents' +complete -c monodis -l implmap -d 'Include ImplMap table contents' +complete -c monodis -l interface -d 'Include InterfaceImpl table contents' +complete -c monodis -l manifest -d 'Include ManifestResource table contents' +complete -c monodis -l marshal -d 'Include FieldMarshal table contents' +complete -c monodis -l numberref -d 'Include MemberRef table contents' +complete -c monodis -l method -d 'Include MethodRef table contents' +complete -c monodis -l methodimpl -d 'Include MethodImpl table contents' +complete -c monodis -l methodspec -d 'Include MethodSpec table contents' +complete -c monodis -l methodsem -d 'Include MethodSemantics table contents' +complete -c monodis -l module -d 'Include Module table contents' +complete -c monodis -l moduleref -d 'Include ModuleRef table contents' +complete -c monodis -l mresources -d 'Save all the managed resources embedded in the assembly into the current directory' +complete -c monodis -l presources -d 'Show offsets and names of manifest resources embedded in the assembly' +complete -c monodis -l nested -d 'Include NestedClass table contents' +complete -c monodis -l param -d 'Include Param table contents' +complete -c monodis -l parconst -d 'Include GenericParameterConstraint table contents' +complete -c monodis -l property -d 'Include Property table contents' +complete -c monodis -l propertymap -d 'Include PropertyMap table contents' +complete -c monodis -l standalonesig -d 'Include StandAloneSig table contents' +complete -c monodis -l typedef -d 'Include TypeDef table contents' +complete -c monodis -l typespec -d 'Include TypeRef table contents' +complete -c monodis -l blob -d 'Use hex for entire contents of the blob stream' +complete -c monodis -l strings -d 'Include Strings table contents' +complete -c monodis -l userstrings -d 'Include User-Strings heap contents' diff --git a/share/completions/monop.fish b/share/completions/monop.fish new file mode 100644 index 000000000..c00488ec8 --- /dev/null +++ b/share/completions/monop.fish @@ -0,0 +1,10 @@ +complete -c monop -s r -d 'Specifies the assembly to use for looking up the type' +complete -c monop -s a -d 'Renders all of the types in the specified assembly' +complete -c monop -s s -s k -l search -d 'Searches through all known assemblies for types containing \'class\'' +complete -c monop -l refs -d 'Print a list of the referenced assemblies for an assembly.' +complete -c monop -s f -l filter-obsolete -d 'Do not show obsolete types and members' +complete -c monop -s d -l declared-only -d 'Only show members declared in the type' +complete -c monop -s p -l private -d 'Show private members' +complete -c monop -l runtime-version -d 'Print runtime version' +complete -c monop -o xa -d 'Set the lookup path to the Xamarin.Android directory' +complete -c monop -o xi -d 'Set the lookup path to the Xamarin.iOS directory' diff --git a/share/completions/montage.fish b/share/completions/montage.fish index 7c4b59334..64a4010ff 100644 --- a/share/completions/montage.fish +++ b/share/completions/montage.fish @@ -1,6 +1,6 @@ complete -c montage -o adjoin -d 'Join images into a single multi-image file' complete -c montage -o affine -d 'Affine transform matrix [matrix]' -complete -c montage -o alpha -d 'On, activate, off, deactivate, set, opaque, copy transparent, extract, background, or shape [option]' -xa '(montage -list alpha)' +complete -c montage -o alpha -d 'Control alpha/matte channel of an image [option]' -xa '(montage -list alpha)' complete -c montage -o authenticate -d 'Decipher image with this password [password]' complete -c montage -o blue-primary -d 'Chromaticity blue primary point [point]' complete -c montage -o bordercolor -d 'Border color [color]' -xa '(__fish_complete_convert_options color)' @@ -37,7 +37,7 @@ complete -c montage -o label -d 'Assign a label to an image [string]' complete -c montage -o limit -d 'Pixel cache resource limit [type value]' -x complete -c montage -o mattecolor -d 'Frame color [color]' -xa '(__fish_complete_convert_options color)' complete -c montage -o mode -d 'Framing style [type]' -xa '(montage -list mode)' -complete -c montage -o monitor -d 'Monitor progress ' +complete -c montage -o monitor -d 'Monitor progress' complete -c montage -o origin -d 'Image origin [geometry]' complete -c montage -o page -d 'Size and location of an image canvas (setting) [geometry]' complete -c montage -o pointsize -d 'Font point size [value]' @@ -51,13 +51,13 @@ complete -c montage -o respect-parentheses -d 'Settings remain in effect until p complete -c montage -o sampling-factor -d 'Horizontal and vertical sampling factor [geometry]' complete -c montage -o scenes -d 'Range image scene range' complete -c montage -o seed -d 'Seed a new sequence of pseudo-random numbers [value]' -complete -c montage -o set -d 'Attribute set an image attribute [ value]' +complete -c montage -o set -d 'Attribute set an image attribute [value]' complete -c montage -o shadow -d 'Add a shadow beneath a tile to simulate depth' complete -c montage -o size -d 'Width and height of image [geometry]' complete -c montage -o stroke -d 'Color to use when stroking a graphic primitive [color]' -xa '(__fish_complete_convert_options color)' complete -c montage -o synchronize -d 'Synchronize image to storage device' complete -c montage -o taint -d 'Declare the image as modified' -complete -c montage -o texture -d 'Name of texture to tile onto the image background [filename]' -r +complete -c montage -o texture -d 'Texture name to tile onto the image background [filename]' -r complete -c montage -o thumbnail -d 'Create a thumbnail of the image [geometry]' complete -c montage -o tile -d 'Number of tiles per row and column [geometry]' complete -c montage -o title -d 'Decorate the montage image with a title [string]' @@ -68,8 +68,8 @@ complete -c montage -o units -d 'The units of image resolution [type]' -xa '(mon complete -c montage -o verbose -d 'Print detailed information about the image' complete -c montage -o virtual-pixel -d 'Virtual pixel access method [method]' -xa '(montage -list virtual-pixel)' complete -c montage -o white-point -d 'Chromaticity white point [point]' -complete -c montage -o adaptive-sharpen -d 'Adaptively sharpen pixels; increase effect near edges annotate geometry text annotate the image with text [geometry]' -complete -c montage -o auto-orient -d 'Automagically orient image' +complete -c montage -o adaptive-sharpen -d 'Adaptively sharpen pixels; increase effect near edges [geometry]' +complete -c montage -o auto-orient -d 'Automagically orient (rotate) image' complete -c montage -o blur -d 'Reduce image noise and reduce detail levels [geometry]' complete -c montage -o border -d 'Surround image with a border of color [geometry]' complete -c montage -o crop -d 'Preferred size and location of the cropped image [geometry]' @@ -90,7 +90,7 @@ complete -c montage -o transparent -d 'Make this color transparent within the im complete -c montage -o type -d 'Image type [type]' -xa '(montage -list type)' complete -c montage -o unsharp -d 'Sharpen the image [geometry]' complete -c montage -o coalesce -d 'Merge a sequence of images' -complete -c montage -o composite -d 'Composite image ' +complete -c montage -o composite -d 'Composite image' complete -c montage -o clone -d 'Clone an image [indexes]' complete -c montage -o delete -d 'Delete the image from the image sequence [indexes]' complete -c montage -o duplicate -d 'Duplicate an image one or more times [count,indexes]' diff --git a/share/completions/mvn.fish b/share/completions/mvn.fish index ea9eb596e..5266c3fad 100644 --- a/share/completions/mvn.fish +++ b/share/completions/mvn.fish @@ -87,8 +87,13 @@ function __fish_mvn_profiles sed -n -e '//{n; s!^.*\([^<]*\).*$!\1!; p}' ~/.m2/settings.xml pom.xml 2>/dev/null end +function __fish_mvn_projects + grep "" pom.xml 2>/dev/null | sed 's/\s*<[^<]*>\(.*\)<[^<]*>/\1/' +end + complete -c mvn -f -r -o P -l activate-profiles -a "(__fish_mvn_profiles)" -d "Comma-delimited list of profiles to activate" +complete -c mvn -f -r -o pl -l projects -a "(__fish_mvn_projects)" -d "Projects to build" #default properties for some plugins / profiles complete -c mvn -o DskipTests -d "Skipping JUnit Tests" diff --git a/share/completions/nmap.fish b/share/completions/nmap.fish index 61b9842c8..213a9f4d9 100644 --- a/share/completions/nmap.fish +++ b/share/completions/nmap.fish @@ -71,9 +71,12 @@ complete -c nmap -l max-os-tries -d 'Set the maximum number of OS detection trie # NMAP SCRIPTING ENGINE (NSE) complete -c nmap -o sC -d 'Scan: Scripts (default)' function __fish_complete_nmap_script + set -l now (date "+%s") + # cache completion for 5 minutes (`nmap --script-help all` is slow) - if test -z "$__fish_nmap_script_completion_cache" -o (date -d "now - 5min" +"%s") -gt "$__fish_nmap_script_completion_cache_time" - set -g __fish_nmap_script_completion_cache_time (date +"%s") + # must use `math` because of differences between BSD and GNU `date` + if test -z "$__fish_nmap_script_completion_cache" -o (math $now - 5 "*" 60) -gt "$__fish_nmap_script_completion_cache_time" + set -g __fish_nmap_script_completion_cache_time $now set -g __fish_nmap_script_completion_cache "" set -l cmd for l in (nmap --script-help all 2> /dev/null | grep -A2 -B1 Categories: | grep -v '^\\(--\\|Categories:\\|https:\\)') diff --git a/share/completions/nodeenv.fish b/share/completions/nodeenv.fish new file mode 100644 index 000000000..6af9ba480 --- /dev/null +++ b/share/completions/nodeenv.fish @@ -0,0 +1,31 @@ +# Generated by fish-python-argparse-completions v0.1.0, for nodeenv v1.6.0 +# (With manual modifications) +complete -c nodeenv -e +complete -c nodeenv -f +complete -c nodeenv -s h -l help -d 'Show this help message and exit' +complete -c nodeenv -l version -d 'Show nodeenv\'s version number and exit' +complete -c nodeenv -s n -l node -r -d 'The Node.js version to use' +complete -c nodeenv -l mirror -r -d 'The mirror of nodejs.org to download from' +complete -c nodeenv -s j -l jobs -r -d 'The number of compile jobs to run in parallel' +complete -c nodeenv -l load-average -r -d 'The maximum load average during parallel compilation.' +complete -c nodeenv -l without-ssl -d 'Build Node.js without SSL support' +complete -c nodeenv -l debug -d 'Enable debug build of Node.js' +complete -c nodeenv -l profile -d 'Enable profiling of Node.js' +complete -c nodeenv -l make -s m -r -d 'Path to make command' +complete -c nodeenv -l source -d 'Install Node.js from source' +complete -c nodeenv -s v -l verbose -d 'Verbose mode' +complete -c nodeenv -s q -l quiet -d 'Quiet mode' +complete -c nodeenv -s C -l config-file -r -d 'Config file to use instead of ~/.nodeenvrc' +complete -c nodeenv -s r -l requirements -r -d 'Install all Node.js packages listed in this file' +complete -c nodeenv -l prompt -r -d 'Set a custom prompt prefix for this environment' +complete -c nodeenv -s l -l list -d 'List available Node.js versions' +complete -c nodeenv -l update -d 'Install npm packages from file without Node.js' +complete -c nodeenv -l with-npm -d 'Build without installing npm into the new virtual environment' +complete -c nodeenv -l npm -r -d 'The npm version to use' +complete -c nodeenv -l no-npm-clean -d 'Skip the npm 0.x cleanup' +complete -c nodeenv -l python-virtualenv -s p -d 'Use the currently-active Python virtualenv' +complete -c nodeenv -l clean-src -s c -d 'Remove "src" directory after installation' +complete -c nodeenv -l force -d 'Force installation to an existing directory' +complete -c nodeenv -l prebuilt -d 'Install Node.js from a prebuilt package (default)' +complete -c nodeenv -l ignore_ssl_certs -d 'UNSAFE! Ignore SSL certs for package downloads' +complete -c nodeenv -F diff --git a/share/completions/octave.fish b/share/completions/octave.fish new file mode 100644 index 000000000..74e1bb093 --- /dev/null +++ b/share/completions/octave.fish @@ -0,0 +1,35 @@ +# Completion for: GNU Octave 5.2.0 + +complete -c octave -x -a '(__fish_complete_suffix .m)' + +complete -c octave -s h -l help -d 'Show help' +complete -c octave -s v -l version -d 'Show version' + +complete -c octave -l built-in-docstrings-file -r -d 'Use docs for built-ins' +complete -c octave -s d -l debug -d 'Enter parser debugging mode' +complete -c octave -l debug-jit -d 'Enable JIT compiler debugging/tracing' +complete -c octave -l doc-cache-file -r -d 'Use doc cache file' +complete -c octave -s x -l echo-commands -d 'Echo commands as they are executed' +complete -c octave -l eval -x -d 'Evaluate code' +complete -c octave -l exec-path -r -d 'Set path for executing subprograms' +complete -c octave -l gui -n 'not __fish_seen_argument --long gui --long no-gui --long no-line-editing' -d 'Start the graphical user interface' +complete -c octave -l image-path -r -a '(.bmp .gif .jpg .jpeg .pbm .pcx .bgm .png .pnm .ppm .ras .tif .tiff .xwd)' -d 'Add path to head of image search path' +complete -c octave -l info-file -r -d 'Use top-level info file' +complete -c octave -l info-program -r -d 'Specify program for reading info files' +complete -c octave -s i -l interactive -d 'Force interactive behavior' +complete -c octave -l jit-compiler -d 'Enable the JIT compiler' +complete -c octave -l line-editing -n 'not __fish_seen_argument --long line-editing --long no-line-editing' -d 'Force readline use for command-line editing' +complete -c octave -l no-gui -n 'not __fish_seen_argument --long gui --long no-gui' -d 'Disable the graphical user interface' +complete -c octave -s H -l no-history -d 'Don\'t save commands to the history list' +complete -c octave -l no-init-file -d 'Don\'t read the ~/.octaverc or .octaverc files' +complete -c octave -l no-init-path -d 'Don\'t initialize function search path' +complete -c octave -l no-line-editing -n 'not __fish_seen_argument --long line-editing --long no-line-editing --long gui' -d 'Don\'t use readline for command-line editing' +complete -c octave -l no-site-file -d 'Don\'t read the site-wide octaverc file' +complete -c octave -s W -l no-window-system -d 'Disable window system, including graphics' +complete -c octave -s f -l norc -d 'Don\'t read any initialization files' +complete -c octave -s p -l path -r -d 'Add path to head of function search path' +complete -c octave -l persist -d 'Go interactive after --eval or reading' +complete -c octave -s q -l quiet --long-option silent -d 'Don\'t print message at startup' +complete -c octave -l texi-macros-file -r -d 'Use Texinfo macros for makeinfo command' +complete -c octave -l traditional -d 'Set variables for closer MATLAB compatibility' +complete -c octave -s V -l verbose -d 'Enable verbose output in some cases' diff --git a/share/completions/opam.fish b/share/completions/opam.fish index fb3f4c4f3..f2db2ec79 100644 --- a/share/completions/opam.fish +++ b/share/completions/opam.fish @@ -102,3 +102,22 @@ complete -f -c opam -n '__fish_opam_using_command admin' -a check -d "Check a lo complete -f -c opam -n '__fish_opam_using_command admin' -a depexts -d "Add external dependencies." complete -f -c opam -n '__fish_opam_using_command admin' -a make -d "Initialize a repo for serving files." complete -f -c opam -n '__fish_opam_using_command admin' -a stats -d "Compute statistics." + +# opam switch +set -l switchcommands create set remove export import reinstall list list-available show set-base set-description link +complete -c opam -f -n "__fish_seen_subcommand_from switch; and not __fish_seen_subcommand_from $switchcommands" -a create -d 'Create a new switch, and install the given compiler there' +complete -c opam -f -n "__fish_seen_subcommand_from switch; and not __fish_seen_subcommand_from $switchcommands" -a set -d 'Set the currently active switch' +complete -c opam -f -n "__fish_seen_subcommand_from switch; and not __fish_seen_subcommand_from $switchcommands" -a remove -d 'Remove the given switch from disk' +complete -c opam -n "__fish_seen_subcommand_from switch; and not __fish_seen_subcommand_from $switchcommands" -a export -d 'Save the current switch state to a file' +complete -c opam -n "__fish_seen_subcommand_from switch; and not __fish_seen_subcommand_from $switchcommands" -a import -d 'Import a saved switch state' +complete -c opam -f -n "__fish_seen_subcommand_from switch; and not __fish_seen_subcommand_from $switchcommands" -a reinstall -d 'Reinstall the given compiler switch and all its packages' +complete -c opam -f -n "__fish_seen_subcommand_from switch; and not __fish_seen_subcommand_from $switchcommands" -a list -d 'Lists installed switches' +complete -c opam -f -n "__fish_seen_subcommand_from switch; and not __fish_seen_subcommand_from $switchcommands" -a list-available -d 'Lists base packages that can be used to create a new switch' +complete -c opam -f -n "__fish_seen_subcommand_from switch; and not __fish_seen_subcommand_from $switchcommands" -a show -d 'Prints the name of the current switch' +complete -c opam -f -n "__fish_seen_subcommand_from switch; and not __fish_seen_subcommand_from $switchcommands" -a set-base -d 'Sets the packages forming the immutable base for the selected switch' +complete -c opam -f -n "__fish_seen_subcommand_from switch; and not __fish_seen_subcommand_from $switchcommands" -a link -d 'Sets a local alias for a given switch' + +complete -c opam -f -n "__fish_seen_subcommand_from switch; and __fish_seen_subcommand_from set" -a '(opam switch list --short)' +complete -c opam -f -n "__fish_seen_subcommand_from switch; and __fish_seen_subcommand_from remove" -a '(opam switch list --short)' + +complete -c opam -f -n "__fish_seen_subcommand_from switch; and __fish_seen_subcommand_from create" -a '(opam switch list-available --short)' diff --git a/share/completions/p4.fish b/share/completions/p4.fish index d5de08778..b83804d20 100644 --- a/share/completions/p4.fish +++ b/share/completions/p4.fish @@ -323,25 +323,25 @@ end ### global options -- can be used before any command ######################################################### -complete -c p4 -n __fish_p4_not_in_command -s b -x -d 'Specifies a batch size (number of arguments) to use when processing a command from a file with the -x argfile option' -complete -c p4 -n __fish_p4_not_in_command -s c -x -d 'Overrides any P4CLIENT setting with the specified client name' -complete -c p4 -n __fish_p4_not_in_command -s d -r -d 'Overrides any PWD setting (current working directory) and replaces it with the specified directory' -complete -c p4 -n __fish_p4_not_in_command -s I -d 'Specify that progress indicators, if available, are desired. This option is not compatible with the -s and -G options' -complete -c p4 -n __fish_p4_not_in_command -s G -d 'Causes all output (and batch input for form commands with -i) to be formatted as marshalled Python dictionary objects' -complete -c p4 -n __fish_p4_not_in_command -s H -x -a '(__fish_print_hostnames)' -d 'Overrides any P4HOST setting and replaces it with the specified hostname' -complete -c p4 -n __fish_p4_not_in_command -s p -x -d 'Overrides any P4PORT setting with the specified protocol:host:port' -complete -c p4 -n __fish_p4_not_in_command -s P -x -d 'Overrides any P4PASSWD setting with the specified password.' -complete -c p4 -n __fish_p4_not_in_command -s r -x -d 'Specifies the number of times to retry a command (notably, p4 sync) if the network times out.' -complete -c p4 -n __fish_p4_not_in_command -s s -d 'Prepends a descriptive field (for example, text:, info:, error:, exit:) to each line of output produced by a Perforce command. This is most often used when scripting.' -complete -c p4 -n __fish_p4_not_in_command -s u -x -a '(__fish_print_p4_users)' -d 'Overrides any P4USER, USER, or USERNAME setting with the specified user name.' -complete -c p4 -n __fish_p4_not_in_command -s x -r -d 'Instructs Perforce to read arguments, one per line, from the specified file. If file is a single hyphen (-), then standard input is read.' -complete -c p4 -n __fish_p4_not_in_command -s C -x -a '(__fish_print_encodings)' -d 'Overrides any P4CHARSET setting with the specified character set.' -complete -c p4 -n __fish_p4_not_in_command -s Q -x -a '(__fish_print_encodings)' -d 'Overrides any P4COMMANDCHARSET setting with the specified character set.' -complete -c p4 -n __fish_p4_not_in_command -s L -x -d 'This feature is reserved for system integrators.' -complete -c p4 -n __fish_p4_not_in_command -s z -x -d 'Causes output of many reporting commands to be in the same tagged format as that generated by p4 fstat.' -complete -c p4 -n __fish_p4_not_in_command -s q -d 'Quiet mode; suppress all informational message and report only warnings or errors.' -complete -c p4 -n __fish_p4_not_in_command -s V -d 'Displays the version of the p4 application and exits.' -complete -c p4 -n __fish_p4_not_in_command -s h -d 'Displays basic usage information and exits.' +complete -c p4 -n __fish_p4_not_in_command -s b -x -d 'Number of arguments when using -x flag' +complete -c p4 -n __fish_p4_not_in_command -s c -x -d 'Overrides P4CLIENT settings' +complete -c p4 -n __fish_p4_not_in_command -s d -r -d 'Overrides PWD settings' +complete -c p4 -n __fish_p4_not_in_command -s I -d 'Show process indicators' +complete -c p4 -n __fish_p4_not_in_command -s G -d 'python dict in/output' +complete -c p4 -n __fish_p4_not_in_command -s H -x -a '(__fish_print_hostnames)' -d 'Overrides P4HOST settings' +complete -c p4 -n __fish_p4_not_in_command -s p -x -d 'Overrides P4PORT settings' +complete -c p4 -n __fish_p4_not_in_command -s P -x -d 'Overrides P4PASSWD settings' +complete -c p4 -n __fish_p4_not_in_command -s r -x -d 'Number of retry attempts' +complete -c p4 -n __fish_p4_not_in_command -s s -d 'Prefix for each line' +complete -c p4 -n __fish_p4_not_in_command -s u -x -a '(__fish_print_p4_users)' -d 'Overrides P4USER/USER/USERNAME settings' +complete -c p4 -n __fish_p4_not_in_command -s x -r -d 'Read arguments from file' +complete -c p4 -n __fish_p4_not_in_command -s C -x -a '(__fish_print_encodings)' -d 'Overrides P4CHARSET settings' +complete -c p4 -n __fish_p4_not_in_command -s Q -x -a '(__fish_print_encodings)' -d 'Overrides P4COMMANDCHARSET settings' +complete -c p4 -n __fish_p4_not_in_command -s L -x -d 'Feature reserved for system integrators' +complete -c p4 -n __fish_p4_not_in_command -s z -x -d 'fstat output' +complete -c p4 -n __fish_p4_not_in_command -s q -d 'Quiet mode' +complete -c p4 -n __fish_p4_not_in_command -s V -d 'Display version' +complete -c p4 -n __fish_p4_not_in_command -s h -d 'Display help' ######################################################### ### sub-commands @@ -457,23 +457,23 @@ __fish_p4_register_command_option info -s s -d "Short output (removes informatio # clean __fish_p4_register_command_option clean -a '(__fish_print_p4_opened_files)' -__fish_p4_register_command_option clean -s a -d "Added files: Find files in the workspace that have no corresponding files in the depot and delete them" -__fish_p4_register_command_option clean -s d -d "Deleted files: Find those files in the depot that do not exist in your workspace and add them to the workspace" -__fish_p4_register_command_option clean -s e -d "Edited files: Find files in the workspace that have been modified and restore them to the last file version that has synced from the depot" -__fish_p4_register_command_option clean -s I -d "Do not perform any ignore checking; ignore any settings specified by P4IGNORE for added files" -__fish_p4_register_command_option clean -s l -d "Display output in local file syntax with relative paths, similar to the workspace-centric view of p4 status" -__fish_p4_register_command_option clean -s n -d "Preview the results of the operation without performing any action" +__fish_p4_register_command_option clean -s a -d "Delete files not in depot" +__fish_p4_register_command_option clean -s d -d "Restore deleted files" +__fish_p4_register_command_option clean -s e -d "Restore edited files" +__fish_p4_register_command_option clean -s I -d "Ignore P4IGNORE settings for added files" +__fish_p4_register_command_option clean -s l -d "Display output in local file syntax with relative paths" +__fish_p4_register_command_option clean -s n -d "Preview what would be done" # client, workspace @TODO: -Fs (only in -f), -c (only in -S stream) for a in client workspace __fish_p4_register_command_option $a -x -a '(__fish_print_p4_workspaces)' - __fish_p4_register_command_option $a -s f -d "Allows the last modification date, which is normally read-only, to be set" - __fish_p4_register_command_option $a -s d -f -a '(__fish_print_p4_workspaces)' -d "Delete the specified client workspace whether or not the workspace is owned by the user" + __fish_p4_register_command_option $a -s f -d "Allows the last modification date to be set" + __fish_p4_register_command_option $a -s d -f -a '(__fish_print_p4_workspaces)' -d "Delete client workspace even if not owned by user" # __fish_p4_register_command_option $a -a '-Fs' -d 'Deletes client with shelves (must follow -f)' __fish_p4_register_command_option $a -s F -a s -d 'Deletes client with shelves (must follow -f)' __fish_p4_register_command_option $a -s o -d "Write the client workspace spec to standard output" __fish_p4_register_command_option $a -s i -d "Read the client workspace spec from standard input" - __fish_p4_register_command_option $a -s c -x -a '(__fish_print_p4_workspace_changelists)' -d "When used with -S stream, displays the workspace spec that would have been created for a stream at the moment the change was submitted" + __fish_p4_register_command_option $a -s c -x -a '(__fish_print_p4_workspace_changelists)' -d "When used with -S stream, preview the workspace spec" __fish_p4_register_command_option $a -s s -d "Switch workspace view" __fish_p4_register_command_option $a -s t -x -d "Specify a client workspace Template" __fish_p4_register_command_option $a -l serverid -x -d "Forcefully delete workspace that is bound to another server" @@ -482,13 +482,13 @@ end # clients, workspaces @TODO -U and others are mutually exclusive for a in clients workspaces - __fish_p4_register_command_option $a -s a -d "List all client workspaces, not just workspaces bound to this server" - __fish_p4_register_command_option $a -s e -x -d "List only client workspaces matching filter (case-sensitive)" - __fish_p4_register_command_option $a -s E -x -d "List only client workspaces matching filter (case-insensitive)" - __fish_p4_register_command_option $a -s m -x -d "List only the first max client workspaces" - __fish_p4_register_command_option $a -s s -x -d "List only client workspaces bound to the specified serverID. On an edge server, the -s option defaults to the edge server’s serverID" + __fish_p4_register_command_option $a -s a -d "List all client workspaces" + __fish_p4_register_command_option $a -s e -x -d "List client workspaces matching filter (case-sensitive)" + __fish_p4_register_command_option $a -s E -x -d "List client workspaces matching filter (case-insensitive)" + __fish_p4_register_command_option $a -s m -x -d "List the first max client workspaces" + __fish_p4_register_command_option $a -s s -x -d "List client workspaces bound to the specified serverID" __fish_p4_register_command_option $a -s S -x -a '(__fish_print_p4_streams)' -d "List client workspaces associated with the specified stream" - __fish_p4_register_command_option $a -s t -d "Display the time as well as the date of the last update to the workspace" + __fish_p4_register_command_option $a -s t -d "Display time and date last update to the workspace" __fish_p4_register_command_option $a -s u -x -a '(__fish_print_p4_users)' -d "List only client workspaces owned by user" __fish_p4_register_command_option $a -s U -d "List only client workspaces unloaded with p4 unload" end @@ -500,15 +500,15 @@ end # sync @TODO --parallel has unique key-value pair syntax: --parallel=optq1=n,opt2=n,opt3=n,opt4=n __fish_p4_register_command_option sync -s f -d "Force sync, overwrite all unopened files" __fish_p4_register_command_option sync -s k -d "Keep existing workspace files, alias for p4 flush" -__fish_p4_register_command_option sync -s L -d "perform the sync on a list of valid file arguments in full depot syntax with a valid revision number" +__fish_p4_register_command_option sync -s L -d "Perform sync on a list of valid file arguments" __fish_p4_register_command_option sync -s m -x -d "Sync only the first max files specified" -__fish_p4_register_command_option sync -s n -d "Preview mode: Display the results of the sync without actually syncing" -__fish_p4_register_command_option sync -s N -d "Preview mode: Display network traffic estimates, don't actually sync" -__fish_p4_register_command_option sync -s p -d "Populate a client workspace, but do not update the have list" +__fish_p4_register_command_option sync -s n -d "Display sync results without actually syncing" +__fish_p4_register_command_option sync -s N -d "Display network traffic estimates without actually syncing" +__fish_p4_register_command_option sync -s p -d "Populate a client workspace, but don't update the have list" __fish_p4_register_command_option sync -l parallel -x -a '(__fish_print_p4_parallel_options)' -d "Specify options for parallel file transfer" __fish_p4_register_command_option sync -s q -d "Quiet operation: suppress normal output messages" -__fish_p4_register_command_option sync -s r -d "Reopen files that are mapped to new locations in the depot, in the new location" -__fish_p4_register_command_option sync -s s -d "Safe sync: Compare the content in your client workspace against what was last synced" +__fish_p4_register_command_option sync -s r -d "Reopen files mapped to new locations, in the new location" +__fish_p4_register_command_option sync -s s -d "Compare client workspace against what was last synced" # update @TODO # where @TODO @@ -534,7 +534,7 @@ __fish_p4_register_command_option add -s t -x -a '(__fish_print_p4_file_types)' # edit __fish_p4_register_command_option edit -s c -x -a '(__fish_print_p4_pending_changelists default)' -d "Changelist number" -__fish_p4_register_command_option edit -s k -d "Keep existing workspace files; mark the file as open for edit even if the file is not in the client view" +__fish_p4_register_command_option edit -s k -d "Keep existing workspace files; mark file as open for edit" __fish_p4_register_command_option edit -s n -d "Preview operation, don't change files" __fish_p4_register_command_option edit -s t -x -a '(__fish_print_p4_file_types)' -d "File type" @@ -558,9 +558,9 @@ __fish_p4_register_command_option edit -s t -x -a '(__fish_print_p4_file_types)' # change, changelist for a in change changelist __fish_p4_register_command_option $a -x -a '(__fish_print_p4_pending_changelists)' - __fish_p4_register_command_option $a -s s -d "Allows jobs to be assigned arbitrary status values on submission of the changelist, rather than the default status of closed" - __fish_p4_register_command_option $a -s f -d "Force operation (The -u and the -f options are mutually exclusive)" - __fish_p4_register_command_option $a -s u -d "Update a submitted changelist (The -u and the -f options are mutually exclusive)" + __fish_p4_register_command_option $a -s s -d "Allows jobs to be assigned any status values on submission" + __fish_p4_register_command_option $a -s f -d "Force operation" + __fish_p4_register_command_option $a -s u -d "Update a submitted changelist" __fish_p4_register_command_option $a -s O -x -a '(__fish_print_p4_pending_changelists)' -d "Changelist number" __fish_p4_register_command_option $a -s d -x -a '(__fish_print_p4_pending_changelists)' -d "Delete a changelist" __fish_p4_register_command_option $a -s o -d "Writes the changelist spec to standard output" @@ -571,10 +571,10 @@ end # changes, changelists for a in changes changelists - __fish_p4_register_command_option $a -s i -d "Include changelists that affected files that were integrated with the specified files" + __fish_p4_register_command_option $a -s i -d "Include changelists of integrated, affected files" __fish_p4_register_command_option $a -s t -d "Display the time as well as the date of each change" - __fish_p4_register_command_option $a -s l -d "List long output, with the full text of each changelist description" - __fish_p4_register_command_option $a -s L -d "List long output, with the full text of each changelist description truncated at 250 characters" + __fish_p4_register_command_option $a -s l -d "List long output, with full changelist" + __fish_p4_register_command_option $a -s L -d "List long output, with full changelist (truncated)" __fish_p4_register_command_option $a -s f -d "View restricted changes (requires admin permission)" __fish_p4_register_command_option $a -c c -x -a '(__fish_print_p4_workspace_changelists)' -d "List only changes made from the named client workspace" __fish_p4_register_command_option $a -c m -x -d "List only the highest numbered max changes" @@ -585,7 +585,7 @@ end # describe @TODO: -dc, -du __fish_p4_register_command_option describe -x -a '(__fish_print_p4_workspace_changelists)' -__fish_p4_register_command_option describe -s f -d 'Force the display of descriptions for restricted changelists' +__fish_p4_register_command_option describe -s f -d 'Force display of descriptions for restricted changelists' __fish_p4_register_command_option describe -s O -d 'Specify the original changelist number' __fish_p4_register_command_option describe -s s -d 'Short output without diffs' __fish_p4_register_command_option describe -s S -d 'Display shelved files with diffs' @@ -596,9 +596,9 @@ __fish_p4_register_command_option describe -s d -x -a '(__fish_print_p4_diff_opt # opened __fish_p4_register_command_option opened -s a -d "List opened files in all client workspaces" __fish_p4_register_command_option opened -s c -x -a '(__fish_print_p4_pending_changelists default)' -d "List the files in a pending changelist" -__fish_p4_register_command_option opened -s C -x -a '(__fish_print_p4_workspaces)' -d "List only files that are open in the specified client workspace" +__fish_p4_register_command_option opened -s C -x -a '(__fish_print_p4_workspaces)' -d "List files that are open in the specified client workspace" __fish_p4_register_command_option opened -s m -x -d "List only the first max open files" -__fish_p4_register_command_option opened -s s -d "Short output; do not output the revision number or file type" +__fish_p4_register_command_option opened -s s -d "Short output; don't output the revision number or file type" __fish_p4_register_command_option opened -s u -x -a '(__fish_print_p4_users)' -d "List only those files that were opened by user" __fish_p4_register_command_option opened -s x -d "List all files that have the +l filetype over all servers" @@ -611,31 +611,31 @@ __fish_p4_register_command_option reopen -s t -x -a '(__fish_print_p4_file_types # shelve __fish_p4_register_command_option shelve -a '(__fish_print_p4_opened_files)' -__fish_p4_register_command_option shelve -s a -x -a 'submitunchanged leaveunchanged' -d "Options: 'submitunchanged' shelves all files, 'leaveunchanged' shelves only changed files" +__fish_p4_register_command_option shelve -s a -x -a 'submitunchanged leaveunchanged' -d "Choose which files to shelve" __fish_p4_register_command_option shelve -s c -x -a '(__fish_print_p4_pending_changelists)' -d "Changelist number" __fish_p4_register_command_option shelve -s d -d 'Discard the shelved files' __fish_p4_register_command_option shelve -s f -d 'Force overwrite of shelved files' __fish_p4_register_command_option shelve -s i -d 'Read a changelist description from standard input' -__fish_p4_register_command_option shelve -s p -d "Promote a shelved change from an Edge server to a Commit server" -__fish_p4_register_command_option shelve -s r -d 'Replace all shelved files in the changelist with the files that are opened in your workspace' +__fish_p4_register_command_option shelve -s p -d "Promote shelved change from Edge server to Commit server" +__fish_p4_register_command_option shelve -s r -d 'Replace shelved files in changelist with opened files' # submit @TODO: parallel syntax __fish_p4_register_command_option submit -a '(__fish_print_p4_opened_files)' __fish_p4_register_command_option submit -s c -x -a '(__fish_print_p4_pending_changelists)' -d "Submit specific changelist" -__fish_p4_register_command_option submit -s d -x -d "Immediately submit the changelist with supplied description and bypass the interactive form" +__fish_p4_register_command_option submit -s d -x -d "Submit changelist and bypass interactive form" __fish_p4_register_command_option submit -s e -x -a '(__fish_print_p4_shelved_changelists)' -d "Submit specific shelved changelist" __fish_p4_register_command_option submit -s f -x -a '(__fish_print_p4_submit_options)' -d "Override the SubmitOptions setting in the p4 client form" __fish_p4_register_command_option submit -s i -d "Read a changelist specification from standard input" __fish_p4_register_command_option submit -l noretransfer -x -a '(__fish_print_p4_noretransfer_options)' __fish_p4_register_command_option submit -l parallel -x -a '(__fish_print_p4_parallel_options "submit")' -d "Specify options for parallel file transfer" -__fish_p4_register_command_option submit -s r -d "Reopen files for edit in the default changelist after submission" -__fish_p4_register_command_option submit -s s -d "Allows jobs to be assigned arbitrary status values on submission of the changelist" +__fish_p4_register_command_option submit -s r -d "Reopen files for edit in default changelist" +__fish_p4_register_command_option submit -s s -d "Allow jobs to be assigned arbitrary status values" # unshelve @TODO: Streams __fish_p4_register_command_option unshelve -s b -x -a '(__fish_print_p4_branches)' -d "Specifies a branch spec for unshelving from" __fish_p4_register_command_option unshelve -s c -x -a '(__fish_print_p4_pending_changelists)' -d "Changelist number into which to unshelve" __fish_p4_register_command_option unshelve -s f -d 'Force the overwriting of writable (but unopened) files' -__fish_p4_register_command_option unshelve -s n -d "Preview result of unshelve operation without restoring files to workspace" +__fish_p4_register_command_option unshelve -s n -d "Preview result of unshelve operation" __fish_p4_register_command_option unshelve -s P -x -a '(__fish_print_p4_streams)' -d "Unshelve to the specified parent stream" __fish_p4_register_command_option unshelve -s s -x -a '(__fish_print_p4_shelved_changelists)' -d "Specify the source shelved pending changelist number" __fish_p4_register_command_option unshelve -s S -x -a '(__fish_print_p4_streams)' -d "Specifies a stream spec for unshelving from" @@ -661,19 +661,19 @@ __fish_p4_register_command_option unshelve -s S -x -a '(__fish_print_p4_streams) # integ, integrate @TODO -s fromFile is based on -b branchname, try resolving for a in integ integrate - __fish_p4_register_command_option $a -s b -x -a '(__fish_print_p4_branches)' -d "Integrate the files using the sourceFile/targetFile mappings included in the branch view of branchname. If the toFiles argument is included, include only those target files in the branch view that match the pattern specified by toFiles" - __fish_p4_register_command_option $a -s n -d "Display the integrations this command would perform without actually performing them" - __fish_p4_register_command_option $a -s v -d "Open files for branching without copying toFiles into the client workspace" - __fish_p4_register_command_option $a -s c -x -a '(__fish_print_p4_pending_changelists)' -d "Open the toFiles for branch, integrate, or delete in the specified pending changelist" + __fish_p4_register_command_option $a -s b -x -a '(__fish_print_p4_branches)' -d "Integrate files using sourceFile/targetFile mappings" + __fish_p4_register_command_option $a -s n -d "Preview the integrations" + __fish_p4_register_command_option $a -s v -d "Open files for branching without copying toFiles" + __fish_p4_register_command_option $a -s c -x -a '(__fish_print_p4_pending_changelists)' -d "Open the toFiles in the specified pending changelist" __fish_p4_register_command_option $a -s q -d "Quiet mode" - __fish_p4_register_command_option $a -a -Di -d "f the source file has been deleted and re-added, revisions that precede the deletion will be considered to be part of the same source file" - __fish_p4_register_command_option $a -s f -d "Force the integration on all revisions of fromFile and toFile, even if some revisions have been integrated in the past" + __fish_p4_register_command_option $a -a -Di -d "If file is deleted and re-added, consider it the same file" + __fish_p4_register_command_option $a -s f -d "Force integration on all revisions of fromFile and toFile" __fish_p4_register_command_option $a -s h -d "Use the have revision" __fish_p4_register_command_option $a -s O -x -a '(__fish_print_p4_integrate_output_options)' -d "Specify output options" __fish_p4_register_command_option $a -s m -x -d "Limit the command to integrating only the first N files" __fish_p4_register_command_option $a -s R -x -a '(__fish_print_p4_integrate_resolve_options)' -d "Specify resolve options" __fish_p4_register_command_option $a -s s -r -d "Source file and revision" - __fish_p4_register_command_option $a -s r -r -d "Reverse the mappings in the branch view, integrating from the target files to the source files" + __fish_p4_register_command_option $a -s r -r -d "Reverse the mappings in the branch view" __fish_p4_register_command_option $a -s S -x -a '(__fish_print_p4_streams)' -d "Source stream" __fish_p4_register_command_option $a -s P -x -a '(__fish_print_p4_streams)' -d "Custom parent stream" end @@ -691,15 +691,15 @@ end # resolve __fish_p4_register_command_option resolve -s a -x -a '(__fish_print_p4_resolve_options a)' -d "Resolve automatically" -__fish_p4_register_command_option resolve -s A -x -a '(__fish_print_p4_resolve_options A)' -d "Constrain the type of resolve to branching, deletion, file type change, or move/rename" -__fish_p4_register_command_option resolve -s d -x -a '(__fish_print_p4_resolve_options d)' -d "Ignore specified differences in whitespace or line-ending convention" -__fish_p4_register_command_option resolve -s f -d "Allow already resolved, but not yet submitted, files to be resolved again" -__fish_p4_register_command_option resolve -s n -d "List the files that need resolving without actually performing the resolve" -__fish_p4_register_command_option resolve -s N -d "Preview the operation with additional information about any non-content resolve actions that are scheduled" -__fish_p4_register_command_option resolve -s o -d "Output the base file name and revision to be used during the resolve" +__fish_p4_register_command_option resolve -s A -x -a '(__fish_print_p4_resolve_options A)' -d "Constrain the type of resolve" +__fish_p4_register_command_option resolve -s d -x -a '(__fish_print_p4_resolve_options d)' -d "Ignore whitespace/line-ending convention" +__fish_p4_register_command_option resolve -s f -d "Re-resolve already resolved files if they're not submitted" +__fish_p4_register_command_option resolve -s n -d "List files that need resolving" +__fish_p4_register_command_option resolve -s N -d "Preview based on scheduled non-content resolve actions" +__fish_p4_register_command_option resolve -s o -d "Show base file name and revision on resolve" __fish_p4_register_command_option resolve -s t -d "Force a three-way merge, even on binary (non-text) files" -__fish_p4_register_command_option resolve -s v -d "Include conflict markers in the file for all changes between yours and base, and between theirs and base" -__fish_p4_register_command_option resolve -s c -x -a '(__fish_print_p4_workspace_changelists)' -d "Limit the scope of the resolve operation to the files opened in the specified changelist number" +__fish_p4_register_command_option resolve -s v -d "Include conflict markers in the file" +__fish_p4_register_command_option resolve -s c -x -a '(__fish_print_p4_workspace_changelists)' -d "Limit scope of resolve based on specified changelist number" # resolved @TODO # stream @TODO @@ -774,5 +774,5 @@ __fish_p4_register_command_option resolve -s c -x -a '(__fish_print_p4_workspace # set __fish_p4_register_command_option set -x -a '(__fish_print_p4_env_vars)' __fish_p4_register_command_option set -s q -d "Reduce the output" -__fish_p4_register_command_option set -s s -d "Set the value of the registry variable for the local machine" -__fish_p4_register_command_option set -s S -x -d "Set the value of the registry variables as used by the service" +__fish_p4_register_command_option set -s s -d "Set value of the registry variable for the local machine" +__fish_p4_register_command_option set -s S -x -d "Set value of the registry variables as used by the service" diff --git a/share/completions/pabcnetcclear.fish b/share/completions/pabcnetcclear.fish index 73caa9276..2d1af57ea 100644 --- a/share/completions/pabcnetcclear.fish +++ b/share/completions/pabcnetcclear.fish @@ -1,17 +1,20 @@ +# Completion for: PascalABC.NET 3.8.1 compiler + function __pabcnetcclear_generate_args --description 'Function to generate args' - set --local current_token (commandline --current-token --cut-at-cursor) - switch $current_token - case '/Debug:*' - echo -e $current_token"0\tEnable generation + set --local current_token (commandline --current-token --cut-at-cursor) + switch $current_token + case '/Debug:*' + echo -e $current_token"0\tEnable generation $current_token"1"\tDisable generation" - case '*' - echo -e "/Help\tShow help + case '*' + echo -e "/Help\tShow help /H\tShow help /?\tShow help /Debug\tGenerate a code debug info /output\tSpecify an executable name -/SearchDir\tSpecify a path to search units" - end +/SearchDir\tSpecify a path to search units +/define\tDefine a symbol" + end end complete --command pabcnetcclear --no-files --arguments '(__pabcnetcclear_generate_args)' diff --git a/share/completions/pg_dump.fish b/share/completions/pg_dump.fish index d35943560..688060590 100644 --- a/share/completions/pg_dump.fish +++ b/share/completions/pg_dump.fish @@ -3,13 +3,13 @@ complete -c pg_dump --no-files -a '(__fish_complete_pg_database)' # General options: complete -c pg_dump -s f -l file -r -d "Output file or directory name" complete -c pg_dump -s F -l format -x -a "p\t'Plain text' c\t'Custom format' d\t'Directory archive' t\t'Tar archive'" -d "Output file format" -complete -c pg_dump -s j -l jobs -x -d "Use this many parallel jobs to dump" +complete -c pg_dump -s j -l jobs -x -d "Number of parallel jobs to dump" complete -c pg_dump -s v -l verbose -d "Verbose mode" -complete -c pg_dump -s V -l version -d "Output version information, then exit" +complete -c pg_dump -s V -l version -d "Output version information" complete -c pg_dump -s Z -l compress -x -d "Compression level for compressed formats" complete -c pg_dump -l lock-wait-timeout -x -d "Fail after waiting TIMEOUT for a table lock" complete -c pg_dump -l no-sync -d "Do not wait for changes to be written safely to disk" -complete -c pg_dump -s '?' -l help -d "Show this help, then exit" +complete -c pg_dump -s '?' -l help -d "Show this help" # Options controlling the output content: complete -c pg_dump -s a -l data-only -d "Dump only the data, not the schema" @@ -47,8 +47,8 @@ complete -c pg_dump -l quote-all-identifiers -d "Quote all identifiers, even if complete -c pg_dump -l section -x -a "pre-data data post-data" -d "Dump named section (pre-data, data, or post-data)" complete -c pg_dump -l serializable-deferrable -d "Wait until the dump can run without anomalies" complete -c pg_dump -l snapshot -x -d "Use given snapshot for the dump" -complete -c pg_dump -l strict-names -d "Require table and/or schema include patterns to match at least one entity each" -complete -c pg_dump -l use-set-session-authorization -d "Use SET SESSION AUTHORIZATION commands instead of ALTER OWNER commands to set ownership" +complete -c pg_dump -l strict-names -d "Require table/schema include patterns to match entities" +complete -c pg_dump -l use-set-session-authorization -d "Use SET SESSION AUTHORIZATION instead of ALTER OWNER" # Connection options: complete -c pg_dump -s d -l dbname -x -a '(__fish_complete_pg_database)' -d "Database to dump" diff --git a/share/completions/pg_dumpall.fish b/share/completions/pg_dumpall.fish index 347474d2c..7ee3b54e2 100644 --- a/share/completions/pg_dumpall.fish +++ b/share/completions/pg_dumpall.fish @@ -3,9 +3,9 @@ complete -c pg_dumpall --no-files # General options: complete -c pg_dumpall -s f -l file -r -d "Output file name" complete -c pg_dumpall -s v -l verbose -d "Verbose mode" -complete -c pg_dumpall -s V -l version -d "Output version information, then exit" +complete -c pg_dumpall -s V -l version -d "Output version information" complete -c pg_dumpall -l lock-wait-timeout -x -d "Fail after waiting TIMEOUT for a table lock" -complete -c pg_dumpall -s '?' -l help -d "Show this help, then exit" +complete -c pg_dumpall -s '?' -l help -d "Show this help" # Options controlling the output content: complete -c pg_dumpall -s a -l data-only -d "Dump only the data, not the schema" @@ -35,7 +35,7 @@ complete -c pg_dumpall -l no-sync -d "Do not wait for changes to be written safe complete -c pg_dumpall -l no-tablespaces -d "Do not dump tablespace assignments" complete -c pg_dumpall -l no-unlogged-table-data -d "Do not dump unlogged table data" complete -c pg_dumpall -l quote-all-identifiers -d "Quote all identifiers, even if not key words" -complete -c pg_dumpall -l use-set-session-authorization -d "Use SET SESSION AUTHORIZATION commands instead of ALTER OWNER commands to set ownership" +complete -c pg_dumpall -l use-set-session-authorization -d "Use SET SESSION AUTHORIZATION instead of ALTER OWNER" # Connection options: complete -c pg_dumpall -s d -l dbname -x -a '(__fish_complete_pg_database)' -d "Database to dump" diff --git a/share/completions/pg_restore.fish b/share/completions/pg_restore.fish index 18abf654e..df8cdea85 100644 --- a/share/completions/pg_restore.fish +++ b/share/completions/pg_restore.fish @@ -4,8 +4,8 @@ complete -c pg_restore -s f -l file -a - -r -d "Output file name (- for stdout)" complete -c pg_restore -s F -l format -x -a "c\t'Custom format (pg_dump)' d\t'Directory archive' t\t'Tar archive'" -d "Backup file format (should be automatic)" complete -c pg_restore -s l -l list -d "Print summarized TOC of the archive" complete -c pg_restore -s v -l verbose -d "Verbose mode" -complete -c pg_restore -s V -l version -d "Output version information, then exit" -complete -c pg_restore -s '?' -l help -d "Show help, then exit" +complete -c pg_restore -s V -l version -d "Output version information" +complete -c pg_restore -s '?' -l help -d "Show help" # Options controlling the restore: complete -c pg_restore -s a -l data-only -d "Restore only the data, no schema" @@ -13,8 +13,8 @@ complete -c pg_restore -s c -l clean -d "Clean (drop) database objects before re complete -c pg_restore -s C -l create -d "Create the target database" complete -c pg_restore -s e -l exit-on-error -d "Exit on error, default is to continue" complete -c pg_restore -s I -l index -x -d "Restore named index" -complete -c pg_restore -s j -l jobs -x -d "Use this many parallel jobs to restore" -complete -c pg_restore -s L -l use-list -r -d "Use table of contents from this file for selecting/ordering output" +complete -c pg_restore -s j -l jobs -x -d "Number of parallel jobs to restore" +complete -c pg_restore -s L -l use-list -r -d "Use table of contents from this file" complete -c pg_restore -s n -l schema -x -d "Restore only objects in this schema" complete -c pg_restore -s N -l exclude-schema -x -d "Do not restore objects in this schema" complete -c pg_restore -s O -l no-owner -d "Skip restoration of object ownership" @@ -29,14 +29,14 @@ complete -c pg_restore -l disable-triggers -d "Disable triggers during data-only complete -c pg_restore -l enable-row-security -d "Enable row security" complete -c pg_restore -l if-exists -d "Use IF EXISTS when dropping objects" complete -c pg_restore -l no-comments -d "Do not restore comments" -complete -c pg_restore -l no-data-for-failed-tables -d "Do not restore data of tables that could not be created" +complete -c pg_restore -l no-data-for-failed-tables -d "Don't restore data of tables that could not be created" complete -c pg_restore -l no-publications -d "Do not restore publications" complete -c pg_restore -l no-security-labels -d "Do not restore security labels" complete -c pg_restore -l no-subscriptions -d "Do not restore subscriptions" complete -c pg_restore -l no-tablespaces -d "Do not restore tablespace assignments" complete -c pg_restore -l section -x -d "Restore named section (pre-data, data, or post-data)" -complete -c pg_restore -l strict-names -d "Require table and/or schema include patterns to match at least one entity each" -complete -c pg_restore -l use-set-session-authorization -d "Use SET SESSION AUTHORIZATION commands instead of ALTER OWNER commands to set ownership" +complete -c pg_restore -l strict-names -d "Require table/schema include patterns to match entities" +complete -c pg_restore -l use-set-session-authorization -d "Use SET SESSION AUTHORIZATION instead of ALTER OWNER" # Connection options: complete -c pg_restore -s h -l host -x -a '(__fish_print_hostnames)' -d "Database server host or socket directory" diff --git a/share/completions/powershell.fish b/share/completions/powershell.fish new file mode 100644 index 000000000..8fc3f5786 --- /dev/null +++ b/share/completions/powershell.fish @@ -0,0 +1,32 @@ +complete --command powershell --short-option '?' --old-option Help --description 'Show help' + +complete --command powershell --old-option PSConsoleFile --require-parameter \ + --description 'Load the specified PowerShell console file' +complete --command powershell --old-option Version --require-parameter --arguments '2.0 3.0' \ + --description 'Start the specified version of PowerShell' +complete --command powershell --old-option NoLogo --description 'Hides the copyright banner at startup' +complete --command powershell --old-option NoExit \ + --description 'Do not exit after running startup commands' +complete --command powershell --old-option Sta \ + --description 'Start PowerShell using a single-threaded apartment' +complete --command powershell --old-option Mta \ + --description 'Start PowerShell using a multi-threaded apartment' +complete --command powershell --old-option NoProfile --description 'Does not load the PowerShell profile' +complete --command powershell --old-option NonInteractive \ + --description 'Do not present an interactive prompt to the user' +complete --command powershell --old-option InputFormat --no-files --require-parameter \ + --arguments 'Text XML' --description 'Describe the format of data sent to PowerShell' +complete --command powershell --old-option OutputFormat --no-files --require-parameter \ + --arguments 'Text XML' --description 'Determine how output is formatted' +complete --command powershell --old-option WindowStyle --no-files --require-parameter \ + --arguments 'Normal Minimized Maximized Hidden' --description 'Set the window style for the session' +complete --command powershell --old-option EncodedCommand --require-parameter \ + --description 'Accept a base-64-encoded string version of a command' +complete --command powershell --old-option ConfigurationName --no-files --require-parameter \ + --description 'Specify a configuration endpoint in which PowerShell is run' +complete --command powershell --old-option File --require-parameter +complete --command powershell --old-option ExecutionPolicy --no-files --require-parameter \ + --arguments 'AllSigned Bypass Default RemoteSigned Restricted Undefined Unrestricted' \ + --description 'Sets the default execution policy for the current session' +complete --command powershell --old-option Command --no-files --require-parameter \ + --description 'Execute the specified commands at the PowerShell command prompt' diff --git a/share/completions/python.fish b/share/completions/python.fish index d0d0fbb1a..f97f1fd14 100644 --- a/share/completions/python.fish +++ b/share/completions/python.fish @@ -16,8 +16,8 @@ complete -c python -o vv -d "Even more verbose mode" complete -c python -s V -l version -d "Display version and exit" complete -c python -s W -x -d "Warning control" -a "ignore default all module once error" complete -c python -s x -d 'Skip first line of source, allowing use of non-Unix forms of #!cmd' -complete -c python -f -n "fish_is_nth_token 1" -k -a "(__fish_complete_suffix .py)" -complete -c python -f -n "fish_is_nth_token 1" -a - -d 'Read program from stdin' +complete -c python -f -n "__fish_is_nth_token 1" -k -a "(__fish_complete_suffix .py)" +complete -c python -f -n "__fish_is_nth_token 1" -a - -d 'Read program from stdin' # Version-specific completions # We have to detect this at runtime because pyenv etc can change diff --git a/share/completions/python2.fish b/share/completions/python2.fish index d4047915b..bdfc25bc2 100644 --- a/share/completions/python2.fish +++ b/share/completions/python2.fish @@ -13,8 +13,8 @@ complete -c python2 -s v -d "Verbose mode" complete -c python2 -s V -d "Display version and exit" complete -c python2 -s W -x -d "Warning control" -a "ignore default all module once error" complete -c python2 -s x -d 'Skip first line of source, allowing use of non-Unix forms of #!cmd' -complete -c python2 -f -n "fish_is_nth_token 1" -k -a "(__fish_complete_suffix .py)" -complete -c python2 -f -n "fish_is_nth_token 1" -a - -d 'Read program from stdin' +complete -c python2 -f -n "__fish_is_nth_token 1" -k -a "(__fish_complete_suffix .py)" +complete -c python2 -f -n "__fish_is_nth_token 1" -a - -d 'Read program from stdin' complete -c python2 -s 3 -d 'Warn about Python 3.x incompatibilities that 2to3 cannot trivially fix' complete -c python2 -s t -d "Warn on mixed tabs and spaces" complete -c python2 -s Q -x -a "old new warn warnall" -d "Division control" diff --git a/share/completions/python3.fish b/share/completions/python3.fish index 5b4447df5..27664ff45 100644 --- a/share/completions/python3.fish +++ b/share/completions/python3.fish @@ -13,8 +13,8 @@ complete -c python3 -s v -d "Verbose mode" complete -c python3 -s V -l version -d "Display version and exit" complete -c python3 -s W -x -d "Warning control" -a "ignore default all module once error" complete -c python3 -s x -d 'Skip first line of source, allowing use of non-Unix forms of #!cmd' -complete -c python3 -n "fish_is_nth_token 1" -k -fa "(__fish_complete_suffix .py)" -complete -c python3 -f -n "fish_is_nth_token 1" -a - -d 'Read program from stdin' +complete -c python3 -n "__fish_is_nth_token 1" -k -fa "(__fish_complete_suffix .py)" +complete -c python3 -f -n "__fish_is_nth_token 1" -a - -d 'Read program from stdin' complete -c python3 -s q -d 'Don\'t print version and copyright messages on interactive startup' complete -c python3 -s X -x -d 'Set implementation-specific option' -a 'faulthandler showrefcount tracemalloc showalloccount importtime dev utf8 pycache_prefex=PATH:' complete -c python3 -s b -d 'Issue warnings for possible misuse of `bytes` with `str`' diff --git a/share/completions/quilt.fish b/share/completions/quilt.fish index b9fc6823e..83544d649 100644 --- a/share/completions/quilt.fish +++ b/share/completions/quilt.fish @@ -1,35 +1,35 @@ # completions for quilt version 0.46 or similar -complete -c quilt -s h -d "show help" -complete -c quilt -l version -d "show version" -complete -c quilt -l quiltrc -r --no-file -d "specify the file to Run Control file to use" +complete -c quilt -s h -d "Show help" +complete -c quilt -l version -d "Show version" +complete -c quilt -l quiltrc -r --no-file -d "Give the config file to use" complete -c quilt -l trace -r --no-file -d "Runs the command in bash trace mode (-x). For internal debugging" -complete -c quilt -a add -r -d "Add one or more files to the topmost or named patch" -complete -c quilt -a annotate -r -d "Print an annotated listing of the specified file" +complete -c quilt -a add -r -d "Add file(s) to the topmost/named patch" +complete -c quilt -a annotate -r -d "Print an annotated listing of the given file" complete -c quilt -a applied -r -d "Print a list of applied patches" -complete -c quilt -a delete -r -d "Remove the specified or topmost patch from the series file" -complete -c quilt -a diff -r -d "Produces a diff of the specified file(s) in the topmost or specified patch" -complete -c quilt -a edit -r -d "Edit the specified file(s) in $EDITOR" -complete -c quilt -a files -r -d "Print the list of files that the topmost or specified patch changes" -complete -c quilt -a fold -r -d "Integrate the patch read from standard input into the topmost patch" -complete -c quilt -a fork -r --no-file -d " Fork the topmost patch" -complete -c quilt -a graph -r --no-file -d "Generate a dot(1) directed graph showing the dependencies between applied patches" -complete -c quilt -a grep -r --no-file -d "Grep through the source files, recursively, skipping patches and quilt meta-information" -complete -c quilt -a header -r --no-file -d " Print or change the header of the topmost or specified patch" +complete -c quilt -a delete -r -d "Remove the topmost/given patch from the series file" +complete -c quilt -a diff -r -d "Produces a diff of the given file(s) in the topmost/given patch" +complete -c quilt -a edit -r -d "Edit the given file(s) in $EDITOR" +complete -c quilt -a files -r -d "Lists files that the topmost/given patch changes" +complete -c quilt -a fold -r -d "Integrate the patch read from standard input into the topmost patch" +complete -c quilt -a fork -r --no-file -d "Fork the topmost patch" +complete -c quilt -a graph -r --no-file -d "Generates a dot directed graph of patch dependencies" +complete -c quilt -a grep -r --no-file -d "Grep through source files recursively" +complete -c quilt -a header -r --no-file -d "Print/change the header of the topmost/given patch" complete -c quilt -a import -r -d "Import external patches" -complete -c quilt -a mail -r -d "Create mail messages from all patches in the series file, and either store or send them" -complete -c quilt -a new -r -d "Create a new patch with the specified file name, and insert it after the topmost patch" -complete -c quilt -a next -r -d "Print the name of the next patch after the specified or topmost patch in the series file" -complete -c quilt -a patches -r -d "Print the list of patches that modify the specified file" -complete -c quilt -a pop -r -d "Remove patch(es) from the stack of applied patches" -complete -c quilt -a previous -r -d "Print the name of the previous patch before the specified or topmost patch in the series file" +complete -c quilt -a mail -r -d "Create mail messages from patches in the series file, stores/sends them" +complete -c quilt -a new -r -d "Creates new patch with the given name, inserts it after topmost patch" +complete -c quilt -a next -r -d "Prints name of patch after the topmost/given patch in the series file" +complete -c quilt -a patches -r -d "Print the list of patches that modify the given file" +complete -c quilt -a pop -r -d "Remove patch(es) from the stack of applied patches" +complete -c quilt -a previous -r -d "Prints name of patch before the topmost/given patch in the series file" complete -c quilt -a push -r -d "Apply patch(es) from the series file" -complete -c quilt -a refresh -r -d "Refreshes the specified patch, or the topmost patch by default" -complete -c quilt -a remove -r -d "Remove one or more files from the topmost or named patch" -complete -c quilt -a rename -r -d "Rename the topmost or named patch" +complete -c quilt -a refresh -r -d "Refresh the given patch, or the topmost patch by default" +complete -c quilt -a remove -r -d "Remove one or more files from the topmost/named patch" +complete -c quilt -a rename -r -d "Rename the topmost/named patch" complete -c quilt -a series -r --no-file -d "Print the names of all patches in the series file" -complete -c quilt -a setup -r -d " Initializes a source tree from an rpm spec file or a quilt series file" -complete -c quilt -a snapshot -r --no-file -d " Take a snapshot of the current working state" -complete -c quilt -a top -d "Print the name of the topmost patch on the current stack of applied patches" -complete -c quilt -a unapplied -r -d "Print a list of patches that are not applied, or all patches that follow the specified patch in the series file" -complete -c quilt -a upgrade -d "Upgrade the meta-data in a working tree from an old version of quilt to the current version" +complete -c quilt -a setup -r -d "Initializes a source tree from an rpm spec or a quilt series file" +complete -c quilt -a snapshot -r --no-file -d "Take a snapshot of the current working state" +complete -c quilt -a top -d "Prints name of the topmost patch in the current stack of applied patches" +complete -c quilt -a unapplied -r -d "List patches not applied or patches that follow the patch in the series file" +complete -c quilt -a upgrade -d "Upgrade meta-data in a working tree to the current version of quilt" diff --git a/share/completions/rc-status.fish b/share/completions/rc-status.fish new file mode 100644 index 000000000..9471e651c --- /dev/null +++ b/share/completions/rc-status.fish @@ -0,0 +1,20 @@ +set -l levels '(set -l p /etc/runlevels/*; string replace /etc/runlevels "" $p)' + +#disable file listing +complete -f rc-status +complete -c rc-status -n "test (__fish_number_of_cmd_args_wo_opts) = 1" \ + -xa "$levels" + +complete -c rc-status -s h -l help -d 'Display the help output' +complete -c rc-status -s a -l all -d 'Show services from all run levels' +complete -c rc-status -s f -l format -d 'format status to be parsable' +complete -c rc-status -s l -l list -d 'Show list of run levels' +complete -c rc-status -s r -l runlevel -d 'Show the name of the current runlevel' +complete -c rc-status -s m -l manual -d 'Show manually started services' +complete -c rc-status -s s -l servicelist 'Show service list' +complete -c rc-status -s S -l supervised 'Show supervised services' +complete -c rc-status -s u -l unused 'Show services not assigned to any runlevel' +complete -c rc-status -s v -l version 'Display software version' +complete -c rc-status -s q -l quiet 'Run quietly' +complete -c rc-status -s C -l nocolor 'Disable color output' +complete -c rc-status -s V -l version 'Display software version' diff --git a/share/completions/reg.fish b/share/completions/reg.fish new file mode 100644 index 000000000..fccfe565e --- /dev/null +++ b/share/completions/reg.fish @@ -0,0 +1,155 @@ +function __reg_add_complete_args -a previous_token + if test "$previous_token" = /t + echo 'REG_SZ +REG_MULTI_SZ +REG_DWORD_BIG_ENDIAN +REG_DWORD +REG_BINARY +REG_DWORD_LITTLE_ENDIAN +REG_LINK +REG_FULL_RESOURCE_DESCRIPTOR +REG_EXPAND_SZ' + return + end + + if not __fish_seen_argument -w v -w ve + echo -e '/v\tSpecify the name of the add registry entry +/ve\tSpecify that the added registry entry has a null value' + end + + echo -e '/t\tSpecify the type for the registry entry +/s\tSpecify the character to be used +/d\tSpecify the data for the new registry entry +/f\tAdd the registry entry without prompting for confirmation +/?\tShow help' +end + +function __reg_compare_complete_args + if not __fish_seen_argument -w v -w ve + echo -e '/v\tSpecify the value name +/ve\tSpecify that only entries that have a value name of null should be compared' + end + + if not __fish_seen_argument -w oa -w od -w os -w on + echo -e '/oa\tSpecify that all differences and matches are displayed +/od\tSpecify that only differences are displayed +/os\tSpecify that only matches are displayed +/on\tSpecify that nothing is displayed' + end + + echo -e '/s\tCompare all subkeys and entries recursively +/?\tShow help' +end + +function __reg_copy_complete_args + echo -e '/s\tCopy all subkeys and entries under the specified subkey +/f\tCopy the subkey without prompting for confirmation +/?\tShow help' +end + +function __reg_delete_complete_args + if not __fish_seen_argument -w v -w ve -w va + echo -e '/v\tDelete a specific entry under the subkey +/ve\tSpecify that only entries that have no value will be deleted +/va\tDelete all entries under the specified subkey' + end + + echo -e '/f\tDelete the existing registry subkey or entry without asking for confirmation +/?\tShow help' +end + +function __reg_export_complete_args + echo -e '/y\tOverwrite any existing file with the name filename without prompting for confirmation +/?\tShow help' +end + +function __reg_query_complete_args -a previous_token + if test "$previous_token" = /t + echo 'REG_SZ +REG_MULTI_SZ +REG_EXPAND_SZ +REG_DWORD +REG_BINARY +REG_NONE' + return + end + + if not __fish_seen_argument -w v -w ve + echo -e '/v\tSpecify the registry value name +/ve\tRun a query for value names that are empty' + end + + if not __fish_seen_argument -w k -w d + echo -e '/k\tSpecify to search in key names only +/d\tSpecify to search in data only' + end + + echo -e '/se\tSpecify the single value separator +/f\tSpecify the data or pattern to search for +/c\tSpecify that the query is case sensitive +/e\tSpecify to return only exact matches +/t\tSpecify registry types to search +/z\tSpecify to include the numeric equivalent for the registry type in search results +/?\tShow help' +end + +function __reg_save_complete_args + echo -e '/y\tOverwrite an existing file with the name filename without prompting for confirmation +/?\tShow help' +end + +function __reg_complete_args -d 'Function to generate args' + set -l previous_token (commandline -oc)[-1] + + if __fish_seen_subcommand_from add + __reg_add_complete_args $previous_token + else if __fish_seen_subcommand_from compare + __reg_compare_complete_args + else if __fish_seen_subcommand_from copy + __reg_copy_complete_args + else if __fish_seen_subcommand_from delete + __reg_delete_complete_args + else if __fish_seen_subcommand_from export + __reg_export_complete_args + else if __fish_seen_subcommand_from query + __reg_query_complete_args $previous_token + else if __fish_seen_subcommand_from save + __reg_save_complete_args + end +end + +complete -c reg -f -a '(__reg_complete_args)' + +complete -c reg -f \ + -n 'not __fish_seen_subcommand_from add compare copy delete export import load query restore save unload' -a add \ + -d 'Add a new subkey or entry' +complete -c reg -f \ + -n 'not __fish_seen_subcommand_from add compare copy delete export import load query restore save unload' -a compare \ + -d 'Compare specified registry subkeys or entries' +complete -c reg -f \ + -n 'not __fish_seen_subcommand_from add compare copy delete export import load query restore save unload' -a copy \ + -d 'Copy a registry entry' +complete -c reg -f \ + -n 'not __fish_seen_subcommand_from add compare copy delete export import load query restore save unload' -a delete \ + -d 'Delete a subkey or entries' +complete -c reg -f \ + -n 'not __fish_seen_subcommand_from add compare copy delete export import load query restore save unload' -a export \ + -d 'Copy the specified subkeys, entries, and values of the local computer into a file' +complete -c reg -f \ + -n 'not __fish_seen_subcommand_from add compare copy delete export import load query restore save unload' -a import \ + -d 'Copy the contents of a file that contains registry data into the registry of the local computer' +complete -c reg -f \ + -n 'not __fish_seen_subcommand_from add compare copy delete export import load query restore save unload' -a load \ + -d 'Write saved subkeys and entries into a different subkey in the registry' +complete -c reg -f \ + -n 'not __fish_seen_subcommand_from add compare copy delete export import load query restore save unload' -a query \ + -d 'Return a list of the next tier of subkeys and entries' +complete -c reg -f \ + -n 'not __fish_seen_subcommand_from add compare copy delete export import load query restore save unload' -a restore \ + -d 'Write saved subkeys and entries back' +complete -c reg -f \ + -n 'not __fish_seen_subcommand_from add compare copy delete export import load query restore save unload' -a save \ + -d 'Save a copy of specified subkeys, entries, and values of the registry in a specified file' +complete -c reg -f \ + -n 'not __fish_seen_subcommand_from add compare copy delete export import load query restore save unload' -a unload \ + -d 'Remove a section of the registry that was loaded using the reg load operation' diff --git a/share/completions/rustup.fish b/share/completions/rustup.fish index 66ae416fe..217ad8ca1 100644 --- a/share/completions/rustup.fish +++ b/share/completions/rustup.fish @@ -1,5 +1,3 @@ -complete -c rustup - set -l subcmds \ show \ update \ @@ -230,7 +228,7 @@ complete -c rustup -n __fish_should_complete_switches -s v -l verbose complete -c rustup -n __fish_should_complete_switches -s h -l help complete -c rustup -n __fish_should_complete_switches -s V -l version -complete -c rustup -n "fish_is_nth_token 1" -xa "$subcmds" +complete -c rustup -n "__fish_is_nth_token 1" -xa "$subcmds" complete -c rustup -n "__fish_prev_arg_in default" -xa "$__rustup_toolchains_short $__rustup_toolchains" complete -c rustup -n "__fish_prev_arg_in toolchain" -xa "add install list remove uninstall link help" diff --git a/share/completions/s3cmd.fish b/share/completions/s3cmd.fish index 5283ed9cb..3c316725b 100644 --- a/share/completions/s3cmd.fish +++ b/share/completions/s3cmd.fish @@ -13,49 +13,49 @@ complete -c s3cmd -f -n __s3cmd_is_valid_remote_path -a "(s3cmd ls (commandline complete -c s3cmd -f -n __s3cmd_is_remote_path # Suppress file completions for initial command -complete -c s3cmd -n "fish_is_nth_token 1" -f +complete -c s3cmd -n "__fish_is_nth_token 1" -f # Available commands -complete -c s3cmd -n "fish_is_nth_token 1" -a mb -d 'Make bucket' -complete -c s3cmd -n "fish_is_nth_token 1" -a rb -d 'Remove bucket' -complete -c s3cmd -n "fish_is_nth_token 1" -a ls -d 'List objects or buckets' -complete -c s3cmd -n "fish_is_nth_token 1" -a la -d 'List all object in all buckets' -complete -c s3cmd -n "fish_is_nth_token 1" -a put -d 'Put file into bucket' -complete -c s3cmd -n "fish_is_nth_token 1" -a get -d 'Get file from bucket' -complete -c s3cmd -n "fish_is_nth_token 1" -a del -d 'Delete file from bucket' -complete -c s3cmd -n "fish_is_nth_token 1" -a rm -d 'Delete file from bucket (alias for del)' -complete -c s3cmd -n "fish_is_nth_token 1" -a restore -d 'Restore file from Glacier storage' -complete -c s3cmd -n "fish_is_nth_token 1" -a sync -d 'Synchronize a directory tree to S3' -complete -c s3cmd -n "fish_is_nth_token 1" -a du -d 'Disk usage by buckets' -complete -c s3cmd -n "fish_is_nth_token 1" -a info -d 'Get various information about Buckets or Files' -complete -c s3cmd -n "fish_is_nth_token 1" -a cp -d 'Copy object' -complete -c s3cmd -n "fish_is_nth_token 1" -a modify -d 'Modify object metadata' -complete -c s3cmd -n "fish_is_nth_token 1" -a mv -d 'Move object' -complete -c s3cmd -n "fish_is_nth_token 1" -a setacl -d 'Modify Access control list for Bucket or Files' -complete -c s3cmd -n "fish_is_nth_token 1" -a setpolicy -d 'Modify Bucket Policy' -complete -c s3cmd -n "fish_is_nth_token 1" -a delpolicy -d 'Delete Bucket Policy' -complete -c s3cmd -n "fish_is_nth_token 1" -a setcors -d 'Modify Bucket CORS' -complete -c s3cmd -n "fish_is_nth_token 1" -a delcors -d 'Delete Bucket CORS' -complete -c s3cmd -n "fish_is_nth_token 1" -a payer -d 'Modify Bucket Requester Pays policy' -complete -c s3cmd -n "fish_is_nth_token 1" -a multipart -d 'Show multipart uploads' -complete -c s3cmd -n "fish_is_nth_token 1" -a abortmp -d 'Abort a multipart upload' -complete -c s3cmd -n "fish_is_nth_token 1" -a listmp -d 'List parts of a multipart upload' -complete -c s3cmd -n "fish_is_nth_token 1" -a accesslog -d 'Enable/disable bucket access logging' -complete -c s3cmd -n "fish_is_nth_token 1" -a sign -d 'Sign arbitrary string using the secret key' -complete -c s3cmd -n "fish_is_nth_token 1" -a signurl -d 'Sign an S3 URL to provide limited public access with expiry' -complete -c s3cmd -n "fish_is_nth_token 1" -a fixbucket -d 'Fix invalid file names in a bucket' -complete -c s3cmd -n "fish_is_nth_token 1" -a ws-create -d 'Create Website from bucket' -complete -c s3cmd -n "fish_is_nth_token 1" -a ws-delete -d 'Delete Website' -complete -c s3cmd -n "fish_is_nth_token 1" -a ws-info -d 'Info about Website' -complete -c s3cmd -n "fish_is_nth_token 1" -a expire -d 'Set or delete expiration rule for the bucket' -complete -c s3cmd -n "fish_is_nth_token 1" -a setlifecycle -d 'Upload a lifecycle policy for the bucket' -complete -c s3cmd -n "fish_is_nth_token 1" -a dellifecycle -d 'Remove a lifecycle policy for the bucket' -complete -c s3cmd -n "fish_is_nth_token 1" -a cflist -d 'List CloudFront distribution points' -complete -c s3cmd -n "fish_is_nth_token 1" -a cfinfo -d 'Display CloudFront distribution point parameters' -complete -c s3cmd -n "fish_is_nth_token 1" -a cfcreate -d 'Create CloudFront distribution point' -complete -c s3cmd -n "fish_is_nth_token 1" -a cfdelete -d 'Delete CloudFront distribution point' -complete -c s3cmd -n "fish_is_nth_token 1" -a cfmodify -d 'Change CloudFront distribution point parameters' -complete -c s3cmd -n "fish_is_nth_token 1" -a cfinvalinfo -d 'Display CloudFront invalidation request(s) status' +complete -c s3cmd -n "__fish_is_nth_token 1" -a mb -d 'Make bucket' +complete -c s3cmd -n "__fish_is_nth_token 1" -a rb -d 'Remove bucket' +complete -c s3cmd -n "__fish_is_nth_token 1" -a ls -d 'List objects or buckets' +complete -c s3cmd -n "__fish_is_nth_token 1" -a la -d 'List all object in all buckets' +complete -c s3cmd -n "__fish_is_nth_token 1" -a put -d 'Put file into bucket' +complete -c s3cmd -n "__fish_is_nth_token 1" -a get -d 'Get file from bucket' +complete -c s3cmd -n "__fish_is_nth_token 1" -a del -d 'Delete file from bucket' +complete -c s3cmd -n "__fish_is_nth_token 1" -a rm -d 'Delete file from bucket (alias for del)' +complete -c s3cmd -n "__fish_is_nth_token 1" -a restore -d 'Restore file from Glacier storage' +complete -c s3cmd -n "__fish_is_nth_token 1" -a sync -d 'Synchronize a directory tree to S3' +complete -c s3cmd -n "__fish_is_nth_token 1" -a du -d 'Disk usage by buckets' +complete -c s3cmd -n "__fish_is_nth_token 1" -a info -d 'Get various information about Buckets or Files' +complete -c s3cmd -n "__fish_is_nth_token 1" -a cp -d 'Copy object' +complete -c s3cmd -n "__fish_is_nth_token 1" -a modify -d 'Modify object metadata' +complete -c s3cmd -n "__fish_is_nth_token 1" -a mv -d 'Move object' +complete -c s3cmd -n "__fish_is_nth_token 1" -a setacl -d 'Modify Access control list for Bucket or Files' +complete -c s3cmd -n "__fish_is_nth_token 1" -a setpolicy -d 'Modify Bucket Policy' +complete -c s3cmd -n "__fish_is_nth_token 1" -a delpolicy -d 'Delete Bucket Policy' +complete -c s3cmd -n "__fish_is_nth_token 1" -a setcors -d 'Modify Bucket CORS' +complete -c s3cmd -n "__fish_is_nth_token 1" -a delcors -d 'Delete Bucket CORS' +complete -c s3cmd -n "__fish_is_nth_token 1" -a payer -d 'Modify Bucket Requester Pays policy' +complete -c s3cmd -n "__fish_is_nth_token 1" -a multipart -d 'Show multipart uploads' +complete -c s3cmd -n "__fish_is_nth_token 1" -a abortmp -d 'Abort a multipart upload' +complete -c s3cmd -n "__fish_is_nth_token 1" -a listmp -d 'List parts of a multipart upload' +complete -c s3cmd -n "__fish_is_nth_token 1" -a accesslog -d 'Enable/disable bucket access logging' +complete -c s3cmd -n "__fish_is_nth_token 1" -a sign -d 'Sign arbitrary string using the secret key' +complete -c s3cmd -n "__fish_is_nth_token 1" -a signurl -d 'Sign an S3 URL to provide limited public access with expiry' +complete -c s3cmd -n "__fish_is_nth_token 1" -a fixbucket -d 'Fix invalid file names in a bucket' +complete -c s3cmd -n "__fish_is_nth_token 1" -a ws-create -d 'Create Website from bucket' +complete -c s3cmd -n "__fish_is_nth_token 1" -a ws-delete -d 'Delete Website' +complete -c s3cmd -n "__fish_is_nth_token 1" -a ws-info -d 'Info about Website' +complete -c s3cmd -n "__fish_is_nth_token 1" -a expire -d 'Set or delete expiration rule for the bucket' +complete -c s3cmd -n "__fish_is_nth_token 1" -a setlifecycle -d 'Upload a lifecycle policy for the bucket' +complete -c s3cmd -n "__fish_is_nth_token 1" -a dellifecycle -d 'Remove a lifecycle policy for the bucket' +complete -c s3cmd -n "__fish_is_nth_token 1" -a cflist -d 'List CloudFront distribution points' +complete -c s3cmd -n "__fish_is_nth_token 1" -a cfinfo -d 'Display CloudFront distribution point parameters' +complete -c s3cmd -n "__fish_is_nth_token 1" -a cfcreate -d 'Create CloudFront distribution point' +complete -c s3cmd -n "__fish_is_nth_token 1" -a cfdelete -d 'Delete CloudFront distribution point' +complete -c s3cmd -n "__fish_is_nth_token 1" -a cfmodify -d 'Change CloudFront distribution point parameters' +complete -c s3cmd -n "__fish_is_nth_token 1" -a cfinvalinfo -d 'Display CloudFront invalidation request(s) status' # Created against s3cmd version 2.0 complete -c s3cmd -s h -l help -d 'Show help and exit' diff --git a/share/completions/sass-convert.fish b/share/completions/sass-convert.fish index 6f45e7154..bdda9be76 100644 --- a/share/completions/sass-convert.fish +++ b/share/completions/sass-convert.fish @@ -9,45 +9,45 @@ # -F, --from FORMAT The format to convert from. Can be css, scss, sass. # By default, this is inferred from the input filename. # If there is none, defaults to css. -complete -c sass-convert -s F -l from -x -a "css scss sass" -d "The format to convert from. Can be css, scss, sass. By default, this is inferred from the input filename. If there is none, defaults to css." +complete -c sass-convert -s F -l from -x -a "css scss sass" -d "The format to convert from" # -T, --to FORMAT The format to convert to. Can be scss or sass. # By default, this is inferred from the output filename. # If there is none, defaults to sass. -complete -c sass-convert -s T -l to -x -a "scss sass" -d "The format to convert to. Can be scss or sass. By default, this is inferred from the output filename. If there is none, defaults to sass." +complete -c sass-convert -s T -l to -x -a "scss sass" -d "The format to convert to" # -i, --in-place Convert a file to its own syntax. # This can be used to update some deprecated syntax. -complete -c sass-convert -s i -l in-place -d "Convert a file to its own syntax. This can be used to update some deprecated syntax." +complete -c sass-convert -s i -l in-place -d "Convert a file to its own syntax" # -R, --recursive Convert all the files in a directory. Requires --from and --to. -complete -c sass-convert -s R -l recursive -d "Convert all the files in a directory. Requires --from and --to." +complete -c sass-convert -s R -l recursive -d "Convert all the files in a directory" # -?, -h, --help Show this help message. -complete -c sass-convert -s '?' -s h -l help -f -d "Show help message." +complete -c sass-convert -s '?' -s h -l help -f -d "Show help message" # -v, --version Print the Sass version. -complete -c sass-convert -s v -l version -f -d "Print the Sass version." +complete -c sass-convert -s v -l version -f -d "Print the Sass version" # Style: # --dasherize Convert underscores to dashes. -complete -c sass-convert -l dasherize -d "Convert underscores to dashes." +complete -c sass-convert -l dasherize -d "Convert underscores to dashes" # --indent NUM How many spaces to use for each level of indentation. Defaults to 2. # "t" means use hard tabs. -complete -c sass-convert -l indent -x -d "How many spaces to use for each level of indentation. Defaults to 2. 't' means use hard tabs." +complete -c sass-convert -l indent -x -d "How many spaces to use for each level of indentation" # --old Output the old-style ":prop val" property syntax. # Only meaningful when generating Sass. -complete -c sass-convert -l old -d "Output the old-style ':prop val' property syntax. Only meaningful when generating Sass." +complete -c sass-convert -l old -d "Output the old-style ':prop val' property syntax" # Input and Output: # -s, --stdin Read input from standard input instead of an input file. # This is the default if no input file is specified. Requires --from. -complete -c sass-convert -s s -l stdin -d "Read input from standard input instead of an input file. This is the default if no input file is specified. Requires --from." +complete -c sass-convert -s s -l stdin -d "Read input from standard input instead of an input file" # -E, --default-encoding ENCODING Specify the default encoding for input files. -complete -c sass-convert -s E -l default-encoding -x -d "Specify the default encoding for input files." +complete -c sass-convert -s E -l default-encoding -x -d "Specify the default encoding for input files" # --unix-newlines Use Unix-style newlines in written files. # Always true on Unix. -complete -c sass-convert -l unix-newlines -d "Use Unix-style newlines in written files. Always true on Unix." +complete -c sass-convert -l unix-newlines -d "Use Unix-style newlines in written files" # Miscellaneous: # --cache-location PATH The path to save parsed Sass files. Defaults to .sass-cache. -complete -c sass-convert -l cache-location -r -d "The path to save parsed Sass files. Defaults to .sass-cache." +complete -c sass-convert -l cache-location -r -d "The path to save parsed Sass files" # -C, --no-cache Don't cache to sassc files. -complete -c sass-convert -s C -l no-cache -d "Don't cache to sassc files." +complete -c sass-convert -s C -l no-cache -d "Don't cache to sassc files" # --trace Show a full Ruby stack trace on error -complete -c sass-convert -l trace -d "Show a full Ruby stack trace on error." +complete -c sass-convert -l trace -d "Show a full Ruby stack trace on error" diff --git a/share/completions/sass.fish b/share/completions/sass.fish index 95a2c1441..1c7421ff7 100644 --- a/share/completions/sass.fish +++ b/share/completions/sass.fish @@ -5,36 +5,36 @@ # Common Options: # -I, --load-path PATH Specify a Sass import path. -complete -c sass -s I -l load-path -r -d "Specify a Sass import path." +complete -c sass -s I -l load-path -r -d "Specify a import path" # -r, --require LIB Require a Ruby library before running Sass. -complete -c sass -s r -l require -x -d "Require a Ruby library before running Sass." +complete -c sass -s r -l require -x -d "Require a Ruby library before running" # --compass Make Compass imports available and load project configuration. -complete -c sass -l compass -d "Make Compass imports available and load project configuration." +complete -c sass -l compass -d "Enable Compass imports and load project configuration" # -t, --style NAME Output style. Can be nested (default), compact, compressed, or expanded. -complete -c sass -s t -l style -x -a "nested compact compressed expanded" -d "Output style. Can be nested (default), compact, compressed, or expanded." +complete -c sass -s t -l style -x -a "nested compact compressed expanded" -d "Output style" # -?, -h, --help Show this help message. -complete -c sass -s '?' -s h -l help -f -d "Show help message." +complete -c sass -s '?' -s h -l help -f -d "Show help message" # -v, --version Print the Sass version. -complete -c sass -s v -l version -f -d "Print the Sass version." +complete -c sass -s v -l version -f -d "Print the version" # Watching and Updating: # --watch Watch files or directories for changes. # The location of the generated CSS can be set using a colon: # sass --watch input.sass:output.css # sass --watch input-dir:output-dir -complete -c sass -l watch -d "Watch files or directories for changes. The location of the generated CSS can be set using a colon: input.sass:output.css input-dir:output-dir" +complete -c sass -l watch -d "Watch files or directories for changes" # --poll Check for file changes manually, rather than relying on the OS. # Only meaningful for --watch. -complete -c sass -l poll -d "Check for file changes manually, rather than relying on the OS. Only meaningful for --watch." +complete -c sass -l poll -d "Check for file changes manually, don't rely on OS" # --update Compile files or directories to CSS. # Locations are set like --watch. -complete -c sass -l update -d "Compile files or directories to CSS. The location of the generated CSS can be set using a colon: input.sass:output.css input-dir:output-dir" +complete -c sass -l update -d "Compile files or directories to CSS" # -f, --force Recompile every Sass file, even if the CSS file is newer. # Only meaningful for --update. -complete -c sass -s f -l force -d "Recompile every Sass file, even if the CSS file is newer. Only meaningful for --update." +complete -c sass -s f -l force -d "Recompile every Sass file, even if the CSS file is newer" # --stop-on-error If a file fails to compile, exit immediately. # Only meaningful for --watch and --update. -complete -c sass -l stop-on-error -d "If a file fails to compile, exit immediately. Only meaningful for --watch and --update." +complete -c sass -l stop-on-error -d "If a file fails to compile, exit immediately" # Input and Output: # --scss Use the CSS-superset SCSS syntax. @@ -47,34 +47,34 @@ complete -c sass -l scss -d "Use the CSS-superset SCSS syntax." complete -c sass -l sourcemap -x -a "auto\t'(default) relative paths where possible, file URIs elsewhere' sfile\t'always absolute file URIs' inline\t'include the source text in the sourcemap' -none\t'no sourcemaps'" -d "How to link generated output to the source files." +none\t'no sourcemaps'" -d "How to link generated output to the source files" # -s, --stdin Read input from standard input instead of an input file. # This is the default if no input file is specified. -complete -c sass -s s -l stdin -d "Read input from standard input instead of an input file. This is the default if no input file is specified." +complete -c sass -s s -l stdin -d "Read input from standard input instead of an input file" # -E, --default-encoding ENCODING Specify the default encoding for input files. -complete -c sass -s E -l default-encoding -x -d "Specify the default encoding for input files." +complete -c sass -s E -l default-encoding -x -d "Specify the default encoding for input files" # --unix-newlines Use Unix-style newlines in written files. # Always true on Unix. -complete -c sass -l unix-newlines -d "Use Unix-style newlines in written files. Always true on Unix." +complete -c sass -l unix-newlines -d "Use Unix-style newlines in written files" # -g, --debug-info Emit output that can be used by the FireSass Firebug plugin. -complete -c sass -s g -l debug-info -d "Emit output that can be used by the FireSass Firebug plugin." +complete -c sass -s g -l debug-info -d "Emit output that can be used by the FireSass Firebug plugin" # -l, --line-numbers Emit comments in the generated CSS indicating the corresponding source line. # --line-comments -complete -c sass -s l -l line-numbers -l line-comments -d "Emit comments in the generated CSS indicating the corresponding source line." +complete -c sass -s l -l line-numbers -l line-comments -d "Indicate corresponding source line with comments" # Miscellaneous: # -i, --interactive Run an interactive SassScript shell. -complete -c sass -s i -l interactive -d "Run an interactive SassScript shell." +complete -c sass -s i -l interactive -d "Run an interactive SassScript shell" # -c, --check Just check syntax, don't evaluate. -complete -c sass -s c -l check -d "Just check syntax, don't evaluate." +complete -c sass -s c -l check -d "Just check syntax, don't evaluate" # --precision NUMBER_OF_DIGITS How many digits of precision to use when outputting decimal numbers. # Defaults to 5. -complete -c sass -l precision -x -d "How many digits of precision to use when outputting decimal numbers. Defaults to 5." +complete -c sass -l precision -x -d "Set precision when outputting decimal numbers" # --cache-location PATH The path to save parsed Sass files. Defaults to .sass-cache. -complete -c sass -l cache-location -r -d "The path to save parsed Sass files. Defaults to .sass-cache." +complete -c sass -l cache-location -r -d "The path to save parsed Sass files" # -C, --no-cache Don't cache parsed Sass files. -complete -c sass -s C -l no-cache -d "Don't cache parsed Sass files." +complete -c sass -s C -l no-cache -d "Don't cache parsed Sass files" # --trace Show a full Ruby stack trace on error. -complete -c sass -l trace -d "Show a full Ruby stack trace on error." +complete -c sass -l trace -d "Show a full Ruby stack trace on error" # -q, --quiet Silence warnings and status messages during compilation. -complete -c sass -s q -l quiet -d "Silence warnings and status messages during compilation." +complete -c sass -s q -l quiet -d "Silence warnings and status messages during compilation" diff --git a/share/completions/schtasks.fish b/share/completions/schtasks.fish new file mode 100644 index 000000000..44553ec66 --- /dev/null +++ b/share/completions/schtasks.fish @@ -0,0 +1,253 @@ +function __schtasks_print_tasks -d 'Helper function to print tasks' + schtasks /query /fo csv /nh | awk -F ',' '{ print $1 }' +end + +function __schtasks_change_complete_args -a previous_token + if test "$previous_token" = /tn + __schtasks_print_tasks + return + end + + if string match -r -q -- "$previous_token" '^/r?u$' + __fish_print_windows_users + return + end + + if __fish_seen_argument -w s + echo -e '/u\tRun this command with the permissions of the specified user account' + end + + if __fish_seen_argument -w u + echo -e '/p\tSpecify the password of the user account specified in the /u parameter' + end + + if not __fish_seen_argument -w et -w du + echo -e '/et\tSpecify the end time for the task +/du\tA value that specifies the duration' + end + + if not __fish_seen_argument -w ENABLE -w DISABLE + echo -e '/ENABLE\tSpecify to enable the scheduled task +/DISABLE\tSpecify to disable the scheduled task' + end + + echo -e '/tn\tIdentify the task to be changed +/s\tSpecify the name or IP address of a remote computer +/ru\tChange the user name under which the scheduled task has to run +/rp\tSpecify a new password for the existing user account, or the user account specified by /ru +/tr\tChange the program that the task runs +/st\tSpecify the start time for the task +/ri\tSpecify the repetition interval for the scheduled task +/k\tStop the program that the task runs at the time specified by /et or /du +/sd\tSpecify the first date on which the task should be run +/ed\tSpecify the last date on which the task should be run +/it\tSpecify to run the scheduled task only when the run as user is logged on to the computer +/z\tSpecify to delete the task upon the completion of its schedule +/?\tShow help' +end + +function __schtasks_create_complete_args -a previous_token + if test "$previous_token" = /sc + echo -e 'MINUTE\tSpecify the number of minutes before the task should run +HOURLY\tSpecify the number of hours before the task should run +DAILY\tSpecify the number of days before the task should run +WEEKLY\tSpecify the number of weeks before the task should run +MONTHLY\tSpecify the number of months before the task should run +ONCE\tSpecify that that task runs once at a specified date and time +ONSTART\tSpecify that the task runs every time the system starts +ONLOGON\tSpecify that the task runs whenever a user logs on +ONIDLE\tSpecify that the task runs whenever the system is idle for a specified period of time' + return + end + + if string match -r -q -- "$previous_token" '^/r?u$' + __fish_print_windows_users + return + end + + if test "$previous_token" = /mo + echo -e 'MINUTE\tSpecify that the task runs every n minutes +HOURLY\tSpecify that the task runs every n hours +DAILY\tSpecify that the task runs every n days +WEEKLY\tSpecify that the task runs every n weeks +MONTHLY\tSpecify that the task runs every n months +ONCE\tSpecify that the task runs once +ONSTART\tSpecify that the task runs at startup +ONLOGON\tSpecify that the task runs when the user specified by the /u parameter logs on +ONIDLE\tSpecify that the task runs after the system is idle for the number of minutes specified by /i' + return + end + + if __fish_seen_argument -w s + echo -e '/u\tRun this command with the permissions of the specified user account' + end + + if __fish_seen_argument -w u + echo -e '/p\tSpecify the password of the user account specified in the /u parameter' + end + + if not __fish_seen_argument -w et -w du + echo -e '/et\tSpecify the time of day that a minute or hourly task schedule ends +/du\tSpecify a maximum length of time for a minute or hourly schedule' + end + + echo -e '/sc\tSpecify the schedule type +/tn\tSpecify a name for the task +/tr\tSpecify the program or command that the task runs +/s\tSpecify the name or IP address of a remote computer +/ru\tRun the task with permissions of the specified user account +/rp\tSpecify a the password for the existing user account, or the user account specified by /ru +/mo\tSpecify how often the task runs within its schedule type +/d\tSpecify how often the task runs within its schedule type +/m\tSpecify a month or months of the year during which the scheduled task should run +/i\tSpecify how many minutes the computer is idle before the task starts +/st\tSpecify the start time for the task +/ri\tSpecify the repetition interval for the scheduled task +/k\tStop the program that the task runs at the time specified by /et or /du +/sd\tSpecify the date on which the task schedule starts +/ed\tSpecify the date on which the schedule ends +/it\tSpecify to run the scheduled task only when the run as user is logged on to the computer +/z\tSpecify to delete the task upon the completion of its schedule +/f\tSpecify to create the task and suppress warnings if the specified task already exists +/?\tShow help' +end + +function __schtasks_delete_complete_args -a previous_token + if test "$previous_token" = /tn + __schtasks_print_tasks + return + end + + if test "$previous_token" = /u + __fish_print_windows_users + return + end + + if __fish_seen_argument -w s + echo -e '/u\tRun this command with the permissions of the specified user account' + end + + if __fish_seen_argument -w u + echo -e '/p\tSpecify the password of the user account specified in the /u parameter' + end + + echo -e '/tn\tIdentify the task to be deleted +/f\tSuppress the confirmation message +/s\tSpecify the name or IP address of a remote computer +/?\tShow help' +end + +function __schtasks_end_complete_args -a previous_token + if test "$previous_token" = /tn + __schtasks_print_tasks + return + end + + if test "$previous_token" = /u + __fish_print_windows_users + return + end + + if __fish_seen_argument -w s + echo -e '/u\tRun this command with the permissions of the specified user account' + end + + if __fish_seen_argument -w u + echo -e '/p\tSpecify the password of the user account specified in the /u parameter' + end + + echo -e '/tn\tIdentify the task that started the program +/s\tSpecify the name or IP address of a remote computer +/?\tShow help' +end + +function __schtasks_query_complete_args -a previous_token + if test "$previous_token" = /fo + echo -e 'TABLE +LIST +CSV' + return + end + + if test "$previous_token" = /u + __fish_print_windows_users + return + end + + if __fish_seen_argument -w s + echo -e '/u\tRun this command with the permissions of the specified user account' + end + + if __fish_seen_argument -w u + echo -e '/p\tSpecify the password of the user account specified in the /u parameter' + end + + echo -e '/fo\tSpecify the output format +/nh\tRemove column headings +/v\tAdd the advanced properties of the task +/s\tSpecify the name or IP address of a remote computer +/?\tShow help' +end + +function __schtasks_run_complete_args -a previous_token + if test "$previous_token" = /tn + __schtasks_print_tasks + return + end + + if test "$previous_token" = /u + __fish_print_windows_users + return + end + + if __fish_seen_argument -w s + echo -e '/u\tRun this command with the permissions of the specified user account' + end + + if __fish_seen_argument -w u + echo -e '/p\tSpecify the password of the user account specified in the /u parameter' + end + + echo -e '/tn\tIdentify the task to start +/s\tSpecify the name or IP address of a remote computer +/?\tShow help' +end + +function __schtasks_complete_args -d 'Function to generate args' + set --local previous_token (commandline -oc)[-1] + + if __fish_seen_argument -w change + __schtasks_change_complete_args "$previous_token" + else if __fish_seen_argument -w create + __schtasks_create_complete_args "$previous_token" + else if __fish_seen_argument -w delete + __schtasks_delete_complete_args "$previous_token" + else if __fish_seen_argument -w end + __schtasks_end_complete_args "$previous_token" + else if __fish_seen_argument -w query + __schtasks_query_complete_args "$previous_token" + else if __fish_seen_argument -w run + __schtasks_run_complete_args "$previous_token" + end +end + +complete -c schtasks -f -a '(__schtasks_complete_args)' + +complete -c schtasks -f -n 'not __fish_seen_argument -w change -w create -w delete -w end \ + -w query -w run' -a /change \ + -d 'Change one or more properties of a task' +complete -c schtasks -f -n 'not __fish_seen_argument -w change -w create -w delete -w end \ + -w query -w run' -a /create \ + -d 'Schedule a new task' +complete -c schtasks -f -n 'not __fish_seen_argument -w change -w create -w delete -w end \ + -w query -w run' -a /delete \ + -d 'Delete a scheduled task' +complete -c schtasks -f -n 'not __fish_seen_argument -w change -w create -w delete -w end \ + -w query -w run' -a /end \ + -d 'Stop a program started by a task' +complete -c schtasks -f -n 'not __fish_seen_argument -w change -w create -w delete -w end \ + -w query -w run' -a /query \ + -d 'Display tasks scheduled to run on the computer' +complete -c schtasks -f -n 'not __fish_seen_argument -w change -w create -w delete -w end \ + -w query -w run' -a /run \ + -d 'Start a scheduled task immediately' diff --git a/share/completions/scss.fish b/share/completions/scss.fish index 0b8765693..23e8f7e7a 100644 --- a/share/completions/scss.fish +++ b/share/completions/scss.fish @@ -5,77 +5,77 @@ # Common Options: # -I, --load-path PATH Specify a Sass import path. -complete -c scss -s I -l load-path -r -d "Specify a Sass import path." +complete -c scss -s I -l load-path -r -d "Specify a Sass import path" # -r, --require LIB Require a Ruby library before running Sass. -complete -c scss -s r -l require -r -d "Require a Ruby library before running Sass." +complete -c scss -s r -l require -r -d "Require a Ruby library before running Sass" # --compass Make Compass imports available and load project configuration. -complete -c scss -l compass -d "Make Compass imports available and load project configuration." +complete -c scss -l compass -d "Enable Compass imports and load project configuration" # -t, --style NAME Output style. Can be nested (default), compact, compressed, or expanded. -complete -c scss -s t -l style -x -a "nested compact compressed expanded" -d "Output style. Can be nested (default), compact, compressed, or expanded." +complete -c scss -s t -l style -x -a "nested compact compressed expanded" -d "Output style" # -?, -h, --help Show this help message. -complete -c scss -s '?' -s h -l help -f -d "Show help message." +complete -c scss -s '?' -s h -l help -f -d "Show help message" # -v, --version Print the Sass version. -complete -c scss -s v -l version -f -d "Print the Sass version." +complete -c scss -s v -l version -f -d "Print the Sass version" # Watching and Updating: # --watch Watch files or directories for changes. # The location of the generated CSS can be set using a colon: # scss --watch input.scss:output.css # scss --watch input-dir:output-dir -complete -c scss -l watch -d "Watch files or directories for changes. The location of the generated CSS can be set using a colon: input.scss:output.css input-dir:output-dir" +complete -c scss -l watch -d "Watch files or directories for changes" # --poll Check for file changes manually, rather than relying on the OS. # Only meaningful for --watch. -complete -c scss -l poll -d "Check for file changes manually, rather than relying on the OS. Only meaningful for --watch." +complete -c scss -l poll -d "Check for file changes manually, don't rely on OS" # --update Compile files or directories to CSS. # Locations are set like --watch. -complete -c scss -l update -d "Compile files or directories to CSS. The location of the generated CSS can be set using a colon: input.scss:output.css input-dir:output-dir" +complete -c scss -l update -d "Compile files or directories to CSS" # -f, --force Recompile every Sass file, even if the CSS file is newer. # Only meaningful for --update. -complete -c scss -s f -l force -d "Recompile every Sass file, even if the CSS file is newer. Only meaningful for --update." +complete -c scss -s f -l force -d "Recompile every Sass file, even if the CSS file is newer" # --stop-on-error If a file fails to compile, exit immediately. # Only meaningful for --watch and --update. -complete -c scss -l stop-on-error -d "If a file fails to compile, exit immediately. Only meaningful for --watch and --update." +complete -c scss -l stop-on-error -d "If a file fails to compile, exit immediately" # Input and Output: # --sass Use the indented Sass syntax. -complete -c scss -l sass -d "Use the indented Sass syntax." +complete -c scss -l sass -d "Use the indented Sass syntax" # --sourcemap=TYPE How to link generated output to the source files. # auto (default): relative paths where possible, file URIs elsewhere # file: always absolute file URIs # inline: include the source text in the sourcemap # none: no sourcemaps -complete -c scss -l sourcemap -x -d "How to link generated output to the source files." -a \ +complete -c scss -l sourcemap -x -d "How to link generated output to the source files" -a \ "auto\t'(default) relative paths where possible, file URIs elsewhere' file\t'always absolute file URIs' inline\t'include the source text in the sourcemap' none\t'no sourcemaps'" # -s, --stdin Read input from standard input instead of an input file. # This is the default if no input file is specified. -complete -c scss -s s -l stdin -d "Read input from standard input instead of an input file. This is the default if no input file is specified." +complete -c scss -s s -l stdin -d "Read input from standard input instead of an input file" # -E, --default-encoding ENCODING Specify the default encoding for input files. -complete -c scss -s E -l default-encoding -x -d "Specify the default encoding for input files." +complete -c scss -s E -l default-encoding -x -d "Specify the default encoding for input files" # --unix-newlines Use Unix-style newlines in written files. # Always true on Unix. -complete -c scss -l unix-newlines -d "Use Unix-style newlines in written files. Always true on Unix." +complete -c scss -l unix-newlines -d "Use Unix-style newlines in written files" # -g, --debug-info Emit output that can be used by the FireSass Firebug plugin. -complete -c scss -s g -l debug-info -d "Emit output that can be used by the FireSass Firebug plugin." +complete -c scss -s g -l debug-info -d "Emit output that can be used by the FireSass Firebug plugin" # -l, --line-numbers Emit comments in the generated CSS indicating the corresponding source line. # --line-comments -complete -c scss -s l -l line-numbers -l line-comments -d "Emit comments in the generated CSS indicating the corresponding source line." +complete -c scss -s l -l line-numbers -l line-comments -d "Indicate corresponding source line with comments" # Miscellaneous: # -i, --interactive Run an interactive SassScript shell. -complete -c scss -s i -l interactive -d "Run an interactive SassScript shell." +complete -c scss -s i -l interactive -d "Run an interactive SassScript shell" # -c, --check Just check syntax, don't evaluate. -complete -c scss -s c -l check -d "Just check syntax, don't evaluate." +complete -c scss -s c -l check -d "Just check syntax, don't evaluate" # --precision NUMBER_OF_DIGITS How many digits of precision to use when outputting decimal numbers. # Defaults to 5. -complete -c scss -l precision -x -d "How many digits of precision to use when outputting decimal numbers. Defaults to 5." +complete -c scss -l precision -x -d "Set precision when outputting decimal numbers" # --cache-location PATH The path to save parsed Sass files. Defaults to .sass-cache. -complete -c scss -l cache-location -r -d "The path to save parsed Sass files. Defaults to .sass-cache." +complete -c scss -l cache-location -r -d "The path to save parsed Sass files" # -C, --no-cache Don't cache parsed Sass files. -complete -c scss -s C -l no-cache -d "Don't cache parsed Sass files." +complete -c scss -s C -l no-cache -d "Don't cache parsed Sass files" # --trace Show a full Ruby stack trace on error. -complete -c scss -l trace -d "Show a full Ruby stack trace on error." +complete -c scss -l trace -d "Show a full Ruby stack trace on error" # -q, --quiet Silence warnings and status messages during compilation. -complete -c scss -s q -l quiet -d "Silence warnings and status messages during compilation." +complete -c scss -s q -l quiet -d "Silence warnings and status messages during compilation" diff --git a/share/completions/service.fish b/share/completions/service.fish index 0a8ccec5c..b043388f1 100644 --- a/share/completions/service.fish +++ b/share/completions/service.fish @@ -1,16 +1,16 @@ # First argument is the names of the service, i.e. a file in /etc/init.d -complete -c service -n "fish_is_nth_token 1" -xa "(__fish_print_service_names)" -d Service +complete -c service -n "__fish_is_nth_token 1" -xa "(__fish_print_service_names)" -d Service # as found in __fish_print_service_names.fish if test -d /run/systemd/system # Systemd systems - complete -c service -n 'not fish_is_nth_token 1' -xa "start stop restart status enable disable" + complete -c service -n 'not __fish_is_nth_token 1' -xa "start stop restart status enable disable" else if type -f rc-service 2>/dev/null # OpenRC (Gentoo) - complete -c service -n 'not fish_is_nth_token 1' -xa "start stop restart" + complete -c service -n 'not __fish_is_nth_token 1' -xa "start stop restart" else if test -d /etc/init.d # SysV on Debian and other linuxen - complete -c service -n 'not fish_is_nth_token 1' -xa "start stop --full-restart" + complete -c service -n 'not __fish_is_nth_token 1' -xa "start stop --full-restart" else # FreeBSD # Use the output of `service -v foo` to retrieve the list of service-specific verbs - complete -c service -n 'not fish_is_nth_token 1' -xa "(__fish_complete_freebsd_service_actions)" + complete -c service -n 'not __fish_is_nth_token 1' -xa "(__fish_complete_freebsd_service_actions)" end function __fish_complete_freebsd_service_actions diff --git a/share/completions/set.fish b/share/completions/set.fish index ef740f44e..f7b24800f 100644 --- a/share/completions/set.fish +++ b/share/completions/set.fish @@ -2,24 +2,21 @@ # Completions for the 'set' builtin # -# -# All locale variables used by set completions -# - -set -g __fish_locale_vars LANG LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME - # # Various helper functions # -function __fish_set_is_color -d 'Test if We are specifying a color value for the prompt' +function __fish_set_is_color -a foreground background -d 'Test if We are specifying a color value for the prompt' set -l cmd (commandline -poc) set -e cmd[1] for i in $cmd switch $i - + case fish_color_search_match fish_color_selection fish_pager_color_selected_background + $background + return case 'fish_color_*' 'fish_pager_color_*' - return 0 + $foreground + return case '-*' @@ -36,7 +33,7 @@ function __fish_set_is_locale -d 'Test if We are specifying a locale value for t for i in $cmd switch $i - case $__fish_locale_vars + case LANG LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME return 0 case '-*' @@ -49,16 +46,24 @@ function __fish_set_is_locale -d 'Test if We are specifying a locale value for t return 1 end -function __fish_set_special_vars - printf %s\t%s\n CDPATH "A list of dirs that cd uses" - printf %s\t%s\n fish_emoji_width "How wide your terminal displays emoji (2 since Unicode 9, 1 previously)" - printf %s\t%s\n fish_ambiguous_width "How wide your terminal displays ambiguous chars (1 or 2)" - printf %s\t%s\n fish_escape_delay_ms "How long fish waits to distinguish escape and alt" - printf %s\t%s\n fish_greeting "The message to display at start (also a function)" - printf %s\t%s\n fish_history "The session id to store history under" - printf %s\t%s\n fish_trace "Enables execution tracing (if set to non-empty value)" - printf %s\t%s\n fish_user_paths "A list of dirs to prepend to PATH" - printf %s\t%s\n BROWSER "The browser to use" +function __fish_complete_special_vars + printf "%s\t%s\n" \ + PATH "list of dirs to look for commands in" \ + CDPATH "list of dirs under which that cd searches" \ + FISH_DEBUG "list of enabled debug categories" \ + FISH_DEBUG_OUTPUT "debug output path" \ + umask "current file creation mask" \ + fish_handle_reflow "if fish should repaint prompt when the term resizes" \ + fish_trace "print cmds as they execute, like set -x" \ + fish_emoji_width "cols wide fish assumes emoji render as" \ + fish_key_bindings "name of function that sets binds" \ + fish_autosuggestion_enabled "turns autosuggestions on or off" \ + fish_ambiguous_width "affects computed width of east asian chars" \ + fish_escape_delay_ms "How long fish waits to distinguish escape and alt" \ + fish_greeting "The message to display at start (also a function)" \ + fish_history "The session id to store history under" \ + fish_trace "Enables execution tracing (if set to non-empty value)" \ + fish_user_paths "A list of dirs to prepend to PATH" end # @@ -66,36 +71,37 @@ end # # Regular switches, set only accepts these before the variable name, -# so we need to test using "fish_is_nth_token 1" +# so we need to test using "__fish_is_nth_token 1" -complete -c set -n "fish_is_nth_token 1" -s e -l erase -d "Erase variable" -complete -c set -n "fish_is_nth_token 1" -s x -l export -d "Export variable to subprocess" -complete -c set -n "fish_is_nth_token 1" -s u -l unexport -d "Do not export variable to subprocess" -complete -c set -n "fish_is_nth_token 1" -s f -l function -d "Make variable function-scoped" -complete -c set -n "fish_is_nth_token 1" -s g -l global -d "Make variable scope global" -complete -c set -n "fish_is_nth_token 1" -s l -l local -d "Make variable scope local" -complete -c set -n "fish_is_nth_token 1" -s U -l universal -d "Share variable persistently across sessions" -complete -c set -n "fish_is_nth_token 1" -s q -l query -d "Test if variable is defined" -complete -c set -n "fish_is_nth_token 1" -s h -l help -d "Display help and exit" -complete -c set -n "fish_is_nth_token 1" -s n -l names -d "List the names of the variables, but not their value" -complete -c set -n "fish_is_nth_token 1" -s a -l append -d "Append value to a list" -complete -c set -n "fish_is_nth_token 1" -s p -l prepend -d "Prepend value to a list" -complete -c set -n "fish_is_nth_token 1" -s S -l show -d "Show variable" -complete -c set -n "fish_is_nth_token 1" -l path -d "Make variable as a path variable" -complete -c set -n "fish_is_nth_token 1" -l unpath -d "Make variable not as a path variable" +complete -c set -n "__fish_is_nth_token 1" -s e -l erase -d "Erase variable" +complete -c set -n "__fish_is_nth_token 1" -s x -l export -d "Export variable to subprocess" +complete -c set -n "__fish_is_nth_token 1" -s u -l unexport -d "Do not export variable to subprocess" +complete -c set -n "__fish_is_nth_token 1" -s f -l function -d "Make variable function-scoped" +complete -c set -n "__fish_is_nth_token 1" -s g -l global -d "Make variable scope global" +complete -c set -n "__fish_is_nth_token 1" -s l -l local -d "Make variable scope local" +complete -c set -n "__fish_is_nth_token 1" -s L -l long -d 'Do not truncate long lines' +complete -c set -n "__fish_is_nth_token 1" -s U -l universal -d "Share variable persistently across sessions" +complete -c set -n "__fish_is_nth_token 1" -s q -l query -d "Test if variable is defined" +complete -c set -n "__fish_is_nth_token 1" -s h -l help -d "Display help and exit" +complete -c set -n "__fish_is_nth_token 1" -s n -l names -d "List the names of the variables, but not their value" +complete -c set -n "__fish_is_nth_token 1" -s a -l append -d "Append value to a list" +complete -c set -n "__fish_is_nth_token 1" -s p -l prepend -d "Prepend value to a list" +complete -c set -n "__fish_is_nth_token 1" -s S -l show -d "Show variable" +complete -c set -n "__fish_is_nth_token 1" -l path -d "Make variable as a path variable" +complete -c set -n "__fish_is_nth_token 1" -l unpath -d "Make variable not as a path variable" #TODO: add CPP code to generate list of read-only variables and exclude them from the following completions # Complete using preexisting variable names -complete -c set -n 'fish_is_nth_token 1; and not __fish_seen_argument -s e -l erase; and not __fish_seen_argument -s l -s g -s U -l local -l global -l universal' -x -a "(set -l | string match -rv '^__' | string replace ' ' \t'Local Variable: ')" -complete -c set -n 'fish_is_nth_token 1; and not __fish_seen_argument -s e -l erase; and not __fish_seen_argument -s l -s g -s U -l local -l global -l universal' -x -a "(set -g | string match -rv '^__' | string replace ' ' \t'Global Variable: ')" -complete -c set -n 'fish_is_nth_token 1; and not __fish_seen_argument -s e -l erase; and not __fish_seen_argument -s l -s g -s U -l local -l global -l universal' -x -a "(set -U | string match -rv '^__' | string replace ' ' \t'Universal Variable: ')" +complete -c set -n '__fish_is_nth_token 1; and not __fish_seen_argument -s e -l erase; and not __fish_seen_argument -s l -s g -s U -l local -l global -l universal' -x -a "(set -l | string match -rv '^__' | string replace ' ' \t'Local Variable: ')" +complete -c set -n '__fish_is_nth_token 1; and not __fish_seen_argument -s e -l erase; and not __fish_seen_argument -s l -s g -s U -l local -l global -l universal' -x -a "(set -g | string match -rv '^__' | string replace ' ' \t'Global Variable: ')" +complete -c set -n '__fish_is_nth_token 1; and not __fish_seen_argument -s e -l erase; and not __fish_seen_argument -s l -s g -s U -l local -l global -l universal' -x -a "(set -U | string match -rv '^__' | string replace ' ' \t'Universal Variable: ')" # Complete some fish configuration variables even if they aren't set. -complete -c set -n 'fish_is_nth_token 1; and not __fish_seen_argument -s e -l erase' -x -a "(__fish_set_special_vars)" +complete -c set -n '__fish_is_nth_token 1; and not __fish_seen_argument -s e -l erase' -x -a "(__fish_complete_special_vars)" # Complete scope-specific variables -complete -c set -n 'fish_is_nth_token 1; and __fish_seen_argument -s l -l local' -x -a "(set -l | string replace ' ' \t'Local Variable: ')" -complete -c set -n 'fish_is_nth_token 1; and __fish_seen_argument -s g -l global' -x -a "(set -g | string replace ' ' \t'Global Variable: ')" -complete -c set -n 'fish_is_nth_token 1; and __fish_seen_argument -s U -l universal' -x -a "(set -U | string replace ' ' \t'Universal Variable: ')" +complete -c set -n '__fish_is_nth_token 1; and __fish_seen_argument -s l -l local' -x -a "(set -l | string replace ' ' \t'Local Variable: ')" +complete -c set -n '__fish_is_nth_token 1; and __fish_seen_argument -s g -l global' -x -a "(set -g | string replace ' ' \t'Global Variable: ')" +complete -c set -n '__fish_is_nth_token 1; and __fish_seen_argument -s U -l universal' -x -a "(set -U | string replace ' ' \t'Universal Variable: ')" # Complete using preexisting variable names for `set --erase` complete -c set -n '__fish_seen_argument -s e -l erase; and not __fish_seen_argument -s l -s U -s g -l local -l global -l Universal' -f -a "(set -g | string replace ' ' \tGlobal\ Variable:\ )" @@ -107,10 +113,13 @@ complete -c set -n '__fish_seen_argument -s e -l erase; and __fish_seen_argument complete -c set -n '__fish_seen_argument -s e -l erase; and __fish_seen_argument -s l -l local' -f -a "(set -l | string replace ' ' \t'Local Variable: ')" # Color completions -complete -c set -n __fish_set_is_color -x -a '(set_color --print-colors)' -complete -c set -n __fish_set_is_color -s b -l background -x -a '(set_color --print-colors)' -d "Change background color" -complete -c set -n __fish_set_is_color -s o -l bold -d 'Make font bold' +complete -c set -n '__fish_set_is_color true false' -x -a '(set_color --print-colors)' -d 'text color' +complete -c set -n '__fish_set_is_color false true' -a '--background=(set_color --print-colors)' +complete -c set -n '__fish_set_is_color true false' -a --bold -x +complete -c set -n '__fish_set_is_color true false' -a --dim -x +complete -c set -n '__fish_set_is_color true false' -a --italics -x +complete -c set -n '__fish_set_is_color true true' -a --reverse -x +complete -c set -n '__fish_set_is_color true false' -a --underline -x # Locale completions complete -c set -n '__fish_set_is_locale; and not __fish_seen_argument -s e -l erase' -x -a '(command -sq locale; and locale -a)' -d Locale -complete -c set -s L -l long -d 'Do not truncate long lines' diff --git a/share/completions/setx.fish b/share/completions/setx.fish new file mode 100644 index 000000000..8dd3e4996 --- /dev/null +++ b/share/completions/setx.fish @@ -0,0 +1,32 @@ +function __setx_complete_args -d 'Function to generate args' + set -l previous_token (commandline -oc)[-1] + + if test "$previous_token" = /u + __fish_print_windows_users + return + end +end + +complete -c setx -f -a '(__setx_complete_args)' + +complete -c setx -f -n '__fish_seen_argument -w s' -a /u \ + -d 'Run the script with the credentials of the specified user account' +complete -c setx -f -n '__fish_seen_argument -w u' -a /p \ + -d 'Specify the password of the user account that is specified in the /u parameter' + +complete -c setx -f -n 'not __fish_seen_argument -w a -w r -w x' -a /a \ + -d 'Specify absolute coordinates and offset as search parameters' +complete -c setx -f -n 'not __fish_seen_argument -w a -w r -w x' -a /r \ + -d 'Specify relative coordinates and offset' +complete -c setx -f -n 'not __fish_seen_argument -w a -w r -w x' -a /x \ + -d 'Display file coordinates, ignoring the /a, /r, and /d command-line options' + +complete -c setx -f -n '__fish_seen_argument -w a -w r' -a /m \ + -d 'Specify to set the variable in the system environment' + +complete -c setx -f -a /s -d 'Specify the name or IP address of a remote computer' +complete -c setx -f -a /k \ + -d 'Specify that the variable is set based on information from a registry key' +complete -c setx -f -a /f -d 'Specify the file that you want to use' +complete -c setx -f -a /d -d 'Specify delimiters to be used' +complete -c setx -f -a '/?' -d 'Show help' diff --git a/share/completions/sqlsharp.fish b/share/completions/sqlsharp.fish new file mode 100644 index 000000000..89e95c250 --- /dev/null +++ b/share/completions/sqlsharp.fish @@ -0,0 +1,3 @@ +complete -c sqlsharp -s f -r -d 'Read SQL commands from file' +complete -c sqlsharp -s o -r -d 'Redirect stdout to file' +complete -c sqlsharp -s s -d 'Use silent mode' diff --git a/share/completions/starship.fish b/share/completions/starship.fish new file mode 100644 index 000000000..cedfbe531 --- /dev/null +++ b/share/completions/starship.fish @@ -0,0 +1 @@ +starship completions fish | source diff --git a/share/completions/stream.fish b/share/completions/stream.fish index b50979943..cf5843110 100644 --- a/share/completions/stream.fish +++ b/share/completions/stream.fish @@ -11,14 +11,14 @@ complete -c stream -o interlace -d 'Type of image interlacing scheme [type]' -xa complete -c stream -o interpolate -d 'Pixel color interpolation method [method]' -xa '(stream -list interpolate)' complete -c stream -o limit -d 'Pixel cache resource limit [type value]' -x complete -c stream -o map -d 'Components one or more pixel components' -complete -c stream -o monitor -d 'Monitor progress ' +complete -c stream -o monitor -d 'Monitor progress' complete -c stream -o quantize -d 'Reduce colors in this colorspace [colorspace]' -xa '(stream -list colorspace)' complete -c stream -o quiet -d 'Suppress all warning messages' complete -c stream -o regard-warnings -d 'Pay attention to warning messages' complete -c stream -o respect-parentheses -d 'Settings remain in effect until parenthesis boundary' complete -c stream -o sampling-factor -d 'Horizontal and vertical sampling factor [geometry]' complete -c stream -o seed -d 'Seed a new sequence of pseudo-random numbers [value]' -complete -c stream -o set -d 'Attribute set an image attribute [ value]' +complete -c stream -o set -d 'Attribute set an image attribute [value]' complete -c stream -o size -d 'Width and height of image [geometry]' complete -c stream -o storage-type -d 'Pixel storage type [type]' -xa '(stream -list storage)' complete -c stream -o synchronize -d 'Synchronize image to storage device' diff --git a/share/completions/sv.fish b/share/completions/sv.fish index c3c7fe26e..cc1f32460 100644 --- a/share/completions/sv.fish +++ b/share/completions/sv.fish @@ -10,15 +10,24 @@ set -l commands \ shutdown force-stop force-reload force-restart force-shutdown \ try-restart check - function __fish_complete_sv_list_services - for dir in $SVDIR /run/runit/service/ /etc/runit/current /etc/runit/runsvdir/ - test -d $dir - and break + set -l svdir + for candidate_svdir in \ + "$SVDIR" \ + /run/runit/runsvdir/current \ + /run/runit/service \ + /etc/services \ + /services + if test -d $candidate_svdir + set svdir $candidate_svdir + break + end end - set -l services (string match -r '[^/]*$' $dir/*) - set -l out (sv status $services 2>/dev/null) - and string replace -r "^(\w+: )(.*?):" '$2\t$1$2:' $out + set -q svdir[1]; or return + set -l services (command ls $svdir) + set -l sv_status (sv status $services 2>/dev/null | + string replace -ar ';.*$' '') + and string replace -r "^(\w+: )(.*?):" '$2\t$1' $sv_status or printf "%s\n" $services end diff --git a/share/completions/tar.fish b/share/completions/tar.fish index 3f43963b2..a420ad88c 100644 --- a/share/completions/tar.fish +++ b/share/completions/tar.fish @@ -20,17 +20,16 @@ end complete -c tar -a "(__fish_complete_tar)" -complete -c tar -s A -l catenate -d "Append archive to archive" -complete -c tar -l concatenate -d "Append archive to archive" +complete -c tar -s A -l catenate -l concatenate -d "Append archive to archive" complete -c tar -s c -l create -d "Create archive" -complete -c tar -s d -l diff -d "Compare archive and filesystem" -complete -c tar -l compare -d "Compare archive and filesystem" +complete -c tar -s d -l diff -l compare -d "Compare archive and filesystem" complete -c tar -l delete -d "Delete from archive" complete -c tar -s r -l append -d "Append files to archive" complete -c tar -s t -l list -d "List archive" complete -c tar -s u -l update -d "Append new files" -complete -c tar -s x -l extract -d "Extract from archive" -complete -c tar -l get -d "Extract from archive" +complete -c tar -s x -l extract -l get -d "Extract from archive" +complete -c tar -s \? -l help -d "Display short option summary" +complete -c tar -l usage -d "List available options" complete -c tar -l atime-preserve -d "Keep access time" complete -c tar -s b -l block-size -d "Block size" complete -c tar -s B -l read-full-blocks -d "Reblock while reading" @@ -46,6 +45,7 @@ complete -c tar -s i -l ignore-zeros -d "Ignore zero block in archive" complete -c tar -s j -l bzip2 -d "Filter through bzip2" complete -c tar -l ignore-failed-read -d "Don't exit on unreadable files" complete -c tar -s k -l keep-old-files -d "Don't overwrite" +complete -c tar -l one-top-level -d "Extract into directory" complete -c tar -s K -l starting-file -r -d "Starting file in archive" complete -c tar -s l -l one-file-system -d "Stay in local filesystem" complete -c tar -s L -l tape-length -r -d "Tape length" diff --git a/share/completions/topgrade.fish b/share/completions/topgrade.fish new file mode 100644 index 000000000..0c1f86796 --- /dev/null +++ b/share/completions/topgrade.fish @@ -0,0 +1,22 @@ +# Flags +complete -f -c topgrade -s c -l cleanup -d "Cleanup temporary or old files" +complete -f -c topgrade -l disable-predefined-git-repos -d "Don't pull the predefined git repos" +complete -f -c topgrade -s n -l dry-run -d "Print what would be done" +complete -f -c topgrade -l edit-config -d "Edit the configuration file" +complete -f -c topgrade -s h -l help -d "Prints help information" +complete -f -c topgrade -s k -l keep -d "Prompt for a key before exiting" +complete -f -c topgrade -l no-retry -d "Do not ask to retry failed steps" +complete -f -c topgrade -s t -l tmux -d "Run inside tmux" +complete -f -c topgrade -l config-reference -d "Show config reference" +complete -f -c topgrade -l show-skipped -d "Show the reason for skipped steps" +complete -f -c topgrade -s V -l version -d "Prints version information" +complete -f -c topgrade -s v -l verbose -d "Output logs" + +# Options +complete -f -c topgrade -l config -r -d "Alternative configuration file" +complete -f -c topgrade -l disable -r -a "asdf atom brew_cask brew_formula bin cargo chezmoi chocolatey choosenim composer custom_commands deno dotnet emacs firmware flatpak flutter fossil gcloud gem git_repos haxelib gnome_shell_extensions home_manager jetpack krew macports mas micro myrepos nix node opam pacdiff pacstall pearl pipx pip3 pkg pkgin pnpm powershell raco remotes restarts rtcl rustup scoop sdkman silnite sheldon shell snap spicetify stack system tldr tlmgr tmux vagrant vcpkg vim winget wsl yadm" -d "Do not perform upgrades for the given steps" + +complete -f -c topgrade -l only -r -a "asdf atom brew_cask brew_formula bin cargo chezmoi chocolatey choosenim composer custom_commands deno dotnet emacs firmware flatpak flutter fossil gcloud gem git_repos haxelib gnome_shell_extensions home_manager jetpack krew macports mas micro myrepos nix node opam pacdiff pacstall pearl pipx pip3 pkg pkgin pnpm powershell raco remotes restarts rtcl rustup scoop sdkman silnite sheldon shell snap spicetify stack system tldr tlmgr tmux vagrant vcpkg vim winget wsl yadm" -d "Perform only the specified steps (experimental)" + +complete -f -c topgrade -l remote-host-limit -r -d "A regular expression for restricting remote host execution" +complete -f -c topgrade -s y -l yes -d "Say yes to package manager's prompt" diff --git a/share/completions/ttx.fish b/share/completions/ttx.fish index 85a709992..1c52ef373 100644 --- a/share/completions/ttx.fish +++ b/share/completions/ttx.fish @@ -9,7 +9,7 @@ set -l line_endings LF CR CRLF set -l woff_fmts woff woff2 complete -f -c ttx -k -a '(__fish_complete_suffix .otf; __fish_complete_suffix .ttf; __fish_complete_suffix .ttx; __fish_complete_suffix .ttc)' -complete -c ttx -f -n "fish_is_nth_token 1" -k -a '(__fish_complete_suffix .otf; __fish_complete_suffix .ttf; __fish_complete_suffix .ttx)' +complete -c ttx -f -n "__fish_is_nth_token 1" -k -a '(__fish_complete_suffix .otf; __fish_complete_suffix .ttf; __fish_complete_suffix .ttx)' # General options complete -c ttx -f -s h -d'Show help message' diff --git a/share/completions/udevadm.fish b/share/completions/udevadm.fish index 15449a425..1253c6101 100644 --- a/share/completions/udevadm.fish +++ b/share/completions/udevadm.fish @@ -1,5 +1,5 @@ set -l commands info trigger settle control monitor test test-builtin -complete -c udevadm -n "fish_is_nth_token 1" -xa "$commands" +complete -c udevadm -n "__fish_is_nth_token 1" -xa "$commands" complete -c udevadm -s h -l help -d "Show help" complete -c udevadm -s V -l version -d "Show version info" @@ -59,4 +59,4 @@ complete -c udevadm -n '__fish_seen_subcommand_from test' -s a -l action -d "Set complete -c udevadm -n '__fish_seen_subcommand_from test' -s N -l resolve-names -d "When to resolve names" -xa "early late never" # udevadm test-builtin -complete -c udevadm -n '__fish_seen_subcommand_from test-builtin; and fish_is_nth_token 2' -xa "blkid\t'Filesystem and partition probing' btrfs\t'btrfs volume management' hwdb\t'Hardware database' input_id\t'Input device properties' keyboard\t'Keybord scan code to key mapping' kmod\t'Kernel module loader' net_id\t'Network device properties' net_setup_link\t'Configure network link' path_id\t'Compose persistent device path' usb_id\t'USB device properties' uaccess\t'Manage device node user ACL'" +complete -c udevadm -n '__fish_seen_subcommand_from test-builtin; and __fish_is_nth_token 2' -xa "blkid\t'Filesystem and partition probing' btrfs\t'btrfs volume management' hwdb\t'Hardware database' input_id\t'Input device properties' keyboard\t'Keybord scan code to key mapping' kmod\t'Kernel module loader' net_id\t'Network device properties' net_setup_link\t'Configure network link' path_id\t'Compose persistent device path' usb_id\t'USB device properties' uaccess\t'Manage device node user ACL'" diff --git a/share/completions/uniq.fish b/share/completions/uniq.fish index 7693c9517..71d657da2 100644 --- a/share/completions/uniq.fish +++ b/share/completions/uniq.fish @@ -17,7 +17,7 @@ else # BSD complete -c uniq -s c -d 'Precede each output line with count of its occurrence' complete -c uniq -s d -d 'Only print duplicates' complete -c uniq -s f -d 'Avoid comparing first N fields' -x - complete -c uniq -s s -d 'Avoid comparing fist N characters' -x + complete -c uniq -s s -d 'Avoid comparing first N characters' -x complete -c uniq -s u -d 'Only print unique lines' complete -c uniq -s i -d 'Case insensitive comparision' end diff --git a/share/completions/unzip.fish b/share/completions/unzip.fish index fe513b87c..080ed29f8 100644 --- a/share/completions/unzip.fish +++ b/share/completions/unzip.fish @@ -28,7 +28,7 @@ complete -c unzip -s M -d "pipe through `more` pager" if unzip -v 2>/dev/null | string match -eq Debian # the first non-switch argument should be the zipfile - complete -c unzip -n "fish_is_nth_token 1" -k -xa '( + complete -c unzip -n "__fish_is_nth_token 1" -k -xa '( __fish_complete_suffix .zip __fish_complete_suffix .jar __fish_complete_suffix .aar @@ -36,7 +36,7 @@ if unzip -v 2>/dev/null | string match -eq Debian # Files thereafter are either files to include or exclude from the operation set -l zipfile - complete -c unzip -n 'not fish_is_nth_token 1' -xa '(unzip -l (eval set zipfile (__fish_first_token); echo $zipfile) | string replace -r --filter ".*:\S+\s+(.*)" "\$1")' + complete -c unzip -n 'not __fish_is_nth_token 1' -xa '(unzip -l (eval set zipfile (__fish_first_token); echo $zipfile) | string replace -r --filter ".*:\S+\s+(.*)" "\$1")' else diff --git a/share/completions/vips.fish b/share/completions/vips.fish index da22df748..58d8e0dea 100644 --- a/share/completions/vips.fish +++ b/share/completions/vips.fish @@ -18,7 +18,7 @@ complete -c vips -l vips-config -d 'Print libvips config' complete -c vips -l vips-pipe-read-limit -d 'Pipe read limit (bytes)' # Operations -complete -c vips -n "fish_is_nth_token 1" -xa "(__fish_vips_ops)" +complete -c vips -n "__fish_is_nth_token 1" -xa "(__fish_vips_ops)" function __fish_vips_ops vips -l | string match -rv _base | string replace -rf '^\s*\S+ \((.+?)\), +(\S.*?)(?:\s*[,(].*)?$' '$1\t$2' diff --git a/share/completions/xargs.fish b/share/completions/xargs.fish index 7f6924389..d7ac935d0 100644 --- a/share/completions/xargs.fish +++ b/share/completions/xargs.fish @@ -2,20 +2,20 @@ #Completions for xargs # -complete -c xargs -s 0 -l null -d "Terminate filenames with a \0 instead of whitespace, ignore quotes and backslash" -complete -c xargs -s e -l eof -d "Set the end of file string to eof-str" -complete -c xargs -s E -r -f -d "Set the end of file string to eof-str" -complete -c xargs -l help -d "Display help and exit" -complete -c xargs -s i -l replace -d "Replace replace-str in the initial arguments with names from standard input" -complete -c xargs -s I -r -f -d "Replace replace-str in the initial arguments with names from standard input" -complete -c xargs -s l -l max-lines -d "Use at most max-lines nonblank input lines per command line" -complete -c xargs -s L -r -f -d "Use at most max-lines nonblank input lines per command line" -complete -c xargs -s n -l max-args -r -f -d "Use at most max-args arguments per command line" -complete -c xargs -s p -l interactive -d "Prompt the user before running each command line" -complete -c xargs -s r -l no-run-if-empty -d "If the standard input does not contain any nonblanks, do not run the command" -complete -c xargs -s s -l max-chars -r -f -d "Use at most max-chars characters per command line" -complete -c xargs -s t -l verbose -d "Print the command line on the standard error output before executing it" -complete -c xargs -l version -d "Display version and exit" -complete -c xargs -s x -l exit -d "Exit if the size is exceeded" -complete -c xargs -s P -l max-procs -r -f -d "Run up to max-procs processes at a time" +complete -c xargs -n __fish_is_first_token -s 0 -l null -d "Terminate filenames with a \0 instead of whitespace, ignore quotes and backslash" +complete -c xargs -n __fish_is_first_token -s e -l eof -d "Set the end of file string to eof-str" +complete -c xargs -n __fish_is_first_token -s E -r -f -d "Set the end of file string to eof-str" +complete -c xargs -n __fish_is_first_token -l help -d "Display help and exit" +complete -c xargs -n __fish_is_first_token -s i -l replace -d "Replace replace-str in the initial arguments with names from standard input" +complete -c xargs -n __fish_is_first_token -s I -r -f -d "Replace replace-str in the initial arguments with names from standard input" +complete -c xargs -n __fish_is_first_token -s l -l max-lines -d "Use at most max-lines nonblank input lines per command line" +complete -c xargs -n __fish_is_first_token -s L -r -f -d "Use at most max-lines nonblank input lines per command line" +complete -c xargs -n __fish_is_first_token -s n -l max-args -r -f -d "Use at most max-args arguments per command line" +complete -c xargs -n __fish_is_first_token -s p -l interactive -d "Prompt the user before running each command line" +complete -c xargs -n __fish_is_first_token -s r -l no-run-if-empty -d "If the standard input does not contain any nonblanks, do not run the command" +complete -c xargs -n __fish_is_first_token -s s -l max-chars -r -f -d "Use at most max-chars characters per command line" +complete -c xargs -n __fish_is_first_token -s t -l verbose -d "Print the command line on the standard error output before executing it" +complete -c xargs -n __fish_is_first_token -l version -d "Display version and exit" +complete -c xargs -n __fish_is_first_token -s x -l exit -d "Exit if the size is exceeded" +complete -c xargs -n __fish_is_first_token -s P -l max-procs -r -f -d "Run up to max-procs processes at a time" complete -c xargs -xa "(__fish_complete_subcommand)" diff --git a/share/completions/xdg-mime.fish b/share/completions/xdg-mime.fish index c80d2846f..6e1f1f3db 100644 --- a/share/completions/xdg-mime.fish +++ b/share/completions/xdg-mime.fish @@ -15,8 +15,8 @@ complete -c xdg-mime -d 'Query default application for type' -n 'contains_seq qu complete -c xdg-mime -d 'Query file\'s filetype' -n 'contains_seq query filetype -- (commandline -cop)' -r # complete xdg-mime default -complete -c xdg-mime -d 'Choose application' -n '__fish_seen_subcommand_from default; and fish_is_nth_token 3' -xa '(__fish_print_xdg_desktop_file_ids)' -complete -c xdg-mime -d Mimetype -n '__fish_seen_subcommand_from default; and fish_is_nth_token 4' -xa '(__fish_print_xdg_mimetypes)' +complete -c xdg-mime -d 'Choose application' -n '__fish_seen_subcommand_from default; and __fish_is_nth_token 3' -xa '(__fish_print_xdg_desktop_file_ids)' +complete -c xdg-mime -d Mimetype -n '__fish_seen_subcommand_from default; and __fish_is_nth_token 4' -xa '(__fish_print_xdg_mimetypes)' # complete xdg-mime install complete -c xdg-mime -d 'Add filetype description' -n 'contains_seq xdg-mime install -- (commandline -cop)' -r diff --git a/share/completions/xinput.fish b/share/completions/xinput.fish index c86445c24..6f8df0274 100644 --- a/share/completions/xinput.fish +++ b/share/completions/xinput.fish @@ -28,5 +28,5 @@ function __fish_xinput_nth_token end complete -c xinput -f -n "not __fish_seen_subcommand_from $cmds" -a "$cmds" -complete -c xinput -f -n "fish_is_nth_token 2; and __fish_seen_subcommand_from list get-feedbacks set-pointer set-mode set-ptr-feedback set-integer-feedback set-button-map query-state list-props set-int-prop set-float-prop set-prop watch-props" -a "(__fish_xinput_devices)" -complete -c xinput -f -n "__fish_seen_subcommand_from list set-int-prop set-float-prop set-prop watch-props; and not fish_is_nth_token 2" -xa "(__fish_xinput_device_props (__fish_xinput_nth_token 2))" +complete -c xinput -f -n "__fish_is_nth_token 2; and __fish_seen_subcommand_from list get-feedbacks set-pointer set-mode set-ptr-feedback set-integer-feedback set-button-map query-state list-props set-int-prop set-float-prop set-prop watch-props" -a "(__fish_xinput_devices)" +complete -c xinput -f -n "__fish_seen_subcommand_from list set-int-prop set-float-prop set-prop watch-props; and not __fish_is_nth_token 2" -xa "(__fish_xinput_device_props (__fish_xinput_nth_token 2))" diff --git a/share/completions/xsp.fish b/share/completions/xsp.fish new file mode 100644 index 000000000..9abdd2d6f --- /dev/null +++ b/share/completions/xsp.fish @@ -0,0 +1,30 @@ +complete -c xsp -l help -d 'Show help' +complete -c xsp -l version -d 'Show version' + +complete -c xsp -l address -x -d 'Use the IP address to listen on' +complete -c xsp -l port -x -d 'Use the port where the XSP server will listen to requests' +complete -c xsp -l backlog -x -d 'Use the backlog of connections to set on the listener socket' +complete -c xsp -l minThreads -x -d 'Specify minimum number of threads the threadpool allocates' +complete -c xsp -l filename -r -d 'Use unix socket file name to listen on' +complete -c xsp -l root -r -d 'Use root directory for XSP' +complete -c xsp -l appconfigfile -r -d 'Add application definitions from the XML configuration file' +complete -c xsp -l appconfigdir -r \ + -d 'Add application definitions from all XML files found in the specified directory' +complete -c xsp -l applications -r \ + -d 'Use a comma separated list of virtual directory and real directory for all the applications' +complete -c xsp -l master -d 'Use this instance by mod_mono to create ASP.NET applications on demand' +complete -c xsp -l no-hidden -d 'Do not protect hidden files/directories from being accessed by clients' +complete -c xsp -l https -d 'Enable HTTPS support on the server' +complete -c xsp -l https-client-accept -d 'Like --https enable HTTPS support on the server' +complete -c xsp -l https-client-require -d 'Like --https enable HTTPS support on the server' +complete -c xsp -l p12file -r -d 'Use to specify the PKCS#12 file to use' +complete -c xsp -l cert -r -d 'Use to specify the server X.509 certificate file' +complete -c xsp -l pkpwd -r -d 'Use password to decode the private key' + +complete -c xsp -l protocol \ + -a 'Default\t"Auto-detect the client protocol and adjust the server protocol accordingly" Tls\t"Tls protocol" Ssl3\t"Ssl3 protocol"' \ + -x -d 'Use protocols available for encrypting the communications' + +complete -c xsp -l terminate -d 'Gracefully terminates a running mod-mono-server instance' +complete -c xsp -l verbose -d 'Show more messages' +complete -c xsp -l pidfile -r -d 'Redirect xsp4 PID output in stdout to file' diff --git a/share/completions/xsv.fish b/share/completions/xsv.fish index a68a3e5eb..edb28fd54 100644 --- a/share/completions/xsv.fish +++ b/share/completions/xsv.fish @@ -1,26 +1,26 @@ -complete -c xsv -n "fish_is_nth_token 1" -xa cat -d 'Concatenate by row or column' -complete -c xsv -n "fish_is_nth_token 1" -xa count -d 'Count records' -complete -c xsv -n "fish_is_nth_token 1" -xa fixlengths -d 'Makes all records have same length' -complete -c xsv -n "fish_is_nth_token 1" -xa flatten -d 'Show one field per line' -complete -c xsv -n "fish_is_nth_token 1" -xa fmt -d 'Format CSV output (change field delimiter)' -complete -c xsv -n "fish_is_nth_token 1" -xa frequency -d 'Show frequency tables' -complete -c xsv -n "fish_is_nth_token 1" -xa headers -d 'Show header names' -complete -c xsv -n "fish_is_nth_token 1" -xa help -d 'Show this usage message.' -complete -c xsv -n "fish_is_nth_token 1" -xa index -d 'Create CSV index for faster access' -complete -c xsv -n "fish_is_nth_token 1" -xa input -d 'Read CSV data with special quoting rules' -complete -c xsv -n "fish_is_nth_token 1" -xa join -d 'Join CSV files' -complete -c xsv -n "fish_is_nth_token 1" -xa sample -d 'Randomly sample CSV data' -complete -c xsv -n "fish_is_nth_token 1" -xa search -d 'Search CSV data with regexes' -complete -c xsv -n "fish_is_nth_token 1" -xa select -d 'Select columns from CSV' -complete -c xsv -n "fish_is_nth_token 1" -xa slice -d 'Slice records from CSV' -complete -c xsv -n "fish_is_nth_token 1" -xa sort -d 'Sort CSV data' -complete -c xsv -n "fish_is_nth_token 1" -xa split -d 'Split CSV data into many files' -complete -c xsv -n "fish_is_nth_token 1" -xa stats -d 'Compute basic statistics' -complete -c xsv -n "fish_is_nth_token 1" -xa table -d 'Align CSV data into columns' +complete -c xsv -n "__fish_is_nth_token 1" -xa cat -d 'Concatenate by row or column' +complete -c xsv -n "__fish_is_nth_token 1" -xa count -d 'Count records' +complete -c xsv -n "__fish_is_nth_token 1" -xa fixlengths -d 'Makes all records have same length' +complete -c xsv -n "__fish_is_nth_token 1" -xa flatten -d 'Show one field per line' +complete -c xsv -n "__fish_is_nth_token 1" -xa fmt -d 'Format CSV output (change field delimiter)' +complete -c xsv -n "__fish_is_nth_token 1" -xa frequency -d 'Show frequency tables' +complete -c xsv -n "__fish_is_nth_token 1" -xa headers -d 'Show header names' +complete -c xsv -n "__fish_is_nth_token 1" -xa help -d 'Show this usage message.' +complete -c xsv -n "__fish_is_nth_token 1" -xa index -d 'Create CSV index for faster access' +complete -c xsv -n "__fish_is_nth_token 1" -xa input -d 'Read CSV data with special quoting rules' +complete -c xsv -n "__fish_is_nth_token 1" -xa join -d 'Join CSV files' +complete -c xsv -n "__fish_is_nth_token 1" -xa sample -d 'Randomly sample CSV data' +complete -c xsv -n "__fish_is_nth_token 1" -xa search -d 'Search CSV data with regexes' +complete -c xsv -n "__fish_is_nth_token 1" -xa select -d 'Select columns from CSV' +complete -c xsv -n "__fish_is_nth_token 1" -xa slice -d 'Slice records from CSV' +complete -c xsv -n "__fish_is_nth_token 1" -xa sort -d 'Sort CSV data' +complete -c xsv -n "__fish_is_nth_token 1" -xa split -d 'Split CSV data into many files' +complete -c xsv -n "__fish_is_nth_token 1" -xa stats -d 'Compute basic statistics' +complete -c xsv -n "__fish_is_nth_token 1" -xa table -d 'Align CSV data into columns' # with a subcommand -complete -c xsv -n 'not fish_is_nth_token 1' -k -xa '(__fish_complete_suffix .csv)' -complete -c xsv -n 'not fish_is_nth_token 1' -s h -l help -d 'Display help for this xsv command' +complete -c xsv -n 'not __fish_is_nth_token 1' -k -xa '(__fish_complete_suffix .csv)' +complete -c xsv -n 'not __fish_is_nth_token 1' -s h -l help -d 'Display help for this xsv command' # without a subcommand complete -c xsv -s h -l help -d 'Display xsv help' diff --git a/share/completions/yadm.fish b/share/completions/yadm.fish index 7a6d07ce8..1f7e2dc79 100644 --- a/share/completions/yadm.fish +++ b/share/completions/yadm.fish @@ -128,4 +128,4 @@ complete -f -c yadm -n "__fish_yadm_using_command config" -l unset -a '(__fish_y complete -f -c yadm -n "__fish_yadm_using_command config" -l unset-all -a '(__fish_yadm_config_keys)' -d 'Remove matching variables' # If no argument is specified for `config`, it's as if --get was used -complete -f -c yadm -n "__fish_yadm_using_command config; and fish_is_nth_token 3" -a '(__fish_yadm_config_keys)' +complete -f -c yadm -n "__fish_yadm_using_command config; and __fish_is_nth_token 3" -a '(__fish_yadm_config_keys)' diff --git a/share/completions/zfs.fish b/share/completions/zfs.fish index 7974a6151..f4f80b048 100644 --- a/share/completions/zfs.fish +++ b/share/completions/zfs.fish @@ -1,16 +1,21 @@ -# Fish completions for the OpenZFS zfs command -# TODO Possible enhancements: -# - add a test to propose iSCSI and Trusted Extensions completions only when such system is present; -# - Illumos man pages suggests that it does not support nbmand nor atime mount option, so these properties should be proposed only when available -# - generally, propose properties only when the current OS and ZFS versions support them; -# - for the promote command, propose only eligible filesystems; -# - for the rollback command, propose only the most recent snapshot for each dataset, as it will not accept an intermediary snapshot; -# - for the release command, complete with existing tags; -# - for the diff command, complete the destination dataset of the diff; -# - for the program command, complete the script to be executed -# - for commands accepting several arguments of different types, propose arguments in the right order: for get, once the ZFS parameters have been given, only propose datasets +# Fish completions for the ZFS `zfs` command +# +# Possible enhancements: +# - Add a test to propose iSCSI and Trusted Extensions completions only when such system is present; +# - Illumos man pages suggests that it does not support nbmand nor atime mount option, so these +# properties should be proposed only when available; +# - Generally, propose properties only when the current OS and ZFS versions support them; +# - For the promote command, propose only eligible filesystems; +# - For the rollback command, propose only the most recent snapshot for each dataset, as it will not +# accept an intermediary snapshot; +# - For the release command, complete with existing tags; +# - For the diff command, complete the destination dataset of the diff; +# - For the program command, complete the script to be executed; +# - For commands accepting several arguments of different types, propose arguments in the right +# order: for get, once the ZFS parameters have been given, only propose datasets. set -l OS "" +set -l freebsd_version "" switch (uname) case Linux set OS Linux @@ -18,6 +23,7 @@ switch (uname) set OS macOS case FreeBSD set OS FreeBSD + set freebsd_version (uname -U) case SunOS set OS SunOS # Others? @@ -25,6 +31,14 @@ switch (uname) set OS unknown end +# Certain functionality is exclusive to platforms using OpenZFS. This used to be just Linux, but it +# now includes FreeBSD 13 and above. +if not type -q __fish_is_openzfs + function __fish_is_openzfs --inherit-variable freebsd_version --inherit-variable OS + test $OS = Linux || test $OS = FreeBSD -a $freebsd_version -gt 1300000 + end +end + # Does the current invocation need a command? function __fish_zfs_needs_command set -l bookmark "" @@ -90,6 +104,87 @@ function __fish_zfs_list_groupspace_types echo -e "all\tBoth types" end +function __fish_zfs_complete_property_values -a name + # To make updates easier, instead of using a switch/case here we just copy-and-paste the lines + # from zfsprops(8) directly, and then parse them when the function is called. + + set all_options " + aclinherit=discard|noallow|restricted|passthrough|passthrough-x + aclmode=discard|groupmask|passthrough|restricted + acltype=off|nfsv4|posix + atime=on|off + canmount=on|off|noauto + checksum=on|off|fletcher2|fletcher4|sha256|noparity|sha512|skein|edonr + compression=on|off|gzip|gzip-N|lz4|lzjb|zle|zstd|zstd-N|zstd-fast|zstd-fast-N + context=none|SELinux_User:SElinux_Role:Selinux_Type:Sensitivity_Level + fscontext=none|SELinux_User:SElinux_Role:Selinux_Type:Sensitivity_Level + defcontext=none|SELinux_User:SElinux_Role:Selinux_Type:Sensitivity_Level + rootcontext=none|SELinux_User:SElinux_Role:Selinux_Type:Sensitivity_Level + copies=1|2|3 + devices=on|off + dedup=off|on|verify|sha256[,verify]|sha512[,verify]|skein[,verify]|edonr,verify + dnodesize=legacy|auto|1k|2k|4k|8k|16k + encryption=off|on|aes-128-ccm|aes-192-ccm|aes-256-ccm|aes-128-gcm|aes-192-gcm|aes-256-gcm + keyformat=raw|hex|passphrase + keylocation=prompt|file:// + pbkdf2iters=iterations + exec=on|off + filesystem_limit=count|none + special_small_blocks=size + mountpoint=path|none|legacy + nbmand=on|off + overlay=on|off + primarycache=all|none|metadata + quota=size|none + snapshot_limit=count|none + recordsize=size + readonly=on|off + redundant_metadata=all|most + refquota=size|none + refreservation=size|none|auto + relatime=on|off + reservation=size|none + secondarycache=all|none|metadata + setuid=on|off + sharesmb=on|off|opts + sharenfs=on|off|opts + logbias=latency|throughput + snapdev=hidden|visible + snapdir=hidden|visible + sync=standard|always|disabled + version=N|current + volsize=size + volmode=default | full | geom | dev | none + vscan=on|off + xattr=on|off|sa + jailed=off | on + casesensitivity=sensitive|insensitive|mixed + normalization=none|formC|formD|formKC|formKD + utf8only=on|off +" + # Convert the list above into an array of strings + set all_options (string split \n -- $all_options | string trim) + + # Make sure the name doesn't already have a trailing = (depending on the context) + set name (string match -r '^[^=]+' -- $name) + # Extract the values "value1|value2" from the long list of "key=value1|value2" + set options (string match "$name=*" -- $all_options | string split =)[2] + # echo o1: (string escape -- $options) + # Put each possible value on its own line and account for formatting disparities + set options (string replace -a '|' \n -- $options | string trim) + # echo o2: (string escape -- $options) + # Remove open-ended options (size, count, path) + set options (string match -rv '^(size|count|iterations|path)$|\<.*?\>' -- $options) + # echo o3: (string escape -- $options) + # Expand optionally comma-separated arguments (e.g. skein[,verify] => skein\nskein,verify) + set options (string replace -r "(.*)\[,(.*?)\]" '$1\n$1,$2' -- $options) + # echo o4: (string escape -- $options) + + if set -q options[1] + printf "$name=%s\n" $options + end +end + # Generate a list of possible values from the man page. # NB: This includes "hints" like "size" or "opts" which may be useful or unwanted. *shrug* if type -q man && type -q col @@ -261,25 +356,29 @@ if test $OS = SunOS # This is currently only supported under Illumos, but that w complete -c zfs -f -n __fish_zfs_needs_command -a program -d 'Execute a ZFS Channel Program' end -# Completions hereafter try to follow the man pages commands order, for maintainability, at the cost of multiple if statements +# Completions hereafter try to follow the man pages commands order, for maintainability, at the cost +# of multiple if statements. # create completions complete -c zfs -f -n '__fish_zfs_using_command create' -s p -d 'Create all needed non-existing parent datasets' if test $OS = Linux # Only Linux supports the comma-separated format; others need multiple -o calls complete -c zfs -x -n '__fish_zfs_using_command create' -s o -d 'Dataset property' -a '(__fish_append , (__fish_complete_zfs_rw_properties; __fish_complete_zfs_write_once_properties))' -else - complete -c zfs -x -n '__fish_zfs_using_command create' -s o -d 'Dataset property' -a '(__fish_complete_zfs_rw_properties; __fish_complete_zfs_write_once_properties)' end -# create completions for volumes; as -V is necessary to zfs to recognize a volume creation request, we use it as a condition to propose volume creation completions -# If -V is typed after -s or -b, zfs should accept it, but fish won't propose -s or -b, but, as these options are for volumes only, it seems reasonable to expect the user to ask for a volume, with -V, before giving its characteristics with -s or -b +complete -c zfs -x -n '__fish_zfs_using_command create' -s o -d 'Dataset property' -a '(__fish_complete_zfs_rw_properties; __fish_complete_zfs_write_once_properties; __fish_zfs_complete_property_values (commandline -t))' +# create completions for volumes; as -V is necessary to zfs to recognize a volume creation request, +# we use it as a condition to propose volume creation completions. +# If -V is typed after -s or -b, zfs should accept it, but fish won't propose -s or -b, but, as +# these options are for volumes only, it seems reasonable to expect the user to ask for a volume, +# with -V, before giving its characteristics with -s or -b complete -c zfs -x -n '__fish_zfs_using_command create' -s V -d 'Volume size' complete -c zfs -f -n '__fish_zfs_using_command create; and __fish_contains_opt -s V' -s s -d 'Create a sparse volume' complete -c zfs -x -n '__fish_zfs_using_command create; and __fish_contains_opt -s V' -s b -d Blocksize -# new dataset completions, applicable for both regular datasets and volumes; must start with pool and may optionally -# be a child of a pre-existing dataset. +# new dataset completions, applicable for both regular datasets and volumes; must start with pool +# and may optionally be a child of a pre-existing dataset. complete -c zfs -x -n '__fish_zfs_using_command create' -a '(printf "%s/\n" (__fish_print_zfs_filesystems))' -# destroy completions; as the dataset is the last item, we can't know yet if it's a snapshot, a bookmark or something else, so we can't separate snapshot-specific options from others +# destroy completions; as the dataset is the last item, we can't know yet if it's a snapshot, a +# bookmark or something else, so we can't separate snapshot-specific options from others. complete -c zfs -f -n '__fish_zfs_using_command destroy' -s r -d 'Recursively destroy children' complete -c zfs -f -n '__fish_zfs_using_command destroy' -s R -d 'Recursively destroy all dependents' complete -c zfs -f -n '__fish_zfs_using_command destroy' -s f -d 'Force unmounting' @@ -293,9 +392,8 @@ complete -c zfs -x -n '__fish_zfs_using_command destroy' -d 'Dataset to destroy' complete -c zfs -f -n '__fish_zfs_using_command snapshot; or __fish_zfs_using_command snap' -s r -d 'Recursively snapshot children' if test $OS = Linux # Only Linux supports the comma-separated format; others need multiple -o calls complete -c zfs -x -n '__fish_zfs_using_command snapshot; or __fish_zfs_using_command snap' -s o -d 'Snapshot property' -a '(__fish_append , (__fish_complete_zfs_rw_properties; __fish_complete_zfs_write_once_properties))' -else - complete -c zfs -x -n '__fish_zfs_using_command snapshot; or __fish_zfs_using_command snap' -s o -d 'Snapshot property' -a '(__fish_complete_zfs_rw_properties; __fish_complete_zfs_write_once_properties)' end +complete -c zfs -x -n '__fish_zfs_using_command snapshot; or __fish_zfs_using_command snap' -s o -d 'Snapshot property' -a '(__fish_complete_zfs_rw_properties; __fish_complete_zfs_write_once_properties; __fish_zfs_complete_property_values (commandline -t))' complete -c zfs -x -n '__fish_zfs_using_command snapshot; or __fish_zfs_using_command snap' -d 'Dataset to snapshot' -a '(__fish_print_zfs_filesystems; __fish_print_zfs_volumes)' # rollback completions @@ -308,22 +406,23 @@ complete -c zfs -x -n '__fish_zfs_using_command rollback' -d 'Snapshot to roll b complete -c zfs -f -n '__fish_zfs_using_command clone' -s p -d 'Create all needed non-existing parent datasets' if test $OS = Linux # Only Linux supports the comma-separated format; others need multiple -o calls complete -c zfs -x -n '__fish_zfs_using_command clone' -s o -d 'Clone property' -a '(__fish_append , (__fish_complete_zfs_rw_properties; __fish_complete_zfs_write_once_properties))' -else - complete -c zfs -x -n '__fish_zfs_using_command clone' -s o -d 'Clone property' -a '(__fish_complete_zfs_rw_properties; __fish_complete_zfs_write_once_properties)' end +complete -c zfs -x -n '__fish_zfs_using_command clone' -s o -d 'Clone property' -a '(__fish_complete_zfs_rw_properties; __fish_complete_zfs_write_once_properties; __fish_zfs_complete_property_values (commandline -t))' complete -c zfs -x -n '__fish_zfs_using_command clone' -d 'Snapshot to clone' -a '(__fish_print_zfs_snapshots --force)' # promote completions complete -c zfs -x -n '__fish_zfs_using_command promote' -d 'Clone to promote' -a '(__fish_print_zfs_filesystems)' -# rename completions; as the dataset is the last item, we can't know yet if it's a snapshot or not, we can't separate snapshot-specific option from others +# rename completions; as the dataset is the last item, we can't know yet if it's a snapshot or not, +# we can't separate snapshot-specific option from others. complete -c zfs -f -n '__fish_zfs_using_command rename' -s p -d 'Create all needed non-existing parent datasets' complete -c zfs -f -n '__fish_zfs_using_command rename' -s r -d 'Recursively rename children snapshots' -if test $OS = Linux +if __fish_is_openzfs complete -c zfs -f -n '__fish_zfs_using_command rename' -s f -d 'Force unmounting if needed' -else if test $OS = FreeBSD +end +# These FreeBSD completions are in addition to any added via the OpenZFS check above +if test $OS = FreeBSD complete -c zfs -f -n '__fish_zfs_using_command rename' -s u -d 'Do not remount filesystems during rename' - complete -c zfs -f -n '__fish_zfs_using_command rename; and __fish_not_contain_opt -s u' -s f -d 'Force unmounting if needed' end complete -c zfs -x -n '__fish_zfs_using_command rename' -d 'Dataset to rename' -a '(__fish_print_zfs_filesystems; __fish_print_zfs_volumes; __fish_print_zfs_snapshots)' @@ -338,11 +437,11 @@ complete -c zfs -x -n '__fish_zfs_using_command list; and __fish_not_contain_opt complete -c zfs -x -n '__fish_zfs_using_command list' -s t -d 'Dataset type' -a '(__fish_zfs_list_dataset_types)' complete -c zfs -x -n '__fish_zfs_using_command list' -d 'Dataset whose properties to list' -a '(__fish_print_zfs_filesystems; __fish_print_zfs_volumes; __fish_print_zfs_snapshots)' -# set completions -complete -c zfs -x -n '__fish_zfs_using_command set' -d 'Property to set' -a '(__fish_complete_zfs_rw_properties)' -complete -c zfs -x -n '__fish_zfs_using_command set; and string match -q -r "zfs set \S+ " (commandline -c)' -d 'Dataset whose property to set' -a '(__fish_print_zfs_filesystems; __fish_print_zfs_volumes; __fish_print_zfs_snapshots)' +# set completions (zfs set PROP VALUE POOL/DATASET) +complete -c zfs -x -n '__fish_zfs_using_command set; and __fish_is_nth_token 2' -d 'Property to set' -a '(__fish_complete_zfs_rw_properties)' +complete -c zfs -x -n '__fish_zfs_using_command set; and __fish_is_nth_token 3' -d 'Dataset whose property to set' -a '(__fish_print_zfs_filesystems; __fish_print_zfs_volumes; __fish_print_zfs_snapshots)' # set property value completions -complete -c zfs -x -n '__fish_zfs_using_command set; and string match -qe = -- (commandline -t)' -a '(__fish_zfs_property_options (commandline -t | string match -r "[^=]+"))' +complete -c zfs -x -n '__fish_zfs_using_command set; and __fish_is_nth_token 2' -a '(__fish_zfs_complete_property_values (fish_nth_token 2))' # get completions complete -c zfs -f -n '__fish_zfs_using_command get' -s r -d 'Operate recursively on datasets' @@ -381,7 +480,10 @@ complete -c zfs -f -n '__fish_zfs_using_command userspace; or __fish_zfs_using_c complete -c zfs -x -n '__fish_zfs_using_command userspace; or __fish_zfs_using_command groupspace' -d 'Dataset whose space usage to get' -a '(__fish_print_zfs_filesystems; __fish_print_zfs_snapshots)' # mount completions -complete -c zfs -x -n '__fish_zfs_using_command mount' -s o -d 'Temporary mount point property' -a '(__fish_append , (__fish_complete_zfs_mountpoint_properties))' +if test $OS = Linux + complete -c zfs -x -n '__fish_zfs_using_command mount' -s o -d 'Temporary mount point property' -a '(__fish_append , (__fish_complete_zfs_mountpoint_properties))' +end +complete -c zfs -x -n '__fish_zfs_using_command mount' -s o -d 'Temporary mount point property' -a '(__fish_complete_zfs_mountpoint_properties; __fish_zfs_complete_property_values (commandline -t))' complete -c zfs -f -n '__fish_zfs_using_command mount' -s v -d 'Report progress' complete -c zfs -f -n '__fish_zfs_using_command mount' -s a -d 'Mount all available ZFS filesystems' if contains -- $OS Linux SunOS diff --git a/share/completions/zpool.fish b/share/completions/zpool.fish index 00de7cf55..f20fa3972 100644 --- a/share/completions/zpool.fish +++ b/share/completions/zpool.fish @@ -1,10 +1,15 @@ -# Fish completions for the OpenZFS zpool command +# Fish completions for the ZFS `zpool` command +# # Possible improvements: -# - whenever possible, propose designation of vdevs using their GUID -# - for eligible commands, with arguments of different types, only propose second type completions after the first have been selected; for instance, only propose pool members for offline command -# - this has been written mainly from manpages, which are known to be out-of-sync with the real feature set; some discrepancies have been addressed, but it is highly likely that others still lie +# - Whenever possible, propose designation of vdevs using their GUID. +# - For eligible commands, with arguments of different types, only propose second type completions +# after the first have been selected; for instance, only propose pool members for offline command. +# - This has been written mainly from manpages, which are known to be out-of-sync with the real +# feature set; some discrepancies have been addressed, but it is highly likely that others still +# lie. set -l OS "" +set -l freebsd_version "" switch (uname) case Linux set OS Linux @@ -12,6 +17,7 @@ switch (uname) set OS macOS case FreeBSD set OS FreeBSD + set freebsd_version (uname -U) case SunOS set OS SunOS # Others? @@ -19,6 +25,14 @@ switch (uname) set OS unknown end +# Certain functionality is exclusive to platforms using OpenZFS. This used to be just Linux, but it +# now includes FreeBSD 13 and above. +if not type -q __fish_is_openzfs + function __fish_is_openzfs --inherit-variable freebsd_version --inherit-variable OS + test $OS = Linux || test $OS = FreeBSD -a $freebsd_version -gt 1300000 + end +end + # Does the current invocation need a command? function __fish_zpool_needs_command not __fish_seen_subcommand_from \? add attach clear create destroy detach events get history import iostat labelclear list offline online reguid reopen remove replace scrub set split status upgrade @@ -39,7 +53,7 @@ end function __fish_zpool_list_used_vdevs -a pool # See discussion and variants discussed at # https://github.com/fish-shell/fish-shell/pull/5743#pullrequestreview-217432149 - zpool list -Hv | string replace -rf "^\t([^\t]+).*" '$1' | string match -rv '^(spare|log|cache|mirror|raidz.?)' + zpool list -Hv $pool | string replace -rf "^\t([^\t]+).*" '$1' | string match -rv '^(spare|log|cache|mirror|raidz.?)' end function __fish_zpool_list_available_vdevs -V OS @@ -53,9 +67,17 @@ function __fish_zpool_list_available_vdevs -V OS end function __fish_zpool_complete_vdevs - # As this function is to be called for completions only when necessary, we don't need to verify that it is relevant for the specified command; this is to be decided by calling, or not, the current function for command completions - # We can display the physical devices, as they are relevant whereas we are in a vdev definition or not + # As this function is to be called for completions only when necessary, we don't need to verify + # that it is relevant for the specified command; this is to be decided by calling, or not, the + # current function for command completions. + # We can display the physical devices, as they are relevant whereas we are in a vdev definition + # or not. Many operations need this list of vdevs winnowed down to some precondition (mostly + # "vdevs associated with pool" or "vdevs not associated with pool") but it's not really feasible + # to do that here as the situations are highly subcommand-dependent and this function is + # structured to operate backwards only analyzing the subcommand at the very end. Long story + # short, that vdev filtering will need to happen at the call site, at least currently. __fish_zpool_list_available_vdevs + # First, reverse token list to analyze it from the end set -l tokens 0 for i in (commandline -co)[-1..1] @@ -80,14 +102,17 @@ function __fish_zpool_complete_vdevs __fish_zpool_list_vdev_types end return - # Here, we accept any possible zpool command; this way, the developper will not have to augment or reduce the list when adding the current function to or removing it from the completions for the said command + # Here, we accept any possible zpool command; this way, the developer will not have + # to augment or reduce the list when adding the current function to or removing it + # from the completions for the said command. case \? add attach clear create destroy detach events get history import iostat labelclear list offline online reguid reopen remove replace scrub set split status upgrade __fish_zpool_list_vdev_types return case "" # Au cas où echo "" >/dev/null case "-*" "*=*" "*,*" - # The token is an option or an option argument; as no option uses a vdev as its argument, we can abandon commandline parsing + # The token is an option or an option argument; as no option uses a vdev as its + # argument, we can abandon commandline parsing. __fish_zpool_list_vdev_types return end @@ -174,7 +199,7 @@ complete -c zpool -f -n __fish_zpool_needs_command -a clear -d 'Clear devices er complete -c zpool -f -n __fish_zpool_needs_command -a create -d 'Create a new storage pool' complete -c zpool -f -n __fish_zpool_needs_command -a destroy -d 'Destroy a storage pool' complete -c zpool -f -n __fish_zpool_needs_command -a detach -d 'Detach virtual device from a mirroring pool' -if test $OS = Linux +if __fish_is_openzfs complete -c zpool -f -n __fish_zpool_needs_command -a events -d 'Display pool event log' end complete -c zpool -f -n __fish_zpool_needs_command -a export -d 'Export a pool' @@ -199,22 +224,34 @@ complete -c zpool -f -n __fish_zpool_needs_command -a upgrade -d 'List upgradeab # add completions complete -c zpool -f -n '__fish_zpool_using_command add' -s f -d 'Force use of virtual device' complete -c zpool -f -n '__fish_zpool_using_command add' -s n -d 'Dry run: only display resulting configuration' -if test $OS = Linux +if __fish_is_openzfs complete -c zpool -f -n '__fish_zpool_using_command add' -s g -d 'Display virtual device GUID instead of device name' complete -c zpool -f -n '__fish_zpool_using_command add' -s L -d 'Resolve device path symbolic links' complete -c zpool -f -n '__fish_zpool_using_command add' -s P -d 'Display device full path' complete -c zpool -x -n '__fish_zpool_using_command add' -s o -d 'Pool property' -a '(__fish_zpool_list_device_properties)' end -complete -c zpool -x -n '__fish_zpool_using_command add; and __fish_prev_arg_in add' -d 'Pool to add virtual devices to' -a '(__fish_complete_zfs_pools)' -complete -c zpool -x -n '__fish_zpool_using_command add; and not __fish_prev_arg_in add' -d 'Virtual device to add' -a '(__fish_zpool_complete_vdevs)' +complete -c zpool -x -n '__fish_zpool_using_command add; and __fish_is_nth_token 2' -d 'Pool to add virtual device(s) to' -a '(__fish_complete_zfs_pools)' +# complete -c zpool -x -n '__fish_zpool_using_command add; and not __fish_prev_arg_in add' -d 'Virtual device to add' -a '(__fish_zpool_complete_vdevs)' +# Exclude devices already part of this pool, and devices already in any other pool unless +# `zpool add -f` was used. +complete -c zpool -x -n '__fish_zpool_using_command add; and not __fish_prev_arg_in add' -k -d 'Virtual device to add' -a '(__fish_zpool_complete_vdevs | string match -vr (__fish_zpool_list_used_vdevs (__fish_seen_argument -s f && __fish_nth_token 2) | string escape --style regex | string replace -r \'(.*)\' \'^$1\\\\\\$\' | string join "|"))' # the insane number of backslashes is unfortunate # attach completions complete -c zpool -f -n '__fish_zpool_using_command attach' -s f -d 'Force use of virtual device' -if test $OS = Linux +if __fish_is_openzfs complete -c zpool -x -n '__fish_zpool_using_command attach' -s o -d 'Pool property' -a '(__fish_zpool_list_device_properties)' end -complete -c zpool -x -n '__fish_zpool_using_command attach' -d 'Pool to attach virtual device to' -a '(__fish_complete_zfs_pools)' -complete -c zpool -x -n '__fish_zpool_using_command attach' -d 'Virtual device to operate on' -a '(__fish_zpool_list_available_vdevs)' +# The ideal behavior for attach is as follows: +# - zpool attach [should list only pools] +# - zpool attach [should list only devices already part of pool] +# - zpool attach [should list only devices not already part of a/the pool] +complete -c zpool -x -n '__fish_zpool_using_command attach; and __fish_is_nth_token 2' -d 'Pool to attach virtual device to' -a '(__fish_complete_zfs_pools)' +complete -c zpool -x -n '__fish_zpool_using_command attach; and __fish_is_nth_token 3' -d 'Existing pool device to attach to' -a '(__fish_zpool_list_used_vdevs (__fish_nth_token 2))' +# Generate a list of devices in the system modulo devices already part of an online zpool. +# These latter can be forcefully added, so we only exclude them if we don't introspect the presence +# of a `-f` argument to `zpool attach` (but still exclude any devices already part of the same pool +# that we're attaching to, "obviously"). +complete -c zpool -x -n '__fish_zpool_using_command attach; and __fish_is_nth_token 4' -d 'Device to be attached' -a '(__fish_zpool_list_available_vdevs | string match -vr (__fish_zpool_list_used_vdevs (__fish_seen_argument -s f && __fish_nth_token 2) | string escape --style regex | string replace -r \'(.*)\' \'^$1\\\\\\$\' | string join "|"))' # the insane number of backslashes is unfortunate # clear completions if test $OS = FreeBSD @@ -236,7 +273,7 @@ complete -c zpool -x -n '__fish_zpool_using_command create' -s o -d 'Pool proper complete -c zpool -x -n '__fish_zpool_using_command create' -s O -d 'Root filesystem property' -a '(__fish_complete_zfs_ro_properties; __fish_complete_zfs_rw_properties; __fish_complete_zfs_write_once_properties)' complete -c zpool -r -n '__fish_zpool_using_command create' -s R -d 'Equivalent to "-o cachefile=none,altroot=ROOT"' complete -c zpool -x -n '__fish_zpool_using_command create' -s m -d 'Root filesystem mountpoint' -a 'legacy none' -if test $OS = Linux +if __fish_is_openzfs complete -c zpool -x -n '__fish_zpool_using_command create' -s t -d 'Set a different in-core pool name' end complete -c zpool -x -n '__fish_zpool_using_command create' -d 'Virtual device to add' -a '(__fish_zpool_complete_vdevs)' @@ -250,7 +287,7 @@ complete -c zpool -x -n '__fish_zpool_using_command clear' -d 'Pool to detach de complete -c zpool -x -n '__fish_zpool_using_command clear' -d 'Physical device to detach' -a '(__fish_zpool_list_used_vdevs)' # events completions -if test $OS = Linux +if __fish_is_openzfs complete -c zpool -f -n '__fish_zpool_using_command events' -s v -d 'Print verbose event information' complete -c zpool -f -n '__fish_zpool_using_command events' -s H -d 'Print output in a machine-parsable format' complete -c zpool -f -n '__fish_zpool_using_command events' -s f -d 'Output appended data as the log grows' @@ -259,7 +296,7 @@ if test $OS = Linux end # export completions -if test $OS = Linux +if __fish_is_openzfs complete -c zpool -f -n '__fish_zpool_using_command export' -s a -d 'Export all pools' end complete -c zpool -f -n '__fish_zpool_using_command export' -s f -d 'Force unmounting of all contained datasets' @@ -292,7 +329,7 @@ complete -c zpool -f -n '__fish_zpool_using_command import' -s m -d 'Ignore miss complete -c zpool -r -n '__fish_zpool_using_command import' -s R -d 'Equivalent to "-o cachefile=none,altroot=ROOT"' complete -c zpool -f -n '__fish_zpool_using_command import' -s N -d 'Do not mount contained filesystems' complete -c zpool -f -n '__fish_zpool_using_command import; and __fish_contains_opt -s F' -s n -d 'Dry run: only determine if the recovery is possible, without attempting it' -if test $OS = Linux +if __fish_is_openzfs complete -c zpool -f -n '__fish_zpool_using_command import; and __fish_contains_opt -s F' -s X -d 'Roll back to a previous TXG (hazardous)' complete -c zpool -r -n '__fish_zpool_using_command import' -s T -d 'TXG to roll back to (implies -FX)' complete -c zpool -f -n '__fish_zpool_using_command import' -s t -d 'Specify, as the last argument, a temporary pool name' @@ -301,7 +338,7 @@ complete -c zpool -f -n '__fish_zpool_using_command import; and __fish_not_conta # iostat completions complete -c zpool -x -n '__fish_zpool_using_command iostat' -s T -d 'Display a timestamp using specified format' -if test $OS = Linux +if __fish_is_openzfs complete -c zpool -f -n '__fish_zpool_using_command iostat' -s g -d 'Display virtual device GUID instead of device name' complete -c zpool -f -n '__fish_zpool_using_command iostat' -s L -d 'Resolve device path symbolic links' complete -c zpool -f -n '__fish_zpool_using_command iostat' -s P -d 'Display device full path' @@ -316,7 +353,7 @@ complete -c zpool -x -n '__fish_zpool_using_command labelclear' -d 'Device to cl # list completions complete -c zpool -f -n '__fish_zpool_using_command list' -s H -d 'Print output in a machine-parsable format' -if test $OS = Linux +if __fish_is_openzfs complete -c zpool -f -n '__fish_zpool_using_command list' -s g -d 'Display virtual device GUID instead of device name' complete -c zpool -f -n '__fish_zpool_using_command list' -s L -d 'Resolve device path symbolic links' end @@ -348,7 +385,7 @@ complete -c zpool -x -n '__fish_zpool_using_command reopen' -d 'Pool which devic # replace completions complete -c zpool -f -n '__fish_zpool_using_command replace' -s f -d 'Force use of virtual device' -if test $OS = Linux +if __fish_is_openzfs complete -c zpool -x -n '__fish_zpool_using_command replace' -s o -d 'Pool property' -a '(__fish_zpool_list_device_properties)' end complete -c zpool -x -n '__fish_zpool_using_command replace' -d 'Pool to replace device' -a '(__fish_complete_zfs_pools)' @@ -367,7 +404,7 @@ complete -c zpool -x -n '__fish_zpool_using_command set' -d 'Property to set' -a complete -c zpool -x -n '__fish_zpool_using_command set' -d 'Pool which property is to be set' -a '(__fish_complete_zfs_pools)' # split completions -if test $OS = Linux +if __fish_is_openzfs complete -c zpool -f -n '__fish_zpool_using_command split' -s g -d 'Display virtual device GUID instead of device name' complete -c zpool -f -n '__fish_zpool_using_command split' -s L -d 'Resolve device path symbolic links' complete -c zpool -f -n '__fish_zpool_using_command split' -s P -d 'Display device full path' @@ -381,7 +418,7 @@ end complete -c zpool -x -n '__fish_zpool_using_command split' -d 'Pool to split' -a '(__fish_complete_zfs_pools)' # status completions -if test $OS = Linux +if __fish_is_openzfs complete -c zpool -f -n '__fish_zpool_using_command status' -s g -d 'Display virtual device GUID instead of device name' complete -c zpool -f -n '__fish_zpool_using_command status' -s L -d 'Resolve device path symbolic links' complete -c zpool -f -n '__fish_zpool_using_command status' -s P -d 'Display device full path' diff --git a/share/config.fish b/share/config.fish index a5792b062..622988f74 100644 --- a/share/config.fish +++ b/share/config.fish @@ -140,7 +140,7 @@ end # # Launch debugger on SIGTRAP # -function fish_sigtrap_handler --on-signal TRAP --no-scope-shadowing --description "Signal handler for the TRAP signal. Launches a debug prompt." +function fish_sigtrap_handler --on-signal TRAP --no-scope-shadowing --description "TRAP handler: debug prompt" breakpoint end diff --git a/share/functions/__fish_complete_gpg.fish b/share/functions/__fish_complete_gpg.fish index 82a83f14a..76dc15521 100644 --- a/share/functions/__fish_complete_gpg.fish +++ b/share/functions/__fish_complete_gpg.fish @@ -47,7 +47,7 @@ function __fish_complete_gpg -d "Internal function for gpg completion code dedup complete -c $__fish_complete_gpg_command -l skip-hidden-recipients -d "During decryption, skip all anonymous recipients" complete -c $__fish_complete_gpg_command -l tofu-default-policy -xa "auto good unknown bad ask" -d "Set the default TOFU policy" complete -c $__fish_complete_gpg_command -l tofu-policy -xa "auto good unknown bad ask" -d "Set the default TOFU policy for the specified keys" - complete -c $__fish_complete_gpg_command -l try-secret-key -xa "(__fish_complete_gpg_key_id $__fish_complete_gpg_command)" -d "Specify keys to be used for trial decryption" + complete -c $__fish_complete_gpg_command -l try-secret-key -xa "(__fish_complete_gpg_key_id $__fish_complete_gpg_command --list-secret-keys)" -d "Specify keys to be used for trial decryption" complete -c $__fish_complete_gpg_command -l with-icao-spelling -d "Print the ICAO spelling of the fingerprint in addition to the hex digits" complete -c $__fish_complete_gpg_command -l with-key-origin -d "Include the locally held information on the origin and last update of a key in a key listing" @@ -101,7 +101,7 @@ function __fish_complete_gpg -d "Internal function for gpg completion code dedup complete -c $__fish_complete_gpg_command -s k -l list-keys -xa "(__fish_complete_gpg_user_id $__fish_complete_gpg_command)" -d "List all keys from the public keyrings, or just the ones given on the command line" complete -c $__fish_complete_gpg_command -l list-public-keys -xa "(__fish_complete_gpg_user_id $__fish_complete_gpg_command)" -d "List all keys from the public keyrings, or just the ones given on the command line" - complete -c $__fish_complete_gpg_command -s K -l list-secret-keys -xa "(__fish_complete_gpg_user_id $__fish_complete_gpg_command)" -d "List all keys from the secret keyrings, or just the ones given on the command line" + complete -c $__fish_complete_gpg_command -s K -l list-secret-keys -xa "(__fish_complete_gpg_user_id $__fish_complete_gpg_command --list-secret-keys)" -d "List all keys from the secret keyrings, or just the ones given on the command line" complete -c $__fish_complete_gpg_command -l list-sigs -xa "(__fish_complete_gpg_user_id $__fish_complete_gpg_command)" -d "Same as --list-keys, but the signatures are listed too" complete -c $__fish_complete_gpg_command -l check-sigs -xa "(__fish_complete_gpg_user_id $__fish_complete_gpg_command)" -d "Same as --list-keys, but the signatures are listed and verified" @@ -116,9 +116,9 @@ function __fish_complete_gpg -d "Internal function for gpg completion code dedup complete -c $__fish_complete_gpg_command -l lsign-key -xa "(__fish_complete_gpg_user_id $__fish_complete_gpg_command)" -d "Sign a public key with your secret key but mark it as non exportable" complete -c $__fish_complete_gpg_command -l delete-key -xa "(__fish_complete_gpg_user_id $__fish_complete_gpg_command)" -d "Remove key from the public keyring" - complete -c $__fish_complete_gpg_command -l delete-secret-key -xa "(__fish_complete_gpg_user_id $__fish_complete_gpg_command)" -d "Remove key from the secret and public keyring" + complete -c $__fish_complete_gpg_command -l delete-secret-key -xa "(__fish_complete_gpg_user_id $__fish_complete_gpg_command --list-secret-keys)" -d "Remove key from the secret and public keyring" complete -c $__fish_complete_gpg_command -l delete-keys -xa "(__fish_complete_gpg_user_id $__fish_complete_gpg_command)" -d "Remove key from the public keyring" - complete -c $__fish_complete_gpg_command -l delete-secret-keys -xa "(__fish_complete_gpg_user_id $__fish_complete_gpg_command)" -d "Remove key from the secret and public keyring" + complete -c $__fish_complete_gpg_command -l delete-secret-keys -xa "(__fish_complete_gpg_user_id $__fish_complete_gpg_command --list-secret-keys)" -d "Remove key from the secret and public keyring" complete -c $__fish_complete_gpg_command -l delete-secret-and-public-key -xa "(__fish_complete_gpg_user_id $__fish_complete_gpg_command)" -d "Same as --delete-key, but if a secret key exists, it will be removed first" complete -c $__fish_complete_gpg_command -l gen-revoke -xa "(__fish_complete_gpg_user_id $__fish_complete_gpg_command)" -d "Generate a revocation certificate for the complete key" @@ -127,7 +127,7 @@ function __fish_complete_gpg -d "Internal function for gpg completion code dedup complete -c $__fish_complete_gpg_command -l export -xa "(__fish_complete_gpg_user_id $__fish_complete_gpg_command)" -d 'Export all or the given keys from all keyrings' complete -c $__fish_complete_gpg_command -l export-ssh-key -xa "(__fish_complete_gpg_user_id $__fish_complete_gpg_command)" -d 'Export all or the given keys in OpenSSH format' complete -c $__fish_complete_gpg_command -l send-keys -xa "(__fish_complete_gpg_key_id $__fish_complete_gpg_command)" -d "Same as --export but sends the keys to a keyserver" - complete -c $__fish_complete_gpg_command -l export-secret-keys -xa "(__fish_complete_gpg_user_id $__fish_complete_gpg_command)" -d "Same as --export, but exports the secret keys instead" + complete -c $__fish_complete_gpg_command -l export-secret-keys -xa "(__fish_complete_gpg_user_id $__fish_complete_gpg_command --list-secret-keys)" -d "Same as --export, but exports the secret keys instead" complete -c $__fish_complete_gpg_command -l export-secret-subkeys -xa "(__fish_complete_gpg_user_id $__fish_complete_gpg_command)" -d "Same as --export, but exports the secret keys instead" complete -c $__fish_complete_gpg_command -l import -d 'Import/merge keys' diff --git a/share/functions/__fish_complete_gpg_key_id.fish b/share/functions/__fish_complete_gpg_key_id.fish index 1993053ff..084601a82 100644 --- a/share/functions/__fish_complete_gpg_key_id.fish +++ b/share/functions/__fish_complete_gpg_key_id.fish @@ -1,16 +1,18 @@ # Helper function for contextual autocompletion of GPG key ids -function __fish_complete_gpg_key_id -d 'Complete using gpg key ids' -a __fish_complete_gpg_command +function __fish_complete_gpg_key_id -d 'Complete using gpg key ids' -a __fish_complete_gpg_command list_arg # Use user id as description set -l keyid - $__fish_complete_gpg_command --list-keys --with-colons | while read -l garbage + set -q list_arg[1]; or set list_arg --list-keys + $__fish_complete_gpg_command $list_arg --with-colons | while read -l garbage switch $garbage case "uid*" # Extract user ids (note: gpg escapes colons as '\x3a') set -l __uid (string split ":" -- $garbage) set -l uid (string replace -a '\x3a' ':' -- $__uid[10]) printf "%s\t%s\n" $keyid $uid - case "pub*" + # NOTE key is preceded by "sec" instead of "pub" when listing secret keys + case "pub*" "sec*" # Extract key fingerprints (no subkeys) set -l __pub (string split ":" -- $garbage) set keyid $__pub[5] diff --git a/share/functions/__fish_complete_gpg_user_id.fish b/share/functions/__fish_complete_gpg_user_id.fish index 449b72f9f..b43e6c5fd 100644 --- a/share/functions/__fish_complete_gpg_user_id.fish +++ b/share/functions/__fish_complete_gpg_user_id.fish @@ -1,11 +1,12 @@ # Helper function for contextual autocompletion of gpg user ids -function __fish_complete_gpg_user_id -d "Complete using gpg user ids" -a __fish_complete_gpg_command +function __fish_complete_gpg_user_id -d "Complete using gpg user ids" -a __fish_complete_gpg_command list_arg # gpg doesn't seem to like it when you use the whole key name as a # completion, so we skip the part and use it as a description. # It also replaces \x3a from gpg's output with colons. # # TODO: I tried with and it worked, this was possibly fixed in gpg. # Regardless, it's probably nicer as a description. - $__fish_complete_gpg_command --list-keys --with-colon | string split -a -f 10 : | string replace '\x3a' : | string replace -r '(.*) <(.*)>' '$1\t$2' + set -q list_arg[1]; or set list_arg --list-keys + $__fish_complete_gpg_command $list_arg --with-colon | string split -a -f 10 : | string replace '\x3a' : | string replace -r '(.*) <(.*)>' '$1\t$2' end diff --git a/share/functions/__fish_complete_lpr.fish b/share/functions/__fish_complete_lpr.fish index eb157a392..74616e15d 100644 --- a/share/functions/__fish_complete_lpr.fish +++ b/share/functions/__fish_complete_lpr.fish @@ -19,7 +19,6 @@ function __fish_complete_lpr -d 'Complete lpr common options' --argument-names c switch $cmd case lp lpr - complete -c $cmd -s o -d 'Sets a job option' -xa '(__fish_complete_lpr_option)' complete -c $cmd -s m -d 'Send an email on job completion' complete -c $cmd -s o -xa landscape -d 'Landscape mode' @@ -33,5 +32,7 @@ function __fish_complete_lpr -d 'Complete lpr common options' --argument-names c complete -c $cmd -s o -xa 'cpi=' -d 'Set the number of characters per inch to use' complete -c $cmd -s o -xa 'lpi=' -d 'Set the number of lines per inch to use' complete -c $cmd -s o -xa 'page-bottom= page-left= page-right= page-top=' -d 'Set the page margins when printing text files' + # this must be last + complete -c $cmd -s o -d 'Sets a job option' -xa '(__fish_complete_lpr_option)' end end diff --git a/share/functions/__fish_config_interactive.fish b/share/functions/__fish_config_interactive.fish index 15da77741..614cd93da 100644 --- a/share/functions/__fish_config_interactive.fish +++ b/share/functions/__fish_config_interactive.fish @@ -26,21 +26,19 @@ function __fish_config_interactive -d "Initializations that should be performed end end - # # If we are starting up for the first time, set various defaults. - if test $__fish_initialized -lt 3100 - + if test $__fish_initialized -lt 3400 # Regular syntax highlighting colors __init_uvar fish_color_normal normal - __init_uvar fish_color_command 005fd7 - __init_uvar fish_color_param 00afff - __init_uvar fish_color_redirection 00afff - __init_uvar fish_color_comment 990000 - __init_uvar fish_color_error ff0000 - __init_uvar fish_color_escape 00a6b2 - __init_uvar fish_color_operator 00a6b2 - __init_uvar fish_color_end 009900 - __init_uvar fish_color_quote 999900 + __init_uvar fish_color_command blue + __init_uvar fish_color_param cyan + __init_uvar fish_color_redirection cyan --bold + __init_uvar fish_color_comment red + __init_uvar fish_color_error brred + __init_uvar fish_color_escape brcyan + __init_uvar fish_color_operator brcyan + __init_uvar fish_color_end green + __init_uvar fish_color_quote yellow __init_uvar fish_color_autosuggestion 555 brblack __init_uvar fish_color_user brgreen __init_uvar fish_color_host normal @@ -52,7 +50,7 @@ function __fish_config_interactive -d "Initializations that should be performed __init_uvar fish_color_cwd_root red # Background color for search matches - __init_uvar fish_color_search_match bryellow --background=brblack + __init_uvar fish_color_search_match --background=111 # Background color for selections __init_uvar fish_color_selection white --bold --background=brblack @@ -62,10 +60,11 @@ function __fish_config_interactive -d "Initializations that should be performed __init_uvar fish_color_cancel -r # Pager colors - __init_uvar fish_pager_color_prefix normal --bold --underline - __init_uvar fish_pager_color_completion - __init_uvar fish_pager_color_description B3A06D yellow + __init_uvar fish_pager_color_prefix cyan --bold --underline + __init_uvar fish_pager_color_completion normal + __init_uvar fish_pager_color_description B3A06D yellow -i __init_uvar fish_pager_color_progress brwhite --background=cyan + __init_uvar fish_pager_color_selected_background -r # # Directory history colors @@ -258,16 +257,19 @@ function __fish_config_interactive -d "Initializations that should be performed # Notify terminals when $PWD changes (issue #906). # VTE based terminals, Terminal.app, iTerm.app (TODO), and foot support this. if not set -q FISH_UNIT_TESTS_RUNNING - if string match -q -- 'foot*' $TERM - or test 0"$VTE_VERSION" -ge 3405 -o "$TERM_PROGRAM" = Apple_Terminal -a (string match -r '\d+' 0"$TERM_PROGRAM_VERSION") -ge 309 -o "$TERM_PROGRAM" = WezTerm - function __update_cwd_osc --on-variable PWD --description 'Notify capable terminals when $PWD changes' - if status --is-command-substitution || set -q INSIDE_EMACS - return - end - printf \e\]7\;file://%s%s\a $hostname (string escape --style=url $PWD) - end - __update_cwd_osc # Run once because we might have already inherited a PWD from an old tab + and begin + string match -q -- 'foot*' $TERM + or test 0"$VTE_VERSION" -ge 3405 + or test "$TERM_PROGRAM" = Apple_Terminal && test (string match -r '\d+' 0"$TERM_PROGRAM_VERSION") -ge 309 + or test "$TERM_PROGRAM" = WezTerm end + function __update_cwd_osc --on-variable PWD --description 'Notify capable terminals when $PWD changes' + if status --is-command-substitution || set -q INSIDE_EMACS + return + end + printf \e\]7\;file://%s%s\a $hostname (string escape --style=url $PWD) + end + __update_cwd_osc # Run once because we might have already inherited a PWD from an old tab end # Create empty configuration directores if they do not already exist @@ -282,5 +284,5 @@ end" >$__fish_config_dir/config.fish # Bump this whenever some code below needs to run once when upgrading to a new version. # The universal variable __fish_initialized is initialized in share/config.fish. - set __fish_initialized 3100 + set __fish_initialized 3400 end diff --git a/share/functions/__fish_is_first_token.fish b/share/functions/__fish_is_first_token.fish index 8f5e4b83f..9e11e3829 100644 --- a/share/functions/__fish_is_first_token.fish +++ b/share/functions/__fish_is_first_token.fish @@ -1,4 +1,4 @@ function __fish_is_first_token -d 'Test if no non-switch argument has been specified yet' - fish_is_nth_token 1 + __fish_is_nth_token 1 end diff --git a/share/functions/__fish_is_nth_token.fish b/share/functions/__fish_is_nth_token.fish index 4f4464fa1..2f3a535e2 100644 --- a/share/functions/__fish_is_nth_token.fish +++ b/share/functions/__fish_is_nth_token.fish @@ -1,3 +1,5 @@ -function __fish_is_nth_token --description 'Test if current token is on Nth place' --argument-names n - fish_is_nth_token $n +function __fish_is_nth_token --description 'Test if current token is the Nth (ignoring command and switches/flags)' --argument-names n + set -l tokens (commandline -poc) + set -l tokens (string replace -r --filter '^([^-].*)' '$1' -- $tokens) + test (count $tokens) -eq "$n" end diff --git a/share/functions/__fish_is_token_n.fish b/share/functions/__fish_is_token_n.fish index 7e3deb51d..5dbcdfda7 100644 --- a/share/functions/__fish_is_token_n.fish +++ b/share/functions/__fish_is_token_n.fish @@ -1,3 +1,3 @@ function __fish_is_token_n --description 'Test if current token is on Nth place' --argument-names n - fish_is_nth_token $n + __fish_is_nth_token $n end diff --git a/share/functions/__fish_man_page.fish b/share/functions/__fish_man_page.fish index 20ad88260..8615f5946 100644 --- a/share/functions/__fish_man_page.fish +++ b/share/functions/__fish_man_page.fish @@ -8,9 +8,9 @@ function __fish_man_page return end - #Skip leading `sudo`/`command` and display then manpage of following command + # Skip leading commands and display then manpage of following command while set -q args[2] - and string match -qr -- '^(sudo|command|.*=.*)$' $args[1] + and string match -qr -- '^(and|begin|builtin|caffeinate|command|doas|entr|env|exec|if|mosh|nice|not|or|pipenv|prime-run|setsid|sudo|systemd-nspawn|time|watch|while|xargs|.*=.*)$' $args[1] set -e args[1] end diff --git a/share/functions/__fish_nth_token.fish b/share/functions/__fish_nth_token.fish new file mode 100644 index 000000000..597bb15ee --- /dev/null +++ b/share/functions/__fish_nth_token.fish @@ -0,0 +1,9 @@ +function __fish_nth_token --description 'Prints the Nth token (ignoring command and switches/flags)' --argument-names n + set -l tokens (commandline -po | string replace -r --filter '^([^-].*)' '$1') + # Increment $n by one to account for ignoring the command + if test (count $tokens) -ge (math "$n" + 1) + echo $tokens[(math $n + 1)] + else + return 1 + end +end diff --git a/share/functions/__fish_print_apt_packages.fish b/share/functions/__fish_print_apt_packages.fish index a582c8c67..7e014aa50 100644 --- a/share/functions/__fish_print_apt_packages.fish +++ b/share/functions/__fish_print_apt_packages.fish @@ -12,20 +12,23 @@ function __fish_print_apt_packages # Do not generate the cache as apparently sometimes this is slow. # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=547550 # (It is safe to use `sed -r` here as we are guaranteed to be on a GNU platform - # if apt-cache was found. Using unicode reserved range in `fish/tr` and the - # little-endian bytecode equivalent in `sed`. Supports localization.) + # if apt-cache was found.) + # Uses the UTF-8/ASCII record separator (0x1A) character. # # Note: This can include "Description:" fields which we need to include, # "Description-en_GB" (or another locale code) fields which we need to include # as well as "Description-md5" fields which we absolutely do *not* want to include # The regex doesn't allow numbers, so unless someone makes a hash algorithm without a number in the name, # we're safe. (yes, this should absolutely have a better format). - apt-cache --no-generate show '.*'(commandline -ct)'.*' 2>/dev/null | sed -r '/^(Package|Description-?[a-zA-Z_]*):/!d;s/Package: (.*)/\1\t/g;s/Description-?[^:]*: (.*)/\1\xee\x80\x80\x0a/g' | tr -d \n | tr -s \uE000 \n | uniq + # + # aptitude has options that control the output formatting, but is orders of magnitude slower + # + # sed could probably do all of the heavy lifting here, but would be even less readable + apt-cache --no-generate show '.*'(commandline -ct)'.*' 2>/dev/null | sed -r '/^(Package|Description-?[a-zA-Z_]*):/!d;s/Package: (.*)/\1\t/g;s/Description-?[^:]*: (.*)/\1\x1a\n/g' | string join "" | string replace --all --regex \x1a+ \n | uniq return 0 else set -l packages (dpkg --get-selections | string replace -fr '(\S+)\s+install' "\$1" | string match -e (commandline -ct)) - apt-cache --no-generate show $packages 2>/dev/null | sed -r '/^(Package|Description-?[a-zA-Z_]*):/!d;s/Package: (.*)/\1\t/g;s/Description-?[^:]*: (.*)/\1\xee\x80\x80\x0a/g' | tr -d \n | tr -s \uE000 \n | uniq - + apt-cache --no-generate show $packages 2>/dev/null | sed -r '/^(Package|Description-?[a-zA-Z_]*):/!d;s/Package: (.*)/\1\t/g;s/Description-?[^:]*: (.*)/\1\x1a\n/g' | string join "" | string replace --all --regex \x1a+ \n | uniq return 0 end end diff --git a/share/functions/__fish_print_windows_drives.fish b/share/functions/__fish_print_windows_drives.fish new file mode 100644 index 000000000..0d92b4560 --- /dev/null +++ b/share/functions/__fish_print_windows_drives.fish @@ -0,0 +1,3 @@ +function __fish_print_windows_drives --description 'Print Windows drives' + wmic logicaldisk get name | tail +2 +end diff --git a/share/functions/__fish_print_windows_users.fish b/share/functions/__fish_print_windows_users.fish new file mode 100644 index 000000000..8f91769b4 --- /dev/null +++ b/share/functions/__fish_print_windows_users.fish @@ -0,0 +1,3 @@ +function __fish_print_windows_users --description 'Print Windows user names' + wmic useraccount get name | tail +2 +end diff --git a/share/functions/__fish_seen_argument.fish b/share/functions/__fish_seen_argument.fish index 170bd4fa1..146e9ce8e 100644 --- a/share/functions/__fish_seen_argument.fish +++ b/share/functions/__fish_seen_argument.fish @@ -1,23 +1,30 @@ -function __fish_seen_argument --description 'Check whether argument used' - argparse 's/short=+' 'o/old=+' 'l/long=+' -- $argv +function __fish_seen_argument --description 'Check whether argument is used' + argparse 's/short=+' 'o/old=+' 'l/long=+' 'w/windows=+' -- $argv - set -l cmd (commandline -poc) - set -e cmd[1] - for t in $cmd + set --local tokens (commandline --current-process --tokenize --cut-at-cursor) + set --erase tokens[1] + + for t in $tokens for s in $_flag_s - if string match -qr "^-[A-z0-9]*"$s"[A-z0-9]*\$" -- $t + if string match --regex --quiet -- "^-[A-z0-9]*"$s"[A-z0-9]*\$" $t return 0 end end for o in $_flag_o - if string match -qr "^-$s\$" -- $t + if string match --quiet -- "-$o" $t return 0 end end for l in $_flag_l - if string match -q -- "--$l" $t + if string match --quiet -- "--$l" $t + return 0 + end + end + + for w in $_flag_w + if string match --quiet -- "/$w" $t return 0 end end diff --git a/share/functions/__fish_set_locale.fish b/share/functions/__fish_set_locale.fish index 75c090597..dec2919ca 100644 --- a/share/functions/__fish_set_locale.fish +++ b/share/functions/__fish_set_locale.fish @@ -53,7 +53,7 @@ function __fish_set_locale # NOTE: Slackware puts the locale in /etc/profile.d/lang.sh, which we can't use because it's a # full POSIX-shell script. set -l user_cfg_dir (set -q XDG_CONFIG_HOME; and echo $XDG_CONFIG_HOME; or echo ~/.config) - for f in $user_cfg_dir/locale.conf /etc/locale.conf /etc/env.d/02locale /etc/sysconfig/i18n + for f in $user_cfg_dir/locale.conf /etc/locale.conf /etc/env.d/02locale /etc/sysconfig/i18n /etc/default/locale if test -r $f while read -l kv set kv (string split '=' -- $kv) diff --git a/share/functions/__fish_tokenizer_state.fish b/share/functions/__fish_tokenizer_state.fish index 42940f2d3..eee33eea2 100644 --- a/share/functions/__fish_tokenizer_state.fish +++ b/share/functions/__fish_tokenizer_state.fish @@ -13,7 +13,7 @@ function __fish_tokenizer_state --description "Print the state of the tokenizer set -l state normal if set -q _flag_initial_state - set str $_flag_initial_state + set state $_flag_initial_state end for char in (string split -- "" $argv[1]) diff --git a/share/functions/delete-or-exit.fish b/share/functions/delete-or-exit.fish deleted file mode 100644 index 70c94f140..000000000 --- a/share/functions/delete-or-exit.fish +++ /dev/null @@ -1,22 +0,0 @@ -# -# This function deletes a character from the commandline if it is -# non-empty, and exits the shell otherwise. Implementing this -# functionality has been a longstanding request from various -# fish-users. -# - -function delete-or-exit - - set -l cmd (commandline) - - switch "$cmd" - - case '' - exit 0 - - case '*' - commandline -f delete-char - - end - -end diff --git a/share/functions/down-or-search.fish b/share/functions/down-or-search.fish index 16a5182f4..bc4553141 100644 --- a/share/functions/down-or-search.fish +++ b/share/functions/down-or-search.fish @@ -1,4 +1,4 @@ -function down-or-search -d "Depending on cursor position and current mode, either search forward or move down one line" +function down-or-search -d "search forward or move down 1 line" # If we are already in search mode, continue if commandline --search-mode commandline -f history-search-forward diff --git a/share/functions/fish_clipboard_paste.fish b/share/functions/fish_clipboard_paste.fish index 490449261..90c86c08d 100644 --- a/share/functions/fish_clipboard_paste.fish +++ b/share/functions/fish_clipboard_paste.fish @@ -7,7 +7,7 @@ function fish_clipboard_paste else if set -q DISPLAY; and type -q xsel set data (xsel --clipboard) else if set -q DISPLAY; and type -q xclip - set data (xclip -selection clipboard -o) + set data (xclip -selection clipboard -o 2>/dev/null) else if type -q powershell.exe set data (powershell.exe Get-Clipboard | string trim -r -c \r) end diff --git a/share/functions/fish_command_not_found.fish b/share/functions/fish_command_not_found.fish index 83c854c51..b3dcd6fe7 100644 --- a/share/functions/fish_command_not_found.fish +++ b/share/functions/fish_command_not_found.fish @@ -32,7 +32,7 @@ else if contains -- suse $os || contains -- sles $os && type -q command-not-foun # Check for Fedora's handler else if test -f /usr/libexec/pk-command-not-found function fish_command_not_found - /usr/libexec/pk-command-not-found $argv[1] + /usr/libexec/pk-command-not-found $argv end # Check in /usr/lib, where Ubuntu places this command else if test -f /usr/lib/command-not-found diff --git a/share/functions/fish_default_key_bindings.fish b/share/functions/fish_default_key_bindings.fish index f9597d487..44311ad87 100644 --- a/share/functions/fish_default_key_bindings.fish +++ b/share/functions/fish_default_key_bindings.fish @@ -1,4 +1,4 @@ -function fish_default_key_bindings -d "Default (Emacs-like) key bindings for fish" +function fish_default_key_bindings -d "emacs-like key binds" if contains -- -h $argv or contains -- --help $argv echo "Sorry but this function doesn't support -h or --help" diff --git a/share/functions/fish_default_mode_prompt.fish b/share/functions/fish_default_mode_prompt.fish index b90461b3c..f8ae0ccaa 100644 --- a/share/functions/fish_default_mode_prompt.fish +++ b/share/functions/fish_default_mode_prompt.fish @@ -1,4 +1,4 @@ -function fish_default_mode_prompt --description "Display the default mode for the prompt" +function fish_default_mode_prompt --description "Display vi prompt mode" # Do nothing if not in vi mode if test "$fish_key_bindings" = fish_vi_key_bindings or test "$fish_key_bindings" = fish_hybrid_key_bindings diff --git a/share/functions/fish_git_prompt.fish b/share/functions/fish_git_prompt.fish index 6457e114b..9920430b9 100644 --- a/share/functions/fish_git_prompt.fish +++ b/share/functions/fish_git_prompt.fish @@ -345,18 +345,18 @@ function __fish_git_prompt_staged --description "fish_git_prompt helper, tells w # The "diff" functions all return > 0 if there _is_ a diff, # but we want to return 0 if there are staged changes. # So we invert the status. - not command git diff-index --cached --quiet HEAD -- 2>/dev/null + not command git -c core.fsmonitor= diff-index --cached --quiet HEAD -- 2>/dev/null and echo 1 end function __fish_git_prompt_untracked --description "fish_git_prompt helper, tells whether or not the current repository has untracked files" - command git ls-files --others --exclude-standard --directory --no-empty-directory --error-unmatch -- :/ >/dev/null 2>&1 + command git -c core.fsmonitor= ls-files --others --exclude-standard --directory --no-empty-directory --error-unmatch -- :/ >/dev/null 2>&1 and echo 1 end function __fish_git_prompt_dirty --description "fish_git_prompt helper, tells whether or not the current branch has tracked, modified files" # Like staged, invert the status because we want 0 to mean there are dirty files. - not command git diff --no-ext-diff --quiet --exit-code 2>/dev/null + not command git -c core.fsmonitor= diff --no-ext-diff --quiet --exit-code 2>/dev/null and echo 1 end @@ -372,7 +372,7 @@ function __fish_git_prompt_informative_status # It's quite a bit faster and unlikely anyone cares about the number of files if it's *all* of the files # in that directory. # The v2 format is better, but we don't actually care in this case. - set -l stats (string sub -l 2 (git status --porcelain -z -unormal | string split0)) + set -l stats (string sub -l 2 (git -c core.fsmonitor= status --porcelain -z -unormal | string split0)) set -l invalidstate (string match -r '^UU' $stats | count) set -l stagedstate (string match -r '^[ACDMR].' $stats | count) set -l dirtystate (string match -r '^.[ACDMR]' $stats | count) diff --git a/share/functions/fish_is_nth_token.fish b/share/functions/fish_is_nth_token.fish deleted file mode 100644 index c3f23cf53..000000000 --- a/share/functions/fish_is_nth_token.fish +++ /dev/null @@ -1,5 +0,0 @@ -function fish_is_nth_token --description 'Test if current token is on Nth place' --argument-names n - set -l tokens (commandline -poc) - set -l tokens (string replace -r --filter '^([^-].*)' '$1' -- $tokens) - test (count $tokens) -eq "$n" -end diff --git a/share/functions/fish_status_to_signal.fish b/share/functions/fish_status_to_signal.fish index 2d09916dc..057345aac 100644 --- a/share/functions/fish_status_to_signal.fish +++ b/share/functions/fish_status_to_signal.fish @@ -1,14 +1,11 @@ -function fish_status_to_signal --description "Print signal name from argument (\$status), or just argument" +function fish_status_to_signal --description "Convert exit code to signal name" + __fish_make_completion_signals # Make sure signals are cached for arg in $argv if test $arg -gt 128 - set -l signals SIGHUP SIGINT SIGQUIT SIGILL SIGTRAP SIGABRT SIGBUS \ - SIGFPE SIGKILL SIGUSR1 SIGSEGV SIGUSR2 SIGPIPE SIGALRM \ - SIGTERM SIGSTKFLT SIGCHLD SIGCONT SIGSTOP SIGTSTP \ - SIGTTIN SIGTTOU SIGURG SIGXCPU SIGXFSZ SIGVTALRM \ - SIGPROF SIGWINCH SIGIO SIGPWR SIGSYS - set -l sigix (math $arg - 128) - if test $sigix -le (count $signals) - echo $signals[$sigix] + # Important: each element of $__kill_signals is a string like "10 USR1" + if set -l signal_names (string replace -r --filter '^'(math $arg-128)' ' SIG $__kill_signals) + # Some signals have multiple mnemonics. Pick the first one. + echo $signal_names[1] else echo $arg end diff --git a/share/functions/fish_title.fish b/share/functions/fish_title.fish index 800f2d8f1..91519b90f 100644 --- a/share/functions/fish_title.fish +++ b/share/functions/fish_title.fish @@ -1,8 +1,21 @@ function fish_title # emacs' "term" is basically the only term that can't handle it. if not set -q INSIDE_EMACS; or string match -vq '*,term:*' -- $INSIDE_EMACS + # If we're connected via ssh, we print the hostname. + set -l ssh + set -q SSH_TTY + and set ssh "[$(prompt_hostname | string sub -l 10)]" # An override for the current command is passed as the first parameter. # This is used by `fg` to show the true process name, among others. - echo (set -q argv[1] && echo $argv[1] || status current-command) (__fish_pwd) + if set -q argv[1] + echo -- $ssh (string sub -l 20 -- $argv[1]) (prompt_pwd -d 1 -D 1) + else + # Don't print "fish" because it's redundant + set -l command (status current-command) + if test "$command" = fish + set command + end + echo -- $ssh (string sub -l 20 -- $command) (prompt_pwd -d 1 -D 1) + end end end diff --git a/share/functions/fish_vcs_prompt.fish b/share/functions/fish_vcs_prompt.fish index ed2d90725..4b1723d36 100644 --- a/share/functions/fish_vcs_prompt.fish +++ b/share/functions/fish_vcs_prompt.fish @@ -1,4 +1,4 @@ -function fish_vcs_prompt --description "Print the prompts for all available vcsen" +function fish_vcs_prompt --description "Print all vcs prompts" # If a prompt succeeded, we assume that it's printed the correct info. # This is so we don't try svn if git already worked. fish_git_prompt $argv diff --git a/share/functions/help.fish b/share/functions/help.fish index dabaea6e8..1d2fecf15 100644 --- a/share/functions/help.fish +++ b/share/functions/help.fish @@ -113,6 +113,7 @@ function help --description 'Show help for the fish shell' # HACK: Hardcode all section titles for each page. # This could possibly be automated. + set -l intropages introduction where-to-go installation starting-and-exiting default-shell uninstalling shebang-line configuration examples resources other-help-pages set -l for_bash_pages arithmetic-expansion bash-command-substitutions blocks-and-loops builtins-and-other-commands command-substitutions fish-for-bash-users heredocs process-substitution prompts quoting special-variables string-manipulation subshells test-test variables wildcards-globs set -l faqpages faq-ssh-interactive faq-unicode faq-uninstalling frequently-asked-questions how-can-i-use-as-a-shortcut-for-cd how-do-i-change-the-greeting-message how-do-i-check-whether-a-variable-is-defined how-do-i-check-whether-a-variable-is-not-empty how-do-i-customize-my-syntax-highlighting-colors how-do-i-get-the-exit-status-of-a-command how-do-i-make-fish-my-default-shell how-do-i-run-a-command-every-login-what-s-fish-s-equivalent-to-bashrc-or-profile how-do-i-run-a-command-from-history how-do-i-run-a-subcommand-the-backtick-doesn-t-work how-do-i-set-my-prompt how-do-i-set-or-clear-an-environment-variable i-accidentally-entered-a-directory-path-and-fish-changed-directory-what-happened i-m-getting-weird-graphical-glitches-a-staircase-effect-ghost-characters-cursor-in-the-wrong-position i-m-seeing-weird-output-before-each-prompt-when-using-screen-what-s-wrong my-command-pkg-config-gives-its-output-as-a-single-long-string my-command-prints-no-matches-for-wildcard-but-works-in-bash the-open-command-doesn-t-work uninstalling-fish what-is-the-equivalent-to-this-thing-from-bash-or-other-shells where-can-i-find-extra-tools-for-fish why-does-my-prompt-show-a-i why-doesn-t-history-substitution-etc-work why-doesn-t-set-ux-exported-universal-variables-seem-to-work why-won-t-ssh-scp-rsync-connect-properly-when-fish-is-my-login-shell set -l interactivepages abbreviations autosuggestions color command-line-editor command-mode configurable-greeting copy-and-paste-kill-ring custom-bindings custom-binds directory-stack editor emacs-mode emacs-mode-commands greeting help history-search id7 insert-mode interactive interactive-use killring multiline multiline-editing navigating-directories pager-color-variables private-mode programmable-prompt programmable-title prompt searchable-command-history shared-bindings shared-binds syntax-highlighting syntax-highlighting-variables tab-completion title variables-color variables-color-pager vi-mode vi-mode-command vi-mode-commands vi-mode-insert vi-mode-visual visual-mode @@ -161,8 +162,11 @@ function help --description 'Show help for the fish shell' set fish_help_page "cmds/$fish_help_item.html" case '' set fish_help_page "index.html" + case $intropages + set fish_help_page "index.html$fish_help_item" case "*" - set fish_help_page "index.html#$fish_help_item" + printf (_ "%s: no fish help topic '%s', try 'man %s'\n") help $fish_help_item $fish_help_item + return 1 end # In Crostini Chrome OS Linux, the default browser opens URLs in Chrome running outside the diff --git a/share/functions/la.fish b/share/functions/la.fish index 29e25d0da..98fcb7765 100644 --- a/share/functions/la.fish +++ b/share/functions/la.fish @@ -2,5 +2,5 @@ # These are very common and useful # function la --wraps ls --description "List contents of directory, including hidden files in directory using long format" - ls -lah $argv + ls -lAh $argv end diff --git a/share/functions/nextd-or-forward-word.fish b/share/functions/nextd-or-forward-word.fish deleted file mode 100644 index 9428b89e2..000000000 --- a/share/functions/nextd-or-forward-word.fish +++ /dev/null @@ -1,9 +0,0 @@ -function nextd-or-forward-word - set -l cmd (commandline) - if test -z "$cmd" - nextd - commandline -f repaint - else - commandline -f forward-word - end -end diff --git a/share/functions/prevd-or-backward-word.fish b/share/functions/prevd-or-backward-word.fish deleted file mode 100644 index 2aaee3b51..000000000 --- a/share/functions/prevd-or-backward-word.fish +++ /dev/null @@ -1,9 +0,0 @@ -function prevd-or-backward-word - set -l cmd (commandline) - if test -z "$cmd" - prevd - commandline -f repaint - else - commandline -f backward-word - end -end diff --git a/share/functions/prompt_hostname.fish b/share/functions/prompt_hostname.fish index 225f437c7..dcb733578 100644 --- a/share/functions/prompt_hostname.fish +++ b/share/functions/prompt_hostname.fish @@ -1,4 +1,3 @@ -function prompt_hostname - # return the short hostname only by default (#4804) +function prompt_hostname --description 'short hostname for the prompt' string replace -r "\..*" "" $hostname end diff --git a/share/functions/prompt_login.fish b/share/functions/prompt_login.fish index eeafcbb6f..632a462bd 100644 --- a/share/functions/prompt_login.fish +++ b/share/functions/prompt_login.fish @@ -1,4 +1,4 @@ -function prompt_login --description "Print a description of the user and host suitable for the prompt" +function prompt_login --description "display user name for the prompt" if not set -q __fish_machine set -g __fish_machine set -l debian_chroot $debian_chroot diff --git a/share/functions/prompt_pwd.fish b/share/functions/prompt_pwd.fish index 8fe7f9815..f75f0dc0b 100644 --- a/share/functions/prompt_pwd.fish +++ b/share/functions/prompt_pwd.fish @@ -1,4 +1,4 @@ -function prompt_pwd --description 'Print the current working directory, shortened to fit the prompt' +function prompt_pwd --description 'short CWD for the prompt' set -l options h/help d/dir-length= D/full-length-dirs= argparse -n prompt_pwd $options -- $argv or return diff --git a/share/functions/up-or-search.fish b/share/functions/up-or-search.fish index 3d7ae1417..1a1bfdab0 100644 --- a/share/functions/up-or-search.fish +++ b/share/functions/up-or-search.fish @@ -1,4 +1,5 @@ -function up-or-search -d "Depending on cursor position and current mode, either search backward or move up one line" +# Depending on cursor position and current mode, either search backward or move up one line" +function up-or-search -d "Search back or move cursor up 1 line" # If we are already in search mode, continue if commandline --search-mode commandline -f history-search-backward diff --git a/share/tools/create_manpage_completions.py b/share/tools/create_manpage_completions.py index 3e007a0a9..6f7026706 100755 --- a/share/tools/create_manpage_completions.py +++ b/share/tools/create_manpage_completions.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Run me like this: ./create_manpage_completions.py /usr/share/man/man{1,8}/* > man_completions.fish @@ -64,7 +65,6 @@ diagnostic_indent = 0 VERY_VERBOSE, BRIEF_VERBOSE, NOT_VERBOSE = 2, 1, 0 # Pick some reasonable default values for settings -global VERBOSITY, WRITE_TO_STDOUT, DEROFF_ONLY, KEEP_FILES VERBOSITY, WRITE_TO_STDOUT, DEROFF_ONLY, KEEP_FILES = NOT_VERBOSE, False, False, False diff --git a/share/tools/deroff.py b/share/tools/deroff.py index 40b4ba1a3..789c4524e 100755 --- a/share/tools/deroff.py +++ b/share/tools/deroff.py @@ -699,7 +699,6 @@ class Deroffer: return False def macro_i_ir(self): - pass return False def macro_Nm(self): @@ -1144,12 +1143,9 @@ if __name__ == "__main__": import gzip paths = sys.argv[1:] - if True: - deroff_files(paths) - else: - import cProfile, profile, pstats - - profile.run("deroff_files(paths)", "fooprof") - p = pstats.Stats("fooprof") - p.sort_stats("time").print_stats(100) - # p.sort_stats('calls').print_callers(.5, 'startswith') + deroff_files(paths) + # import cProfile, profile, pstats + # profile.run("deroff_files(paths)", "fooprof") + # p = pstats.Stats("fooprof") + # p.sort_stats("time").print_stats(100) + # p.sort_stats('calls').print_callers(.5, 'startswith') diff --git a/share/tools/web_config/fishconfig.css b/share/tools/web_config/fishconfig.css index 761fcace1..e1afc50f7 100644 --- a/share/tools/web_config/fishconfig.css +++ b/share/tools/web_config/fishconfig.css @@ -1,6 +1,7 @@ body { background: linear-gradient(to bottom, #a7cfdf 0%, #23538a 100%); - font-family: monospace, fixed; + /* List explained in the doc theme pydoctheme.css */ + font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, "Ubuntu Mono", "Hack", "Noto Sans Mono", Liberation Mono, monospace; color: #222; } @@ -14,11 +15,6 @@ body { border-radius: 8px; } -code { - font-family: "Source Code Pro", "DejaVu Sans Mono", Menlo, "Ubuntu Mono", Consolas, Monaco, - "Lucida Console", monospace, fixed; -} - #parent { width: 100%; min-height: 480px; @@ -394,11 +390,11 @@ code { } .colorpicker_text_sample_tight { - font-size: 10pt; - line-height: 1.2em; - margin: 0px 6px; - max-width: 220px; - padding: 5px; + font-size: 11pt; + line-height: 1.5em; + margin: 0; + width: fit-content; + padding: 1em; white-space: nowrap; overflow: hidden; text-overflow: clip; @@ -626,7 +622,7 @@ img.delete_icon { cursor: default; } -@media screen and (max-width: 800px) { +@media screen and (max-width: 1000px) { /* On small screens remove the margins to leave more for the actual content */ body { width: 100%; diff --git a/share/tools/web_config/js/colorutils.js b/share/tools/web_config/js/colorutils.js index 23674bf93..4fff5e606 100644 --- a/share/tools/web_config/js/colorutils.js +++ b/share/tools/web_config/js/colorutils.js @@ -85,21 +85,21 @@ function adjust_lightness(color_str, func) { if (color_str == 'white') color_str = 'c0c0c0'; - rgb = parseInt(color_str, 16) - r = (rgb >> 16) & 0xFF - g = (rgb >> 8) & 0xFF - b = (rgb >> 0) & 0xFF + var rgb = parseInt(color_str, 16) + var r = (rgb >> 16) & 0xFF + var g = (rgb >> 8) & 0xFF + var b = (rgb >> 0) & 0xFF - hsl = rgb_to_hsl(r, g, b) - new_lightness = func(hsl[2]) + var hsl = rgb_to_hsl(r, g, b) + var new_lightness = func(hsl[2]) function to_int_str(val) { - str = Math.round(val).toString(16) + var str = Math.round(val).toString(16) while (str.length < 2) str = '0' + str return str } - new_rgb = hsl_to_rgb(hsl[0], hsl[1], new_lightness) + var new_rgb = hsl_to_rgb(hsl[0], hsl[1], new_lightness) return to_int_str(new_rgb[0]) + to_int_str(new_rgb[1]) + to_int_str(new_rgb[2]) } @@ -218,7 +218,7 @@ function interpret_color(str) { if (str == 'brpurple') return '#ff00ff'; if (str == 'brcyan') return '#00ffff'; if (str == 'brwhite') return '#ffffff'; - if (str == 'normal') return ''; + if (str == 'normal') return '#ffffff'; if (str == 'reset') return ''; return '#' + str } diff --git a/share/tools/web_config/js/controllers.js b/share/tools/web_config/js/controllers.js index f30f1d4ec..958649cdf 100644 --- a/share/tools/web_config/js/controllers.js +++ b/share/tools/web_config/js/controllers.js @@ -73,6 +73,7 @@ controllers.controller("colorsController", function($scope, $http) { $scope.changeSelectedTextColor = function(color) { $scope.selectedColorScheme[$scope.selectedColorSetting] = color; + $scope.selectedColorScheme["colordata-" + $scope.selectedColorSetting].color = color; $scope.noteThemeChanged(); } @@ -82,7 +83,7 @@ controllers.controller("colorsController", function($scope, $http) { $scope.colorSchemes = []; isValidColor = function(col) { - // Check if preferred_background is actually a valid color + if (col == "normal") return true; var s = new Option().style; s.color = col; return !!s.color; @@ -103,9 +104,12 @@ controllers.controller("colorsController", function($scope, $http) { if (scheme["url"]) currentScheme["url"] = scheme["url"]; for (var i in data) { - if (isValidColor(data[i].color)) { - currentScheme[data[i].name] = data[i].color; - } + currentScheme[data[i].name] = interpret_color(data[i].color).replace(/#/, ''); + // HACK: For some reason the colors array is cleared later + // So we cheesily encode the actual objects as colordata-, so we can send them. + // TODO: We should switch to keeping the objects, and also displaying them + // with underlines and such. + currentScheme["colordata-" + data[i].name] = data[i]; } $scope.colorSchemes.push(currentScheme); } @@ -140,25 +144,41 @@ controllers.controller("colorsController", function($scope, $http) { "user", "host", "cancel", + // Cheesy hardcoded variable names ahoy! + // These are all the pager vars, + // we should really just save all these in a dictionary. + "fish_pager_color_background", + "fish_pager_color_prefix", + "fish_pager_color_progress", "fish_pager_color_completion", "fish_pager_color_description", - "fish_pager_color_prefix", - "fish_pager_color_progress" + "fish_pager_color_selected_background", + "fish_pager_color_selected_prefix", + "fish_pager_color_selected_completion", + "fish_pager_color_selected_description", + // TODO: Setting these to empty currently makes them weird. Figure out why! + /* + "fish_pager_color_secondary_background", + "fish_pager_color_secondary_prefix", + "fish_pager_color_secondary_completion", + "fish_pager_color_secondary_description", + */ ]; var remaining = settingNames.length; - postdata = { + var postdata = { "theme" : $scope.selectedColorScheme["name"], "colors": [], } - for (name of settingNames) { + for (var name of settingNames) { var selected; + var realname = "colordata-" + name; // Skip colors undefined in the current theme // js is dumb - the empty string is false, // but we want that to mean unsetting a var. - if (!$scope.selectedColorScheme[name] && $scope.selectedColorScheme[name] !== '') { - selected = ''; + if (!$scope.selectedColorScheme[realname] && $scope.selectedColorScheme[realname] !== '') { + continue; } else { - selected = $scope.selectedColorScheme[name]; + selected = $scope.selectedColorScheme[realname]; } postdata.colors.push({ "what" : name, @@ -235,16 +255,16 @@ controllers.controller("functionsController", function($scope, $http) { $scope.cleanupFishFunction = function (contents) { /* Replace leading tabs and groups of four spaces at the beginning of a line with two spaces. */ - lines = contents ? contents.split('\n') : []; - rx = /^[\t ]+/ + var lines = contents ? contents.split('\n') : []; + var rx = /^[\t ]+/ for (var i=0; i < lines.length; i++) { - line = lines[i] + var line = lines[i] /* Get leading tabs and spaces */ - whitespace_arr = rx.exec(line) + var whitespace_arr = rx.exec(line) if (whitespace_arr) { /* Replace four spaces with two spaces, and tabs with two spaces */ var whitespace = whitespace_arr[0] - new_whitespace = whitespace.replace(/( )|(\t)/g, ' ') + var new_whitespace = whitespace.replace(/( )|(\t)/g, ' ') lines[i] = new_whitespace + line.slice(whitespace.length) } } @@ -380,7 +400,7 @@ controllers.controller("abbreviationsController", function($scope, $http) { $scope.abbreviations = []; $scope.addBlank = function() { // Add blank entry if it is missing - hasBlank = {hasBlank: false} + var hasBlank = {hasBlank: false} angular.forEach($scope.abbreviations, function(value, key) { if (value.phrase === "" && value.word === "") { this.hasBlank = true; diff --git a/share/tools/web_config/js/filters.js b/share/tools/web_config/js/filters.js index a3a4ec70d..073869550 100644 --- a/share/tools/web_config/js/filters.js +++ b/share/tools/web_config/js/filters.js @@ -6,8 +6,8 @@ filters.filter("filterVariable", function() { if (variables == undefined) return result; if (query == null) { return variables }; - for(i=0; i/dev/null) + # The git prompt's default format is ' (%s)'. + # We don't want the leading space. + set -l vcs (fish_vcs_prompt '(%s)' 2>/dev/null) set -l d (set_color brgrey)(date "+%R")(set_color normal) @@ -82,6 +86,6 @@ function fish_right_prompt set -q VIRTUAL_ENV and set -l venv (string replace -r '.*/' '' -- "$VIRTUAL_ENV") - set_color reset + set_color normal string join " " -- $venv $duration $vcs $d end diff --git a/share/tools/web_config/themes/Base16 Default Dark.theme b/share/tools/web_config/themes/Base16 Default Dark.theme index f6c5e8e59..c4f64e583 100644 --- a/share/tools/web_config/themes/Base16 Default Dark.theme +++ b/share/tools/web_config/themes/Base16 Default Dark.theme @@ -27,5 +27,6 @@ fish_pager_color_completion normal fish_pager_color_description B3A06D yellow fish_pager_color_prefix normal --bold --underline fish_pager_color_progress brwhite --background=cyan +fish_pager_color_selected_background --background=brblack fish_color_option d8d8d8 fish_color_keyword a1b56c diff --git a/share/tools/web_config/themes/Base16 Default Light.theme b/share/tools/web_config/themes/Base16 Default Light.theme index cb19839b6..734d09b92 100644 --- a/share/tools/web_config/themes/Base16 Default Light.theme +++ b/share/tools/web_config/themes/Base16 Default Light.theme @@ -27,5 +27,6 @@ fish_pager_color_description B3A06D yellow fish_pager_color_completion normal fish_pager_color_prefix normal --bold --underline fish_pager_color_progress brwhite --background=cyan +fish_pager_color_selected_background --background=brblack fish_color_option 383838 fish_color_keyword a1b56c diff --git a/share/tools/web_config/themes/Base16 Eighties.theme b/share/tools/web_config/themes/Base16 Eighties.theme index 283b29866..a70c306f9 100644 --- a/share/tools/web_config/themes/Base16 Eighties.theme +++ b/share/tools/web_config/themes/Base16 Eighties.theme @@ -27,5 +27,6 @@ fish_pager_color_completion normal fish_pager_color_description B3A06D yellow fish_pager_color_prefix normal --bold --underline fish_pager_color_progress brwhite --background=cyan +fish_pager_color_selected_background --background=brblack fish_color_option d3d0c8 fish_color_keyword 99cc99 diff --git a/share/tools/web_config/themes/Bay Cruise.theme b/share/tools/web_config/themes/Bay Cruise.theme index e4a742609..b2397b4d5 100644 --- a/share/tools/web_config/themes/Bay Cruise.theme +++ b/share/tools/web_config/themes/Bay Cruise.theme @@ -26,5 +26,6 @@ fish_pager_color_completion normal fish_pager_color_description B3A06D yellow fish_pager_color_prefix normal --bold --underline fish_pager_color_progress brwhite --background=cyan +fish_pager_color_selected_background --background=brblack fish_color_option 33CCCC fish_color_keyword 009999 diff --git a/share/tools/web_config/themes/Dracula.theme b/share/tools/web_config/themes/Dracula.theme index 45bcc0f48..e7cd77930 100644 --- a/share/tools/web_config/themes/Dracula.theme +++ b/share/tools/web_config/themes/Dracula.theme @@ -26,5 +26,6 @@ fish_pager_color_completion normal fish_pager_color_description B3A06D yellow fish_pager_color_prefix normal --bold --underline fish_pager_color_progress brwhite --background=cyan +fish_pager_color_selected_background --background=brblack fish_color_option FF79C6 fish_color_keyword F8F8F2 diff --git a/share/tools/web_config/themes/Fairground.theme b/share/tools/web_config/themes/Fairground.theme index 0c0b10694..4d570d684 100644 --- a/share/tools/web_config/themes/Fairground.theme +++ b/share/tools/web_config/themes/Fairground.theme @@ -26,5 +26,6 @@ fish_pager_color_completion normal fish_pager_color_prefix normal --bold --underline fish_pager_color_description B3A06D yellow fish_pager_color_progress brwhite --background=cyan +fish_pager_color_selected_background --background=brblack fish_color_option 225E79 fish_color_keyword 0772A1 diff --git a/share/tools/web_config/themes/Just a Touch.theme b/share/tools/web_config/themes/Just a Touch.theme index 3f3689de3..72f511f0a 100644 --- a/share/tools/web_config/themes/Just a Touch.theme +++ b/share/tools/web_config/themes/Just a Touch.theme @@ -26,5 +26,6 @@ fish_pager_color_completion normal fish_pager_color_description B3A06D yellow fish_pager_color_prefix normal --bold --underline fish_pager_color_progress brwhite --background=cyan +fish_pager_color_selected_background --background=brblack fish_color_option A0A0F0 fish_color_keyword F4F4F4 diff --git a/share/tools/web_config/themes/Lava.theme b/share/tools/web_config/themes/Lava.theme index 9cf97843a..31bf8c730 100644 --- a/share/tools/web_config/themes/Lava.theme +++ b/share/tools/web_config/themes/Lava.theme @@ -26,5 +26,6 @@ fish_pager_color_completion normal fish_pager_color_description B3A06D yellow fish_pager_color_prefix normal --bold --underline fish_pager_color_progress brwhite --background=cyan +fish_pager_color_selected_background --background=brblack fish_color_option FFC000 fish_color_keyword FF9400 diff --git a/share/tools/web_config/themes/Mono Lace.theme b/share/tools/web_config/themes/Mono Lace.theme index 6e4b2466b..2155fc7b0 100644 --- a/share/tools/web_config/themes/Mono Lace.theme +++ b/share/tools/web_config/themes/Mono Lace.theme @@ -26,5 +26,6 @@ fish_color_cancel -r fish_pager_color_completion normal fish_pager_color_progress brwhite --background=cyan fish_pager_color_description B3A06D yellow +fish_pager_color_selected_background --background=brblack fish_color_option 303030 fish_color_keyword 000000 diff --git a/share/tools/web_config/themes/Mono Smoke.theme b/share/tools/web_config/themes/Mono Smoke.theme index fd43489a6..72052d7a4 100644 --- a/share/tools/web_config/themes/Mono Smoke.theme +++ b/share/tools/web_config/themes/Mono Smoke.theme @@ -26,5 +26,6 @@ fish_pager_color_completion normal fish_pager_color_description B3A06D yellow fish_pager_color_prefix normal --bold --underline fish_pager_color_progress brwhite --background=cyan +fish_pager_color_selected_background --background=brblack fish_color_option d7d7d7 fish_color_keyword ffffff diff --git a/share/tools/web_config/themes/Nord.theme b/share/tools/web_config/themes/Nord.theme index 797927abe..6daf1d9ec 100644 --- a/share/tools/web_config/themes/Nord.theme +++ b/share/tools/web_config/themes/Nord.theme @@ -27,5 +27,6 @@ fish_pager_color_completion normal fish_pager_color_prefix normal --bold --underline fish_pager_color_description B3A06D yellow fish_pager_color_progress brwhite --background=cyan +fish_pager_color_selected_background --background=brblack fish_color_option eceff4 fish_color_keyword 81a1c1 diff --git a/share/tools/web_config/themes/Old School.theme b/share/tools/web_config/themes/Old School.theme index f2b2a1b78..06acb565f 100644 --- a/share/tools/web_config/themes/Old School.theme +++ b/share/tools/web_config/themes/Old School.theme @@ -26,5 +26,6 @@ fish_pager_color_completion normal fish_pager_color_description B3A06D yellow fish_pager_color_prefix normal --bold --underline fish_pager_color_progress brwhite --background=cyan +fish_pager_color_selected_background --background=brblack fish_color_option 30BE30 fish_color_keyword 00FF00 diff --git a/share/tools/web_config/themes/Seaweed.theme b/share/tools/web_config/themes/Seaweed.theme index 42976649d..ca7d294cf 100644 --- a/share/tools/web_config/themes/Seaweed.theme +++ b/share/tools/web_config/themes/Seaweed.theme @@ -26,5 +26,6 @@ fish_pager_color_description B3A06D yellow fish_pager_color_prefix normal --bold --underline fish_pager_color_completion normal fish_pager_color_progress brwhite --background=cyan +fish_pager_color_selected_background --background=brblack fish_color_option 04819E fish_color_keyword 00BF32 diff --git a/share/tools/web_config/themes/Snow Day.theme b/share/tools/web_config/themes/Snow Day.theme index b2b5889d9..289632ee4 100644 --- a/share/tools/web_config/themes/Snow Day.theme +++ b/share/tools/web_config/themes/Snow Day.theme @@ -26,5 +26,6 @@ fish_pager_color_completion normal fish_pager_color_description B3A06D yellow fish_pager_color_prefix normal --bold --underline fish_pager_color_progress brwhite --background=cyan +fish_pager_color_selected_background --background=brblack fish_color_option 4319CC fish_color_keyword 164CC9 diff --git a/share/tools/web_config/themes/Solarized Dark.theme b/share/tools/web_config/themes/Solarized Dark.theme index 263b3389a..f05744d93 100644 --- a/share/tools/web_config/themes/Solarized Dark.theme +++ b/share/tools/web_config/themes/Solarized Dark.theme @@ -27,5 +27,6 @@ fish_pager_color_completion B3A06D fish_pager_color_description B3A06D fish_pager_color_prefix cyan --underline fish_pager_color_progress brwhite --background=cyan +fish_pager_color_selected_background --background=brblack fish_color_option 839496 fish_color_keyword 93a1a1 diff --git a/share/tools/web_config/themes/Solarized Light.theme b/share/tools/web_config/themes/Solarized Light.theme index abbef71f9..aa7cc0417 100644 --- a/share/tools/web_config/themes/Solarized Light.theme +++ b/share/tools/web_config/themes/Solarized Light.theme @@ -27,5 +27,6 @@ fish_pager_color_completion green fish_pager_color_description B3A06D fish_pager_color_prefix cyan --underline fish_pager_color_progress brwhite --background=cyan +fish_pager_color_selected_background --background=white fish_color_option 657b83 fish_color_keyword 586e75 diff --git a/share/tools/web_config/themes/Tomorrow Night Bright.theme b/share/tools/web_config/themes/Tomorrow Night Bright.theme index 4ddb2bef8..fbe1d056c 100644 --- a/share/tools/web_config/themes/Tomorrow Night Bright.theme +++ b/share/tools/web_config/themes/Tomorrow Night Bright.theme @@ -27,5 +27,6 @@ fish_pager_color_completion normal fish_pager_color_description B3A06D yellow fish_pager_color_prefix normal --bold --underline fish_pager_color_progress brwhite --background=cyan +fish_pager_color_selected_background --background=brblack fish_color_option 7aa6da fish_color_keyword c397d8 diff --git a/share/tools/web_config/themes/Tomorrow Night.theme b/share/tools/web_config/themes/Tomorrow Night.theme index 17ef24a88..a52da6313 100644 --- a/share/tools/web_config/themes/Tomorrow Night.theme +++ b/share/tools/web_config/themes/Tomorrow Night.theme @@ -27,5 +27,6 @@ fish_pager_color_completion normal fish_pager_color_description B3A06D yellow fish_pager_color_prefix normal --bold --underline fish_pager_color_progress brwhite --background=cyan +fish_pager_color_selected_background --background=brblack fish_color_option 81a2be fish_color_keyword b294bb diff --git a/share/tools/web_config/themes/Tomorrow.theme b/share/tools/web_config/themes/Tomorrow.theme index 494426ea3..27353fd83 100644 --- a/share/tools/web_config/themes/Tomorrow.theme +++ b/share/tools/web_config/themes/Tomorrow.theme @@ -27,5 +27,6 @@ fish_pager_color_completion normal fish_color_cancel -r fish_pager_color_prefix normal --bold --underline fish_pager_color_progress brwhite --background=cyan +fish_pager_color_selected_background --background=brblack fish_color_option 4271ae fish_color_keyword 8959a8 diff --git a/share/tools/web_config/themes/ayu Dark.theme b/share/tools/web_config/themes/ayu Dark.theme index fe1b93bc1..9cd7eeb33 100644 --- a/share/tools/web_config/themes/ayu Dark.theme +++ b/share/tools/web_config/themes/ayu Dark.theme @@ -27,5 +27,6 @@ fish_pager_color_completion normal fish_pager_color_description B3A06D yellow fish_pager_color_prefix normal --bold --underline fish_pager_color_progress brwhite --background=cyan +fish_pager_color_selected_background --background=E6B450 fish_color_option B3B1AD fish_color_keyword 39BAE6 diff --git a/share/tools/web_config/themes/ayu Light.theme b/share/tools/web_config/themes/ayu Light.theme index 52457b88c..1c4448d0b 100644 --- a/share/tools/web_config/themes/ayu Light.theme +++ b/share/tools/web_config/themes/ayu Light.theme @@ -27,5 +27,6 @@ fish_pager_color_description B3A06D yellow fish_pager_color_completion normal fish_pager_color_prefix normal --bold --underline fish_pager_color_progress brwhite --background=cyan +fish_pager_color_selected_background --background=FF9940 fish_color_option 575F66 fish_color_keyword 55B4D4 diff --git a/share/tools/web_config/themes/ayu Mirage.theme b/share/tools/web_config/themes/ayu Mirage.theme index bbeb79da2..2b891f0da 100644 --- a/share/tools/web_config/themes/ayu Mirage.theme +++ b/share/tools/web_config/themes/ayu Mirage.theme @@ -27,5 +27,6 @@ fish_pager_color_completion normal fish_pager_color_description B3A06D yellow fish_pager_color_prefix normal --bold --underline fish_pager_color_progress brwhite --background=cyan +fish_pager_color_selected_background --background=FFCC66 fish_color_option CBCCC6 fish_color_keyword 5CCFE6 diff --git a/share/tools/web_config/themes/coolbeans.theme b/share/tools/web_config/themes/coolbeans.theme index dfbd78eb9..6a951337a 100644 --- a/share/tools/web_config/themes/coolbeans.theme +++ b/share/tools/web_config/themes/coolbeans.theme @@ -17,7 +17,7 @@ fish_color_match 0AA fish_color_normal B2B2B2 fish_color_operator 0AA fish_color_param ccccff -fish_color_quote F50 +fish_color_quote 9ce781 fish_color_redirection FFF fish_color_search_match --background=533 fish_color_selection --background=B218B2 diff --git a/share/tools/web_config/themes/fish default.theme b/share/tools/web_config/themes/fish default.theme index 075d9c308..4a66a85ac 100644 --- a/share/tools/web_config/themes/fish default.theme +++ b/share/tools/web_config/themes/fish default.theme @@ -1,19 +1,19 @@ # name: fish default fish_color_normal normal -fish_color_command 005fd7 -fish_color_quote 999900 -fish_color_redirection 00afff -fish_color_end 009900 -fish_color_error ff0000 -fish_color_param 00afff -fish_color_comment 990000 +fish_color_command blue +fish_color_quote yellow +fish_color_redirection cyan --bold +fish_color_end green +fish_color_error brred +fish_color_param cyan +fish_color_comment red fish_color_match --background=brblue fish_color_search_match bryellow --background=brblack fish_color_selection white --bold --background=brblack fish_color_history_current --bold -fish_color_operator 00a6b2 -fish_color_escape 00a6b2 +fish_color_operator brcyan +fish_color_escape brcyan fish_color_cwd green fish_color_valid_path --underline fish_color_cwd_root red @@ -21,9 +21,10 @@ fish_color_user brgreen fish_color_autosuggestion 555 brblack fish_pager_color_completion normal fish_color_host normal -fish_pager_color_description B3A06D yellow +fish_pager_color_description B3A06D yellow -i fish_color_cancel -r fish_pager_color_prefix normal --bold --underline fish_pager_color_progress brwhite --background=cyan -fish_color_option 00afff -fish_color_keyword 005fd7 +fish_pager_color_selected_background -r +fish_color_option cyan +fish_color_keyword blue diff --git a/share/tools/web_config/webconfig.py b/share/tools/web_config/webconfig.py index 2a73bb889..c5b5290ab 100755 --- a/share/tools/web_config/webconfig.py +++ b/share/tools/web_config/webconfig.py @@ -67,7 +67,7 @@ def isMacOS10_12_5_OrLater(): """ Return whether this system is macOS 10.12.5 or a later version. """ try: return [int(x) for x in platform.mac_ver()[0].split(".")] >= [10, 12, 5] - except: + except ValueError: return False @@ -93,7 +93,10 @@ def is_chromeos_garcon(): # Linux filesystem. This uses Garcon, see for example # https://chromium.googlesource.com/chromiumos/platform2/+/master/vm_tools/garcon/#opening-urls # https://source.chromium.org/search?q=garcon-url-handler - return "garcon-url-handler" in webbrowser.get().name + try: + return "garcon-url-handler" in webbrowser.get().name + except AttributeError: + return False def run_fish_cmd(text): @@ -191,30 +194,44 @@ def better_color(c1, c2): def parse_color(color_str): """A basic function to parse a color string, for example, 'red' '--bold'.""" comps = color_str.split(" ") - color = "normal" + color = "" background_color = "" bold, underline, italics, dim, reverse = False, False, False, False, False for comp in comps: # Remove quotes comp = comp.strip("'\" ") - if comp == "--bold": + if comp == "--bold" or comp == "-o": bold = True - elif comp == "--underline": + elif comp == "--underline" or comp == "-u": underline = True - elif comp == "--italics": + elif comp == "--italics" or comp == "-i": italics = True - elif comp == "--dim": + elif comp == "--dim" or comp == "-d": dim = True - elif comp == "--reverse": + elif comp == "--reverse" or comp == "-r": reverse = True - elif comp.startswith("--background="): + elif comp.startswith("--background"): # Background color - background_color = better_color( - background_color, parse_one_color(comp[len("--background=") :]) - ) + c = comp[len("--background=") :] + parsed_c = parse_one_color(c) + # We prefer the unparsed version - if it says "brgreen", we use brgreen, + # instead of 00ff00 + if better_color(background_color, parsed_c) == parsed_c: + background_color = c + elif comp.startswith("-b"): + # Background color in short. + skip = len("-b") + if comp[len("-b=")] in ["=", " "]: + skip += 1 + c = comp[skip :] + parsed_c = parse_one_color(c) + if better_color(background_color, parsed_c) == parsed_c: + background_color = c else: # Regular color - color = better_color(color, parse_one_color(comp)) + parsed_c = parse_one_color(comp) + if better_color(color, parsed_c) == parsed_c: + color = comp return { "color": color, @@ -226,6 +243,26 @@ def parse_color(color_str): "reverse": reverse, } +def unparse_color(col): + """A basic function to return the fish version of a color dict""" + if isinstance(col, str): + return col + ret = "" + if col["color"]: + ret += col["color"] + if col["bold"]: + ret += " --bold" + if col["underline"]: + ret += " --underline" + if col["italics"]: + ret += " --italics" + if col["dim"]: + ret += " --dim" + if col["reverse"]: + ret += " --reverse" + if col["background"]: + ret += " --background=" + col["background"] + return ret def parse_bool(val): val = val.lower() @@ -538,8 +575,7 @@ def get_special_ansi_escapes(): 'bold': '\x1b[1m', 'underline': '\x1b[4m' } - pass - + return g_special_escapes_dict @@ -971,8 +1007,10 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): extrainfo[key] = value - for match in re.finditer(r"^fish_color_(\S+) ?(.*)", line): - color_name, color_value = [x.strip() for x in match.group(1, 2)] + for match in re.finditer(r"^fish_(pager_)?color_(\S+) ?(.*)", line): + color_name, color_value = [x.strip() for x in match.group(2, 3)] + if match.group(1): + color_name = "fish_pager_color_" + color_name color_desc = descriptions.get(color_name, "") data = {"name": color_name, "description": color_desc} data.update(parse_color(color_value)) @@ -1103,25 +1141,33 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): return result def do_get_color_for_variable(self, name): - # Return the color with the given name, or the empty string if there is - # none. + "Return the color with the given name, or the empty string if there is none." out, err = run_fish_cmd("echo -n $" + name) return out - def do_set_color_for_variable( - self, name, color - ): + def do_set_color_for_variable(self, name, color): "Sets a color for a fish color name, like 'autosuggestion'" if not name: raise ValueError - if not color: + if not color and not color == "": color = "normal" - varname = "fish_color_" + name + else: + color = unparse_color(color) + if not name.startswith("fish_pager_color_"): + varname = "fish_color_" + name # If the name already starts with "fish_", use it as the varname # This is needed for 'fish_pager_color' vars. if name.startswith("fish_"): varname = name - # TODO: Check if the varname is allowable. + # Check if the varname is allowable. + varname = varname.strip() + if not re.match("^[a-zA-Z0-9_]+$", varname): + print("Refusing to use variable name: '", varname, "'") + return + color = color.strip() + if not re.match("^[a-zA-Z0-9_= -]*$", color): + print("Refusing to use color value: ", color) + return command = "set -U " + varname command += " " + color @@ -1416,12 +1462,8 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): color = item.get("color") if what: - output = self.do_set_color_for_variable( - what, - color, - ) - else: - output = "Bad request" + output = self.do_set_color_for_variable(what, color) + elif p == "/get_function/": what = postvars.get("what") output = [self.do_get_function(what[0])] diff --git a/src/ast.cpp b/src/ast.cpp index 6e8c8357f..6afa534f6 100644 --- a/src/ast.cpp +++ b/src/ast.cpp @@ -182,6 +182,16 @@ class token_stream_t { assert(token.length <= SOURCE_OFFSET_INVALID); result.source_length = static_cast(token.length); + + if (token.error != tokenizer_error_t::none) { + auto subtoken_offset = static_cast(token.error_offset_within_token); + // Skip invalid tokens that have a zero length, especially if they are at EOF. + if (subtoken_offset < result.source_length) { + result.source_start += subtoken_offset; + result.source_length -= subtoken_offset; + } + } + return result; } @@ -1212,26 +1222,26 @@ struct populator_t { visit_stack_.pop_back(); } - // Flags controlling parsing. + /// Flags controlling parsing. parse_tree_flags_t flags_{}; - // Stream of tokens which we consume. - token_stream_t tokens_; - - // The type which we are attempting to parse, typically job_list but may be - // freestanding_argument_list. - const type_t top_type_; - - // If set, we are unwinding due to error recovery. - bool unwinding_{false}; - - // If set, we have encountered an error. - bool any_error_{false}; - - // Extra stuff like comment ranges. + /// Extra stuff like comment ranges. ast_t::extras_t extras_{}; - // A stack containing the nodes whose fields we are visiting. + /// Stream of tokens which we consume. + token_stream_t tokens_; + + /** The type which we are attempting to parse, typically job_list but may be + freestanding_argument_list. */ + const type_t top_type_; + + /// If set, we are unwinding due to error recovery. + bool unwinding_{false}; + + /// If set, we have encountered an error. + bool any_error_{false}; + + /// A stack containing the nodes whose fields we are visiting. std::vector visit_stack_{}; // If non-null, populate with errors. diff --git a/src/ast.h b/src/ast.h index 4f05f1862..7ef51498a 100644 --- a/src/ast.h +++ b/src/ast.h @@ -926,9 +926,6 @@ class traversal_t { // Construct an empty visitor, used for iterator support. traversal_t() = default; - // \return whether we are finished visiting. - bool finished() const { return stack_.empty(); } - // Append a node. void push(const node_t *n) { assert(n && "Should not push null node"); diff --git a/src/builtin.cpp b/src/builtin.cpp index 30f08af91..683f49079 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -358,24 +358,22 @@ static constexpr builtin_data_t builtin_datas[] = { {L":", &builtin_true, N_(L"Return a successful result")}, {L"[", &builtin_test, N_(L"Test a condition")}, {L"_", &builtin_gettext, N_(L"Translate a string")}, - {L"and", &builtin_generic, N_(L"Execute command if previous command succeeded")}, + {L"and", &builtin_generic, N_(L"Run command if last command succeeded")}, {L"argparse", &builtin_argparse, N_(L"Parse options in fish script")}, {L"begin", &builtin_generic, N_(L"Create a block of code")}, {L"bg", &builtin_bg, N_(L"Send job to background")}, {L"bind", &builtin_bind, N_(L"Handle fish key bindings")}, {L"block", &builtin_block, N_(L"Temporarily block delivery of events")}, {L"break", &builtin_break_continue, N_(L"Stop the innermost loop")}, - {L"breakpoint", &builtin_breakpoint, - N_(L"Temporarily halt execution of a script and launch an interactive debug prompt")}, - {L"builtin", &builtin_builtin, N_(L"Run a builtin command instead of a function")}, - {L"case", &builtin_generic, N_(L"Conditionally execute a block of commands")}, + {L"breakpoint", &builtin_breakpoint, N_(L"Halt execution and start debug prompt")}, + {L"builtin", &builtin_builtin, N_(L"Run a builtin specifically")}, + {L"case", &builtin_generic, N_(L"Block of code to run conditionally")}, {L"cd", &builtin_cd, N_(L"Change working directory")}, - {L"command", &builtin_command, N_(L"Run a program instead of a function or builtin")}, + {L"command", &builtin_command, N_(L"Run a command specifically")}, {L"commandline", &builtin_commandline, N_(L"Set or get the commandline")}, {L"complete", &builtin_complete, N_(L"Edit command specific completions")}, {L"contains", &builtin_contains, N_(L"Search for a specified string in a list")}, - {L"continue", &builtin_break_continue, - N_(L"Skip the rest of the current lap of the innermost loop")}, + {L"continue", &builtin_break_continue, N_(L"Skip over remaining innermost loop")}, {L"count", &builtin_count, N_(L"Count the number of arguments")}, {L"disown", &builtin_disown, N_(L"Remove job from job list")}, {L"echo", &builtin_echo, N_(L"Print arguments")}, @@ -400,19 +398,19 @@ static constexpr builtin_data_t builtin_datas[] = { {L"pwd", &builtin_pwd, N_(L"Print the working directory")}, {L"random", &builtin_random, N_(L"Generate random number")}, {L"read", &builtin_read, N_(L"Read a line of input into variables")}, - {L"realpath", &builtin_realpath, N_(L"Convert path to absolute path without symlinks")}, + {L"realpath", &builtin_realpath, N_(L"Show absolute path sans symlinks")}, {L"return", &builtin_return, N_(L"Stop the currently evaluated function")}, {L"set", &builtin_set, N_(L"Handle environment variables")}, {L"set_color", &builtin_set_color, N_(L"Set the terminal color")}, {L"source", &builtin_source, N_(L"Evaluate contents of file")}, {L"status", &builtin_status, N_(L"Return status information about fish")}, {L"string", &builtin_string, N_(L"Manipulate strings")}, - {L"switch", &builtin_generic, N_(L"Conditionally execute a block of commands")}, + {L"switch", &builtin_generic, N_(L"Conditionally run blocks of code")}, {L"test", &builtin_test, N_(L"Test a condition")}, {L"time", &builtin_generic, N_(L"Measure how long a command or block takes")}, {L"true", &builtin_true, N_(L"Return a successful result")}, {L"type", &builtin_type, N_(L"Check if a thing is a thing")}, - {L"ulimit", &builtin_ulimit, N_(L"Set or get the shells resource usage limits")}, + {L"ulimit", &builtin_ulimit, N_(L"Get/set resource usage limits")}, {L"wait", &builtin_wait, N_(L"Wait for background processes completed")}, {L"while", &builtin_generic, N_(L"Perform a command multiple times")}, }; diff --git a/src/builtins/argparse.cpp b/src/builtins/argparse.cpp index 53824abc3..9f06d19ac 100644 --- a/src/builtins/argparse.cpp +++ b/src/builtins/argparse.cpp @@ -596,6 +596,9 @@ static int argparse_parse_flags(parser_t &parser, argparse_cmd_opts_t &opts, opts.argv.push_back(arg_contents - 1); // Work around weirdness with wgetopt, which crashes if we `continue` here. if (w.woptind == argc) break; + // Explain to wgetopt that we want to skip to the next arg, + // because we can't handle this opt group. + w.nextchar = nullptr; } if (retval != STATUS_CMD_OK) return retval; long_idx = -1; diff --git a/src/builtins/block.cpp b/src/builtins/block.cpp index f9851bf5e..3083179eb 100644 --- a/src/builtins/block.cpp +++ b/src/builtins/block.cpp @@ -1,4 +1,4 @@ -// Implementation of the bind builtin. +// Implementation of the block builtin. #include "config.h" // IWYU pragma: keep #include "block.h" diff --git a/src/builtins/command.cpp b/src/builtins/command.cpp index 71b0e0530..33d0d999d 100644 --- a/src/builtins/command.cpp +++ b/src/builtins/command.cpp @@ -110,5 +110,5 @@ maybe_t builtin_command(parser_t &parser, io_streams_t &streams, const wcha } } - return found ? STATUS_CMD_OK : STATUS_CMD_ERROR; + return found ? STATUS_CMD_OK : STATUS_CMD_UNKNOWN; } diff --git a/src/builtins/commandline.cpp b/src/builtins/commandline.cpp index 212558eaa..2c2a7c712 100644 --- a/src/builtins/commandline.cpp +++ b/src/builtins/commandline.cpp @@ -143,6 +143,7 @@ maybe_t builtin_commandline(parser_t &parser, io_streams_t &streams, const bool line_mode = false; bool search_mode = false; bool paging_mode = false; + bool paging_full_mode = false; bool is_valid = false; const wchar_t *begin = nullptr, *end = nullptr; const wchar_t *override_buffer = nullptr; @@ -167,6 +168,7 @@ maybe_t builtin_commandline(parser_t &parser, io_streams_t &streams, const {L"line", no_argument, nullptr, 'L'}, {L"search-mode", no_argument, nullptr, 'S'}, {L"paging-mode", no_argument, nullptr, 'P'}, + {L"paging-full-mode", no_argument, nullptr, 'F'}, {L"is-valid", no_argument, nullptr, 1}, {nullptr, 0, nullptr, 0}}; @@ -239,6 +241,10 @@ maybe_t builtin_commandline(parser_t &parser, io_streams_t &streams, const paging_mode = true; break; } + case 'F': { + paging_full_mode = true; + break; + } case 1: { is_valid = true; break; @@ -323,7 +329,7 @@ maybe_t builtin_commandline(parser_t &parser, io_streams_t &streams, const } if ((buffer_part || tokenize || cut_at_cursor) && - (cursor_mode || line_mode || search_mode || paging_mode) && + (cursor_mode || line_mode || search_mode || paging_mode || paging_full_mode) && // Special case - we allow to get/set cursor position relative to the process/job/token. !(buffer_part && cursor_mode)) { streams.err.append_format(BUILTIN_ERR_COMBO, argv[0]); @@ -366,6 +372,11 @@ maybe_t builtin_commandline(parser_t &parser, io_streams_t &streams, const return commandline_get_state().pager_mode ? 0 : 1; } + if (paging_full_mode) { + auto state = commandline_get_state(); + return (state.pager_mode && state.pager_fully_disclosed) ? 0 : 1; + } + // At this point we have (nearly) exhausted the options which always operate on the true command // line. Now we respect the possibility of a transient command line due to evaluating a wrapped // completion. Don't do this in cursor_mode: it makes no sense to move the cursor based on a diff --git a/src/builtins/complete.cpp b/src/builtins/complete.cpp index 5d527ea72..a25b90438 100644 --- a/src/builtins/complete.cpp +++ b/src/builtins/complete.cpp @@ -122,6 +122,10 @@ static void builtin_complete_print(const wcstring &cmd, io_streams_t &streams, p } } +/// Values used for long-only options. +enum { + opt_escape = 1, +}; /// The complete builtin. Used for specifying programmable tab-completions. Calls the functions in // complete.cpp for any heavy lifting. maybe_t builtin_complete(parser_t &parser, io_streams_t &streams, const wchar_t **argv) { @@ -139,6 +143,7 @@ maybe_t builtin_complete(parser_t &parser, io_streams_t &streams, const wch wcstring_list_t path; wcstring_list_t wrap_targets; bool preserve_order = false; + bool unescape_output = true; static const wchar_t *const short_options = L":a:c:p:s:l:o:d:fFrxeuAn:C::w:hk"; static const struct woption long_options[] = { @@ -162,6 +167,7 @@ maybe_t builtin_complete(parser_t &parser, io_streams_t &streams, const wch {L"do-complete", optional_argument, nullptr, 'C'}, {L"help", no_argument, nullptr, 'h'}, {L"keep-order", no_argument, nullptr, 'k'}, + {L"escape", no_argument, nullptr, opt_escape}, {nullptr, 0, nullptr, 0}}; int opt; @@ -272,6 +278,10 @@ maybe_t builtin_complete(parser_t &parser, io_streams_t &streams, const wch if (have_do_complete_param) do_complete_param = w.woptarg; break; } + case opt_escape: { + unescape_output = false; + break; + } case 'h': { builtin_print_help(parser, streams, cmd); return STATUS_CMD_OK; @@ -347,7 +357,7 @@ maybe_t builtin_complete(parser_t &parser, io_streams_t &streams, const wch if (!state.initialized) { // This corresponds to using 'complete -C' in non-interactive mode. // See #2361 . - builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]); + builtin_missing_argument(parser, streams, cmd, L"-C"); return STATUS_INVALID_ARGS; } do_complete_param = std::move(state.text); @@ -388,10 +398,12 @@ maybe_t builtin_complete(parser_t &parser, io_streams_t &streams, const wch faux_cmdline_with_completion.resize(faux_cmdline_with_completion.size() - 1); } - // The input data is meant to be something like you would have on the command - // line, e.g. includes backslashes. The output should be raw, i.e. unescaped. So - // we need to unescape the command line. See #1127. - unescape_string_in_place(&faux_cmdline_with_completion, UNESCAPE_DEFAULT); + if (unescape_output) { + // The input data is meant to be something like you would have on the command + // line, e.g. includes backslashes. The output should be raw, i.e. unescaped. So + // we need to unescape the command line. See #1127. + unescape_string_in_place(&faux_cmdline_with_completion, UNESCAPE_DEFAULT); + } streams.out.append(faux_cmdline_with_completion); // Append any description. diff --git a/src/builtins/history.cpp b/src/builtins/history.cpp index e3648b4bf..0bd0acda5 100644 --- a/src/builtins/history.cpp +++ b/src/builtins/history.cpp @@ -276,10 +276,7 @@ maybe_t builtin_history(parser_t &parser, io_streams_t &streams, const wcha status = STATUS_INVALID_ARGS; break; } - for (wcstring delete_string : args) { - if (delete_string[0] == '"' && delete_string[delete_string.length() - 1] == '"') { - delete_string = delete_string.substr(1, delete_string.length() - 2); - } + for (const wcstring &delete_string : args) { history->remove(delete_string); } break; diff --git a/src/builtins/pwd.cpp b/src/builtins/pwd.cpp index 92add9a2a..7e4de3f8d 100644 --- a/src/builtins/pwd.cpp +++ b/src/builtins/pwd.cpp @@ -61,7 +61,7 @@ maybe_t builtin_pwd(parser_t &parser, io_streams_t &streams, const wchar_t pwd = std::move(*real_pwd); } else { const char *error = std::strerror(errno); - streams.err.append_format(L"%ls: realpath failed:", cmd, error); + streams.err.append_format(L"%ls: realpath failed: %s", cmd, error); return STATUS_CMD_ERROR; } } diff --git a/src/builtins/test.cpp b/src/builtins/test.cpp index cde90430e..dfd92da7c 100644 --- a/src/builtins/test.cpp +++ b/src/builtins/test.cpp @@ -560,9 +560,12 @@ unique_ptr test_parser::parse_args(const wcstring_list_t &args, wcst // Handle errors. // For now we only show the first error. - if (!parser.errors.empty()) { + if (!parser.errors.empty() || result->range.end < args.size()) { int narg = 0; int len_to_err = 0; + if (parser.errors.empty()) { + parser.error_idx = result->range.end; + } wcstring commandline; for (const wcstring &arg : args) { if (narg > 0) { @@ -576,7 +579,13 @@ unique_ptr test_parser::parse_args(const wcstring_list_t &args, wcst } err.append(program_name); err.append(L": "); - err.append(parser.errors.at(0)); + if (!parser.errors.empty()) { + err.append(parser.errors.at(0)); + } else { + append_format(err, L"unexpected argument at index %lu: '%ls'", + static_cast(result->range.end) + 1, + args.at(result->range.end).c_str()); + } err.push_back(L'\n'); err.append(commandline); err.push_back(L'\n'); @@ -588,11 +597,6 @@ unique_ptr test_parser::parse_args(const wcstring_list_t &args, wcst // parse_expression(). assert(result->range.end <= args.size()); if (result->range.end < args.size()) { - if (err.empty()) { - append_format(err, L"%ls: unexpected argument at index %lu: '%ls'\n", program_name, - static_cast(result->range.end) + 1, - args.at(result->range.end).c_str()); - } result.reset(nullptr); } } diff --git a/src/common.cpp b/src/common.cpp index cbf381dda..38313c6c2 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -523,6 +523,13 @@ const wchar_t *quote_end(const wchar_t *pos, wchar_t quote) { return nullptr; } +const wchar_t *comment_end(const wchar_t *pos) { + do { + pos++; + } while (*pos && *pos != L'\n'); + return pos; +} + void fish_setlocale() { // Use various Unicode symbols if they can be encoded using the current locale, else a simple // ASCII char alternative. All of the can_be_encoded() invocations should return the same @@ -1212,6 +1219,8 @@ maybe_t read_unquoted_escape(const wchar_t *input, wcstring *result, boo for (size_t i = 0; i < chars; i++) { long d = convert_digit(input[in_pos], base); if (d < 0) { + // If we have no digit, this is a tokenizer error. + if (i == 0) errored = true; break; } @@ -1219,7 +1228,7 @@ maybe_t read_unquoted_escape(const wchar_t *input, wcstring *result, boo in_pos++; } - if (res <= max_val) { + if (!errored && res <= max_val) { result_char_or_none = static_cast((byte_literal ? ENCODE_DIRECT_BASE : 0) + res); } else { @@ -1301,7 +1310,7 @@ maybe_t read_unquoted_escape(const wchar_t *input, wcstring *result, boo } /// Returns the unescaped version of input_str into output_str (by reference). Returns true if -/// successful. If false, the contents of output_str are undefined (!). +/// successful. If false, the contents of output_str are unchanged. static bool unescape_string_internal(const wchar_t *const input, const size_t input_len, wcstring *output_str, unescape_flags_t flags) { // Set up result string, which we'll swap with the output on success. @@ -1579,12 +1588,12 @@ bool unescape_string_in_place(wcstring *str, unescape_flags_t escape_special) { return success; } -bool unescape_string(const wchar_t *input, wcstring *output, unescape_flags_t escape_special, - escape_string_style_t style) { +bool unescape_string(const wchar_t *input, size_t len, wcstring *output, + unescape_flags_t escape_special, escape_string_style_t style) { bool success = false; switch (style) { case STRING_STYLE_SCRIPT: { - success = unescape_string_internal(input, std::wcslen(input), output, escape_special); + success = unescape_string_internal(input, len, output, escape_special); break; } case STRING_STYLE_URL: { @@ -1605,30 +1614,14 @@ bool unescape_string(const wchar_t *input, wcstring *output, unescape_flags_t es return success; } +bool unescape_string(const wchar_t *input, wcstring *output, unescape_flags_t escape_special, + escape_string_style_t style) { + return unescape_string(input, std::wcslen(input), output, escape_special, style); +} + bool unescape_string(const wcstring &input, wcstring *output, unescape_flags_t escape_special, escape_string_style_t style) { - bool success = false; - switch (style) { - case STRING_STYLE_SCRIPT: { - success = unescape_string_internal(input.c_str(), input.size(), output, escape_special); - break; - } - case STRING_STYLE_URL: { - success = unescape_string_url(input.c_str(), output); - break; - } - case STRING_STYLE_VAR: { - success = unescape_string_var(input.c_str(), output); - break; - } - case STRING_STYLE_REGEX: { - // unescaping PCRE2 is not needed/supported, the PCRE2 engine is responsible for that - success = false; - break; - } - } - if (!success) output->clear(); - return success; + return unescape_string(input.c_str(), input.size(), output, escape_special, style); } [[gnu::noinline]] void bugreport() { diff --git a/src/common.h b/src/common.h index 91feaa2d7..178e339a1 100644 --- a/src/common.h +++ b/src/common.h @@ -451,6 +451,11 @@ std::unique_ptr make_unique(Args &&...args) { /// \param quote the quote to use, usually pointed to by \c pos. const wchar_t *quote_end(const wchar_t *pos, wchar_t quote); +/// This functions returns the end of the comment substring beginning at \c pos. +/// +/// \param pos the position where the comment starts, including the '#' symbol. +const wchar_t *comment_end(const wchar_t *pos); + /// This function should be called after calling `setlocale()` to perform fish specific locale /// initialization. void fish_setlocale(); @@ -504,6 +509,10 @@ bool unescape_string_in_place(wcstring *str, unescape_flags_t escape_special); bool unescape_string(const wchar_t *input, wcstring *output, unescape_flags_t escape_special, escape_string_style_t style = STRING_STYLE_SCRIPT); +bool unescape_string(const wchar_t *input, size_t len, wcstring *output, + unescape_flags_t escape_special, + escape_string_style_t style = STRING_STYLE_SCRIPT); + bool unescape_string(const wcstring &input, wcstring *output, unescape_flags_t escape_special, escape_string_style_t style = STRING_STYLE_SCRIPT); diff --git a/src/complete.cpp b/src/complete.cpp index ae9681b61..5ee3ce877 100644 --- a/src/complete.cpp +++ b/src/complete.cpp @@ -594,7 +594,7 @@ void completer_t::complete_cmd_desc(const wcstring &str) { // least two characters if we don't know the location of the whatis-database. if (cmd.length() < 2) return; - if (wildcard_has(cmd, false)) { + if (wildcard_has(cmd)) { return; } @@ -1390,7 +1390,7 @@ void completer_t::complete_custom(const wcstring &cmd, const wcstring &cmdline, // buitin_commandline will refer to the wrapped command. But not if // we're doing autosuggestions. maybe_t remove_transient{}; - bool wants_transient = ad->wrap_depth > 0 && !is_autosuggest; + bool wants_transient = (ad->wrap_depth > 0 || ad->var_assignments) && !is_autosuggest; if (wants_transient) { ctx.parser->libdata().transient_commandlines.push_back(cmdline); remove_transient.emplace([=] { ctx.parser->libdata().transient_commandlines.pop_back(); }); @@ -1575,6 +1575,7 @@ void completer_t::perform_for_commandline(wcstring cmdline) { // Get all the arguments. std::vector tokens; parse_util_process_extent(cmdline.c_str(), position_in_statement, nullptr, nullptr, &tokens); + size_t actual_token_count = tokens.size(); // Hack: fix autosuggestion by removing prefixing "and"s #6249. if (is_autosuggest) { @@ -1603,6 +1604,14 @@ void completer_t::perform_for_commandline(wcstring cmdline) { return; } + wcstring *effective_cmdline, effective_cmdline_buf; + if (tokens.size() == actual_token_count) { + effective_cmdline = &cmdline; + } else { + effective_cmdline_buf.assign(cmdline, tokens.front().offset, wcstring::npos); + effective_cmdline = &effective_cmdline_buf; + } + const tok_t &cmd_tok = tokens.front(); const tok_t &cur_tok = tokens.back(); @@ -1674,10 +1683,8 @@ void completer_t::perform_for_commandline(wcstring cmdline) { custom_arg_data_t arg_data{&var_assignments}; arg_data.had_ddash = had_ddash; - assert(cmd_tok.offset < std::numeric_limits::max()); - assert(cmd_tok.length < std::numeric_limits::max()); - source_range_t command_range = {static_cast(cmd_tok.offset), - static_cast(cmd_tok.length)}; + source_offset_t bias = cmdline.size() - effective_cmdline->size(); + source_range_t command_range = {cmd_tok.offset - bias, cmd_tok.length}; wcstring exp_command = cmd_tok.get_source(cmdline); bool unescaped = @@ -1687,7 +1694,7 @@ void completer_t::perform_for_commandline(wcstring cmdline) { if (unescaped) { // Have to walk over the command and its entire wrap chain. If any command // disables do_file, then they all do. - walk_wrap_chain(exp_command, cmdline, command_range, &arg_data); + walk_wrap_chain(exp_command, *effective_cmdline, command_range, &arg_data); do_file = arg_data.do_file; // If we're autosuggesting, and the token is empty, don't do file suggestions. diff --git a/src/env.cpp b/src/env.cpp index b33345062..49fc2c75a 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -600,6 +600,7 @@ class env_scoped_impl_t : public environment_t, noncopyable_t { // query. maybe_t try_get_computed(const wcstring &key) const; maybe_t try_get_local(const wcstring &key) const; + maybe_t try_get_function(const wcstring &key) const; maybe_t try_get_global(const wcstring &key) const; maybe_t try_get_universal(const wcstring &key) const; @@ -667,8 +668,6 @@ bool env_scoped_impl_t::export_array_needs_regeneration() const { } std::shared_ptr env_scoped_impl_t::create_export_array() const { - var_table_t table; - FLOG(env_export, L"create_export_array() recalc"); var_table_t vals; get_exported(this->globals_, vals); @@ -767,23 +766,31 @@ maybe_t env_scoped_impl_t::try_get_computed(const wcstring &key) cons } maybe_t env_scoped_impl_t::try_get_local(const wcstring &key) const { - auto cursor = locals_; - while (cursor) { - auto where = cursor->env.find(key); - if (where != cursor->env.end()) { - return where->second; - } - cursor = cursor->next; + maybe_t entry; + for (auto cur = locals_; cur; cur=cur->next) { + if ((entry = cur->find_entry(key))) break; } - return none(); + return entry; // this is either the entry or none() from find_entry +} + +maybe_t env_scoped_impl_t::try_get_function(const wcstring &key) const { + maybe_t entry; + auto node = locals_; + while (node->next) { + node = node->next; + // The first node that introduces a new scope is ours. + // If this doesn't happen, we go on until we've reached the + // topmost local scope. + if (node->new_scope) break; + } + for (auto cur = node; cur; cur=cur->next) { + if ((entry = cur->find_entry(key))) break; + } + return entry; // this is either the entry or none() from find_entry } maybe_t env_scoped_impl_t::try_get_global(const wcstring &key) const { - auto where = globals_->env.find(key); - if (where != globals_->env.end()) { - return where->second; - } - return none(); + return globals_->find_entry(key); } maybe_t env_scoped_impl_t::try_get_universal(const wcstring &key) const { @@ -802,6 +809,9 @@ maybe_t env_scoped_impl_t::get(const wcstring &key, env_mode_flags_t if (!result && query.local) { result = try_get_local(key); } + if (!result && query.function) { + result = try_get_function(key); + } if (!result && query.global) { result = try_get_global(key); } diff --git a/src/env_dispatch.cpp b/src/env_dispatch.cpp index 0331d31fa..4181743e4 100644 --- a/src/env_dispatch.cpp +++ b/src/env_dispatch.cpp @@ -60,21 +60,14 @@ #define DEFAULT_TERM2 "dumb" /// List of all locale environment variable names that might trigger (re)initializing the locale -/// subsystem. +/// subsystem. These are only the variables we're possibly interested in. static const wcstring locale_variables[] = {L"LANG", L"LANGUAGE", L"LC_ALL", - L"LC_ADDRESS", L"LC_COLLATE", L"LC_CTYPE", - L"LC_IDENTIFICATION", - L"LC_MEASUREMENT", L"LC_MESSAGES", - L"LC_MONETARY", - L"LC_NAME", L"LC_NUMERIC", - L"LC_PAPER", - L"LC_TELEPHONE", L"LC_TIME", L"fish_allow_singlebyte_locale", L"LOCPATH"}; diff --git a/src/env_universal_common.cpp b/src/env_universal_common.cpp index 8a1db4b82..1dc4459ef 100644 --- a/src/env_universal_common.cpp +++ b/src/env_universal_common.cpp @@ -501,7 +501,7 @@ void env_universal_t::initialize_at_path(callback_data_list_t &callbacks, wcstri void env_universal_t::initialize(callback_data_list_t &callbacks) { // Set do_flock to false immediately if the default variable path is on a remote filesystem. // See #7968. - if (path_get_config_is_remote() == 1) do_flock = false; + if (path_get_config_remoteness() == dir_remoteness_t::remote) do_flock = false; this->initialize_at_path(callbacks, default_vars_path(), true /* migrate legacy */); } @@ -1459,7 +1459,7 @@ class universal_notifier_named_pipe_t final : public universal_notifier_t { // If we're no longer readable, go back to wait mode. // Conversely, if we have been readable too long, perhaps some fish died while its // written data was still on the pipe; drain some. - if (!select_wrapper_t::poll_fd_readable(pipe_fd.fd())) { + if (!fd_readable_set_t::poll_fd_readable(pipe_fd.fd())) { set_state(waiting_for_readable); } else if (get_time() >= state_start_usec + k_readable_too_long_duration_usec) { drain_excess(); @@ -1479,7 +1479,7 @@ class universal_notifier_named_pipe_t final : public universal_notifier_t { // change occurred with ours. if (get_time() >= state_start_usec + k_flash_duration_usec) { drain_written(); - if (!select_wrapper_t::poll_fd_readable(pipe_fd.fd())) { + if (!fd_readable_set_t::poll_fd_readable(pipe_fd.fd())) { set_state(waiting_for_readable); } else { set_state(polling_during_readable); diff --git a/src/event.cpp b/src/event.cpp index 801ba1b62..7f574d66e 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -143,7 +143,7 @@ static bool handler_matches(const event_handler_t &classv, const event_t &instan } /// Test if specified event is blocked. -static int event_is_blocked(parser_t &parser, const event_t &e) { +static bool event_is_blocked(parser_t &parser, const event_t &e) { (void)e; const block_t *block; size_t idx = 0; diff --git a/src/exec.cpp b/src/exec.cpp index ee1873fec..c6658df4d 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -150,6 +150,7 @@ bool is_thompson_shell_script(const char *path) { // This function never returns, so we take certain liberties with constness. auto envv = const_cast(cenvv); auto argv = const_cast(cargv); + auto cmd2 = const_cast(actual_cmd); execve(actual_cmd, argv, envv); err = errno; @@ -169,6 +170,9 @@ bool is_thompson_shell_script(const char *path) { char interp[] = _PATH_BSHELL; argv2[0] = interp; std::copy_n(argv, 1 + nargs, &argv2[1]); // +1 to copy terminating nullptr + // The command to call should use the full path, + // not what we would pass as argv0. + argv2[1] = cmd2; execve(_PATH_BSHELL, argv2, envv); } } @@ -1096,6 +1100,7 @@ bool exec_job(parser_t &parser, const shared_ptr &j, const io_chain_t &bl } procs_launched += 1; } + pipe_next_read.close(); // If our pipeline was aborted before any process was successfully launched, then there is // nothing to reap, and we can perform an early return. diff --git a/src/expand.cpp b/src/expand.cpp index 0bbaf6905..7a2aa30e7 100644 --- a/src/expand.cpp +++ b/src/expand.cpp @@ -1027,9 +1027,7 @@ expand_result_t expander_t::stage_braces(wcstring input, completion_receiver_t * } expand_result_t expander_t::stage_home_and_self(wcstring input, completion_receiver_t *out) { - if (!(flags & expand_flag::skip_home_directories)) { - expand_home_directory(input, ctx.vars); - } + expand_home_directory(input, ctx.vars); expand_percent_self(input); if (!out->add(std::move(input))) { return append_overflow_error(errors); @@ -1041,7 +1039,7 @@ expand_result_t expander_t::stage_wildcards(wcstring path_to_expand, completion_ expand_result_t result = expand_result_t::ok; remove_internal_separator(&path_to_expand, flags & expand_flag::skip_wildcards); - const bool has_wildcard = wildcard_has(path_to_expand, true /* internal, i.e. ANY_STRING */); + const bool has_wildcard = wildcard_has_internal(path_to_expand); // e.g. ANY_STRING const bool for_completions = flags & expand_flag::for_completions; const bool skip_wildcards = flags & expand_flag::skip_wildcards; @@ -1199,9 +1197,7 @@ expand_result_t expander_t::expand_string(wcstring input, completion_receiver_t if (total_result == expand_result_t::ok) { // Hack to un-expand tildes (see #647). - if (!(flags & expand_flag::skip_home_directories)) { - unexpand_tildes(input, ctx.vars, &completions); - } + unexpand_tildes(input, ctx.vars, &completions); if (!out_completions->add_list(std::move(completions))) { total_result = append_overflow_error(errors); } diff --git a/src/expand.h b/src/expand.h index 7629a3620..81f80e7d1 100644 --- a/src/expand.h +++ b/src/expand.h @@ -40,8 +40,6 @@ enum class expand_flag { directories_only, /// Generate descriptions, stored in the description field of completions. gen_descriptions, - /// Don't expand home directories. - skip_home_directories, /// Allow fuzzy matching. fuzzy_match, /// Disallow directory abbreviations like /u/l/b for /usr/local/bin. Only applicable if diff --git a/src/fallback.cpp b/src/fallback.cpp index c93d685be..d5104daab 100644 --- a/src/fallback.cpp +++ b/src/fallback.cpp @@ -243,12 +243,6 @@ int fish_wcwidth(wchar_t wc) { else if (wc == variation_selector_15) return 0; - // Korean Hangul Jamo median vowels and final consonants. - // These can either appear in combined form, taking 0 width themselves, - // or standalone with a 1 width. Since that's literally not expressible with wcwidth(), - // we take the position that the typical way for them to show up is composed. - if (wc >= L'\u1160' && wc <= L'\u11FF') return 0; - // Check for Emoji_Modifier property. Only the Fitzpatrick modifiers have this, in range // 1F3FB..1F3FF. This is a hack because such an emoji appearing on its own would be drawn as // width 2, but that's unlikely to be useful. See #8275. diff --git a/src/fd_monitor.cpp b/src/fd_monitor.cpp index 020ae3d2c..25b745476 100644 --- a/src/fd_monitor.cpp +++ b/src/fd_monitor.cpp @@ -87,7 +87,7 @@ uint64_t fd_monitor_item_t::usec_remaining(const time_point_t &now) const { return since >= timeout_usec ? 0 : timeout_usec - since; } -bool fd_monitor_item_t::service_item(const select_wrapper_t &fds, const time_point_t &now) { +bool fd_monitor_item_t::service_item(const fd_readable_set_t &fds, const time_point_t &now) { bool should_retain = true; bool readable = fds.test(fd.fd()); bool timed_out = !readable && usec_remaining(now) == 0; @@ -113,7 +113,7 @@ bool fd_monitor_item_t::poke_item(const poke_list_t &pokelist) { void fd_monitor_t::run_in_background() { ASSERT_IS_BACKGROUND_THREAD(); poke_list_t pokelist; - select_wrapper_t fds; + fd_readable_set_t fds; for (;;) { // Poke any items that need it. if (!pokelist.empty()) { @@ -149,7 +149,7 @@ void fd_monitor_t::run_in_background() { } // Call select(). - int ret = fds.select(timeout_usec); + int ret = fds.check_readable(timeout_usec); if (ret < 0 && errno != EINTR) { // Surprising error. wperror(L"select"); diff --git a/src/fd_monitor.h b/src/fd_monitor.h index c2b85221d..7ac71da25 100644 --- a/src/fd_monitor.h +++ b/src/fd_monitor.h @@ -33,7 +33,7 @@ struct fd_monitor_item_t { using callback_t = std::function; /// A sentinel value meaning no timeout. - static constexpr uint64_t kNoTimeout = select_wrapper_t::kNoTimeout; + static constexpr uint64_t kNoTimeout = fd_readable_set_t::kNoTimeout; /// The fd to monitor. autoclose_fd_t fd{}; @@ -71,7 +71,7 @@ struct fd_monitor_item_t { // Invoke this item's callback if its value is set in fd or has timed out. // \return true to retain the item, false to remove it. - bool service_item(const select_wrapper_t &fds, const time_point_t &now); + bool service_item(const fd_readable_set_t &fds, const time_point_t &now); // Invoke this item's callback with a poke, if its ID is present in the (sorted) pokelist. // \return true to retain the item, false to remove it. diff --git a/src/fds.cpp b/src/fds.cpp index 5be48d77f..385196b8c 100644 --- a/src/fds.cpp +++ b/src/fds.cpp @@ -20,9 +20,8 @@ // The first fd in the "high range." fds below this are allowed to be used directly by users in // redirections, e.g. >&3 const int k_first_high_fd = 10; - static constexpr uint64_t kUsecPerMsec = 1000; -static constexpr uint64_t kUsecPerSec = 1000 * kUsecPerMsec; +static constexpr uint64_t kUsecPerSec [[gnu::unused]] = 1000 * kUsecPerMsec; void autoclose_fd_t::close() { if (fd_ < 0) return; @@ -30,23 +29,85 @@ void autoclose_fd_t::close() { fd_ = -1; } -select_wrapper_t::select_wrapper_t() { clear(); } +fd_readable_set_t::fd_readable_set_t() { clear(); } -void select_wrapper_t::clear() { +#if FISH_READABLE_SET_USE_POLL + +// Convert from a usec to a poll-friendly msec. +static int usec_to_poll_msec(uint64_t timeout_usec) { + uint64_t timeout_msec = timeout_usec / kUsecPerMsec; + // Round to nearest, down for halfway. + timeout_msec += ((timeout_usec % kUsecPerMsec) > kUsecPerMsec / 2) ? 1 : 0; + if (timeout_usec == fd_readable_set_t::kNoTimeout || + timeout_msec > std::numeric_limits::max()) { + // Negative values mean wait forever in poll-speak. + return -1; + } + return static_cast(timeout_msec); +} + +void fd_readable_set_t::clear() { pollfds_.clear(); } + +static inline bool pollfd_less_than(const pollfd &lhs, int rhs) { return lhs.fd < rhs; } + +void fd_readable_set_t::add(int fd) { + if (fd >= 0) { + auto where = std::lower_bound(pollfds_.begin(), pollfds_.end(), fd, pollfd_less_than); + if (where == pollfds_.end() || where->fd != fd) { + pollfds_.insert(where, pollfd{fd, POLLIN, 0}); + } + } +} + +bool fd_readable_set_t::test(int fd) const { + // If a pipe is widowed with no data, Linux sets POLLHUP but not POLLIN, so test for both. + auto where = std::lower_bound(pollfds_.begin(), pollfds_.end(), fd, pollfd_less_than); + return where != pollfds_.end() && where->fd == fd && (where->revents & (POLLIN | POLLHUP)); +} + +// static +int fd_readable_set_t::do_poll(struct pollfd *fds, size_t count, uint64_t timeout_usec) { + assert(count <= std::numeric_limits::max() && "count too big"); + return ::poll(fds, static_cast(count), usec_to_poll_msec(timeout_usec)); +} + +int fd_readable_set_t::check_readable(uint64_t timeout_usec) { + if (pollfds_.empty()) return 0; + return do_poll(&pollfds_[0], pollfds_.size(), timeout_usec); +} + +// static +bool fd_readable_set_t::is_fd_readable(int fd, uint64_t timeout_usec) { + if (fd < 0) return false; + struct pollfd pfd { + fd, POLLIN, 0 + }; + int ret = fd_readable_set_t::do_poll(&pfd, 1, timeout_usec); + return ret > 0 && (pfd.revents & POLLIN); +} + +#else +// Implementation based on select(). + +void fd_readable_set_t::clear() { FD_ZERO(&fdset_); nfds_ = 0; } -void select_wrapper_t::add(int fd) { +void fd_readable_set_t::add(int fd) { + if (fd >= FD_SETSIZE) { + FLOGF(error, "fd %d too large for select()", fd); + return; + } if (fd >= 0) { FD_SET(fd, &fdset_); nfds_ = std::max(nfds_, fd + 1); } } -bool select_wrapper_t::test(int fd) const { return fd >= 0 && FD_ISSET(fd, &fdset_); } +bool fd_readable_set_t::test(int fd) const { return fd >= 0 && FD_ISSET(fd, &fdset_); } -int select_wrapper_t::select(uint64_t timeout_usec) { +int fd_readable_set_t::check_readable(uint64_t timeout_usec) { if (timeout_usec == kNoTimeout) { return ::select(nfds_, &fdset_, nullptr, nullptr, nullptr); } else { @@ -58,16 +119,18 @@ int select_wrapper_t::select(uint64_t timeout_usec) { } // static -bool select_wrapper_t::is_fd_readable(int fd, uint64_t timeout_usec) { +bool fd_readable_set_t::is_fd_readable(int fd, uint64_t timeout_usec) { if (fd < 0) return false; - select_wrapper_t s; + fd_readable_set_t s; s.add(fd); - int res = s.select(timeout_usec); + int res = s.check_readable(timeout_usec); return res > 0 && s.test(fd); } +#endif // not FISH_READABLE_SET_USE_POLL + // static -bool select_wrapper_t::poll_fd_readable(int fd) { return is_fd_readable(fd, 0); } +bool fd_readable_set_t::poll_fd_readable(int fd) { return is_fd_readable(fd, 0); } #ifdef HAVE_EVENTFD // Note we do not want to use EFD_SEMAPHORE because we are binary (not counting) semaphore. diff --git a/src/fds.h b/src/fds.h index 3d8be84cb..2ae7101ff 100644 --- a/src/fds.h +++ b/src/fds.h @@ -5,6 +5,7 @@ #include "config.h" // IWYU pragma: keep +#include #include #include @@ -62,12 +63,23 @@ class autoclose_fd_t : noncopyable_t { ~autoclose_fd_t() { close(); } }; -/// A modest wrapper around fd_set and select(). -/// This allows accumulating a set of fds and then select()ing on them. +// Resolve whether to use poll() or select(). +#ifndef FISH_READABLE_SET_USE_POLL +#ifdef __APPLE__ +// Apple's `man poll`: "The poll() system call currently does not support devices." +#define FISH_READABLE_SET_USE_POLL 0 +#else +// Use poll other places so we can support unlimited fds. +#define FISH_READABLE_SET_USE_POLL 1 +#endif +#endif + +/// A modest wrapper around select() or poll(), according to FISH_READABLE_SET_USE_POLL. +/// This allows accumulating a set of fds and then seeing if they are readable. /// This only handles readability. -struct select_wrapper_t { +struct fd_readable_set_t { /// Construct an empty set. - select_wrapper_t(); + fd_readable_set_t(); /// Reset back to an empty set. void clear(); @@ -78,15 +90,15 @@ struct select_wrapper_t { /// \return true if the given fd is marked as set, in our set. \returns false if negative. bool test(int fd) const; - /// Call select(), with this set as 'readfds' and null for the other sets, with a timeout given - /// by timeout_usec. Note this destructively modifies the set. \return the result of select(). - int select(uint64_t timeout_usec = select_wrapper_t::kNoTimeout); + /// Call select() or poll(), according to FISH_READABLE_SET_USE_POLL. Note this destructively + /// modifies the set. \return the result of select() or poll(). + int check_readable(uint64_t timeout_usec = fd_readable_set_t::kNoTimeout); - /// Poll a single fd: select() on it with a given timeout. + /// Check if a single fd is readable, with a given timeout. /// \return true if readable, false if not. static bool is_fd_readable(int fd, uint64_t timeout_usec); - /// Poll a single fd: select() on it with zero timeout. + /// Check if a single fd is readable, without blocking. /// \return true if readable, false if not. static bool poll_fd_readable(int fd); @@ -94,9 +106,17 @@ struct select_wrapper_t { static constexpr uint64_t kNoTimeout = std::numeric_limits::max(); private: - /// The underlying fdset and nfds value to pass to select(). +#if FISH_READABLE_SET_USE_POLL + // Our list of FDs, sorted by fd. + std::vector pollfds_{}; + + // Helper function. + static int do_poll(struct pollfd *fds, size_t count, uint64_t timeout_usec); +#else + // The underlying fdset and nfds value to pass to select(). fd_set fdset_; int nfds_{0}; +#endif }; /// Helper type returned from making autoclose pipes. diff --git a/src/fish_key_reader.cpp b/src/fish_key_reader.cpp index 69bf64689..8bda6df01 100644 --- a/src/fish_key_reader.cpp +++ b/src/fish_key_reader.cpp @@ -260,7 +260,7 @@ static void process_input(bool continuous_mode, bool verbose) { output_bind_command(bind_chars); } - if (should_exit(wc)) { + if (continuous_mode && should_exit(wc)) { std::fwprintf(stderr, L"\nExiting at your request.\n"); break; } diff --git a/src/fish_test_helper.cpp b/src/fish_test_helper.cpp index af9ca427b..d8da3f6cc 100644 --- a/src/fish_test_helper.cpp +++ b/src/fish_test_helper.cpp @@ -156,6 +156,22 @@ static void sigkill_self() { abort(); } +static void stdin_make_nonblocking() { + const int fd = STDIN_FILENO; + // Catch SIGCONT so pause() wakes us up. + signal(SIGCONT, [](int) {}); + + for (;;) { + int flags = fcntl(fd, F_GETFL, 0); + fprintf(stdout, "stdin was %sblocking\n", (flags & O_NONBLOCK) ? "non" : ""); + if (fcntl(fd, F_SETFL, flags | O_NONBLOCK)) { + perror("fcntl"); + exit(EXIT_FAILURE); + } + pause(); + } +} + static void show_help(); /// A thing that fish_test_helper can do. @@ -188,6 +204,8 @@ static fth_command_t s_commands[] = { "Print to stdout the name(s) of ignored signals"}, {"print_stop_cont", print_stop_cont, "Print when we get SIGTSTP and SIGCONT, exiting on input"}, {"sigkill_self", sigkill_self, "Send SIGKILL to self"}, + {"stdin_make_nonblocking", stdin_make_nonblocking, + "Print if stdin is blocking and then make it nonblocking"}, {"help", show_help, "Print list of fish_test_helper commands"}, }; diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp index 2cd7c5051..94221bf12 100644 --- a/src/fish_tests.cpp +++ b/src/fish_tests.cpp @@ -2194,13 +2194,16 @@ static bool expand_test(const wchar_t *in, expand_flags_t flags, ...) { static void test_expand() { say(L"Testing parameter expansion"); const expand_flags_t noflags{}; + const wchar_t *const wnull = nullptr; - expand_test(L"foo", noflags, L"foo", 0, L"Strings do not expand to themselves"); - expand_test(L"a{b,c,d}e", noflags, L"abe", L"ace", L"ade", 0, L"Bracket expansion is broken"); - expand_test(L"a*", expand_flag::skip_wildcards, L"a*", 0, L"Cannot skip wildcard expansion"); - expand_test(L"/bin/l\\0", expand_flag::for_completions, 0, + expand_test(L"foo", noflags, L"foo", wnull, L"Strings do not expand to themselves"); + expand_test(L"a{b,c,d}e", noflags, L"abe", L"ace", L"ade", wnull, + L"Bracket expansion is broken"); + expand_test(L"a*", expand_flag::skip_wildcards, L"a*", wnull, + L"Cannot skip wildcard expansion"); + expand_test(L"/bin/l\\0", expand_flag::for_completions, wnull, L"Failed to handle null escape in expansion"); - expand_test(L"foo\\$bar", expand_flag::skip_variables, L"foo$bar", 0, + expand_test(L"foo\\$bar", expand_flag::skip_variables, L"foo$bar", wnull, L"Failed to handle dollar sign in variable-skipping expansion"); // bb @@ -2237,7 +2240,6 @@ static void test_expand() { // This is checking that .* does NOT match . and .. // (https://github.com/fish-shell/fish-shell/issues/270). But it does have to match literal // components (e.g. "./*" has to match the same as "*". - const wchar_t *const wnull = nullptr; expand_test(L"test/fish_expand_test/.*", noflags, L"test/fish_expand_test/.foo", wnull, L"Expansion not correctly handling dotfiles"); @@ -2985,7 +2987,7 @@ static void test_wcstod() { auto tod_test = [](const wchar_t *a, const char *b) { char *narrow_end = nullptr; wchar_t *wide_end = nullptr; - double val1 = std::wcstod(a, &wide_end); + double val1 = fish_wcstod(a, &wide_end); double val2 = strtod(b, &narrow_end); do_test((std::isnan(val1) && std::isnan(val2)) || fabs(val1 - val2) <= __DBL_EPSILON__); do_test(wide_end - a == narrow_end - b); @@ -3147,6 +3149,29 @@ static std::shared_ptr make_test_func_props() { return ret; } +static void test_wildcards() { + say(L"Testing wildcards"); + do_test(!wildcard_has(L"")); + do_test(wildcard_has(L"*")); + do_test(!wildcard_has(L"\\*")); + do_test(!wildcard_has(L"\"*\"")); + + wcstring wc = L"foo*bar"; + do_test(wildcard_has(wc) && !wildcard_has_internal(wc)); + unescape_string_in_place(&wc, UNESCAPE_SPECIAL); + do_test(!wildcard_has(wc) && wildcard_has_internal(wc)); + + auto &feat = mutable_fish_features(); + auto saved = feat.test(features_t::flag_t::qmark_noglob); + feat.set(features_t::flag_t::qmark_noglob, false); + do_test(wildcard_has(L"?")); + do_test(!wildcard_has(L"\\?")); + feat.set(features_t::flag_t::qmark_noglob, true); + do_test(!wildcard_has(L"?")); + do_test(!wildcard_has(L"\\?")); + feat.set(features_t::flag_t::qmark_noglob, saved); +} + static void test_complete() { say(L"Testing complete"); @@ -3549,7 +3574,8 @@ static void perform_one_autosuggestion_cd_test(const wcstring &command, const wc static void perform_one_completion_cd_test(const wcstring &command, const wcstring &expected, const environment_t &vars, long line) { - completion_list_t comps = complete(command, {}, operation_context_t{vars}); + completion_list_t comps = complete( + command, {}, operation_context_t{parser_t::principal_parser().shared(), vars, no_cancel}); bool expects_error = (expected == L""); @@ -3588,7 +3614,10 @@ static void test_autosuggest_suggest_special() { if (system("mkdir -p 'test/autosuggest_test/0foobar'")) err(L"mkdir failed"); if (system("mkdir -p 'test/autosuggest_test/1foo bar'")) err(L"mkdir failed"); if (system("mkdir -p 'test/autosuggest_test/2foo bar'")) err(L"mkdir failed"); +#ifndef __CYGWIN__ + // Cygwin disallows backslashes in filenames. if (system("mkdir -p 'test/autosuggest_test/3foo\\bar'")) err(L"mkdir failed"); +#endif if (system("mkdir -p test/autosuggest_test/4foo\\'bar")) { err(L"mkdir failed"); // a path with a single quote } @@ -3629,11 +3658,13 @@ static void test_autosuggest_suggest_special() { __LINE__); perform_one_autosuggestion_cd_test(L"cd 'test/autosuggest_test/2", L"foo bar/", vars, __LINE__); +#ifndef __CYGWIN__ perform_one_autosuggestion_cd_test(L"cd test/autosuggest_test/3", L"foo\\bar/", vars, __LINE__); perform_one_autosuggestion_cd_test(L"cd \"test/autosuggest_test/3", L"foo\\bar/", vars, __LINE__); perform_one_autosuggestion_cd_test(L"cd 'test/autosuggest_test/3", L"foo\\bar/", vars, __LINE__); +#endif perform_one_autosuggestion_cd_test(L"cd test/autosuggest_test/4", L"foo'bar/", vars, __LINE__); perform_one_autosuggestion_cd_test(L"cd \"test/autosuggest_test/4", L"foo'bar/", vars, __LINE__); @@ -3662,9 +3693,11 @@ static void test_autosuggest_suggest_special() { perform_one_autosuggestion_cd_test(L"cd 2", L"foo bar/", vars, __LINE__); perform_one_autosuggestion_cd_test(L"cd \"2", L"foo bar/", vars, __LINE__); perform_one_autosuggestion_cd_test(L"cd '2", L"foo bar/", vars, __LINE__); +#ifndef __CYGWIN__ perform_one_autosuggestion_cd_test(L"cd 3", L"foo\\bar/", vars, __LINE__); perform_one_autosuggestion_cd_test(L"cd \"3", L"foo\\bar/", vars, __LINE__); perform_one_autosuggestion_cd_test(L"cd '3", L"foo\\bar/", vars, __LINE__); +#endif perform_one_autosuggestion_cd_test(L"cd 4", L"foo'bar/", vars, __LINE__); perform_one_autosuggestion_cd_test(L"cd \"4", L"foo'bar/", vars, __LINE__); perform_one_autosuggestion_cd_test(L"cd '4", L"foo'bar/", vars, __LINE__); @@ -4099,7 +4132,7 @@ bool poll_notifier(const std::unique_ptr ¬e) { bool result = false; int fd = note->notification_fd(); - if (fd >= 0 && select_wrapper_t::poll_fd_readable(fd)) { + if (fd >= 0 && fd_readable_set_t::poll_fd_readable(fd)) { result = note->notification_fd_became_readable(fd); } return result; @@ -4354,6 +4387,14 @@ void history_tests_t::test_history_races() { return; } + // This fails too often on Github Actions, + // leading to a bunch of spurious test failures on unrelated PRs. + // For now it's better to disable it. + // TODO: Figure out *why* it does that and fix it. + if (getenv("CI")) { + return; + } + say(L"Testing history race conditions"); // It appears TSAN and ASAN's allocators do not release their locks properly in atfork, so @@ -5737,7 +5778,7 @@ static void test_string() { const wchar_t *argv[15]; int expected_rc; const wchar_t *expected_out; - } string_tests[] = { + } string_tests[] = { // {{L"string", L"escape", nullptr}, STATUS_CMD_ERROR, L""}, {{L"string", L"escape", L"", nullptr}, STATUS_CMD_OK, L"''\n"}, {{L"string", L"escape", L"-n", L"", nullptr}, STATUS_CMD_OK, L"\n"}, @@ -5769,7 +5810,9 @@ static void test_string() { {{L"string", L"length", L"", nullptr}, STATUS_CMD_ERROR, L"0\n"}, {{L"string", L"length", L"", L"", L"", nullptr}, STATUS_CMD_ERROR, L"0\n0\n0\n"}, {{L"string", L"length", L"a", nullptr}, STATUS_CMD_OK, L"1\n"}, +#if WCHAR_T_BITS > 16 {{L"string", L"length", L"\U0002008A", nullptr}, STATUS_CMD_OK, L"1\n"}, +#endif {{L"string", L"length", L"um", L"dois", L"três", nullptr}, STATUS_CMD_OK, L"2\n4\n4\n"}, {{L"string", L"length", L"um", L"dois", L"três", nullptr}, STATUS_CMD_OK, L"2\n4\n4\n"}, {{L"string", L"length", L"-q", nullptr}, STATUS_CMD_ERROR, L""}, @@ -6041,7 +6084,8 @@ static void test_string() { {{L"string", L"trim", L"-c", L"\\/", L"/a\\"}, STATUS_CMD_OK, L"a\n"}, {{L"string", L"trim", L"-c", L"\\/", L"a/"}, STATUS_CMD_OK, L"a\n"}, {{L"string", L"trim", L"-c", L"\\/", L"\\a/"}, STATUS_CMD_OK, L"a\n"}, - {{L"string", L"trim", L"-c", L"", L".a."}, STATUS_CMD_ERROR, L".a.\n"}}; + {{L"string", L"trim", L"-c", L"", L".a."}, STATUS_CMD_ERROR, L".a.\n"} + }; for (const auto &t : string_tests) { run_one_string_test(t.argv, t.expected_rc, t.expected_out); @@ -6765,6 +6809,7 @@ static const test_t s_tests[]{ {TEST_GROUP("word_motion"), test_word_motion}, {TEST_GROUP("is_potential_path"), test_is_potential_path}, {TEST_GROUP("colors"), test_colors}, + {TEST_GROUP("wildcard"), test_wildcards}, {TEST_GROUP("complete"), test_complete}, {TEST_GROUP("autoload"), test_autoload}, {TEST_GROUP("input"), test_input}, @@ -6777,7 +6822,7 @@ static const test_t s_tests[]{ {TEST_GROUP("universal"), test_universal_callbacks}, {TEST_GROUP("universal"), test_universal_formats}, {TEST_GROUP("universal"), test_universal_ok_to_save}, - {TEST_GROUP("notifiers"), test_universal_notifiers}, + {TEST_GROUP("universal"), test_universal_notifiers}, {TEST_GROUP("wait_handles"), test_wait_handles}, {TEST_GROUP("completion_insertions"), test_completion_insertions}, {TEST_GROUP("autosuggestion_ignores"), test_autosuggestion_ignores}, diff --git a/src/future_feature_flags.cpp b/src/future_feature_flags.cpp index 15a5b6b92..4ec30cf09 100644 --- a/src/future_feature_flags.cpp +++ b/src/future_feature_flags.cpp @@ -21,7 +21,7 @@ const features_t::metadata_t features_t::metadata[features_t::flag_count] = { {string_replace_backslash, L"regex-easyesc", L"3.1", L"string replace -r needs fewer \\'s", false}, {ampersand_nobg_in_token, L"ampersand-nobg-in-token", L"3.4", - L"& only backgrounds if followed by a separating character", false}, + L"& only backgrounds if followed by a separator", false}, }; const struct features_t::metadata_t *features_t::metadata_for(const wchar_t *name) { diff --git a/src/highlight.cpp b/src/highlight.cpp index 9f7d7f41f..67e582b81 100644 --- a/src/highlight.cpp +++ b/src/highlight.cpp @@ -878,9 +878,10 @@ void highlighter_t::color_as_argument(const ast::node_t &node, bool options_allo // Now do command substitutions. size_t cmdsub_cursor = 0, cmdsub_start = 0, cmdsub_end = 0; wcstring cmdsub_contents; + bool is_quoted = false; while (parse_util_locate_cmdsubst_range(arg_str, &cmdsub_cursor, &cmdsub_contents, &cmdsub_start, &cmdsub_end, - true /* accept incomplete */) > 0) { + true /* accept incomplete */, &is_quoted) > 0) { // The cmdsub_start is the open paren. cmdsub_end is either the close paren or the end of // the string. cmdsub_contents extends from one past cmdsub_start to cmdsub_end. assert(cmdsub_end > cmdsub_start); diff --git a/src/history.cpp b/src/history.cpp index bb8834392..f57239965 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -380,7 +380,7 @@ bool history_impl_t::maybe_lock_file(int fd, int lock_type) { // is on a remote filesystem. if (abandoned_locking) return false; if (history_t::chaos_mode) return false; - if (path_get_data_is_remote() == 1) return false; + if (path_get_data_remoteness() == dir_remoteness_t::remote) return false; double start_time = timef(); int retval = flock(fd, lock_type); diff --git a/src/history.h b/src/history.h index 2877f273b..5073bce1b 100644 --- a/src/history.h +++ b/src/history.h @@ -26,42 +26,43 @@ class env_stack_t; class environment_t; class operation_context_t; -// Fish supports multiple shells writing to history at once. Here is its strategy: -// -// 1. All history files are append-only. Data, once written, is never modified. -// -// 2. A history file may be re-written ("vacuumed"). This involves reading in the file and writing a -// new one, while performing maintenance tasks: discarding items in an LRU fashion until we reach -// the desired maximum count, removing duplicates, and sorting them by timestamp (eventually, not -// implemented yet). The new file is atomically moved into place via rename(). -// -// 3. History files are mapped in via mmap(). Before the file is mapped, the file takes a fcntl read -// lock. The purpose of this lock is to avoid seeing a transient state where partial data has been -// written to the file. -// -// 4. History is appended to under a fcntl write lock. -// -// 5. The chaos_mode boolean can be set to true to do things like lower buffer sizes which can -// trigger race conditions. This is useful for testing. +/** +Fish supports multiple shells writing to history at once. Here is its strategy: -typedef std::vector path_list_t; +1. All history files are append-only. Data, once written, is never modified. + +2. A history file may be re-written ("vacuumed"). This involves reading in the file and writing a +new one, while performing maintenance tasks: discarding items in an LRU fashion until we reach +the desired maximum count, removing duplicates, and sorting them by timestamp (eventually, not +implemented yet). The new file is atomically moved into place via rename(). + +3. History files are mapped in via mmap(). Before the file is mapped, the file takes a fcntl read +lock. The purpose of this lock is to avoid seeing a transient state where partial data has been +written to the file. + +4. History is appended to under a fcntl write lock. + +5. The chaos_mode boolean can be set to true to do things like lower buffer sizes which can +trigger race conditions. This is useful for testing. +*/ +using path_list_t = std::vector; enum class history_search_type_t { - // Search for commands exactly matching the given string. + /// Search for commands exactly matching the given string. exact, - // Search for commands containing the given string. + /// Search for commands containing the given string. contains, - // Search for commands starting with the given string. + /// Search for commands starting with the given string. prefix, - // Search for commands containing the given glob pattern. + /// Search for commands containing the given glob pattern. contains_glob, - // Search for commands starting with the given glob pattern. + /// Search for commands starting with the given glob pattern. prefix_glob, - // Matches everything. + /// Matches everything. match_everything, }; -typedef uint64_t history_identifier_t; +using history_identifier_t = uint64_t; /// Ways that a history item may be written to disk (or omitted). enum class history_persistence_mode_t : uint8_t { @@ -73,7 +74,7 @@ enum class history_persistence_mode_t : uint8_t { class history_item_t { public: /// Construct from a text, timestamp, and optional identifier. - /// If \p no_persist is set, then do not write this item to disk. + /// If \p persist_mode is ::ephemeral, then do not write this item to disk. explicit history_item_t( wcstring str = {}, time_t when = 0, history_identifier_t ident = 0, history_persistence_mode_t persist_mode = history_persistence_mode_t::disk); @@ -84,7 +85,7 @@ class history_item_t { /// \return whether the text is empty. bool empty() const { return contents.empty(); } - // \return wehther our contents matches a search term. + /// \return wehther our contents matches a search term. bool matches_search(const wcstring &term, enum history_search_type_t type, bool case_sensitive) const; @@ -100,22 +101,22 @@ class history_item_t { void set_required_paths(path_list_t paths) { required_paths = std::move(paths); } private: - // Attempts to merge two compatible history items together. + /// Attempts to merge two compatible history items together. bool merge(const history_item_t &item); - // The actual contents of the entry. + /// The actual contents of the entry. wcstring contents; - // Original creation time for the entry. + /// Original creation time for the entry. time_t creation_timestamp; - // Paths that we require to be valid for this item to be autosuggested. + /// Paths that we require to be valid for this item to be autosuggested. path_list_t required_paths; - // Sometimes unique identifier used for hinting. + /// Sometimes unique identifier used for hinting. history_identifier_t identifier; - // If set, do not write this item to disk. + /// If set, do not write this item to disk. history_persistence_mode_t persist_mode; friend class history_t; @@ -124,7 +125,7 @@ class history_item_t { friend class history_tests_t; }; -typedef std::deque history_item_list_t; +using history_item_list_t = std::deque; struct history_impl_t; @@ -136,98 +137,98 @@ class history_t : noncopyable_t, nonmovable_t { acquired_lock impl(); acquired_lock impl() const; - // Privately add an item. If pending, the item will not be returned by history searches until a - // call to resolve_pending. Any trailing ephemeral items are dropped. + /// Privately add an item. If pending, the item will not be returned by history searches until a + /// call to resolve_pending. Any trailing ephemeral items are dropped. void add(history_item_t &&item, bool pending = false); - // Add a new history item with text \p str to the end of history. + /// Add a new history item with text \p str to the end of history. void add(wcstring str); public: explicit history_t(wcstring name); ~history_t(); - // Whether we're in maximum chaos mode, useful for testing. - // This causes things like locks to fail. + /// Whether we're in maximum chaos mode, useful for testing. + /// This causes things like locks to fail. static bool chaos_mode; - // Whether to force the read path instead of mmap. This is useful for testing. + /// Whether to force the read path instead of mmap. This is useful for testing. static bool never_mmap; - // Returns history with the given name, creating it if necessary. + /// Returns history with the given name, creating it if necessary. static std::shared_ptr with_name(const wcstring &name); /// Returns whether this is using the default name. bool is_default() const; - // Determines whether the history is empty. Unfortunately this cannot be const, since it may - // require populating the history. + /// Determines whether the history is empty. Unfortunately this cannot be const, since it may + /// require populating the history. bool is_empty(); - // Remove a history item. + /// Remove a history item. void remove(const wcstring &str); /// Remove any trailing ephemeral items. void remove_ephemeral_items(); - // Add a new pending history item to the end, and then begin file detection on the items to - // determine which arguments are paths. Arguments may be expanded (e.g. with PWD and variables) - // using the given \p vars. The item has the given \p persist_mode. + /// Add a new pending history item to the end, and then begin file detection on the items to + /// determine which arguments are paths. Arguments may be expanded (e.g. with PWD and variables) + /// using the given \p vars. The item has the given \p persist_mode. static void add_pending_with_file_detection( const std::shared_ptr &self, const wcstring &str, const std::shared_ptr &vars, history_persistence_mode_t persist_mode = history_persistence_mode_t::disk); - // Resolves any pending history items, so that they may be returned in history searches. + /// Resolves any pending history items, so that they may be returned in history searches. void resolve_pending(); - // Saves history. + /// Saves history. void save(); - // Searches history. + /// Searches history. bool search(history_search_type_t search_type, const wcstring_list_t &search_args, const wchar_t *show_time_format, size_t max_items, bool case_sensitive, bool null_terminate, bool reverse, const cancel_checker_t &cancel_check, io_streams_t &streams); - // Irreversibly clears history. + /// Irreversibly clears history. void clear(); - // Irreversibly clears history for the current session. + /// Irreversibly clears history for the current session. void clear_session(); - // Populates from older location (in config path, rather than data path). + /// Populates from older location (in config path, rather than data path). void populate_from_config_path(); - // Populates from a bash history file. + /// Populates from a bash history file. void populate_from_bash(FILE *f); - // Incorporates the history of other shells into this history. + /// Incorporates the history of other shells into this history. void incorporate_external_changes(); - // Gets all the history into a list. This is intended for the $history environment variable. - // This may be long! + /// Gets all the history into a list. This is intended for the $history environment variable. + /// This may be long! void get_history(wcstring_list_t &result); - // Let indexes be a list of one-based indexes into the history, matching the interpretation of - // $history. That is, $history[1] is the most recently executed command. Values less than one - // are skipped. Return a mapping from index to history item text. + /// Let indexes be a list of one-based indexes into the history, matching the interpretation of + /// $history. That is, $history[1] is the most recently executed command. Values less than one + /// are skipped. Return a mapping from index to history item text. std::unordered_map items_at_indexes(const std::vector &idxs); - // Return the specified history at the specified index. 0 is the index of the current - // commandline. (So the most recent item is at index 1.) + /// Return the specified history at the specified index. 0 is the index of the current + /// commandline. (So the most recent item is at index 1.) history_item_t item_at_index(size_t idx); - // Return the number of history entries. + /// Return the number of history entries. size_t size(); }; /// Flags for history searching. enum { - // If set, ignore case. + /// If set, ignore case. history_search_ignore_case = 1 << 0, - // If set, do not deduplicate, which can help performance. + /// If set, do not deduplicate, which can help performance. history_search_no_dedup = 1 << 1 }; using history_search_flags_t = uint32_t; @@ -236,52 +237,52 @@ using history_search_flags_t = uint32_t; /// Note this does NOT de-duplicate; it is the caller's responsibility to do so. class history_search_t { private: - // The history in which we are searching. - // TODO: this should be a shared_ptr. + /// The history in which we are searching. + /// TODO: this should be a shared_ptr. history_t *history_; - // The original search term. + /// The original search term. wcstring orig_term_; - // The (possibly lowercased) search term. + /// The (possibly lowercased) search term. wcstring canon_term_; - // Our search type. + /// Our search type. enum history_search_type_t search_type_ { history_search_type_t::contains }; - // Our flags. + /// Our flags. history_search_flags_t flags_{0}; - // The current history item. + /// The current history item. maybe_t current_item_; - // Index of the current history item. + /// Index of the current history item. size_t current_index_{0}; - // If deduping, the items we've seen. + /// If deduping, the items we've seen. std::unordered_set deduper_; - // return whether we are case insensitive. + /// return whether we are case insensitive. bool ignores_case() const { return flags_ & history_search_ignore_case; } - // return whether we deduplicate items. + /// return whether we deduplicate items. bool dedup() const { return !(flags_ & history_search_no_dedup); } public: - // Gets the original search term. + /// Gets the original search term. const wcstring &original_term() const { return orig_term_; } - // Finds the previous search result (backwards in time). Returns true if one was found. + /// Finds the previous search result (backwards in time). Returns true if one was found. bool go_backwards(); - // Returns the current search result item. asserts if there is no current item. + /// Returns the current search result item. asserts if there is no current item. const history_item_t ¤t_item() const; - // Returns the current search result item contents. asserts if there is no current item. + /// Returns the current search result item contents. asserts if there is no current item. const wcstring ¤t_string() const; - // Construct from a history pointer; the caller is responsible for ensuring the history stays - // alive. + /// Construct from a history pointer; the caller is responsible for ensuring the history stays + /// alive. history_search_t(history_t *hist, const wcstring &str, enum history_search_type_t type = history_search_type_t::contains, history_search_flags_t flags = 0) @@ -291,39 +292,43 @@ class history_search_t { } } - // Construct from a shared_ptr. TODO: this should be the only constructor. + /// Construct from a shared_ptr. TODO: this should be the only constructor. history_search_t(const std::shared_ptr &hist, const wcstring &str, enum history_search_type_t type = history_search_type_t::contains, history_search_flags_t flags = 0) : history_search_t(hist.get(), str, type, flags) {} - // Default constructor. + /** Default constructor. */ history_search_t() = default; }; -/// Saves the new history to disk. +/** Saves the new history to disk. */ void history_save_all(); -/// Return the prefix for the files to be used for command and read history. +/** Return the prefix for the files to be used for command and read history. */ wcstring history_session_id(const environment_t &vars); -/// Given a list of proposed paths and a context, perform variable and home directory expansion, -/// and detect if the result expands to a value which is also the path to a file. -/// Wildcard expansions are suppressed - see implementation comments for why. -/// This is used for autosuggestion hinting. If we add an item to history, and one of its arguments -/// refers to a file, then we only want to suggest it if there is a valid file there. -/// This does disk I/O and may only be called in a background thread. +/** + Given a list of proposed paths and a context, perform variable and home directory expansion, + and detect if the result expands to a value which is also the path to a file. + Wildcard expansions are suppressed - see implementation comments for why. + This is used for autosuggestion hinting. If we add an item to history, and one of its arguments + refers to a file, then we only want to suggest it if there is a valid file there. + This does disk I/O and may only be called in a background thread. +*/ path_list_t expand_and_detect_paths(const path_list_t &paths, const environment_t &vars); -/// Given a list of proposed paths and a context, expand each one and see if it refers to a file. -/// Wildcard expansions are suppressed. -/// \return true if \p paths is empty or every path is valid. +/** + Given a list of proposed paths and a context, expand each one and see if it refers to a file. + Wildcard expansions are suppressed. + \return true if \p paths is empty or every path is valid. +*/ bool all_paths_are_valid(const path_list_t &paths, const operation_context_t &ctx); -/// Sets private mode on. Once in private mode, it cannot be turned off. +/** Sets private mode on. Once in private mode, it cannot be turned off. */ void start_private_mode(env_stack_t &vars); -/// Queries private mode status. +/** Queries private mode status. */ bool in_private_mode(const environment_t &vars); #endif diff --git a/src/history_file.cpp b/src/history_file.cpp index 89db75da9..711e66825 100644 --- a/src/history_file.cpp +++ b/src/history_file.cpp @@ -23,8 +23,8 @@ static maybe_t offset_of_next_item_fish_1_x(const char *begin, size_t mm static bool should_mmap() { if (history_t::never_mmap) return false; - // mmap only if we are known not-remote (return is 0). - return path_get_data_is_remote() == 0; + // mmap only if we are known not-remote. + return path_get_config_remoteness() == dir_remoteness_t::local; } // Read up to len bytes from fd into address, zeroing the rest. diff --git a/src/input.cpp b/src/input.cpp index 58e98cdf8..4ead777f0 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -143,8 +143,10 @@ static constexpr const input_function_metadata_t input_function_metadata[] = { {L"kill-selection", readline_cmd_t::kill_selection}, {L"kill-whole-line", readline_cmd_t::kill_whole_line}, {L"kill-word", readline_cmd_t::kill_word}, + {L"nextd-or-forward-word", readline_cmd_t::nextd_or_forward_word}, {L"or", readline_cmd_t::func_or}, {L"pager-toggle-search", readline_cmd_t::pager_toggle_search}, + {L"prevd-or-backward-word", readline_cmd_t::prevd_or_backward_word}, {L"redo", readline_cmd_t::redo}, {L"repaint", readline_cmd_t::repaint}, {L"repaint-mode", readline_cmd_t::repaint_mode}, @@ -502,6 +504,14 @@ class event_queue_peeker_t { idx_ = 0; } + /// Test if any of our peeked events are readline or check_exit. + bool char_sequence_interrupted() const { + for (const auto &evt : peeked_) { + if (evt.is_readline() || evt.is_check_exit()) return true; + } + return false; + } + /// Reset our index back to 0. void restart() { idx_ = 0; } @@ -592,7 +602,9 @@ static bool try_peek_sequence(event_queue_peeker_t *peeker, const wcstring &str) } /// \return the first mapping that matches, walking first over the user's mapping list, then the -/// preset list. \return null if nothing matches. +/// preset list. +/// \return none if nothing matches, or if we may have matched a longer sequence but it was +/// interrupted by a readline event. maybe_t inputter_t::find_mapping(event_queue_peeker_t *peeker) { const input_mapping_t *generic = nullptr; const auto &vars = parser_->vars(); @@ -625,6 +637,12 @@ maybe_t inputter_t::find_mapping(event_queue_peeker_t *peeker) peeker->restart(); } + if (peeker->char_sequence_interrupted()) { + // We might have matched a longer sequence, but we were interrupted, e.g. by a signal. + FLOG(reader, "torn sequence, rearranging events"); + return none(); + } + if (escape) { // We need to reconsume the escape. peeker->next(); @@ -669,11 +687,17 @@ void inputter_t::mapping_execute_matching_or_generic(const command_handler_t &co } peeker.restart(); + if (peeker.char_sequence_interrupted()) { + // This may happen if we received a signal in the middle of an escape sequence or other + // multi-char binding. Move these non-char events to the front of the queue, handle them + // first, and then later we'll return and try the sequence again. See #8628. + peeker.consume(); + this->promote_interruptions_to_front(); + return; + } + FLOGF(reader, L"no generic found, ignoring char..."); auto evt = peeker.next(); - if (evt.is_eof()) { - this->push_front(evt); - } peeker.consume(); } @@ -748,7 +772,11 @@ char_event_t inputter_t::read_char(const command_handler_t &command_handler) { // If we have EOF, we need to immediately quit. // There's no need to go through the input functions. return evt; + } else if (evt.is_check_exit()) { + // Allow the reader to check for exit conditions. + return evt; } else { + assert(evt.is_char() && "Should be char event"); this->push_front(evt); mapping_execute_matching_or_generic(command_handler); // Regarding allow_commands, we're in a loop, but if a fish command is executed, diff --git a/src/input_common.cpp b/src/input_common.cpp index e280c9605..7d5b5ece6 100644 --- a/src/input_common.cpp +++ b/src/input_common.cpp @@ -2,6 +2,7 @@ #include "config.h" #include +#include #include #include @@ -10,6 +11,7 @@ #endif #include #include +#include #include #include @@ -60,7 +62,7 @@ using readb_result_t = int; static readb_result_t readb(int in_fd) { assert(in_fd >= 0 && "Invalid in fd"); universal_notifier_t& notifier = universal_notifier_t::default_notifier(); - select_wrapper_t fdset; + fd_readable_set_t fdset; for (;;) { fdset.clear(); fdset.add(in_fd); @@ -75,13 +77,13 @@ static readb_result_t readb(int in_fd) { // Get its suggested delay (possibly none). // Note a 0 here means do not poll. - uint64_t timeout = select_wrapper_t::kNoTimeout; + uint64_t timeout = fd_readable_set_t::kNoTimeout; if (uint64_t usecs_delay = notifier.usec_delay_between_polls()) { timeout = usecs_delay; } // Here's where we call select(). - int select_res = fdset.select(timeout); + int select_res = fdset.check_readable(timeout); if (select_res < 0) { if (errno == EINTR || errno == EAGAIN) { // A signal. @@ -223,9 +225,27 @@ maybe_t input_event_queue_t::readch_timed() { if (auto evt = try_pop()) { return evt; } - const uint64_t usec_per_msec = 1000; - uint64_t timeout_usec = static_cast(wait_on_escape_ms) * usec_per_msec; - if (select_wrapper_t::is_fd_readable(in_, timeout_usec)) { + // We are not prepared to handle a signal immediately; we only want to know if we get input on + // our fd before the timeout. Use pselect to block all signals; we will handle signals + // before the next call to getch(). + sigset_t sigs; + sigfillset(&sigs); + + // pselect expects timeouts in nanoseconds. + const uint64_t nsec_per_msec = 1000 * 1000; + const uint64_t nsec_per_sec = nsec_per_msec * 1000; + const uint64_t wait_nsec = wait_on_escape_ms * nsec_per_msec; + struct timespec timeout; + timeout.tv_sec = (wait_nsec) / nsec_per_sec; + timeout.tv_nsec = (wait_nsec) % nsec_per_sec; + + // We have one fd of interest. + fd_set fdset; + FD_ZERO(&fdset); + FD_SET(in_, &fdset); + + int res = pselect(in_ + 1, &fdset, nullptr, nullptr, &timeout, &sigs); + if (res > 0) { return readch(); } return none(); @@ -235,6 +255,15 @@ void input_event_queue_t::push_back(const char_event_t& ch) { queue_.push_back(c void input_event_queue_t::push_front(const char_event_t& ch) { queue_.push_front(ch); } +void input_event_queue_t::promote_interruptions_to_front() { + // Find the first sequence of non-char events. + // EOF is considered a char: we don't want to pull EOF in front of real chars. + auto is_char = [](const char_event_t& ch) { return ch.is_char() || ch.is_eof(); }; + auto first = std::find_if_not(queue_.begin(), queue_.end(), is_char); + auto last = std::find_if(first, queue_.end(), is_char); + std::rotate(queue_.begin(), first, last); +} + void input_event_queue_t::prepare_to_select() {} void input_event_queue_t::select_interrupted() {} input_event_queue_t::~input_event_queue_t() = default; diff --git a/src/input_common.h b/src/input_common.h index 07b1539fd..c02621492 100644 --- a/src/input_common.h +++ b/src/input_common.h @@ -19,6 +19,8 @@ enum class readline_cmd_t { backward_word, forward_bigword, backward_bigword, + nextd_or_forward_word, + prevd_or_backward_word, history_search_backward, history_search_forward, history_prefix_search_backward, @@ -205,6 +207,9 @@ class input_event_queue_t { /// will be the next character returned by readch. void push_front(const char_event_t &ch); + /// Find the first sequence of non-char events, and promote them to the front. + void promote_interruptions_to_front(); + /// Add multiple characters or readline events to the front of the queue of unread characters. /// The order of the provided events is not changed, i.e. they are not inserted in reverse /// order. diff --git a/src/iothread.cpp b/src/iothread.cpp index 9c5d10bab..1ba046627 100644 --- a/src/iothread.cpp +++ b/src/iothread.cpp @@ -25,10 +25,7 @@ #include "global_safety.h" #include "wutil.h" -// We just define a thread limit of 1024. -// On all systems I've seen the limit is higher, -// but on some (like linux with glibc) the setting for _POSIX_THREAD_THREADS_MAX is 64, -// which is too low, even tho the system can handle more than 64 threads. +/// We just define a thread limit of 1024. #define IO_MAX_THREADS 1024 // iothread has a thread pool. Sometimes there's no work to do, but extant threads wait around for a @@ -221,7 +218,7 @@ int thread_pool_t::perform(void_function_t &&func, bool cant_wait) { // Kick off the thread if we decided to do so. if (wakeup_thread) { - FLOGF(iothread, L"notifying a thread", this_thread()); + FLOGF(iothread, L"notifying thread: %p", this_thread()); pool.queue_cond.notify_one(); } if (spawn_new_thread) { @@ -247,7 +244,7 @@ void iothread_perform_impl(void_function_t &&func, bool cant_wait) { int iothread_port() { return get_notify_signaller().read_fd(); } void iothread_service_main_with_timeout(uint64_t timeout_usec) { - if (select_wrapper_t::is_fd_readable(iothread_port(), timeout_usec)) { + if (fd_readable_set_t::is_fd_readable(iothread_port(), timeout_usec)) { iothread_service_main(); } } @@ -356,14 +353,25 @@ bool make_detached_pthread(void *(*func)(void *), void *param) { // Spawn a thread. If this fails, it means there's already a bunch of threads; it is very // unlikely that they are all on the verge of exiting, so one is likely to be ready to handle // extant requests. So we can ignore failure with some confidence. - pthread_t thread = 0; - int err = pthread_create(&thread, nullptr, func, param); + pthread_t thread; + pthread_attr_t thread_attr; + DIE_ON_FAILURE(pthread_attr_init(&thread_attr)); + + int err = pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED); if (err == 0) { - // Success, return the thread. - FLOGF(iothread, "pthread %p spawned", (intptr_t)thread); - DIE_ON_FAILURE(pthread_detach(thread)); + err = pthread_create(&thread, &thread_attr, func, param); + if (err == 0) { + FLOGF(iothread, "pthread %d spawned", thread); + } else { + perror("pthread_create"); + } + int err2 = pthread_attr_destroy(&thread_attr); + if (err2 != 0) { + perror("pthread_attr_destroy"); + err = err2; + } } else { - perror("pthread_create"); + perror("pthread_attr_setdetachstate"); } // Restore our sigmask. DIE_ON_FAILURE(pthread_sigmask(SIG_SETMASK, &saved_set, nullptr)); diff --git a/src/parse_constants.h b/src/parse_constants.h index 904e75ad5..a03e416fc 100644 --- a/src/parse_constants.h +++ b/src/parse_constants.h @@ -7,6 +7,9 @@ #include "common.h" #include "enum_map.h" +using source_offset_t = uint32_t; +constexpr source_offset_t SOURCE_OFFSET_INVALID = static_cast(-1); + #define PARSER_DIE() \ do { \ FLOG(error, L"Parser dying!"); \ @@ -15,10 +18,10 @@ // A range of source code. struct source_range_t { - uint32_t start; - uint32_t length; + source_offset_t start; + source_offset_t length; - uint32_t end() const { + source_offset_t end() const { assert(start + length >= start && "Overflow"); return start + length; } diff --git a/src/parse_tree.h b/src/parse_tree.h index dae6c8cd1..7f9d9e1e2 100644 --- a/src/parse_tree.h +++ b/src/parse_tree.h @@ -16,10 +16,6 @@ #include "parse_constants.h" #include "tokenizer.h" -typedef uint32_t source_offset_t; - -constexpr source_offset_t SOURCE_OFFSET_INVALID = static_cast(-1); - /// A struct representing the token type that we use internally. struct parse_token_t { enum parse_token_type_t type; // The type of the token as represented by the parser diff --git a/src/parse_util.cpp b/src/parse_util.cpp index be9d30843..c626804d0 100644 --- a/src/parse_util.cpp +++ b/src/parse_util.cpp @@ -88,8 +88,10 @@ size_t parse_util_get_offset(const wcstring &str, int line, long line_offset) { } static int parse_util_locate_cmdsub(const wchar_t *in, const wchar_t **begin, const wchar_t **end, - bool allow_incomplete, bool *is_quoted) { + bool allow_incomplete, bool *inout_is_quoted) { bool escaped = false; + bool is_first = true; + bool is_token_begin = true; bool syntax_error = false; int paran_count = 0; std::vector quoted_cmdsubs; @@ -97,21 +99,35 @@ static int parse_util_locate_cmdsub(const wchar_t *in, const wchar_t **begin, co const wchar_t *paran_begin = nullptr, *paran_end = nullptr; assert(in && "null parameter"); - for (const wchar_t *pos = in; *pos; pos++) { + + const wchar_t *pos = in; + auto process_opening_quote = [&](wchar_t quote) -> bool /* ok */ { + const wchar_t *q_end = quote_end(pos, quote); + if (!q_end) return false; + if (*q_end == L'$') { + quoted_cmdsubs.push_back(paran_count); + } + // We want to report whether the outermost comand substitution between + // paran_begin..paran_end is quoted. + if (paran_count == 0 && inout_is_quoted) { + *inout_is_quoted = *q_end == L'$'; + } + pos = q_end; + return true; + }; + + if (inout_is_quoted && *inout_is_quoted && *pos) { + if (!process_opening_quote(L'"')) pos += std::wcslen(pos); + } + + for (; *pos; pos++) { if (!escaped) { if (*pos == L'\'' || *pos == L'"') { - const wchar_t *q_end = quote_end(pos, *pos); - if (q_end && *q_end) { - if (*q_end == L'$') { - quoted_cmdsubs.push_back(paran_count); - // We want to report if the outermost comand substitution between - // paran_begin..paran_end is quoted. - if (paran_count == 0 && is_quoted) *is_quoted = true; - } - pos = q_end; - } else { - break; - } + if (!process_opening_quote(*pos)) break; + } else if (*pos == L'\\') { + escaped = true; + } else if (*pos == L'#' && is_token_begin) { + pos = comment_end(pos) - 1; } else { if (*pos == L'(') { if ((paran_count == 0) && (paran_begin == nullptr)) { @@ -151,12 +167,12 @@ static int parse_util_locate_cmdsub(const wchar_t *in, const wchar_t **begin, co } } } - } - if (*pos == '\\') { - escaped = !escaped; + is_token_begin = is_token_delimiter(pos[0], is_first, pos[1]); } else { escaped = false; + is_token_begin = false; } + is_first = false; } syntax_error |= (paran_count < 0); @@ -225,12 +241,11 @@ long parse_util_slice_length(const wchar_t *in) { int parse_util_locate_cmdsubst_range(const wcstring &str, size_t *inout_cursor_offset, wcstring *out_contents, size_t *out_start, size_t *out_end, - bool accept_incomplete, bool *out_is_quoted) { + bool accept_incomplete, bool *inout_is_quoted) { // Clear the return values. if (out_contents != nullptr) out_contents->clear(); *out_start = 0; *out_end = str.size(); - bool cmdsub_is_quoted = false; // Nothing to do if the offset is at or past the end of the string. if (*inout_cursor_offset >= str.size()) return 0; @@ -243,7 +258,7 @@ int parse_util_locate_cmdsubst_range(const wcstring &str, size_t *inout_cursor_o const wchar_t *bracket_range_end = nullptr; int ret = parse_util_locate_cmdsub(valid_range_start, &bracket_range_begin, &bracket_range_end, - accept_incomplete, &cmdsub_is_quoted); + accept_incomplete, inout_is_quoted); if (ret <= 0) { return ret; } @@ -264,28 +279,10 @@ int parse_util_locate_cmdsubst_range(const wcstring &str, size_t *inout_cursor_o // Return the start and end. *out_start = bracket_range_begin - buff; *out_end = bracket_range_end - buff; - if (out_is_quoted) *out_is_quoted = cmdsub_is_quoted; // Update the inout_cursor_offset. Note this may cause it to exceed str.size(), though // overflow is not likely. *inout_cursor_offset = 1 + *out_end; - if (cmdsub_is_quoted && *bracket_range_end) { - // We are usually called in a loop, to process all command substitutions in this string. - // If we just located a quoted cmdsub like $(A) inside "$(A)B"(C), the B part is also - // quoted but the naïve next caller wouldn't know. Since next caller only cares about - // the next command substitution - (C) - and not about the B part, just advance the - // cursor to the closing quote. - if (auto *q_end = quote_end(bracket_range_end, L'"')) { - *inout_cursor_offset = 1 + q_end - buff; - } else { - if (accept_incomplete) { - // We want to skip quoted text, so if there is no closing quote, skip to the end. - *inout_cursor_offset = bracket_range_end + std::wcslen(bracket_range_end) - buff; - } else { - return -1; - } - } - } return ret; } @@ -819,10 +816,10 @@ static bool append_syntax_error(parse_error_list_t *errors, size_t source_locati return true; } -/// Returns 1 if the specified command is a builtin that may not be used in a pipeline. +/// Returns true if the specified command is a builtin that may not be used in a pipeline. static const wchar_t *const forbidden_pipe_commands[] = {L"exec", L"case", L"break", L"return", L"continue"}; -static int parser_is_pipe_forbidden(const wcstring &word) { +static bool parser_is_pipe_forbidden(const wcstring &word) { return contains(forbidden_pipe_commands, word); } @@ -950,11 +947,12 @@ parser_test_error_bits_t parse_util_detect_errors_in_argument(const ast::argumen wcstring subst; bool do_loop = true; + bool is_quoted = false; while (do_loop) { size_t paren_begin = 0; size_t paren_end = 0; switch (parse_util_locate_cmdsubst_range(arg_src, &cursor, &subst, &paren_begin, &paren_end, - false)) { + false, &is_quoted)) { case -1: { err |= PARSER_TEST_ERROR; if (out_errors) { @@ -1236,7 +1234,6 @@ parser_test_error_bits_t parse_util_detect_errors(const ast::ast_t &ast, const w // Expand all commands. // Verify 'or' and 'and' not used inside pipelines. - // Verify pipes via parser_is_pipe_forbidden. // Verify return only within a function. // Verify no variable expansions. wcstring storage; diff --git a/src/parse_util.h b/src/parse_util.h index dff4f06e1..1338ed8e4 100644 --- a/src/parse_util.h +++ b/src/parse_util.h @@ -29,10 +29,11 @@ long parse_util_slice_length(const wchar_t *in); /// \param out_end On output, the offset of the end of the command substitution (close paren), or /// the end of the string if it was incomplete /// \param accept_incomplete whether to permit missing closing parenthesis +/// \param inout_is_quoted whether the cursor is in a double-quoted context. /// \return -1 on syntax error, 0 if no subshells exist and 1 on success int parse_util_locate_cmdsubst_range(const wcstring &str, size_t *inout_cursor_offset, wcstring *out_contents, size_t *out_start, size_t *out_end, - bool accept_incomplete, bool *out_is_quoted = nullptr); + bool accept_incomplete, bool *inout_is_quoted = nullptr); /// Find the beginning and end of the command substitution under the cursor. If no subshell is /// found, the entire string is returned. If the current command substitution is not ended, i.e. the diff --git a/src/parser.cpp b/src/parser.cpp index d44bdab18..bdbc0ac37 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -26,7 +26,6 @@ #include "parse_util.h" #include "proc.h" #include "reader.h" -#include "sanity.h" #include "signal.h" #include "wutil.h" // IWYU pragma: keep diff --git a/src/path.cpp b/src/path.cpp index ad2a78cf1..eff0cf852 100644 --- a/src/path.cpp +++ b/src/path.cpp @@ -108,13 +108,13 @@ static bool path_is_executable(const std::string &path) { return S_ISREG(buff.st_mode); } -/// \return 1 if the path is remote, 0 if local, -1 if unknown. -static int path_is_remote(const wcstring &path) { +/// \return whether the given path is on a remote filesystem. +static dir_remoteness_t path_remoteness(const wcstring &path) { std::string narrow = wcs2string(path); #if defined(__linux__) struct statfs buf {}; if (statfs(narrow.c_str(), &buf) < 0) { - return -1; + return dir_remoteness_t::unknown; } // Linux has constants for these like NFS_SUPER_MAGIC, SMB_SUPER_MAGIC, CIFS_MAGIC_NUMBER but // these are in varying headers. Simply hard code them. @@ -124,23 +124,23 @@ static int path_is_remote(const wcstring &path) { case 0x517B: // SMB_SUPER_MAGIC case 0xFE534D42U: // SMB2_MAGIC_NUMBER - not in the manpage case 0xFF534D42U: // CIFS_MAGIC_NUMBER - return 1; + return dir_remoteness_t::remote; default: // Other FSes are assumed local. - return 0; + return dir_remoteness_t::local; } #elif defined(ST_LOCAL) // ST_LOCAL is a flag to statvfs, which is itself standardized. // In practice the only system to use this path is NetBSD. struct statvfs buf {}; - if (statvfs(narrow.c_str(), &buf) < 0) return -1; - return (buf.f_flag & ST_LOCAL) ? 0 : 1; + if (statvfs(narrow.c_str(), &buf) < 0) return dir_remoteness_t::unknown; + return (buf.f_flag & ST_LOCAL) ? false : true; #elif defined(MNT_LOCAL) struct statfs buf {}; - if (statfs(narrow.c_str(), &buf) < 0) return -1; - return (buf.f_flags & MNT_LOCAL) ? 0 : 1; + if (statfs(narrow.c_str(), &buf) < 0) return dir_remoteness_t::unknown; + return (buf.f_flags & MNT_LOCAL) ? dir_remoteness_t::local : dir_remoteness_t::remote; #else - return -1; + return dir_remoteness_t::unknown; #endif } @@ -336,12 +336,11 @@ namespace { /// The following type wraps up a user's "base" directories, corresponding (conceptually if not /// actually) to XDG spec. struct base_directory_t { - wcstring path{}; /// the path where we attempted to create the directory. - int err{0}; /// the error code if creating the directory failed, or 0 on success. - int is_remote{-1}; /// 1 if the directory is remote (e.g. NFS), 0 if local, -1 if unknown. - bool used_xdg{false}; /// whether an XDG variable was used in resolving the directory. - + wcstring path{}; /// the path where we attempted to create the directory. + dir_remoteness_t remoteness{dir_remoteness_t::unknown}; // whether the dir is remote + int err{0}; /// the error code if creating the directory failed, or 0 on success. bool success() const { return err == 0; } + bool used_xdg{false}; /// whether an XDG variable was used in resolving the directory. }; } // namespace @@ -374,7 +373,7 @@ static base_directory_t make_base_directory(const wcstring &xdg_var, } else { result.err = 0; // Need to append a trailing slash to check the contents of the directory, not its parent. - result.is_remote = path_is_remote(result.path + L'/'); + result.remoteness = path_remoteness(result.path + L'/'); } return result; } @@ -395,7 +394,7 @@ void path_emit_config_directory_messages(env_stack_t &vars) { maybe_issue_path_warning(L"data", _(L"can not save history"), data.used_xdg, L"XDG_DATA_HOME", data.path, data.err, vars); } - if (data.is_remote > 0) { + if (data.remoteness == dir_remoteness_t::remote) { FLOG(path, "data path appears to be on a network volume"); } @@ -405,7 +404,7 @@ void path_emit_config_directory_messages(env_stack_t &vars) { config.used_xdg, L"XDG_CONFIG_HOME", config.path, config.err, vars); } - if (config.is_remote > 0) { + if (config.remoteness == dir_remoteness_t::remote) { FLOG(path, "config path appears to be on a network volume"); } } @@ -422,9 +421,9 @@ bool path_get_data(wcstring &path) { return dir.success(); } -int path_get_data_is_remote() { return get_data_directory().is_remote; } +dir_remoteness_t path_get_data_remoteness() { return get_data_directory().remoteness; } -int path_get_config_is_remote() { return get_config_directory().is_remote; } +dir_remoteness_t path_get_config_remoteness() { return get_config_directory().remoteness; } void path_make_canonical(wcstring &path) { // Ignore trailing slashes, unless it's the first character. diff --git a/src/path.h b/src/path.h index 21bcc1dc2..c20190665 100644 --- a/src/path.h +++ b/src/path.h @@ -26,12 +26,18 @@ bool path_get_config(wcstring &path); /// \return whether the directory was returned successfully bool path_get_data(wcstring &path); -/// \return if the data directory is remote (eg. NFS). -/// -1 means unknown, 0 means known local, 1 means known remote. -int path_get_data_is_remote(); +enum class dir_remoteness_t { + unknown, // directory status is unknown + local, // directory is known local + remote, // directory is known remote +}; -/// Like path_get_data_is_remote but for config directory. -int path_get_config_is_remote(); +/// \return the remoteness of the fish data directory. +/// This will be remote for filesystems like NFS, SMB, etc. +dir_remoteness_t path_get_data_remoteness(); + +/// Like path_get_data_remoteness but for the config directory. +dir_remoteness_t path_get_config_remoteness(); /// Emit any errors if config directories are missing. /// Use the given environment stack to ensure this only occurs once. diff --git a/src/postfork.cpp b/src/postfork.cpp index 0c7c6ef88..980e72889 100644 --- a/src/postfork.cpp +++ b/src/postfork.cpp @@ -350,7 +350,11 @@ maybe_t posix_spawner_t::spawn(const char *cmd, char *const argv[], char std::vector argv2; char interp[] = _PATH_BSHELL; argv2.push_back(interp); - for (size_t i = 0; argv[i] != nullptr; i++) { + // The command to call should use the full path, + // not what we would pass as argv0. + std::string cmd2 = cmd; + argv2.push_back(&cmd2[0]); + for (size_t i = 1; argv[i] != nullptr; i++) { argv2.push_back(argv[i]); } argv2.push_back(nullptr); @@ -414,9 +418,27 @@ void safe_report_exec_error(int err, const char *actual_cmd, const char *const * case ENOEXEC: { FLOGF_SAFE(exec, - "The file '%s' is marked as an executable but could not be run by the " + "Failed to execute process: '%s' the file could not be run by the " "operating system.", actual_cmd); + char interpreter_buff[128] = {}; + const char *interpreter = + get_interpreter(actual_cmd, interpreter_buff, sizeof interpreter_buff); + if (!interpreter) { + // Paths ending in ".fish" need to start with a shebang + if (const char *lastdot = strrchr(actual_cmd, '.')) { + if (0 == strcmp(lastdot, ".fish")) { + FLOGF_SAFE(exec, + "fish scripts require an interpreter directive (must start with " + "'#!/path/to/fish')."); + } + } + } else { + // If the shebang line exists, we would get an ENOENT or similar instead, + // so I don't know how to reach this. + FLOGF_SAFE(exec, "Maybe the interpreter directive (#! line) is broken?", + actual_cmd); + } break; } @@ -429,11 +451,11 @@ void safe_report_exec_error(int err, const char *actual_cmd, const char *const * const char *interpreter = get_interpreter(actual_cmd, interpreter_buff, sizeof interpreter_buff); if (interpreter && 0 != access(interpreter, X_OK)) { - // Detect windows line endings and complain specifically about them. + // Detect Windows line endings and complain specifically about them. auto len = strlen(interpreter); if (len && interpreter[len - 1] == '\r') { FLOGF_SAFE(exec, - "Failed to execute process '%s': The file uses windows line " + "Failed to execute process '%s': The file uses Windows line " "endings (\\r\\n). Run dos2unix or similar to fix it.", actual_cmd); } else { @@ -540,6 +562,9 @@ static char *get_interpreter(const char *command, char *buffer, size_t buff_size return buffer + 3; } else if (std::strncmp(buffer, "#!/", const_strlen("#!/")) == 0) { return buffer + 2; + } else if (std::strncmp(buffer, "#!", const_strlen("#!")) == 0) { + // Relative path, basically always an issue. + return buffer + 2; } return nullptr; }; diff --git a/src/proc.cpp b/src/proc.cpp index 90e1a57c1..96296caf3 100644 --- a/src/proc.cpp +++ b/src/proc.cpp @@ -50,7 +50,6 @@ #include "parser.h" #include "proc.h" #include "reader.h" -#include "sanity.h" #include "signal.h" #include "wcstringutil.h" #include "wutil.h" // IWYU pragma: keep @@ -925,7 +924,7 @@ int terminal_maybe_give_to_job_group(const job_group_t *jg, bool continuing_from } else { // Debug the original tcsetpgrp error (not the waitpid errno) to the log, and // then retry until not EPERM or the process group has exited. - FLOGF(proc_termowner, L"terminal_give_to_job(): EPERM.\n", pgid); + FLOGF(proc_termowner, L"terminal_give_to_job(): EPERM with pgid %d.", pgid); continue; } } else if (errno == ENOTTY) { diff --git a/src/proc.h b/src/proc.h index ec28b2388..7a589c50c 100644 --- a/src/proc.h +++ b/src/proc.h @@ -403,6 +403,7 @@ class job_t : noncopyable_t { bool notified_of_stop{false}; /// Whether the exit status should be negated. This flag can only be set by the not builtin. + /// Two "not" prefixes on a single job cancel each other out. bool negate{false}; /// This job is disowned, and should be removed from the active jobs list. diff --git a/src/reader.cpp b/src/reader.cpp index 541341045..eb612815f 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -37,6 +37,7 @@ #include #include +#include #include #include #include @@ -71,7 +72,6 @@ #include "parser.h" #include "proc.h" #include "reader.h" -#include "sanity.h" #include "screen.h" #include "signal.h" #include "termsize.h" @@ -565,7 +565,7 @@ struct selection_data_t { bool operator!=(const selection_data_t &rhs) const { return !(*this == rhs); } }; -/// A value-type struct representing a layout from which we can call to s_write(). +/// A value-type struct representing a layout that can be rendered. /// The intent is that everything we send to the screen is encapsulated in this struct. struct layout_data_t { /// Text of the command line. @@ -629,6 +629,9 @@ class reader_data_t : public std::enable_shared_from_this { /// Whether this is the first prompt. bool first_prompt{true}; + /// The time when the last flash() completed + std::chrono::time_point last_flash; + /// The representation of the current screen contents. screen_t screen; @@ -1290,11 +1293,13 @@ void reader_write_title(const wcstring &cmd, parser_t &parser, bool reset_cursor wcstring_list_t lst; (void)exec_subshell(fish_title_command, parser, lst, false /* ignore exit status */); if (!lst.empty()) { - std::fputws(L"\x1B]0;", stdout); + wcstring title_line = L"\x1B]0;"; for (const auto &i : lst) { - std::fputws(i.c_str(), stdout); + title_line += i; } - ignore_result(write(STDOUT_FILENO, "\a", 1)); + title_line += L"\a"; + std::string narrow = wcs2string(title_line); + ignore_result(write_loop(STDOUT_FILENO, narrow.data(), narrow.size())); } outputter_t::stdoutput().set_color(rgb_color_t::reset(), rgb_color_t::reset()); @@ -1463,6 +1468,8 @@ static bool command_ends_paging(readline_cmd_t c, bool focused_on_search_field) case rl::backward_word: case rl::forward_bigword: case rl::backward_bigword: + case rl::nextd_or_forward_word: + case rl::prevd_or_backward_word: case rl::delete_char: case rl::backward_delete_char: case rl::kill_line: @@ -1878,6 +1885,15 @@ void reader_data_t::select_completion_in_direction(selection_motion_t dir) { /// Flash the screen. This function changes the color of the current line momentarily. void reader_data_t::flash() { + // Multiple flashes may be enqueued by keypress repeat events and can pile up to cause a + // significant delay in processing future input while all the flash() calls complete, as we + // effectively sleep for 100ms each go. See #8610. + auto now = std::chrono::steady_clock::now(); + if ((now - last_flash) < std::chrono::milliseconds{50}) { + last_flash = now; + return; + } + struct timespec pollint; editable_line_t *el = &command_line; layout_data_t data = make_layout_data(); @@ -1900,6 +1916,10 @@ void reader_data_t::flash() { data.colors = std::move(saved_colors); this->rendered_layout = std::move(data); paint_layout(L"unflash"); + + // Save the time we stopped flashing as the time of the most recent flash. We can't just + // increment the old `now` value because the sleep is non-deterministic. + last_flash = std::chrono::steady_clock::now(); } maybe_t reader_data_t::get_selection() const { @@ -1912,7 +1932,7 @@ maybe_t reader_data_t::get_selection() const { /// Characters that may not be part of a token that is to be replaced by a case insensitive /// completion. -#define REPLACE_UNCLEAN L"$*?({})" +const wchar_t *REPLACE_UNCLEAN = L"$*?({})"; /// Check if the specified string can be replaced by a case insensitive completion with the /// specified flags. @@ -2741,6 +2761,7 @@ void reader_data_t::update_commandline_state() const { snapshot->history = this->history; snapshot->selection = this->get_selection(); snapshot->pager_mode = !this->current_page_rendering.screen_data.empty(); + snapshot->pager_fully_disclosed = this->current_page_rendering.remaining_to_disclose == 0; snapshot->search_mode = this->history_search.active(); snapshot->initialized = true; } @@ -2933,7 +2954,7 @@ maybe_t reader_data_t::read_normal_chars(readline_loop_state_t &rl while (accumulated_chars.size() < limit) { bool allow_commands = (accumulated_chars.empty()); auto evt = inputter.read_char(allow_commands ? normal_handler : empty_handler); - if (!event_is_normal_char(evt) || !select_wrapper_t::poll_fd_readable(conf.in)) { + if (!event_is_normal_char(evt) || !fd_readable_set_t::poll_fd_readable(conf.in)) { event_needing_handling = std::move(evt); break; } else if (evt.input_style == char_input_style_t::notfirst && accumulated_chars.empty() && @@ -3510,7 +3531,17 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat break; } case rl::backward_word: - case rl::backward_bigword: { + case rl::backward_bigword: + case rl::prevd_or_backward_word: { + if (c == rl::prevd_or_backward_word && command_line.empty()) { + auto last_statuses = parser().get_last_statuses(); + (void)parser().eval(L"prevd", io_chain_t{}); + parser().set_last_statuses(std::move(last_statuses)); + force_exec_prompt_and_repaint = true; + inputter.queue_char(readline_cmd_t::repaint); + break; + } + auto move_style = (c == rl::backward_word) ? move_word_style_punctuation : move_word_style_whitespace; move_word(active_edit_line(), MOVE_DIR_LEFT, false /* do not erase */, move_style, @@ -3518,7 +3549,17 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat break; } case rl::forward_word: - case rl::forward_bigword: { + case rl::forward_bigword: + case rl::nextd_or_forward_word: { + if (c == rl::nextd_or_forward_word && command_line.empty()) { + auto last_statuses = parser().get_last_statuses(); + (void)parser().eval(L"nextd", io_chain_t{}); + parser().set_last_statuses(std::move(last_statuses)); + force_exec_prompt_and_repaint = true; + inputter.queue_char(readline_cmd_t::repaint); + break; + } + auto move_style = (c == rl::forward_word) ? move_word_style_punctuation : move_word_style_whitespace; editable_line_t *el = active_edit_line(); @@ -4053,6 +4094,7 @@ maybe_t reader_data_t::readline(int nchars_or_0) { clear_transient_edit(); } history_search.reset(); + command_line_has_transient_edit = false; } rls.last_cmd = readline_cmd; @@ -4167,7 +4209,12 @@ bool reader_data_t::jump(jump_direction_t dir, jump_precision_t precision, edita return success; } -maybe_t reader_readline(int nchars) { return current_data()->readline(nchars); } +maybe_t reader_readline(int nchars) { + auto *data = current_data(); + // Apply any outstanding commandline changes (#8633). + data->apply_commandline_state_changes(); + return data->readline(nchars); +} int reader_reading_interrupted() { int res = reader_test_and_clear_interrupted(); diff --git a/src/reader.h b/src/reader.h index 75370e084..1cef1c71b 100644 --- a/src/reader.h +++ b/src/reader.h @@ -257,6 +257,7 @@ struct commandline_state_t { maybe_t selection{}; // visual selection, or none if none std::shared_ptr history{}; // current reader history, or null if not interactive bool pager_mode{false}; // pager is visible + bool pager_fully_disclosed{false}; // pager already shows everything if possible bool search_mode{false}; // pager is visible and search is active bool initialized{false}; // if false, the reader has not yet been entered }; diff --git a/src/sanity.cpp b/src/sanity.cpp deleted file mode 100644 index a87dd6c64..000000000 --- a/src/sanity.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// Functions for performing sanity checks on the program state. -#include "config.h" // IWYU pragma: keep - -#include "sanity.h" - -#include - -#include "common.h" -#include "fallback.h" // IWYU pragma: keep -#include "flog.h" -#include "global_safety.h" -#include "history.h" -#include "kill.h" -#include "proc.h" -#include "reader.h" - -/// Status from earlier sanity checks. -static relaxed_atomic_bool_t insane{false}; - -void sanity_lose() { - FLOG(error, _(L"Errors detected, shutting down. Break on sanity_lose() to debug.")); - insane = true; -} - -void validate_pointer(const void *ptr, const wchar_t *err, int null_ok) { - // Test if the pointer data crosses a segment boundary. - if ((0x00000003L & reinterpret_cast(ptr)) != 0) { - FLOGF(error, _(L"The pointer '%ls' is invalid"), err); - sanity_lose(); - } - - if ((!null_ok) && (ptr == nullptr)) { - FLOGF(error, _(L"The pointer '%ls' is null"), err); - sanity_lose(); - } -} diff --git a/src/sanity.h b/src/sanity.h deleted file mode 100644 index e156dd28d..000000000 --- a/src/sanity.h +++ /dev/null @@ -1,15 +0,0 @@ -// Prototypes for functions for performing sanity checks on the program state. -#ifndef FISH_SANITY_H -#define FISH_SANITY_H - -/// Call this function to tell the program it is not in a sane state. -void sanity_lose(); - -/// Try and determine if ptr is a valid pointer. If not, loose sanity. -/// -/// \param ptr The pointer to validate -/// \param err A description of what the pointer refers to, for use in error messages -/// \param null_ok Whether the pointer is allowed to point to 0 -void validate_pointer(const void *ptr, const wchar_t *err, int null_ok); - -#endif diff --git a/src/screen.cpp b/src/screen.cpp index abb043859..7ef17100b 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -1220,6 +1220,8 @@ void screen_t::write(const wcstring &left_prompt, const wcstring &right_prompt, cursor_arr = this->desired.cursor; } + int full_line_count = this->desired.cursor.y + 1; + // Now that we've output everything, set the cursor to the position that we saved in the loop // above. this->desired.cursor = cursor_arr; @@ -1231,7 +1233,6 @@ void screen_t::write(const wcstring &left_prompt, const wcstring &right_prompt, // Re-render our completions page if necessary. Limit the term size of the pager to the true // term size, minus the number of lines consumed by our string. - int full_line_count = cursor_arr.y + 1; pager.set_term_size(termsize_t{std::max(1, curr_termsize.width), std::max(1, curr_termsize.height - full_line_count)}); pager.update_rendering(&page_rendering); diff --git a/src/timer.cpp b/src/timer.cpp index 699844a61..3906afc52 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -157,30 +157,30 @@ wcstring timer_snapshot_t::print_delta(const timer_snapshot_t &t1, const timer_s auto wall_unit = get_unit(net_wall_micros); auto cpu_unit = get_unit(std::max(net_sys_micros, net_usr_micros)); - auto wall_time = convert(net_wall_micros, wall_unit); - auto usr_time = convert(net_usr_micros, cpu_unit); - auto sys_time = convert(net_sys_micros, cpu_unit); + double wall_time = convert(net_wall_micros, wall_unit); + double usr_time = convert(net_usr_micros, cpu_unit); + double sys_time = convert(net_sys_micros, cpu_unit); wcstring output; if (!verbose) { - append_format(output, - L"\n_______________________________" - L"\nExecuted in %6.2F %s" - L"\n usr time %6.2F %s" - L"\n sys time %6.2F %s" - L"\n", - wall_time, unit_name(wall_unit), usr_time, unit_name(cpu_unit), sys_time, - unit_name(cpu_unit)); + append_format(output, L"\n_______________________________" + L"\nExecuted in %6.2F %s" + L"\n usr time %6.2F %s" + L"\n sys time %6.2F %s" + L"\n", + wall_time, unit_name(wall_unit), + usr_time, unit_name(cpu_unit), + sys_time, unit_name(cpu_unit)); } else { auto fish_unit = get_unit(std::max(fish_sys_micros, fish_usr_micros)); auto child_unit = get_unit(std::max(child_sys_micros, child_usr_micros)); - auto fish_usr_time = convert(fish_usr_micros, fish_unit); - auto fish_sys_time = convert(fish_sys_micros, fish_unit); - auto child_usr_time = convert(child_usr_micros, child_unit); - auto child_sys_time = convert(child_sys_micros, child_unit); + double fish_usr_time = convert(fish_usr_micros, fish_unit); + double fish_sys_time = convert(fish_sys_micros, fish_unit); + double child_usr_time = convert(child_usr_micros, child_unit); + double child_sys_time = convert(child_sys_micros, child_unit); - auto column2_unit_len = - std::max(strlen(unit_short_name(wall_unit)), strlen(unit_short_name(cpu_unit))); + int column2_unit_len = std::max(strlen(unit_short_name(wall_unit)), + strlen(unit_short_name(cpu_unit))); append_format(output, L"\n________________________________________________________" L"\nExecuted in %6.2F %-*s %-*s %s" @@ -188,13 +188,12 @@ wcstring timer_snapshot_t::print_delta(const timer_snapshot_t &t1, const timer_s L"\n sys time %6.2F %-*s %6.2F %s %6.2F %s" L"\n", wall_time, column2_unit_len, unit_short_name(wall_unit), - strlen(unit_short_name(fish_unit)) + 7, "fish", "external", // - usr_time, column2_unit_len, unit_short_name(cpu_unit), fish_usr_time, // + static_cast(strlen(unit_short_name(fish_unit))) + 7, "fish", "external", + usr_time, column2_unit_len, unit_short_name(cpu_unit), fish_usr_time, unit_short_name(fish_unit), child_usr_time, unit_short_name(child_unit), sys_time, column2_unit_len, unit_short_name(cpu_unit), fish_sys_time, unit_short_name(fish_unit), child_sys_time, unit_short_name(child_unit)); } - return output; }; diff --git a/src/tinyexpr.cpp b/src/tinyexpr.cpp index 1d0d7bcc5..e7d4449fd 100644 --- a/src/tinyexpr.cpp +++ b/src/tinyexpr.cpp @@ -375,11 +375,27 @@ static te_expr *base(state *s) { te_expr *ret; int arity; + auto previous = s->start; + auto next = s->next; switch (s->type) { case TOK_NUMBER: ret = new_expr(TE_CONSTANT, nullptr); ret->value = s->value; next_token(s); + if (s->type == TOK_NUMBER || s->type == TE_FUNCTION0) { + // Two numbers after each other: + // math '5 2' + // math '3 pi' + // (of course 3 pi could also be interpreted as 3 x pi) + s->type = TOK_ERROR; + s->error = TE_ERROR_MISSING_OPERATOR; + // The error should be given *between* + // the last two tokens. + // Since these are two separate numbers there is at least + // one space between. + s->start = previous; + s->next = next + 1; + } break; case TE_FUNCTION0: @@ -451,6 +467,9 @@ static te_expr *base(state *s) { ret = expr(s); if (s->type == TOK_CLOSE) { next_token(s); + } else if (s->type != TOK_ERROR && s->type != TOK_END && s->error == TE_ERROR_NONE) { + s->type = TOK_ERROR; + s->error = TE_ERROR_TOO_MANY_ARGS; } else if (s->type != TOK_ERROR || s->error == TE_ERROR_UNKNOWN) { s->type = TOK_ERROR; s->error = TE_ERROR_MISSING_CLOSING_PAREN; @@ -620,10 +639,7 @@ te_expr *te_compile(const wchar_t *expression, te_error_t *error) { error->type = s.error; } else { // If we're not at the end but there's no error, then that means we have a - // superfluous token that we have no idea what to do with. This occurs in e.g. `2 + - // 2 4` - the "4" is just not part of the expression. We can report either "too many - // arguments" or "expected operator", but the operator should be reported between - // the "2" and the "4". So we report TOO_MANY_ARGS on the "4". + // superfluous token that we have no idea what to do with. error->type = TE_ERROR_TOO_MANY_ARGS; } } diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index e43065714..861c57f61 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -154,6 +154,7 @@ tok_t tokenizer_t::read_string() { int slice_offset = 0; const wchar_t *const buff_start = this->token_cursor; bool is_first = true; + bool is_token_begin = true; auto process_opening_quote = [&](wchar_t quote) -> const wchar_t * { const wchar_t *end = quote_end(this->token_cursor, quote); @@ -192,6 +193,8 @@ tok_t tokenizer_t::read_string() { // has been explicitly ignored (escaped). else if (c == L'\\') { mode |= tok_modes::char_escape; + } else if (c == L'#' && is_token_begin) { + this->token_cursor = comment_end(this->token_cursor) - 1; } else if (c == L'(') { paran_offsets.push_back(this->token_cursor - this->start); expecting.push_back(L')'); @@ -214,11 +217,11 @@ tok_t tokenizer_t::read_string() { mode &= ~(tok_modes::subshell); } expecting.pop_back(); - // Check if the ) did complete a quoted command substituion. + // Check if the ) completed a quoted command substitution. if (!quoted_cmdsubs.empty() && quoted_cmdsubs.back() == paran_offsets.size()) { quoted_cmdsubs.pop_back(); - // Quoted command substitutions temporarily close double quotes, after ), - // we need to act as if there was an invisible double quote. + // The "$(" part of a quoted command substitution closes double quotes. To keep + // quotes balanced, act as if there was an invisible double quote after the ")". if (const wchar_t *error_loc = process_opening_quote(L'"')) { if (!this->accept_unfinished) { return this->call_error(tokenizer_error_t::unterminated_quote, buff_start, @@ -278,8 +281,9 @@ tok_t tokenizer_t::read_string() { FLOGF(error, msg.c_str(), c, c, int(mode_begin), int(mode)); #endif - this->token_cursor++; + is_token_begin = is_token_delimiter(this->token_cursor[0], is_first, this->token_cursor[1]); is_first = false; + this->token_cursor++; } if (!this->accept_unfinished && (mode != tok_modes::regular_text)) { @@ -540,8 +544,7 @@ maybe_t tokenizer_t::next() { while (*this->token_cursor == L'#') { // We have a comment, walk over the comment. const wchar_t *comment_start = this->token_cursor; - while (this->token_cursor[0] != L'\n' && this->token_cursor[0] != L'\0') - this->token_cursor++; + this->token_cursor = comment_end(this->token_cursor); size_t comment_len = this->token_cursor - comment_start; // If we are going to continue after the comment, skip any trailing newline. @@ -679,6 +682,10 @@ maybe_t tokenizer_t::next() { return result; } +bool is_token_delimiter(wchar_t c, bool is_first, maybe_t next) { + return c == L'(' || !tok_is_string_character(c, is_first, next); +} + wcstring tok_first(const wcstring &str) { tokenizer_t t(str.c_str(), 0); if (auto token = t.next()) { diff --git a/src/tokenizer.h b/src/tokenizer.h index aaa139f3f..fccff61db 100644 --- a/src/tokenizer.h +++ b/src/tokenizer.h @@ -10,8 +10,8 @@ #include "parse_constants.h" #include "redirection.h" -/// Token types. -enum class token_type_t { +/// Token types. XXX Why this isn't parse_token_type_t, I'm not really sure. +enum class token_type_t : uint8_t { error, /// Error reading token string, /// String token pipe, /// Pipe token @@ -39,7 +39,7 @@ enum class token_type_t { using tok_flags_t = unsigned int; -enum class tokenizer_error_t { +enum class tokenizer_error_t : uint8_t { none, unterminated_quote, unterminated_subshell, @@ -60,20 +60,20 @@ enum class tokenizer_error_t { const wchar_t *tokenizer_get_error_message(tokenizer_error_t err); struct tok_t { - // The type of the token. - token_type_t type; - // Offset of the token. - size_t offset{0}; + source_offset_t offset{0}; // Length of the token. - size_t length{0}; + source_offset_t length{0}; + + // If an error, this is the offset of the error within the token. A value of 0 means it occurred + // at 'offset'. + source_offset_t error_offset_within_token{SOURCE_OFFSET_INVALID}; // If an error, this is the error code. tokenizer_error_t error{tokenizer_error_t::none}; - // If an error, this is the offset of the error within the token. A value of 0 means it occurred - // at 'offset'. - size_t error_offset_within_token{size_t(-1)}; + // The type of the token. + token_type_t type; // Construct from a token type. explicit tok_t(token_type_t type); @@ -85,6 +85,7 @@ struct tok_t { /// Gets source for the token, or the empty string if it has no source. wcstring get_source(const wcstring &str) const { return wcstring(str, offset, length); } }; +static_assert(sizeof(tok_t) <= 32, "tok_t expected to be 32 bytes or less"); /// The tokenizer struct. class tokenizer_t : noncopyable_t { @@ -132,6 +133,9 @@ class tokenizer_t : noncopyable_t { } }; +/// Tests if this character can delimit tokens. +bool is_token_delimiter(wchar_t c, bool is_first, maybe_t next); + /// Returns only the first token from the specified string. This is a convenience function, used to /// retrieve the first token of a string. This can be useful for error messages, etc. On failure, /// returns the empty string. diff --git a/src/topic_monitor.cpp b/src/topic_monitor.cpp index c6ab5ec10..a2562189f 100644 --- a/src/topic_monitor.cpp +++ b/src/topic_monitor.cpp @@ -89,8 +89,8 @@ void binary_semaphore_t::wait() { #ifdef FISH_TSAN_WORKAROUNDS // Under tsan our notifying pipe is non-blocking, so we would busy-loop on the read() // call until data is available (that is, fish would use 100% cpu while waiting for - // processes). The select prevents that. - (void)select_wrapper_t::is_fd_readable(fd, select_wrapper_t::kNoTimeout); + // processes). This call prevents that. + (void)fd_readable_set_t::is_fd_readable(fd, fd_readable_set_t::kNoTimeout); #endif uint8_t ignored; auto amt = read(fd, &ignored, sizeof ignored); diff --git a/src/wcstringutil.cpp b/src/wcstringutil.cpp index 71800061b..9f2e2dadf 100644 --- a/src/wcstringutil.cpp +++ b/src/wcstringutil.cpp @@ -317,7 +317,7 @@ int fish_wcwidth_visible(wchar_t widechar) { } int fish_wcswidth_visible(const wcstring &str) { - size_t res = 0; + int res = 0; for (wchar_t ch : str) { if (ch == L'\b') { res += -1; diff --git a/src/widecharwidth/widechar_width.h b/src/widecharwidth/widechar_width.h index 0843f7b6c..b1a1f43ef 100644 --- a/src/widecharwidth/widechar_width.h +++ b/src/widecharwidth/widechar_width.h @@ -1,5 +1,5 @@ /** - * widechar_width.h, generated on 2021-10-26. + * widechar_width.h, generated on 2022-02-14. * See https://github.com/ridiculousfish/widecharwidth/ * * SHA1 file hashes: @@ -378,43 +378,16 @@ static const struct widechar_range widechar_combining_table[] = { {0xE0100, 0xE01EF} }; +/* Width 0 combining letters. */ +static const struct widechar_range widechar_combiningletters_table[] = { + {0x01160, 0x011FF}, + {0x0D7B0, 0x0D7FF} +}; + /* Width 2 characters. */ static const struct widechar_range widechar_doublewide_table[] = { {0x01100, 0x0115F}, - {0x0231A, 0x0231B}, {0x02329, 0x0232A}, - {0x023E9, 0x023EC}, - {0x023F0, 0x023F0}, - {0x023F3, 0x023F3}, - {0x025FD, 0x025FE}, - {0x02614, 0x02615}, - {0x02648, 0x02653}, - {0x0267F, 0x0267F}, - {0x02693, 0x02693}, - {0x026A1, 0x026A1}, - {0x026AA, 0x026AB}, - {0x026BD, 0x026BE}, - {0x026C4, 0x026C5}, - {0x026CE, 0x026CE}, - {0x026D4, 0x026D4}, - {0x026EA, 0x026EA}, - {0x026F2, 0x026F3}, - {0x026F5, 0x026F5}, - {0x026FA, 0x026FA}, - {0x026FD, 0x026FD}, - {0x02705, 0x02705}, - {0x0270A, 0x0270B}, - {0x02728, 0x02728}, - {0x0274C, 0x0274C}, - {0x0274E, 0x0274E}, - {0x02753, 0x02755}, - {0x02757, 0x02757}, - {0x02795, 0x02797}, - {0x027B0, 0x027B0}, - {0x027BF, 0x027BF}, - {0x02B1B, 0x02B1C}, - {0x02B50, 0x02B50}, - {0x02B55, 0x02B55}, {0x02E80, 0x02E99}, {0x02E9B, 0x02EF3}, {0x02F00, 0x02FD5}, @@ -451,46 +424,29 @@ static const struct widechar_range widechar_doublewide_table[] = { {0x1B150, 0x1B152}, {0x1B164, 0x1B167}, {0x1B170, 0x1B2FB}, - {0x1F004, 0x1F004}, - {0x1F0CF, 0x1F0CF}, - {0x1F18E, 0x1F18E}, - {0x1F191, 0x1F19A}, - {0x1F200, 0x1F202}, - {0x1F210, 0x1F23B}, + {0x1F200, 0x1F200}, + {0x1F202, 0x1F202}, + {0x1F210, 0x1F219}, + {0x1F21B, 0x1F22E}, + {0x1F230, 0x1F231}, + {0x1F237, 0x1F237}, + {0x1F23B, 0x1F23B}, {0x1F240, 0x1F248}, - {0x1F250, 0x1F251}, {0x1F260, 0x1F265}, - {0x1F300, 0x1F320}, - {0x1F32D, 0x1F335}, - {0x1F337, 0x1F37C}, - {0x1F37E, 0x1F393}, - {0x1F3A0, 0x1F3CA}, - {0x1F3CF, 0x1F3D3}, - {0x1F3E0, 0x1F3F0}, - {0x1F3F4, 0x1F3F4}, - {0x1F3F8, 0x1F43E}, - {0x1F440, 0x1F440}, - {0x1F442, 0x1F4FC}, - {0x1F4FF, 0x1F53D}, - {0x1F54B, 0x1F54E}, - {0x1F550, 0x1F567}, - {0x1F595, 0x1F596}, - {0x1F5FB, 0x1F64F}, - {0x1F680, 0x1F6C5}, - {0x1F6CC, 0x1F6CC}, - {0x1F6D0, 0x1F6D0}, + {0x1F57A, 0x1F57A}, + {0x1F5A4, 0x1F5A4}, + {0x1F6D1, 0x1F6D2}, {0x1F6D5, 0x1F6D7}, {0x1F6DD, 0x1F6DF}, - {0x1F6EB, 0x1F6EC}, - {0x1F6F9, 0x1F6FC}, + {0x1F6F4, 0x1F6FC}, {0x1F7E0, 0x1F7EB}, {0x1F7F0, 0x1F7F0}, - {0x1F90C, 0x1F918}, - {0x1F93F, 0x1F93F}, - {0x1F94D, 0x1F94F}, - {0x1F96C, 0x1F984}, - {0x1F998, 0x1F9CF}, - {0x1F9E7, 0x1F9FF}, + {0x1F90C, 0x1F90F}, + {0x1F919, 0x1F93A}, + {0x1F93C, 0x1F945}, + {0x1F947, 0x1F97F}, + {0x1F985, 0x1F9BF}, + {0x1F9C1, 0x1F9FF}, {0x1FA70, 0x1FA74}, {0x1FA78, 0x1FA7C}, {0x1FA80, 0x1FA86}, @@ -1431,17 +1387,72 @@ static const struct widechar_range widechar_nonchar_table[] = { /* Characters that were widened from width 1 to 2 in Unicode 9. */ static const struct widechar_range widechar_widened_table[] = { - {0x1F57A, 0x1F57A}, - {0x1F5A4, 0x1F5A4}, - {0x1F6D1, 0x1F6D2}, - {0x1F6F4, 0x1F6F8}, - {0x1F919, 0x1F93A}, - {0x1F93C, 0x1F93E}, - {0x1F940, 0x1F945}, - {0x1F947, 0x1F94C}, - {0x1F950, 0x1F96B}, - {0x1F985, 0x1F997}, - {0x1F9D0, 0x1F9E6} + {0x0231A, 0x0231B}, + {0x023E9, 0x023EC}, + {0x023F0, 0x023F0}, + {0x023F3, 0x023F3}, + {0x025FD, 0x025FE}, + {0x02614, 0x02615}, + {0x02648, 0x02653}, + {0x0267F, 0x0267F}, + {0x02693, 0x02693}, + {0x026A1, 0x026A1}, + {0x026AA, 0x026AB}, + {0x026BD, 0x026BE}, + {0x026C4, 0x026C5}, + {0x026CE, 0x026CE}, + {0x026D4, 0x026D4}, + {0x026EA, 0x026EA}, + {0x026F2, 0x026F3}, + {0x026F5, 0x026F5}, + {0x026FA, 0x026FA}, + {0x026FD, 0x026FD}, + {0x02705, 0x02705}, + {0x0270A, 0x0270B}, + {0x02728, 0x02728}, + {0x0274C, 0x0274C}, + {0x0274E, 0x0274E}, + {0x02753, 0x02755}, + {0x02757, 0x02757}, + {0x02795, 0x02797}, + {0x027B0, 0x027B0}, + {0x027BF, 0x027BF}, + {0x02B1B, 0x02B1C}, + {0x02B50, 0x02B50}, + {0x02B55, 0x02B55}, + {0x1F004, 0x1F004}, + {0x1F0CF, 0x1F0CF}, + {0x1F18E, 0x1F18E}, + {0x1F191, 0x1F19A}, + {0x1F201, 0x1F201}, + {0x1F21A, 0x1F21A}, + {0x1F22F, 0x1F22F}, + {0x1F232, 0x1F236}, + {0x1F238, 0x1F23A}, + {0x1F250, 0x1F251}, + {0x1F300, 0x1F320}, + {0x1F32D, 0x1F335}, + {0x1F337, 0x1F37C}, + {0x1F37E, 0x1F393}, + {0x1F3A0, 0x1F3CA}, + {0x1F3CF, 0x1F3D3}, + {0x1F3E0, 0x1F3F0}, + {0x1F3F4, 0x1F3F4}, + {0x1F3F8, 0x1F43E}, + {0x1F440, 0x1F440}, + {0x1F442, 0x1F4FC}, + {0x1F4FF, 0x1F53D}, + {0x1F54B, 0x1F54E}, + {0x1F550, 0x1F567}, + {0x1F595, 0x1F596}, + {0x1F5FB, 0x1F64F}, + {0x1F680, 0x1F6C5}, + {0x1F6CC, 0x1F6CC}, + {0x1F6D0, 0x1F6D0}, + {0x1F6EB, 0x1F6EC}, + {0x1F910, 0x1F918}, + {0x1F980, 0x1F984}, + {0x1F9C0, 0x1F9C0} }; template @@ -1463,6 +1474,8 @@ int widechar_wcwidth(uint32_t c) { return widechar_non_character; if (widechar_in_table(widechar_combining_table, c)) return widechar_combining; + if (widechar_in_table(widechar_combiningletters_table, c)) + return widechar_combining; if (widechar_in_table(widechar_doublewide_table, c)) return 2; if (widechar_in_table(widechar_ambiguous_table, c)) diff --git a/src/wildcard.cpp b/src/wildcard.cpp index 899f95ab9..f468d0e35 100644 --- a/src/wildcard.cpp +++ b/src/wildcard.cpp @@ -38,34 +38,29 @@ static size_t wildcard_find(const wchar_t *wc) { return wcstring::npos; } -/// Implementation of wildcard_has. Needs to take the length to handle embedded nulls (issue #1631). -static bool wildcard_has_impl(const wchar_t *str, size_t len, bool internal) { - assert(str != nullptr); - bool qmark_is_wild = !feature_test(features_t::qmark_noglob); - const wchar_t *end = str + len; - if (internal) { - for (; str < end; str++) { - if ((*str == ANY_CHAR) || (*str == ANY_STRING) || (*str == ANY_STRING_RECURSIVE)) - return true; - } - } else { - wchar_t prev = 0; - for (; str < end; str++) { - if (((*str == L'*') || (*str == L'?' && qmark_is_wild)) && (prev != L'\\')) return true; - prev = *str; +bool wildcard_has_internal(const wchar_t *s, size_t len) { + for (size_t i = 0; i < len; i++) { + wchar_t c = s[i]; + if (c == ANY_CHAR || c == ANY_STRING || c == ANY_STRING_RECURSIVE) { + return true; } } - return false; } -bool wildcard_has(const wchar_t *str, bool internal) { +// Note we want to handle embedded nulls (issue #1631). +bool wildcard_has(const wchar_t *str, size_t len) { assert(str != nullptr); - return wildcard_has_impl(str, std::wcslen(str), internal); -} - -bool wildcard_has(const wcstring &str, bool internal) { - return wildcard_has_impl(str.data(), str.size(), internal); + const wchar_t *end = str + len; + bool qmark_is_wild = !feature_test(features_t::qmark_noglob); + // Fast check for * or ?; if none there is no wildcard. + // Note some strings contain * but no wildcards, e.g. if they are quoted. + if (std::find(str, end, L'*') == end && (!qmark_is_wild || std::find(str, end, L'?') == end)) { + return false; + } + wcstring unescaped; + unescape_string(str, len, &unescaped, UNESCAPE_SPECIAL); + return wildcard_has_internal(unescaped); } /// Check whether the string str matches the wildcard string wc. @@ -876,8 +871,7 @@ void wildcard_expander_t::expand(const wcstring &base_dir, const wchar_t *wc, const bool is_last_segment = (next_slash == nullptr); const size_t wc_segment_len = next_slash ? next_slash - wc : std::wcslen(wc); const wcstring wc_segment = wcstring(wc, wc_segment_len); - const bool segment_has_wildcards = - wildcard_has(wc_segment, true /* internal, i.e. look for ANY_CHAR instead of ? */); + const bool segment_has_wildcards = wildcard_has_internal(wc_segment); // e.g. ANY_STRING. const wchar_t *const wc_remainder = next_slash ? next_slash + 1 : nullptr; if (wc_segment.empty()) { diff --git a/src/wildcard.h b/src/wildcard.h index 3829f39ed..4e4babc8b 100644 --- a/src/wildcard.h +++ b/src/wildcard.h @@ -86,9 +86,15 @@ wildcard_result_t wildcard_expand_string(const wcstring &wc, const wcstring &wor bool wildcard_match(const wcstring &str, const wcstring &wc, bool leading_dots_fail_to_match = false); -/// Check if the specified string contains wildcards. -bool wildcard_has(const wcstring &, bool internal); -bool wildcard_has(const wchar_t *, bool internal); +// Check if the string has any unescaped wildcards (e.g. ANY_STRING). +bool wildcard_has_internal(const wchar_t *s, size_t len); +inline bool wildcard_has_internal(const wcstring &s) { + return wildcard_has_internal(s.c_str(), s.size()); +} + +/// Check if the specified string contains wildcards (e.g. *). +bool wildcard_has(const wchar_t *s, size_t len); +inline bool wildcard_has(const wcstring &s) { return wildcard_has(s.c_str(), s.size()); } /// Test wildcard completion. wildcard_result_t wildcard_complete(const wcstring &str, const wchar_t *wc, diff --git a/tests/checks/argparse.fish b/tests/checks/argparse.fish index a55844b63..9a5885de1 100644 --- a/tests/checks/argparse.fish +++ b/tests/checks/argparse.fish @@ -498,3 +498,14 @@ begin #CHECKERR: ^ #CHECKERR: (Type 'help argparse' for related documentation) end + +begin + argparse --ignore-unknown h i -- -hoa -oia + echo -- $argv + #CHECK: -hoa -oia + echo $_flag_h + #CHECK: -h + set -q _flag_i + or echo No flag I + #CHECK: No flag I +end diff --git a/tests/checks/basic.fish b/tests/checks/basic.fish index 5c8d8e517..cfade8f88 100644 --- a/tests/checks/basic.fish +++ b/tests/checks/basic.fish @@ -533,6 +533,23 @@ echo banana echo (echo hello\\) # CHECK: hello\ +# This used to be a parse error - #7866. +echo (echo foo;#) + ) +# CHECK: foo +echo (echo bar #' + ) +# CHECK: bar +echo (#" + echo baz) +# CHECK: baz + +# Make sure we don't match up brackets within comments (#8022). +$fish -c 'echo f[oo # not valid, no matching ]' +# CHECKERR: fish: Unexpected end of string, square brackets do not match +# CHECKERR: echo f[oo # not valid, no matching ] +# CHECKERR: {{ }}^ + # Should fail because $PWD is read-only. for PWD in foo bar true @@ -541,3 +558,13 @@ end # CHECKERR: for PWD in foo bar # CHECKERR: ^ # XXX FIXME carat should point at PWD + +$fish -c 'echo \xtest' +# CHECKERR: fish: Invalid token '\xtest' +# CHECKERR: echo \xtest +# CHECKERR: ^ + +$fish -c 'echo \utest' +# CHECKERR: fish: Invalid token '\utest' +# CHECKERR: echo \utest +# CHECKERR: ^ diff --git a/tests/checks/cmdsub.fish b/tests/checks/cmdsub.fish index e6d475615..fca2b6b45 100644 --- a/tests/checks/cmdsub.fish +++ b/tests/checks/cmdsub.fish @@ -57,3 +57,9 @@ echo "$(echo 1) ( $(echo 2)" echo "$(echo A)B$(echo C)D"(echo E) # CHECK: ABCDE + +echo "($(echo A)B$(echo C))" +# CHECK: (ABC) + +echo "quoted1""quoted2"(echo unquoted3)"$(echo quoted4)_$(echo quoted5)" +# CHECK: quoted1quoted2unquoted3quoted4_quoted5 diff --git a/tests/checks/command-not-found.fish b/tests/checks/command-not-found.fish index 748f0bfe5..128d3b94c 100644 --- a/tests/checks/command-not-found.fish +++ b/tests/checks/command-not-found.fish @@ -21,6 +21,11 @@ $fish -C 'functions --erase fish_command_not_found' -c 'nonexistent-command appl #CHECKERR: nonexistent-command apple friday #CHECKERR: ^ +command -v nonexistent-command-1234 +echo $status +#CHECK: 127 + + { echo; echo } # CHECKERR: {{.*}}: Unknown command: '{ echo; echo }' # CHECKERR: {{.*}}: '{ ... }' is not supported for grouping commands. Please use 'begin; ...; end' diff --git a/tests/checks/complete.fish b/tests/checks/complete.fish index 50076af04..30be47359 100644 --- a/tests/checks/complete.fish +++ b/tests/checks/complete.fish @@ -9,6 +9,8 @@ complete -c complete_test_alpha3 --no-files -w 'complete_test_alpha2 extra2' complete -C'complete_test_alpha1 arg1 ' # CHECK: complete_test_alpha1 arg1 +complete --escape -C'complete_test_alpha1 arg1 ' +# CHECK: complete_test_alpha1\ arg1\ complete -C'complete_test_alpha2 arg2 ' # CHECK: complete_test_alpha1 extra1 arg2 complete -C'complete_test_alpha3 arg3 ' @@ -454,3 +456,10 @@ function crookshanks --wraps '$path_to_cat' end complete -C 'crookshanks ' # CHECK: +pet + +# Custom completion works with variable overrides. +complete cmd_with_fancy_completion -xa '(commandline -opc | count)' +complete -C"a=1 b=2 cmd_with_fancy_completion " +# CHECK: 1 +complete -C"a=1 b=2 cmd_with_fancy_completion 1 " +# CHECK: 2 diff --git a/tests/checks/git.fish b/tests/checks/git.fish index 6f1cafd8c..a96bc8bac 100644 --- a/tests/checks/git.fish +++ b/tests/checks/git.fish @@ -80,3 +80,18 @@ set -g __fish_git_prompt_status_order untrackedfiles fish_git_prompt echo #CHECK: (newbranch %) + +# Turn on everything and verify we correctly ignore sus config files. +set -g __fish_git_prompt_status_order stagedstate invalidstate dirtystate untrackedfiles stashstate +set -g __fish_git_prompt_showdirtystate 1 +set -g __fish_git_prompt_show_informative_status 1 +set -g __fish_git_prompt_showuntrackedfiles 1 +rm -Rf .git * +git init >/dev/null 2>&1 +echo -n > ran.txt +git config core.fsmonitor 'echo fsmonitor >> ran.txt; false' +git config core.sshCommand 'echo sshCommand >> ran.txt; false' +git config diff.external 'echo diff >> ran.txt; false' +touch untracked_file +fish_git_prompt > /dev/null +cat ran.txt # should output nothing diff --git a/tests/checks/math.fish b/tests/checks/math.fish index 9575c83c7..ae3ba8680 100644 --- a/tests/checks/math.fish +++ b/tests/checks/math.fish @@ -126,9 +126,23 @@ not math 'sin()' # CHECKERR: 'sin()' # CHECKERR: ^ not math '2 + 2 4' -# CHECKERR: math: Error: Too many arguments +# CHECKERR: math: Error: Missing operator # CHECKERR: '2 + 2 4' -# CHECKERR: ^ +# This regex to check whitespace - the error appears between the second 2 and the 4! +# (right after the 2) +# CHECKERR: {{^}} ^ +not math '(1 2)' +# CHECKERR: math: Error: Missing operator +# CHECKERR: '(1 2)' +# CHECKERR: ^ +not math '(1 pi)' +# CHECKERR: math: Error: Missing operator +# CHECKERR: '(1 pi)' +# CHECKERR: ^ +not math '(1 pow 1,2)' +# CHECKERR: math: Error: Too many arguments +# CHECKERR: '(1 pow 1,2)' +# CHECKERR: ^ not math # CHECKERR: math: expected >= 1 arguments; got 0 not math -s 12 @@ -182,6 +196,11 @@ math 'log(16' # CHECKERR: 'log(16' # CHECKERR: ^ +math '(2' +# CHECKERR: math: Error: Missing closing parenthesis +# CHECKERR: '(2' +# CHECKERR: ^ + math --base=16 255 / 15 # CHECK: 0x11 math -bhex 16 x 2 diff --git a/tests/checks/noshebang.fish b/tests/checks/noshebang.fish index 7826fb947..010179035 100644 --- a/tests/checks/noshebang.fish +++ b/tests/checks/noshebang.fish @@ -48,9 +48,11 @@ echo $status rm file.fish #CHECK: 126 #CHECKERR: exec: {{.*}}{{.*}} +#CHECKERR: exec: {{.*}} #CHECK: 126 #CHECKERR: exec: {{.*}} +#CHECKERR: exec: {{.*}} # On to NUL bytes. @@ -80,3 +82,13 @@ runfile #CHECK: 126 #CHECKERR: exec: {{.*}} + +echo 'echo foo' >./- +sleep 0.1 +chmod +x ./- +set PATH ./ $PATH +sleep 0.1 +- +#CHECK: foo +echo $status +#CHECK: 0 diff --git a/tests/checks/not.fish b/tests/checks/not.fish new file mode 100644 index 000000000..77a03c419 --- /dev/null +++ b/tests/checks/not.fish @@ -0,0 +1,10 @@ +#RUN: %fish %s + +not true +echo $status +# CHECK: 1 + +# Two "not" prefixes on a single job cancel each other out. +not not sh -c 'exit 34' +echo $status +# CHECK: 34 diff --git a/tests/checks/read.fish b/tests/checks/read.fish index 9a80402b4..8801b6246 100644 --- a/tests/checks/read.fish +++ b/tests/checks/read.fish @@ -244,7 +244,9 @@ if test $status -ne 0 echo the read of the max amount of data failed unexpectedly end if test (string length "$x") -ne $fish_read_limit - echo reading the max amount of data with --nchars failed the length test: (string length "$x") / $fish_read_limit + # See how much data 'yes' produced. + set yeslen (yes $line | dd bs=1024 count=(math "$fish_read_limit / 1024") 2>/dev/null | wc -c | tr -d " \t\n\r") + echo reading the max amount of data with --nchars failed the length test. read: (string length "$x"), limit: $fish_read_limit, yes produced: $yeslen end # Confirm reading non-interactively works -- \#4206 regression diff --git a/tests/checks/set.fish b/tests/checks/set.fish index 7849800b5..65cb9b1f5 100644 --- a/tests/checks/set.fish +++ b/tests/checks/set.fish @@ -635,6 +635,34 @@ end #CHECK: $var6[1]: |ghi| #CHECK: $var6[2]: |jkl| +# `and` creates no new scope on its own +true; and set -l var7a 89 179 +set -q var7a +echo $status +#CHECK: 0 + +# `begin` of an `and` creates a new scope +true; and begin + set -l var7b 359 719 +end +set -q var7b +echo $status +#CHECK: 1 + +# `or` creates no new scope on its own +false; or set -l var8a 1439 2879 +set -q var8a +echo $status +#CHECK: 0 + +# `begin` of an `or` creates a new scope +false; or begin + set -l var8b 9091 9901 +end +set -q var8b +echo $status +#CHECK: 1 + # Exporting works set -x TESTVAR0 set -x TESTVAR1 a @@ -840,6 +868,29 @@ end erase-funcvar +set -f foo +set -l banana +set -g global +begin + set -qf foo + and echo foo is function scoped + # CHECK: foo is function scoped + + set -l localvar414 + set -qf localvar414 + or echo localvar414 is not function scoped + # CHECK: localvar414 is not function scoped + + set -qf banana + and echo banana is function scoped + # CHECK: banana is function scoped + + set -l global + set -qf global + or echo global is not function scoped + # CHECK: global is not function scoped +end + set --query $this_is_not_set echo $status # CHECK: 255 diff --git a/tests/checks/status.fish b/tests/checks/status.fish index 1015ee1ab..924f1caef 100644 --- a/tests/checks/status.fish +++ b/tests/checks/status.fish @@ -56,7 +56,7 @@ status features #CHECK: stderr-nocaret on 3.0 ^ no longer redirects stderr #CHECK: qmark-noglob off 3.0 ? no longer globs #CHECK: regex-easyesc off 3.1 string replace -r needs fewer \'s -#CHECK: ampersand-nobg-in-token off 3.4 & only backgrounds if followed by a separating character +#CHECK: ampersand-nobg-in-token off 3.4 & only backgrounds if followed by a separator status test-feature stderr-nocaret echo $status #CHECK: 0 diff --git a/tests/checks/string.fish b/tests/checks/string.fish index b77e09e9f..afade5ca9 100644 --- a/tests/checks/string.fish +++ b/tests/checks/string.fish @@ -93,11 +93,11 @@ string length --visible (set_color red)abc begin set -l fish_emoji_width 2 # This should print the emoji width - string length --visible . 🥁 + string length --visible . \U2693 # CHECK: 1 # CHECK: 2 set -l fish_emoji_width 1 - string length --visible . 🥁 + string length --visible . \U2693 # CHECK: 1 # CHECK: 1 end diff --git a/tests/checks/syntax-error-location.fish b/tests/checks/syntax-error-location.fish index 22e281170..bf5c9a9ce 100644 --- a/tests/checks/syntax-error-location.fish +++ b/tests/checks/syntax-error-location.fish @@ -22,3 +22,13 @@ echo ' # CHECK: # CHECK: <(true one)> # CHECK: <^> + +$fish -c 'echo "unfinished "(subshell' 2>| string replace -r '.*' '<$0>' +# CHECK: +# CHECK: +# CHECK: < ^> + +$fish -c 'echo "unfinished "$(subshell' 2>| string replace -r '.*' '<$0>' +# CHECK: +# CHECK: +# CHECK: < ^> diff --git a/tests/checks/test.fish b/tests/checks/test.fish index 6372c73f3..75219a76d 100644 --- a/tests/checks/test.fish +++ b/tests/checks/test.fish @@ -51,3 +51,11 @@ t 5,2 # CHECKERR: ^ # CHECKERR: in function 't' with arguments '5,2' # CHECKERR: called on line {{\d+}} of file {{.*}}test.fish + +test -x /usr/bin/go /usr/local/bin/go +# CHECKERR: test: unexpected argument at index 3: '/usr/local/bin/go' +# CHECKERR: -x /usr/bin/go /usr/local/bin/go +# CHECKERR: {{ \^}} +# CHECKERR: {{.*}}test.fish (line {{\d+}}): +# CHECKERR: test -x /usr/bin/go /usr/local/bin/go +# CHECKERR: ^ diff --git a/tests/checks/tmux-complete.fish b/tests/checks/tmux-complete.fish index bad378881..3c12a02ac 100644 --- a/tests/checks/tmux-complete.fish +++ b/tests/checks/tmux-complete.fish @@ -28,3 +28,14 @@ isolated-tmux capture-pane -p # The "bc" part is the autosuggestion - we could use "capture-pane -e" to check colors. # CHECK: prompt 2> foo2 aabc # CHECK: aabc aaBd + +# Check that a larger-than-screen completion list does not stomp a multiline commandline (#8509). +isolated-tmux send-keys C-u 'complete -c foo3 -fa "(seq $LINES)\t(string repeat -n $COLUMNS d)"' Enter \ + C-l begin Enter foo3 Enter "echo some trailing line" \ + C-p C-e Space Tab Tab +tmux-sleep +isolated-tmux capture-pane -p | sed -n '1p;$p' +# Assert that we didn't change the command line. +# CHECK: prompt 3> begin +# Also ensure that the pager is actually fully disclosed. +# CHECK: rows 1 to {{\d+}} of {{\d+}} diff --git a/tests/checks/tmux-history-search.fish b/tests/checks/tmux-history-search.fish new file mode 100644 index 000000000..877651cbf --- /dev/null +++ b/tests/checks/tmux-history-search.fish @@ -0,0 +1,14 @@ +#RUN: %fish %s +#REQUIRES: command -v tmux + +isolated-tmux-start + +isolated-tmux send-keys 'true needle' Enter +# CHECK: prompt 0> true needle +tmux-sleep +isolated-tmux send-keys 'true hay ee hay' Enter +# CHECK: prompt 1> true hay ee hay +isolated-tmux send-keys C-p C-a M-f M-f M-f M-. +# CHECK: prompt 2> true hay needle hay +tmux-sleep +isolated-tmux capture-pane -p diff --git a/tests/pexpects/bind_mode_events.py b/tests/pexpects/bind_mode_events.py index d7ab5d675..4bed3c1f4 100644 --- a/tests/pexpects/bind_mode_events.py +++ b/tests/pexpects/bind_mode_events.py @@ -44,7 +44,8 @@ expect_prompt() timeout = 0.15 if "CI" in os.environ: - # This doesn't work under tsan. + # This doesn't work under TSan, because TSan prevents select() being + # interrupted by a signal. import sys print("SKIPPING the last of bind_mode_events.py") sys.exit(0) diff --git a/tests/pexpects/cancel_event.py b/tests/pexpects/cancel_event.py index c83efe857..ad6c7484c 100644 --- a/tests/pexpects/cancel_event.py +++ b/tests/pexpects/cancel_event.py @@ -16,7 +16,8 @@ expect_prompt() timeout = 0.15 if "CI" in os.environ: - # This doesn't work under tsan. + # This doesn't work under TSan, because TSan prevents select() being + # interrupted by a signal. import sys print("SKIPPING cancel_event.py") sys.exit(0) diff --git a/tests/pexpects/read.py b/tests/pexpects/read.py index 3e0d416ef..929f7a796 100644 --- a/tests/pexpects/read.py +++ b/tests/pexpects/read.py @@ -54,6 +54,18 @@ expect_prompt() expect_marker(2) print_var_contents("foo", "bar") +# read -c (see #8633) +sendline(r"read -c init_text somevar && echo $somevar") +expect_re("\r\n?read> init_text$") +sendline("someval") +expect_prompt("someval\r\n") + +sendline(r"read --command='some other text' somevar && echo $somevar") +expect_re("\r\n?read> some other text$") +sendline("another value") +expect_prompt("another value\r\n") + + # read -s sendline("read -s foo") diff --git a/tests/pexpects/stdin_nonblocking.py b/tests/pexpects/stdin_nonblocking.py new file mode 100644 index 000000000..d1f6a0eeb --- /dev/null +++ b/tests/pexpects/stdin_nonblocking.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 +# Verify that stdin is properly set to blocking even if a job tweaks it. +from pexpect_helper import SpawnedProc +import sys +import signal +import time +import os + +sp = SpawnedProc() +send, sendline, expect_prompt, expect_str, sleep = ( + sp.send, + sp.sendline, + sp.expect_prompt, + sp.expect_str, + sp.sleep, +) + +# Launch fish_test_helper. +expect_prompt() +exe_path = os.environ.get("fish_test_helper") +sendline(exe_path + " stdin_make_nonblocking") + +expect_str("stdin was blocking") +sleep(0.1) + +send("\x1A") # ctrl-Z +expect_prompt("has stopped") + +# We don't "restore" non-blocking state when continuing a stopped job. +sleep(0.1) +sendline("fg") +expect_str("stdin was blocking") + +# Kill the job and do it again. +send("\x03") # ctrl-c +expect_prompt() +sendline(exe_path + " stdin_make_nonblocking") +expect_str("stdin was blocking") +send("\x03") # ctrl-c +expect_prompt() diff --git a/tests/pexpects/torn_escapes.py b/tests/pexpects/torn_escapes.py new file mode 100644 index 000000000..b26db8fc7 --- /dev/null +++ b/tests/pexpects/torn_escapes.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python3 +import os +import signal +from pexpect_helper import SpawnedProc + + +sp = SpawnedProc() +send, sendline, sleep, expect_prompt, expect_str, expect_re = ( + sp.send, + sp.sendline, + sp.sleep, + sp.expect_prompt, + sp.expect_str, + sp.expect_re, +) +# Ensure that signals don't tear escape sequences. See #8628. +expect_prompt() + +# Allow for long delays before matching escape. +sendline(r"set -g fish_escape_delay_ms 2000") +expect_prompt() + +# Set up a handler for SIGUSR1. +sendline(r"set -g sigusr1_count 0") +expect_prompt() + +sendline( + r""" + function usr1_handler --on-signal SIGUSR1; + set sigusr1_count (math $sigusr1_count + 1); + echo Got SIGUSR1 $sigusr1_count; + commandline -f repaint; + end +""".strip().replace( + "\n", os.linesep + ) +) +expect_prompt() + +# Set up a wacky binding with an escape. +sendline(r"function wacky_handler; echo Wacky Handler; end") +expect_prompt() + +sendline(r"bind abc\edef wacky_handler") +expect_prompt() + +# We can respond to SIGUSR1. +os.kill(sp.spawn.pid, signal.SIGUSR1) +expect_str(r"Got SIGUSR1 1") +sendline(r"") +expect_prompt() + +# Our wacky binding works. +send("abc\x1bdef") +expect_str(r"Wacky Handler") +sendline(r"") +expect_prompt() + +# Now we interleave the sequence with SIGUSR1. +# What we expect to happen is that the signal is "shuffled to the front" ahead of the key events. +send("abc") +sleep(0.05) +os.kill(sp.spawn.pid, signal.SIGUSR1) +sleep(0.05) +send("\x1bdef") +expect_str(r"Got SIGUSR1 2") +expect_str(r"Wacky Handler") +sendline(r"") +expect_prompt() + +# As before but it comes after the ESC. +# The signal will arrive while we are waiting in getch_timed(). +send("abc\x1b") +sleep(0.05) +os.kill(sp.spawn.pid, signal.SIGUSR1) +sleep(0.05) +send("def") +expect_str(r"Got SIGUSR1 3") +expect_str(r"Wacky Handler") +sendline(r"") +expect_prompt()