Compare commits
No commits in common. "master" and "Integration_3.4.1" have entirely different histories.
master
...
Integratio
|
|
@ -22,4 +22,4 @@ tasks:
|
|||
ninja
|
||||
- test: |
|
||||
cd fish/build
|
||||
env ninja test
|
||||
env SHOW_INTERACTIVE_LOG=1 ninja test
|
||||
|
|
|
|||
|
|
@ -19,4 +19,4 @@ tasks:
|
|||
ninja
|
||||
- test: |
|
||||
cd fish/build
|
||||
env ninja test
|
||||
env SHOW_INTERACTIVE_LOG=1 ninja test
|
||||
|
|
|
|||
|
|
@ -23,4 +23,4 @@ tasks:
|
|||
gmake -j2
|
||||
- test: |
|
||||
cd fish/build
|
||||
gmake test
|
||||
gmake test SHOW_INTERACTIVE_LOG=1
|
||||
|
|
|
|||
118
.cirrus.yml
118
.cirrus.yml
|
|
@ -1,118 +0,0 @@
|
|||
env:
|
||||
CIRRUS_CLONE_DEPTH: 1
|
||||
CI: 1
|
||||
|
||||
linux_task:
|
||||
matrix:
|
||||
- name: alpine
|
||||
container: &step
|
||||
image: ghcr.io/fish-shell/fish-ci/alpine:latest
|
||||
memory: 4GB
|
||||
- name: bionic
|
||||
container:
|
||||
<<: *step
|
||||
image: ghcr.io/fish-shell/fish-ci/bionic:latest
|
||||
- name: bionic-asan-clang
|
||||
container:
|
||||
<<: *step
|
||||
image: ghcr.io/fish-shell/fish-ci/bionic-asan-clang:latest
|
||||
- name: bionic-tsan
|
||||
container:
|
||||
<<: *step
|
||||
image: ghcr.io/fish-shell/fish-ci/bionic-tsan:latest
|
||||
- name: bionic-tsan-clang
|
||||
container:
|
||||
<<: *step
|
||||
image: ghcr.io/fish-shell/fish-ci/bionic-tsan-clang:latest
|
||||
- name: centos7
|
||||
container:
|
||||
<<: *step
|
||||
image: ghcr.io/fish-shell/fish-ci/centos7:latest
|
||||
- name: centos8
|
||||
container:
|
||||
<<: *step
|
||||
image: ghcr.io/fish-shell/fish-ci/centos8:latest
|
||||
- name: focal-32bit
|
||||
container:
|
||||
<<: *step
|
||||
image: ghcr.io/fish-shell/fish-ci/focal-32bit:latest
|
||||
- name: xenial
|
||||
container:
|
||||
<<: *step
|
||||
image: ghcr.io/fish-shell/fish-ci/xenial:latest
|
||||
|
||||
tests_script:
|
||||
# cirrus at times gives us 32 procs and 2 GB of RAM
|
||||
# Unrestriced parallelism results in OOM
|
||||
- lscpu || true
|
||||
- (cat /proc/meminfo | grep MemTotal) || true
|
||||
- mkdir build && cd build
|
||||
- cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCTEST_PARALLEL_LEVEL=6 ..
|
||||
- ninja -j 6 fish fish_tests
|
||||
- ninja fish_run_tests
|
||||
|
||||
# CI task disabled during RIIR transition
|
||||
only_if: false && $CIRRUS_REPO_OWNER == 'fish-shell'
|
||||
|
||||
linux_arm_task:
|
||||
matrix:
|
||||
- name: focal-arm64
|
||||
arm_container:
|
||||
image: ghcr.io/fish-shell/fish-ci/focal-arm64
|
||||
only_if: $CIRRUS_REPO_OWNER == 'fish-shell'
|
||||
- name: jammy-armv7-32bit
|
||||
arm_container:
|
||||
image: ghcr.io/fish-shell/fish-ci/jammy-armv7-32bit
|
||||
|
||||
tests_script:
|
||||
# cirrus at times gives us 32 procs and 2 GB of RAM
|
||||
# Unrestriced parallelism results in OOM
|
||||
- lscpu || true
|
||||
- (cat /proc/meminfo | grep MemTotal) || true
|
||||
- mkdir build && cd build
|
||||
- cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCTEST_PARALLEL_LEVEL=6 ..
|
||||
- ninja -j 6 fish fish_tests
|
||||
- file ./fish
|
||||
- ninja fish_run_tests
|
||||
|
||||
# CI task disabled during RIIR transition
|
||||
only_if: false && $CIRRUS_REPO_OWNER == 'fish-shell'
|
||||
|
||||
freebsd_task:
|
||||
matrix:
|
||||
# - name: FreeBSD 14
|
||||
# freebsd_instance:
|
||||
# image_family: freebsd-14-0-snap
|
||||
- name: FreeBSD 13
|
||||
freebsd_instance:
|
||||
image: freebsd-13-1-release-amd64
|
||||
- name: FreeBSD 12.3
|
||||
freebsd_instance:
|
||||
image: freebsd-12-3-release-amd64
|
||||
tests_script:
|
||||
- pkg install -y cmake-core devel/pcre2 devel/ninja misc/py-pexpect git-lite
|
||||
# libclang.so is a required build dependency for rust-c++ ffi bridge
|
||||
- pkg install -y llvm
|
||||
# BSDs have the following behavior: root may open or access files even if
|
||||
# the mode bits would otherwise disallow it. For example root may open()
|
||||
# a file with write privileges even if the file has mode 400. This breaks
|
||||
# our tests for e.g. cd and path. So create a new unprivileged user to run tests.
|
||||
- pw user add -n fish-user -s /bin/csh -d /home/fish-user
|
||||
- mkdir -p /home/fish-user
|
||||
- chown -R fish-user /home/fish-user
|
||||
- mkdir build && cd build
|
||||
- chown -R fish-user ..
|
||||
- sudo -u fish-user -s whoami
|
||||
# FreeBSD's pkg currently has rust 1.66.0 while we need rust 1.67.0+. Use rustup to install
|
||||
# the latest, but note that it only installs rust per-user.
|
||||
- sudo -u fish-user -s fetch -qo - https://sh.rustup.rs > rustup.sh
|
||||
- sudo -u fish-user -s sh ./rustup.sh -y --profile=minimal
|
||||
# `sudo -s ...` does not invoke a login shell so we need a workaround to make sure the
|
||||
# rustup environment is configured for subsequent `sudo -s ...` commands.
|
||||
# For some reason, this doesn't do the job:
|
||||
# - sudo -u fish-user sh -c 'echo source \$HOME/.cargo/env >> $HOME/.cshrc'
|
||||
- sudo -u fish-user -s cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCTEST_PARALLEL_LEVEL=1 ..
|
||||
- sudo -u fish-user sh -c '. $HOME/.cargo/env; ninja -j 6 fish fish_tests'
|
||||
- sudo -u fish-user sh -c '. $HOME/.cargo/env; ninja fish_run_tests'
|
||||
|
||||
only_if: $CIRRUS_REPO_OWNER == 'fish-shell'
|
||||
|
|
@ -24,5 +24,5 @@ indent_size = 2
|
|||
[share/{completions,functions}/**.fish]
|
||||
max_line_length = none
|
||||
|
||||
[{COMMIT_EDITMSG,git-revise-todo}]
|
||||
[COMMIT_EDITMSG]
|
||||
max_line_length = 80
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -7,19 +7,13 @@ on:
|
|||
# min 0-59 ┘ │ │ │ └ weekday 0-6
|
||||
# hour 0-23 ┘ │ └ month 1-12
|
||||
# └ day 1-31
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
lock:
|
||||
permissions:
|
||||
issues: write # for dessant/lock-threads to lock issues
|
||||
pull-requests: write # for dessant/lock-threads to lock PRs
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: dessant/lock-threads@v4
|
||||
- uses: dessant/lock-threads@v2
|
||||
with:
|
||||
github-token: ${{ github.token }}
|
||||
issue-inactive-days: '365'
|
||||
pr-inactive-days: '365'
|
||||
exclude-any-issue-labels: 'question, needs more info'
|
||||
issue-lock-inactive-days: '365'
|
||||
pr-lock-inactive-days: '365'
|
||||
issue-exclude-labels: 'question, needs more info'
|
||||
|
|
|
|||
|
|
@ -6,20 +6,13 @@ env:
|
|||
CTEST_PARALLEL_LEVEL: "1"
|
||||
CMAKE_BUILD_PARALLEL_LEVEL: "4"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
ubuntu:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: SetupRust
|
||||
uses: ATiltedTree/setup-rust@v1
|
||||
with:
|
||||
rust-version: 1.67
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt install gettext libncurses5-dev libpcre2-dev python3-pip tmux
|
||||
|
|
@ -40,17 +33,12 @@ jobs:
|
|||
run: |
|
||||
make test
|
||||
|
||||
ubuntu-32bit-fetched-pcre2:
|
||||
ubuntu-32bit-vendored-pcre2:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: SetupRust
|
||||
uses: ATiltedTree/setup-rust@v1
|
||||
with:
|
||||
rust-version: 1.67
|
||||
targets: "i686-unknown-linux-gnu" # setup-rust wants this space-separated
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt update
|
||||
|
|
@ -62,10 +50,10 @@ jobs:
|
|||
CFLAGS: "-m32"
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake -DFISH_USE_SYSTEM_PCRE2=OFF -DRust_CARGO_TARGET=i686-unknown-linux-gnu ..
|
||||
cmake -DFISH_USE_SYSTEM_PCRE2=OFF ..
|
||||
- name: make
|
||||
run: |
|
||||
make VERBOSE=1
|
||||
make
|
||||
- name: make test
|
||||
run: |
|
||||
make test
|
||||
|
|
@ -73,24 +61,9 @@ jobs:
|
|||
ubuntu-asan:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
# Rust has two different memory sanitizers of interest; they can't be used at the same time:
|
||||
# * AddressSanitizer detects out-of-bound access, use-after-free, use-after-return,
|
||||
# use-after-scope, double-free, invalid-free, and memory leaks.
|
||||
# * MemorySanitizer detects uninitialized reads.
|
||||
#
|
||||
RUSTFLAGS: "-Zsanitizer=address"
|
||||
# RUSTFLAGS: "-Zsanitizer=memory -Zsanitizer-memory-track-origins"
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: SetupRust
|
||||
uses: ATiltedTree/setup-rust@v1
|
||||
with:
|
||||
# All -Z options require running nightly
|
||||
rust-version: nightly
|
||||
# ASAN uses `cargo build -Zbuild-std` which requires the rust-src component
|
||||
components: rust-src
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt install gettext libncurses5-dev libpcre2-dev python3-pip tmux
|
||||
|
|
@ -99,72 +72,50 @@ jobs:
|
|||
env:
|
||||
CC: clang
|
||||
CXX: clang++
|
||||
CXXFLAGS: "-fno-omit-frame-pointer -fsanitize=undefined -fsanitize=address -DFISH_CI_SAN"
|
||||
CXXFLAGS: "-fno-omit-frame-pointer -fsanitize=undefined -fsanitize=address"
|
||||
ASAN_OPTIONS: check_initialization_order=1:detect_stack_use_after_return=1:detect_leaks=1
|
||||
UBSAN_OPTIONS: print_stacktrace=1:report_error_type=1
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
# Rust's ASAN requires the build system to explicitly pass a --target triple. We read that
|
||||
# value from CMake variable Rust_CARGO_TARGET (shared with corrosion).
|
||||
cmake .. -DASAN=1 -DRust_CARGO_TARGET=x86_64-unknown-linux-gnu -DCMAKE_BUILD_TYPE=Debug
|
||||
cmake ..
|
||||
- name: make
|
||||
run: |
|
||||
make
|
||||
- name: make test
|
||||
env:
|
||||
FISH_CI_SAN: 1
|
||||
ASAN_OPTIONS: check_initialization_order=1:detect_stack_use_after_return=1:detect_leaks=1
|
||||
UBSAN_OPTIONS: print_stacktrace=1:report_error_type=1
|
||||
# use_tls=0 is a workaround for LSAN crashing with "Tracer caught signal 11" (SIGSEGV),
|
||||
# which seems to be an issue with TLS support in newer glibc versions under virtualized
|
||||
# environments. Follow https://github.com/google/sanitizers/issues/1342 and
|
||||
# https://github.com/google/sanitizers/issues/1409 to track this issue.
|
||||
LSAN_OPTIONS: verbosity=0:log_threads=0:use_tls=0
|
||||
run: |
|
||||
make test
|
||||
|
||||
# Our clang++ tsan builds are not recognizing safe rust patterns (such as the fact that Drop
|
||||
# cannot be called while a thread is using the object in question). Rust has its own way of
|
||||
# running TSAN, but for the duration of the port from C++ to Rust, we'll keep this disabled.
|
||||
ubuntu-threadsan:
|
||||
|
||||
# ubuntu-threadsan:
|
||||
#
|
||||
# runs-on: ubuntu-latest
|
||||
#
|
||||
# steps:
|
||||
# - uses: actions/checkout@v3
|
||||
# - name: SetupRust
|
||||
# uses: ATiltedTree/setup-rust@v1
|
||||
# with:
|
||||
# rust-version: 1.67
|
||||
# - name: Install deps
|
||||
# run: |
|
||||
# sudo apt install gettext libncurses5-dev libpcre2-dev python3-pip tmux
|
||||
# sudo pip3 install pexpect
|
||||
# - name: cmake
|
||||
# env:
|
||||
# FISH_CI_SAN: 1
|
||||
# CC: clang
|
||||
# CXX: clang++
|
||||
# CXXFLAGS: "-fsanitize=thread"
|
||||
# run: |
|
||||
# mkdir build && cd build
|
||||
# cmake ..
|
||||
# - name: make
|
||||
# run: |
|
||||
# make
|
||||
# - name: make test
|
||||
# run: |
|
||||
# make test
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt install gettext libncurses5-dev libpcre2-dev python3-pip tmux
|
||||
sudo pip3 install pexpect
|
||||
- name: cmake
|
||||
env:
|
||||
CC: clang
|
||||
CXX: clang++
|
||||
CXXFLAGS: "-fsanitize=thread"
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
- name: make
|
||||
run: |
|
||||
make
|
||||
- name: make test
|
||||
run: |
|
||||
make test
|
||||
|
||||
macos:
|
||||
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: SetupRust
|
||||
uses: ATiltedTree/setup-rust@v1
|
||||
with:
|
||||
rust-version: 1.67
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo pip3 install pexpect
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
name: Rust checks
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
rustfmt:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: SetupRust
|
||||
uses: ATiltedTree/setup-rust@v1
|
||||
with:
|
||||
rust-version: stable
|
||||
- name: cargo fmt
|
||||
run: |
|
||||
cd fish-rust
|
||||
cargo fmt --check --all
|
||||
|
||||
clippy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: SetupRust
|
||||
uses: ATiltedTree/setup-rust@v1
|
||||
with:
|
||||
rust-version: stable
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt install gettext libncurses5-dev libpcre2-dev python3-pip tmux
|
||||
sudo pip3 install pexpect
|
||||
- name: cmake
|
||||
run: |
|
||||
cmake -B build
|
||||
- name: cargo clippy
|
||||
run: |
|
||||
cd fish-rust
|
||||
cargo clippy --workspace --all-targets -- --deny=warnings
|
||||
|
|
@ -89,16 +89,3 @@ __pycache__
|
|||
/tags
|
||||
xcuserdata/
|
||||
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
debug/
|
||||
target/
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||
*.pdb
|
||||
|
||||
# Generated by clangd
|
||||
/.cache
|
||||
|
|
|
|||
444
CHANGELOG.rst
444
CHANGELOG.rst
|
|
@ -1,446 +1,3 @@
|
|||
fish 3.7.0 (released ???)
|
||||
===================================
|
||||
|
||||
.. ignore: 9439 9440 9442 9452 9469 9480 9482
|
||||
|
||||
Notable improvements and fixes
|
||||
------------------------------
|
||||
- ``abbr --erase`` now also erases the universal variables used by the old abbr function. That means::
|
||||
abbr --erase (abbr --list)
|
||||
|
||||
can now be used to clean out all old abbreviations (:issue:`9468`).
|
||||
- ``abbr --add --universal`` now warns about --universal being non-functional, to make it easier to detect old-style ``abbr`` calls (:issue:`9475`).
|
||||
- ``functions --handlers-type caller-exit`` once again lists functions defined as ``function --on-job-exit caller``, rather than them being listed by ``functions --handlers-type process-exit``.
|
||||
|
||||
Deprecations and removed features
|
||||
---------------------------------
|
||||
|
||||
Scripting improvements
|
||||
----------------------
|
||||
- ``abbr --list`` no longer escapes the abbr name, which is necessary to be able to pass it to ``abbr --erase`` (:issue:`9470`).
|
||||
- ``read`` will now print an error if told to set a read-only variable instead of silently doing nothing (:issue:`9346`).
|
||||
- ``functions`` and ``type`` now show where a function was copied and where it originally was instead of saying ``Defined interactively``.
|
||||
- Stack trace now shows line numbers for copied functions.
|
||||
|
||||
Interactive improvements
|
||||
------------------------
|
||||
- Using ``fish_vi_key_bindings`` in combination with fish's ``--no-config`` mode works without locking up the shell (:issue:`9443`).
|
||||
- The history pager now uses more screen space, usually half the screen (:issue:`9458`).
|
||||
- The history pager now shows fuzzy (subsequence) matches in the absence of exact substring matches (:issue:`9476`).
|
||||
- Variables that were set while the locale was C (i.e. ASCII) will now properly be encoded if the locale is switched (:issue:`2613`, :issue:`9473`).
|
||||
- Escape during history search restores the original commandline again (regressed in 3.6.0).
|
||||
- Using ``--help`` on builtins now respects the $MANPAGER variable in preference to $PAGER (:issue:`9488`).
|
||||
- Command-specific tab completions may now offer results whose first character is a period. For example, it is now possible to tab-complete ``git add`` for files with leading periods. The default file completions hide these files, unless the token itself has a leading period (:issue:`3707`).
|
||||
- A new variable, :envvar:`fish_cursor_external`, can be used to specify to cursor shape when a command is launched. When unspecified, the value defaults to the value of :envvar:`fish_cursor_default` (:issue:`4656`).
|
||||
|
||||
New or improved bindings
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Improved prompts
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
Completions
|
||||
^^^^^^^^^^^
|
||||
- Added completions for:
|
||||
|
||||
- ``otool``
|
||||
- ``mix phx``
|
||||
- ``neovim``
|
||||
- ``stow``
|
||||
- ``trash`` and helper utilities ``trash-empty``, ``trash-list``, ``trash-put``, ``trash-restore``
|
||||
- ``apkanalyzer``
|
||||
- ``scrypt``
|
||||
- ``fastboot``
|
||||
|
||||
- git's completion for ``git-foo``-style commands was fixed (:issue:`9457`)
|
||||
- File completion now offers ``../`` and ``./`` again (:issue:`9477`)
|
||||
|
||||
Improved terminal support
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Other improvements
|
||||
------------------
|
||||
|
||||
|
||||
For distributors
|
||||
----------------
|
||||
- *Placeholder to fix Sphinx warning*
|
||||
|
||||
--------------
|
||||
|
||||
|
||||
fish 3.6.0 (released January 7, 2023)
|
||||
=====================================
|
||||
|
||||
Notable improvements and fixes
|
||||
------------------------------
|
||||
- By default, :kbd:`Control-R` now opens the command history in the pager (:issue:`602`). This is fully searchable and syntax-highlighted, as an alternative to the incremental search seen in other shells. The new special input function ``history-pager`` has been added for custom bindings.
|
||||
- Abbrevations are more flexible (:issue:`9313`, :issue:`5003`, :issue:`2287`):
|
||||
|
||||
- They may optionally replace tokens anywhere on the command line, instead of only commands
|
||||
- Matching tokens may be described using a regular expression instead of a literal word
|
||||
- The replacement text may be produced by a fish function, instead of a literal word
|
||||
- They may position the cursor anywhere in the expansion, instead of at the end
|
||||
|
||||
For example::
|
||||
|
||||
function multicd
|
||||
echo cd (string repeat -n (math (string length -- $argv[1]) - 1) ../)
|
||||
end
|
||||
|
||||
abbr --add dotdot --regex '^\.\.+$' --function multicd
|
||||
|
||||
This expands ``..`` to ``cd ../``, ``...`` to ``cd ../../`` and ``....`` to ``cd ../../../`` and so on.
|
||||
|
||||
Or::
|
||||
|
||||
function last_history_item; echo $history[1]; end
|
||||
abbr -a !! --position anywhere --function last_history_item
|
||||
|
||||
which expands ``!!`` to the last history item, anywhere on the command line, mimicking other shells' history expansion.
|
||||
|
||||
See :ref:`the documentation <cmd-abbr>` for more.
|
||||
- ``path`` gained a new ``mtime`` subcommand to print the modification time stamp for files. For example, this can be used to handle cache file ages (:issue:`9057`)::
|
||||
|
||||
> touch foo
|
||||
> sleep 10
|
||||
> path mtime --relative foo
|
||||
10
|
||||
|
||||
- ``string`` gained a new ``shorten`` subcommand to shorten strings to a given visible width (:issue:`9156`)::
|
||||
|
||||
> string shorten --max 10 "Hello this is a long string"
|
||||
Hello thi…
|
||||
|
||||
- ``test`` (aka ``[``) gained ``-ot`` (older than) and ``-nt`` (newer than) operators to compare file modification times, and ``-ef`` to compare whether the arguments are the same file (:issue:`3589`).
|
||||
- fish will now mark the extent of many errors with a squiggly line, instead of just a caret (``^``) at the beginning (:issue:`9130`). For example::
|
||||
|
||||
checks/set.fish (line 471): for: a,b: invalid variable name. See `help identifiers`
|
||||
for a,b in y 1 z 3
|
||||
^~^
|
||||
- A new function, ``fish_delta``, shows changes that have been made in fish's configuration from the defaults (:issue:`9255`).
|
||||
- ``set --erase`` can now be used with multiple scopes at once, like ``set -efglU foo`` (:issue:`7711`, :issue:`9280`).
|
||||
- ``status`` gained a new subcommand, ``current-commandline``, which retrieves the entirety of the currently-executing command line when called from a function during execution. This allows easier job introspection (:issue:`8905`, :issue:`9296`).
|
||||
|
||||
Deprecations and removed features
|
||||
---------------------------------
|
||||
- The ``\x`` and ``\X`` escape syntax is now equivalent. ``\xAB`` previously behaved the same as ``\XAB``, except that it would error if the value "AB" was larger than "7f" (127 in decimal, the highest ASCII value) (:issue:`9247`, :issue:`9245`, :issue:`1352`).
|
||||
- The ``fish_git_prompt`` will now only turn on features if the appropriate variable has been set to a true value (of "1", "yes" or "true") instead of just checking if it is defined. This allows specifically turning features *off* without having to erase variables, such as via universal variables. If you have defined a variable to a different value and expect it to count as true, you need to change it (:issue:`9274`).
|
||||
For example, ``set -g __fish_git_prompt_show_informative_status 0`` previously would have enabled informative status (because any value would have done so), but now it turns it off.
|
||||
- Abbreviations are no longer stored in universal variables. Existing universal abbreviations are still imported, but new abbreviations should be added to ``config.fish``.
|
||||
- The short option ``-r`` for abbreviations has changed from ``rename`` to ``regex``, for consistency with ``string``.
|
||||
|
||||
Scripting improvements
|
||||
----------------------
|
||||
- ``argparse`` can now be used without option specifications, to allow using ``--min-args``, ``--max-args`` or for commands that take no options (but might in future) (:issue:`9006`)::
|
||||
|
||||
function my_copy
|
||||
argparse --min-args 2 -- $argv
|
||||
or return
|
||||
|
||||
cp $argv
|
||||
end
|
||||
|
||||
- ``set --show`` now shows when a variable was inherited from fish's parent process, which should help with debugging (:issue:`9029`)::
|
||||
|
||||
> set --show XDG_DATA_DIRS
|
||||
$XDG_DATA_DIRS: set in global scope, exported, a path variable with 4 elements
|
||||
$XDG_DATA_DIRS[1]: |/home/alfa/.local/share/flatpak/exports/share|
|
||||
$XDG_DATA_DIRS[2]: |/var/lib/flatpak/exports/share|
|
||||
$XDG_DATA_DIRS[3]: |/usr/local/share|
|
||||
$XDG_DATA_DIRS[4]: |/usr/share|
|
||||
$XDG_DATA_DIRS: originally inherited as |/home/alfa/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share/:/usr/share/|
|
||||
|
||||
- The read limit is now restored to the default when :envvar:`fish_read_limit` is unset (:issue:`9129`).
|
||||
- ``math`` produces an error for division-by-zero, as well as augmenting some errors with their extent (:issue:`9190`). This changes behavior in some limited cases, such as::
|
||||
|
||||
math min 1 / 0, 5
|
||||
|
||||
which would previously print "5" (because in floating point division "1 / 0" yields infinite, and 5 is smaller than infinite) but will now return an error.
|
||||
- ``fish_clipboard_copy`` and ``fish_clipboard_paste`` can now be used in pipes (:issue:`9271`)::
|
||||
|
||||
git rev-list 3.5.1 | fish_clipboard_copy
|
||||
|
||||
fish_clipboard_paste | string join + | math
|
||||
|
||||
- ``status fish-path`` returns a fully-normalised path, particularly noticeable on NetBSD (:issue:`9085`).
|
||||
|
||||
Interactive improvements
|
||||
------------------------
|
||||
- If the terminal definition for :envvar:`TERM` can't be found, fish now tries using the "xterm-256color" and "xterm" definitions before "ansi" and "dumb". As the majority of terminal emulators in common use are now more or less xterm-compatible (often even explicitly claiming the xterm-256color entry), this should often result in a fully or almost fully usable terminal (:issue:`9026`).
|
||||
- A new variable, :envvar:`fish_cursor_selection_mode`, can be used to configure whether the command line selection includes the character under the cursor (``inclusive``) or not (``exclusive``). The new default is ``exclusive``; use ``set fish_cursor_selection_mode inclusive`` to get the previous behavior back (:issue:`7762`).
|
||||
- fish's completion pager now fills half the terminal on first tab press instead of only 4 rows, which should make results visible more often and save key presses, without constantly snapping fish to the top of the terminal (:issue:`9105`, :issue:`2698`).
|
||||
- The ``complete-and-search`` binding, used with :kbd:`Shift-Tab` by default, selects the first item in the results immediately (:issue:`9080`).
|
||||
- ``bind`` output is now syntax-highlighted when used interacively.
|
||||
- :kbd:`Alt-H` (the default ``__fish_man_page`` binding) does a better job of showing the manual page of the command under cursor (:issue:`9020`).
|
||||
- If :envvar:`fish_color_valid_path` contains an actual color instead of just modifiers, those will be used for valid paths even if the underlying color isn't "normal" (:issue:`9159`).
|
||||
- The key combination for the QUIT terminal sequence, often :kbd:`Control-Backslash` (``\x1c``), can now be sused as a binding (:issue:`9234`).
|
||||
- fish's vi mode uses normal xterm-style sequences to signal cursor change, instead of using the iTerm's proprietary escape sequences. This allows for a blinking cursor and makes it work in complicated scenarios with nested terminals. (:issue:`3741`, :issue:`9172`)
|
||||
- When running fish on a remote system (such as inside SSH or a container), :kbd:`Control-X` now copies to the local client system's clipboard if the terminal supports OSC 52.
|
||||
- ``commandline`` gained two new options, ``--selection-start`` and ``--selection-end``, to set the start/end of the current selection (:issue:`9197`, :issue:`9215`).
|
||||
- fish's builtins now handle keyboard interrupts (:kbd:`Control-C`) correctly (:issue:`9266`).
|
||||
|
||||
Completions
|
||||
^^^^^^^^^^^
|
||||
- Added completions for:
|
||||
|
||||
- ``ark``
|
||||
- ``asciinema`` (:issue:`9257`)
|
||||
- ``clojure`` (:issue:`9272`)
|
||||
- ``csh``
|
||||
- ``direnv`` (:issue:`9268`)
|
||||
- ``dive`` (:issue:`9082`)
|
||||
- ``dolphin``
|
||||
- ``dua`` (:issue:`9277`)
|
||||
- ``efivar`` (:issue:`9318`)
|
||||
- ``eg``
|
||||
- ``es`` (:issue:`9388`)
|
||||
- ``firefox-developer-edition`` and ``firefox`` (:issue:`9090`)
|
||||
- ``fortune`` (:issue:`9177`)
|
||||
- ``kb``
|
||||
- ``kind`` (:issue:`9110`)
|
||||
- ``konsole``
|
||||
- ``ksh``
|
||||
- ``loadkeys`` (:issue:`9312`)
|
||||
- ``okular``
|
||||
- ``op`` (:issue:`9300`)
|
||||
- ``ouch`` (:issue:`9405`)
|
||||
- ``pix``
|
||||
- ``readelf`` (:issue:`8746`, :issue:`9386`)
|
||||
- ``qshell``
|
||||
- ``rc``
|
||||
- ``sad`` (:issue:`9145`)
|
||||
- ``tcsh``
|
||||
- ``toot``
|
||||
- ``tox`` (:issue:`9078`)
|
||||
- ``wish``
|
||||
- ``xed``
|
||||
- ``xonsh`` (:issue:`9389`)
|
||||
- ``xplayer``
|
||||
- ``xreader``
|
||||
- ``xviewer``
|
||||
- ``yash`` (:issue:`9391`)
|
||||
- ``zig`` (:issue:`9083`)
|
||||
|
||||
- Improvements to many completions, including making ``cd`` completion much faster (:issue:`9220`).
|
||||
- Completion of tilde (``~``) works properly even when the file name contains an escaped character (:issue:`9073`).
|
||||
- fish no longer loads completions if the command is used via a relative path and is not in :envvar:`PATH` (:issue:`9133`).
|
||||
- fish no longer completes inside of comments (:issue:`9320`).
|
||||
|
||||
Improved terminal support
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
- Opening ``help`` on WSL now uses PowerShell to open the browser if available, removing some awkward UNC path errors (:issue:`9119`).
|
||||
|
||||
Other improvements
|
||||
------------------
|
||||
- The Web-based configuration tool now works on systems with IPv6 disabled (:issue:`3857`).
|
||||
- Aliases can ignore arguments by ending them with ``#`` (:issue:`9199`).
|
||||
- ``string`` is now faster when reading large strings from stdin (:issue:`9139`).
|
||||
- ``string repeat`` uses less memory and is faster. (:issue:`9124`)
|
||||
- Builtins are much faster when writing to a pipe or file. (:issue:`9229`).
|
||||
- Performance improvements to highlighting (:issue:`9180`) should make using fish more pleasant on slow systems.
|
||||
- On 32-bit systems, globs like ``*`` will no longer fail to return some files, as large file support has been enabled.
|
||||
|
||||
Fixed bugs
|
||||
----------
|
||||
- The history search text for a token search is now highlighted correctly if the line contains multiple instances of that text (:issue:`9066`).
|
||||
- ``process-exit`` and ``job-exit`` events are now generated for all background jobs, including those launched from event handlers (:issue:`9096`).
|
||||
- A crash when completing a token that contained both a potential glob and a quoted variable expansion was fixed (:issue:`9137`).
|
||||
- ``prompt_pwd`` no longer accidentally overwrites a global or universal ``$fish_prompt_pwd_full_dirs`` when called with the ``-d`` or ``--full-length-dirs`` option (:issue:`9123`).
|
||||
- A bug which caused fish to freeze or exit after running a command which does not preserve the foreground process group was fixed (:issue:`9181`).
|
||||
- The "Disco" sample prompt no longer prints an error in some working directories (:issue:`9164`). If you saved this prompt, you should run ``fish_config prompt save disco`` again.
|
||||
- fish launches external commands via the given path again, rather than always using an absolute path. This behaviour was inadvertently changed in 3.5.0 and is visible, for example, when launching a bash script which checks ``$0`` (:issue:`9143`).
|
||||
- ``printf`` no longer tries to interpret the first argument as an option (:issue:`9132`).
|
||||
- Interactive ``read`` in scripts will now have the correct keybindings again (:issue:`9227`).
|
||||
- A possible stack overflow when recursively evaluating substitutions has been fixed (:issue:`9302`).
|
||||
- A crash with relative $CDPATH has been fixed (:issue:`9407`).
|
||||
- ``printf`` now properly fills extra ``%d`` specifiers with 0 even on macOS and BSD (:issue:`9321`).
|
||||
- ``fish_key_reader`` now correctly exits when receiving a SIGHUP (like after closing the terminal) (:issue:`9309`).
|
||||
- ``fish_config theme save`` now works as documented instead of erroring out (:issue:`9088`, :issue:`9273`).
|
||||
- fish no longer triggers prompts to install command line tools when first run on macOS (:issue:`9343`).
|
||||
- ``fish_git_prompt`` now quietly fails on macOS if the xcrun cache is not yet populated (:issue:`6625`), working around a potential hang.
|
||||
|
||||
For distributors
|
||||
----------------
|
||||
- The vendored PCRE2 sources have been removed. It is recommended to declare PCRE2 as a dependency when packaging fish. If the CMake variable FISH_USE_SYSTEM_PCRE2 is false, fish will now download and build PCRE2 from the official repo (:issue:`8355`, :issue:`8363`). Note this variable defaults to true if PCRE2 is found installed on the system.
|
||||
|
||||
--------------
|
||||
|
||||
fish 3.5.1 (released July 20, 2022)
|
||||
===================================
|
||||
|
||||
This release of fish introduces the following small enhancements:
|
||||
|
||||
- Cursor shaping for Vi mode is enabled by default in tmux, and will be used if the outer terminal is capable (:issue:`8981`).
|
||||
- ``printf`` returns a better error when used with arguments interpreted as octal numbers (:issue:`9035`).
|
||||
- ``history merge`` when in private mode is now an error, rather than wiping out other sessions' history (:issue:`9050`).
|
||||
- The error message when launching a command that is built for the wrong architecture on macOS is more helpful (:issue:`9052`).
|
||||
- Added completions for:
|
||||
|
||||
- ``choose`` (:issue:`9065`)
|
||||
- ``expect`` (:issue:`9060`)
|
||||
- ``navi`` (:issue:`9064`)
|
||||
- ``qdbus`` (:issue:`9031`)
|
||||
- ``reflector`` (:issue:`9027`)
|
||||
|
||||
- Improvements to some completions.
|
||||
|
||||
This release also fixes a number of problems identified in fish 3.5.0.
|
||||
|
||||
- Completing ``git blame`` or ``git -C`` works correctly (:issue:`9053`).
|
||||
- On terminals that emit a ``CSI u`` sequence for :kbd:`Shift-Space`, fish inserts a space instead of printing an error. (:issue:`9054`).
|
||||
- ``status fish-path`` on Linux-based platforms could print the path with a " (deleted)" suffix (such as ``/usr/bin/fish (deleted)``), which is now removed (:issue:`9019`).
|
||||
- Cancelling an initial command (from fish's ``--init-command`` option) with :kbd:`Control-C` no longer prevents configuration scripts from running (:issue:`9024`).
|
||||
- The job summary contained extra blank lines if the prompt used multiple lines, which is now fixed (:issue:`9044`).
|
||||
- Using special input functions in bindings, in combination with ``and``/``or`` conditionals, no longer crashes (:issue:`9051`).
|
||||
|
||||
--------------
|
||||
|
||||
fish 3.5.0 (released June 16, 2022)
|
||||
===================================
|
||||
|
||||
Notable improvements and fixes
|
||||
------------------------------
|
||||
- A new ``path`` builtin command to filter and transform paths (:issue:`7659`, :issue:`8958`). For example, to list all the separate extensions used on files in /usr/share/man (after removing one extension, commonly a ".gz")::
|
||||
|
||||
path filter -f /usr/share/man/** | path change-extension '' | path extension | path sort -u
|
||||
- Tab (or any key bound to ``complete``) now expands wildcards instead of invoking completions, if there is a wildcard in the path component under the cursor (:issue:`954`, :issue:`8593`).
|
||||
- Scripts can now catch and handle the SIGINT and SIGTERM signals, either via ``function --on-signal`` or with ``trap`` (:issue:`6649`).
|
||||
|
||||
Deprecations and removed features
|
||||
---------------------------------
|
||||
- The ``stderr-nocaret`` feature flag, introduced in fish 3.0 and enabled by default in fish 3.1, has been made read-only.
|
||||
That means it is no longer possible to disable it, and code supporting the ``^`` redirection has been removed (:issue:`8857`, :issue:`8865`).
|
||||
|
||||
To recap: fish used to support ``^`` to redirect stderr, so you could use commands like::
|
||||
|
||||
test "$foo" -gt 8 ^/dev/null
|
||||
|
||||
to ignore error messages. This made the ``^`` symbol require escaping and quoting, and was a bit of a weird shortcut considering ``2>`` already worked, which is only one character longer.
|
||||
|
||||
So the above can simply become::
|
||||
|
||||
test "$foo" -gt 8 2>/dev/null
|
||||
|
||||
- The following feature flags have been enabled by default:
|
||||
|
||||
- ``regex-easyesc``, which makes ``string replace -r`` not do a superfluous round of unescaping in the replacement expression.
|
||||
That means e.g. to escape any "a" or "b" in an argument you can use ``string replace -ra '([ab])' '\\\\$1' foobar`` instead of needing 8 backslashes.
|
||||
|
||||
This only affects the *replacement* expression, not the *match* expression (the ``'([ab])'`` part in the example).
|
||||
A survey of plugins on GitHub did not turn up any affected code, so we do not expect this to affect many users.
|
||||
|
||||
This flag was introduced in fish 3.1.
|
||||
- ``ampersand-nobg-in-token``, which means that ``&`` will not create a background job if it occurs in the middle of a word. For example, ``echo foo&bar`` will print "foo&bar" instead of running ``echo foo`` in the background and then starting ``bar`` as a second job.
|
||||
|
||||
Reformatting with ``fish_indent`` would already introduce spaces, turning ``echo foo&bar`` into ``echo foo & bar``.
|
||||
|
||||
This flag was introduced in fish 3.4.
|
||||
|
||||
To turn off these flags, add ``no-regex-easyesc`` or ``no-ampersand-nobg-in-token`` to :envvar:`fish_features` and restart fish::
|
||||
|
||||
set -Ua fish_features no-regex-easyesc
|
||||
|
||||
Like ``stderr-nocaret``, they will eventually be made read-only.
|
||||
- Most ``string`` subcommands no longer append a newline to their input if the input didn't have one (:issue:`8473`, :issue:`3847`)
|
||||
- Fish's escape sequence removal (like for ``string length --visible`` or to figure out how wide the prompt is) no longer has special support for non-standard color sequences like from Data General terminals, e.g. the Data General Dasher D220 from 1984. This removes a bunch of work in the common case, allowing ``string length --visible`` to be much faster with unknown escape sequences. We don't expect anyone to have ever used fish with such a terminal (:issue:`8769`).
|
||||
- Code to upgrade universal variables from fish before 3.0 has been removed. Users who upgrade directly from fish versions 2.7.1 or before will have to set their universal variables & abbreviations again. (:issue:`8781`)
|
||||
- The meaning of an empty color variable has changed (:issue:`8793`). Previously, when a variable was set but empty, it would be interpreted as the "normal" color. Now, empty color variables cause the same effect as unset variables - the general highlighting variable for that type is used instead. For example::
|
||||
|
||||
set -g fish_color_command blue
|
||||
set -g fish_color_keyword
|
||||
|
||||
would previously make keywords "normal" (usually white in a dark terminal). Now it'll make them blue. To achieve the previous behavior, use the normal color explicitly: ``set -g fish_color_keyword normal``.
|
||||
|
||||
This makes it easier to make self-contained color schemes that don't accidentally use color that was set before.
|
||||
``fish_config`` has been adjusted to set known color variables that a theme doesn't explicitly set to empty.
|
||||
- ``eval`` is now a reserved keyword, so it can't be used as a function name. This follows ``set`` and ``read``, and is necessary because it can't be cleanly shadowed by a function - at the very least ``eval set -l argv foo`` breaks. Fish will ignore autoload files for it, so left over ``eval.fish`` from previous fish versions won't be loaded.
|
||||
- The git prompt in informative mode now defaults to skipping counting untracked files, as this was extremely slow. To turn it on, set :envvar:`__fish_git_prompt_showuntrackedfiles` or set the git config value "bash.showuntrackedfiles" to ``true`` explicitly (which can be done for individual repositories). The "informative+vcs" sample prompt already skipped display of untracked files, but didn't do so in a way that skipped the computation, so it should be quite a bit faster in many cases (:issue:`8980`).
|
||||
- The ``__terlar_git_prompt`` function, used by the "Terlar" sample prompt, has been rebuilt as a configuration of the normal ``fish_git_prompt`` to ease maintenance, improve performance and add features (like reading per-repo git configuration). Some slight changes remain; users who absolutely must have the same behavior are encouraged to copy the old function (:issue:`9011`, :issue:`7918`, :issue:`8979`).
|
||||
|
||||
Scripting improvements
|
||||
----------------------
|
||||
- Quoted command substitution that directly follow a variable expansion (like ``echo "$var$(echo x)"``) no longer affect the variable expansion (:issue:`8849`).
|
||||
- Fish now correctly expands command substitutions that are preceded by an escaped dollar (like ``echo \$(echo)``). This regressed in version 3.4.0.
|
||||
- ``math`` can now handle underscores (``_``) as visual separators in numbers (:issue:`8611`, :issue:`8496`)::
|
||||
|
||||
math 5 + 2_123_252
|
||||
|
||||
- ``math``'s ``min`` and ``max`` functions now take a variable number of arguments instead of always requiring 2 (:issue:`8644`, :issue:`8646`)::
|
||||
|
||||
> math min 8,2,4
|
||||
2
|
||||
|
||||
- ``read`` is now faster as the last process in a pipeline (:issue:`8552`).
|
||||
- ``string join`` gained a new ``--no-empty`` flag to skip empty arguments (:issue:`8774`, :issue:`8351`).
|
||||
- ``read`` now only triggers the ``fish_read`` event, not the ``fish_prompt`` event (:issue:`8797`). It was supposed to work this way in fish 3.2.0 and later, but both events were emitted.
|
||||
- The TTY modes are no longer restored when non-interactive shells exit. This fixes wrong tty modes in pipelines with interactive commands. (:issue:`8705`).
|
||||
- Some functions shipped with fish printed error messages to standard output, but they now they rightly go to standard error (:issue:`8855`).
|
||||
- ``jobs`` now correctly reports CPU usage as a percentage, instead of as a number of clock ticks (:issue:`8919`).
|
||||
- ``process-exit`` events now fire when the process exits even if the job has not yet exited, fixing a regression in 3.4.1 (:issue:`8914`).
|
||||
|
||||
Interactive improvements
|
||||
------------------------
|
||||
- Fish now reports a special error if a command wasn't found and there is a non-executable file by that name in :envvar:`PATH` (:issue:`8804`).
|
||||
- ``less`` and other interactive commands would occasionally be stopped when run in a pipeline with fish functions; this has been fixed (:issue:`8699`).
|
||||
- Case-changing autosuggestions generated mid-token now correctly append only the suffix, instead of duplicating the token (:issue:`8820`).
|
||||
- ``ulimit`` learned a number of new options for the resource limits available on Linux, FreeBSD ande NetBSD, and returns a specific warning if the limit specified is not available on the active operating system (:issue:`8823`, :issue:`8786`).
|
||||
- The ``vared`` command can now successfully edit variables named "tmp" or "prompt" (:issue:`8836`, :issue:`8837`).
|
||||
- ``time`` now emits an error if used after the first command in a pipeline (:issue:`8841`).
|
||||
- ``fish_add_path`` now prints a message for skipped non-existent paths when using the ``-v`` flag (:issue:`8884`).
|
||||
- Since fish 3.2.0, pressing :kbd:`Control-D` while a command is running would end up inserting a space into the next commandline, which has been fixed (:issue:`8871`).
|
||||
- A bug that caused multi-line prompts to be moved down a line when pasting or switching modes has been fixed (:issue:`3481`).
|
||||
- The Web-based configuration system no longer strips too many quotes in the abbreviation display (:issue:`8917`, :issue:`8918`).
|
||||
- Fish started with ``--no-config`` will now use the default keybindings (:issue:`8493`)
|
||||
- When fish inherits a :envvar:`USER` environment variable value that doesn't correspond to the current effective user ID, it will now correct it in all cases (:issue:`8879`, :issue:`8583`).
|
||||
- Fish sets a new :envvar:`EUID` variable containing the current effective user id (:issue:`8866`).
|
||||
- ``history search`` no longer interprets the search term as an option (:issue:`8853`)
|
||||
- The status message when a job terminates should no longer be erased by a multiline prompt (:issue:`8817`)
|
||||
|
||||
New or improved bindings
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
- The :kbd:`Alt-S` binding will now insert ``doas`` instead of ``sudo`` if necessary (:issue:`8942`).
|
||||
- The ``kill-whole-line`` special input function now kills the newline preceeding the last line. This makes ``dd`` in vi-mode clear the last line properly.
|
||||
- The new ``kill-inner-line`` special input function kills the line without any newlines, allowing ``cc`` in vi-mode to clear the line while preserving newlines (:issue:`8983`).
|
||||
- On terminals that emit special sequences for these combinations, :kbd:`Shift-Space` is bound like :kbd:`Space`, and :kbd:`Ctrl-Return` is bound like :kbd:`Return` (:issue:`8874`).
|
||||
|
||||
Improved prompts
|
||||
^^^^^^^^^^^^^^^^
|
||||
- A new ``Astronaut`` prompt (:issue:`8775`), a multi-line prompt using plain text reminiscent of the Starship.rs prompt.
|
||||
|
||||
Completions
|
||||
^^^^^^^^^^^
|
||||
- Added completions for:
|
||||
|
||||
- ``archlinux-java`` (:issue:`8911`)
|
||||
- ``apk`` (:issue:`8951`)
|
||||
- ``brightnessctl`` (:issue:`8758`)
|
||||
- ``efibootmgr`` (:issue:`9010`)
|
||||
- ``fastboot`` (:issue:`8904`)
|
||||
- ``optimus-manager`` (:issue:`8913`)
|
||||
- ``rclone`` (:issue:`8819`)
|
||||
- ``sops`` (:issue:`8821`)
|
||||
- ``tuned-adm`` (:issue:`8760`)
|
||||
- ``wg-quick`` (:issue:`8687`)
|
||||
|
||||
- ``complete`` can now be given multiple ``--condition`` options. They will be attempted in the order they were given, and only if all succeed will the completion be made available (as if they were connected with ``&&``). This helps with caching - fish's complete system stores the return value of each condition as long as the commandline doesn't change, so this can reduce the number of conditions that need to be evaluated (:issue:`8536`, :issue:`8967`).
|
||||
|
||||
Improved terminal support
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
- Working directory reporting is enabled for kitty (:issue:`8806`).
|
||||
- Changing the cursor shape is now enabled by default in iTerm2 (:issue:`3696`).
|
||||
|
||||
For distributors
|
||||
----------------
|
||||
- libatomic is now correctly detected as necessary when building on RISC-V (:issue:`8850`, :issue:`8851`).
|
||||
- In some cases, the build process found the wrong libintl on macOS. This has been corrected (:issue:`5244`).
|
||||
- The paths for completions, functions, and configuration snippets now include
|
||||
subdirectories ``fish/vendor_completions.d``, ``fish/vendor_functions.d``, and
|
||||
``fish/vendor_conf.d`` (respectively) within ``XDG_DATA_HOME`` (or ``~/.local/share``
|
||||
if not defined) (:issue:`8887`, :issue:`7816`).
|
||||
|
||||
--------------
|
||||
|
||||
fish 3.4.1 (released March 25, 2022)
|
||||
====================================
|
||||
|
||||
|
|
@ -2192,7 +1749,6 @@ Interactive improvements
|
|||
key both on its own and as part of a control sequence, was applied to
|
||||
all control characters; this has been reduced to just the escape key.
|
||||
- Completing a function shows the description properly (:issue:`5206`).
|
||||
- `commandline` can now be used to set the commandline for the next command, restoring a behavior in 3.4.1 (:issue:`8807`).
|
||||
- Added completions for
|
||||
|
||||
- ``ansible``, including ``ansible-galaxy``, ``ansible-playbook``
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
|||
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}")
|
||||
endif()
|
||||
|
||||
include(cmake/Rust.cmake)
|
||||
|
||||
# Error out when linking statically, it doesn't work.
|
||||
if (CMAKE_EXE_LINKER_FLAGS MATCHES ".*-static.*")
|
||||
message(FATAL_ERROR "Fish does not support static linking")
|
||||
|
|
@ -45,9 +43,6 @@ endif()
|
|||
# - address, because that occurs for our mkostemp check (weak-linking requires us to compare `&mkostemp == nullptr`).
|
||||
add_compile_options(-Wall -Wextra -Wno-comment -Wno-address)
|
||||
|
||||
# Get extra C++ files from Rust.
|
||||
get_property(FISH_EXTRA_SOURCES TARGET fish-rust PROPERTY fish_extra_cpp_files)
|
||||
|
||||
if ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"))
|
||||
add_compile_options(-Wunused-template -Wunused-local-typedef -Wunused-macros)
|
||||
endif()
|
||||
|
|
@ -58,15 +53,6 @@ add_compile_options(-fno-exceptions)
|
|||
# Undefine NDEBUG to keep assert() in release builds.
|
||||
add_definitions(-UNDEBUG)
|
||||
|
||||
# Allow including Rust headers in normal (not bindgen) builds.
|
||||
add_definitions(-DINCLUDE_RUST_HEADERS)
|
||||
|
||||
# Enable large files on GNU.
|
||||
add_definitions(-D_LARGEFILE_SOURCE
|
||||
-D_LARGEFILE64_SOURCE
|
||||
-D_FILE_OFFSET_BITS=64
|
||||
-D_ATFILE_SOURCE)
|
||||
|
||||
# Hide the CMake Rules directories in Xcode projects.
|
||||
source_group("CMake Rules" REGULAR_EXPRESSION "^$")
|
||||
|
||||
|
|
@ -99,34 +85,36 @@ endif()
|
|||
|
||||
# List of sources for builtin functions.
|
||||
set(FISH_BUILTIN_SRCS
|
||||
src/builtin.cpp src/builtins/argparse.cpp src/builtins/bind.cpp
|
||||
src/builtin.cpp src/builtins/argparse.cpp
|
||||
src/builtins/bg.cpp src/builtins/bind.cpp src/builtins/block.cpp
|
||||
src/builtins/builtin.cpp src/builtins/cd.cpp src/builtins/command.cpp
|
||||
src/builtins/commandline.cpp src/builtins/complete.cpp
|
||||
src/builtins/disown.cpp
|
||||
src/builtins/eval.cpp src/builtins/fg.cpp
|
||||
src/builtins/commandline.cpp src/builtins/complete.cpp src/builtins/contains.cpp
|
||||
src/builtins/disown.cpp src/builtins/echo.cpp src/builtins/emit.cpp
|
||||
src/builtins/eval.cpp src/builtins/exit.cpp src/builtins/fg.cpp
|
||||
src/builtins/function.cpp src/builtins/functions.cpp src/builtins/history.cpp
|
||||
src/builtins/jobs.cpp src/builtins/math.cpp src/builtins/printf.cpp src/builtins/path.cpp
|
||||
src/builtins/read.cpp src/builtins/set.cpp
|
||||
src/builtins/jobs.cpp src/builtins/math.cpp src/builtins/printf.cpp
|
||||
src/builtins/pwd.cpp src/builtins/random.cpp src/builtins/read.cpp
|
||||
src/builtins/realpath.cpp src/builtins/return.cpp src/builtins/set.cpp
|
||||
src/builtins/set_color.cpp src/builtins/source.cpp src/builtins/status.cpp
|
||||
src/builtins/string.cpp src/builtins/test.cpp src/builtins/type.cpp src/builtins/ulimit.cpp
|
||||
)
|
||||
src/builtins/wait.cpp)
|
||||
|
||||
# List of other sources.
|
||||
set(FISH_SRCS
|
||||
src/ast.cpp src/autoload.cpp src/color.cpp src/common.cpp src/complete.cpp
|
||||
src/env.cpp src/env_dispatch.cpp src/env_universal_common.cpp src/event.cpp
|
||||
src/exec.cpp src/expand.cpp src/fallback.cpp src/fish_version.cpp
|
||||
src/flog.cpp src/function.cpp src/highlight.cpp
|
||||
src/ast.cpp src/autoload.cpp src/color.cpp src/common.cpp src/complete.cpp src/env.cpp
|
||||
src/env_dispatch.cpp src/env_universal_common.cpp src/event.cpp src/exec.cpp
|
||||
src/expand.cpp src/fallback.cpp src/fd_monitor.cpp src/fish_version.cpp
|
||||
src/flog.cpp src/function.cpp src/future_feature_flags.cpp src/highlight.cpp
|
||||
src/history.cpp src/history_file.cpp src/input.cpp src/input_common.cpp
|
||||
src/io.cpp src/iothread.cpp src/kill.cpp
|
||||
src/intern.cpp src/io.cpp src/iothread.cpp src/job_group.cpp src/kill.cpp
|
||||
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/re.cpp src/reader.cpp src/screen.cpp
|
||||
src/signals.cpp src/termsize.cpp src/tinyexpr.cpp
|
||||
src/trace.cpp src/utf8.cpp
|
||||
src/wait_handle.cpp src/wcstringutil.cpp src/wgetopt.cpp src/wildcard.cpp
|
||||
src/wutil.cpp src/fds.cpp src/rustffi.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
|
||||
src/wutil.cpp src/fds.cpp
|
||||
)
|
||||
|
||||
# Header files are just globbed.
|
||||
|
|
@ -139,11 +127,6 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config_cmake.h.in
|
|||
${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
# Pull in our src directory for headers searches, but only quoted ones.
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -iquote ${CMAKE_CURRENT_SOURCE_DIR}/src")
|
||||
|
||||
|
||||
|
||||
# Set up standard directories.
|
||||
include(GNUInstallDirs)
|
||||
add_definitions(-D_UNICODE=1
|
||||
|
|
@ -186,10 +169,8 @@ endfunction(FISH_LINK_DEPS_AND_SIGN)
|
|||
add_library(fishlib STATIC ${FISH_SRCS} ${FISH_BUILTIN_SRCS})
|
||||
target_sources(fishlib PRIVATE ${FISH_HEADERS})
|
||||
target_link_libraries(fishlib
|
||||
fish-rust
|
||||
${CURSES_LIBRARY} ${CURSES_EXTRA_LIBRARY} Threads::Threads ${CMAKE_DL_LIBS}
|
||||
${PCRE2_LIB} ${Intl_LIBRARIES} ${ATOMIC_LIBRARY}
|
||||
"fish-rust")
|
||||
${PCRE2_LIB} ${Intl_LIBRARIES} ${ATOMIC_LIBRARY})
|
||||
target_include_directories(fishlib PRIVATE
|
||||
${CURSES_INCLUDE_DIRS})
|
||||
|
||||
|
|
|
|||
126
CONTRIBUTING.rst
126
CONTRIBUTING.rst
|
|
@ -10,40 +10,8 @@ In short:
|
|||
- Be conservative in what you need (``C++11``, few dependencies)
|
||||
- Use automated tools to help you (including ``make test``, ``build_tools/style.fish`` and ``make lint``)
|
||||
|
||||
Contributing completions
|
||||
------------------------
|
||||
|
||||
Completion scripts are the most common contribution to fish, and they are very welcome.
|
||||
|
||||
In general, we'll take all well-written completion scripts for a command that is publically available.
|
||||
This means no private tools or personal scripts, and we do reserve the right to reject for other reasons.
|
||||
|
||||
Before you try to contribute them to fish, consider if the authors of the tool you are completing want to maintain the script instead.
|
||||
Often that makes more sense, specifically because they can add new options to the script immediately once they add them,
|
||||
and don't have to maintain one completion script for multiple versions. If the authors no longer wish to maintain the script,
|
||||
they can of course always contact the fish maintainers to hand it over, preferably by opening a PR.
|
||||
This isn't a requirement - if the authors don't want to maintain it, or you simply don't want to contact them,
|
||||
you can contribute your script to fish.
|
||||
|
||||
Completion scripts should
|
||||
|
||||
1. Use as few dependencies as possible - try to use fish's builtins like ``string`` instead of ``grep`` and ``awk``,
|
||||
use ``python`` to read json instead of ``jq`` (because it's already a soft dependency for fish's tools)
|
||||
2. If it uses a common unix tool, use posix-compatible invocations - ideally it would work on GNU/Linux, macOS, the BSDs and other systems
|
||||
3. Option and argument descriptions should be kept short.
|
||||
The shorter the description, the more likely it is that fish can use more columns.
|
||||
4. Function names should start with ``__fish``, and functions should be kept in the completion file unless they're used elsewhere.
|
||||
5. Run ``fish_indent`` on your script.
|
||||
6. Try not to use minor convenience features right after they are available in fish - we do try to keep completion scripts backportable.
|
||||
If something has a real impact on the correctness or performance, feel free to use it,
|
||||
but if it is just a shortcut, please leave it.
|
||||
|
||||
Put your completion script into share/completions/name-of-command.fish. If you have multiple commands, you need multiple files.
|
||||
|
||||
If you want to add tests, you probably want to add a littlecheck test. See below for details.
|
||||
|
||||
Contributing to fish's C++ core
|
||||
-------------------------------
|
||||
General
|
||||
-------
|
||||
|
||||
Fish uses C++11. Newer C++ features should not be used to make it possible to use on older systems.
|
||||
|
||||
|
|
@ -53,23 +21,37 @@ Don't introduce new dependencies unless absolutely necessary, and if you do,
|
|||
please make it optional with graceful failure if possible.
|
||||
Add any new dependencies to the README.rst under the *Running* and/or *Building* sections.
|
||||
|
||||
Linters
|
||||
-------
|
||||
This also goes for completion scripts and functions - if at all possible, they should only use
|
||||
POSIX-compatible invocations of any tools, and no superfluous dependencies.
|
||||
|
||||
Automated analysis tools like cppcheck can point out
|
||||
E.g. some completions deal with JSON data. In those it's preferable to use python to handle it,
|
||||
as opposed to ``jq``, because fish already optionally uses python elsewhere. (It also happens to be quite a bit *faster*)
|
||||
|
||||
Lint Free Code
|
||||
--------------
|
||||
|
||||
Automated analysis tools like cppcheck and oclint can point out
|
||||
potential bugs or code that is extremely hard to understand. They also
|
||||
help ensure the code has a consistent style and that it avoids patterns
|
||||
that tend to confuse people.
|
||||
|
||||
To make linting the code easy there are two make targets: ``lint``,
|
||||
to lint any modified but not committed ``*.cpp`` files, and
|
||||
``lint-all`` to lint all files.
|
||||
To make linting the code easy there are two make targets: ``lint`` and
|
||||
``lint-all``. The latter does exactly what the name implies. The former
|
||||
will lint any modified but not committed ``*.cpp`` files. If there is no
|
||||
uncommitted work it will lint the files in the most recent commit.
|
||||
|
||||
Fish has custom cppcheck rules in the file ``.cppcheck.rule``. These
|
||||
help catch mistakes such as using ``wcwidth()`` rather than
|
||||
``fish_wcwidth()``. Please add a new rule if you find similar mistakes
|
||||
being made.
|
||||
|
||||
Dealing With Lint Warnings
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
You are strongly encouraged to address a lint warning by refactoring the
|
||||
code, changing variable names, or whatever action is implied by the
|
||||
warning.
|
||||
|
||||
Suppressing Lint Warnings
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
@ -91,20 +73,24 @@ following:
|
|||
|
||||
[src/complete.cpp:1727]: warning (nullPointerRedundantCheck): Either the condition 'cmd_node' is redundant or there is possible null pointer dereference: cmd_node.
|
||||
|
||||
Code Style
|
||||
----------
|
||||
Suppressing oclint warnings is more complicated to describe so I’ll
|
||||
refer you to the `OCLint
|
||||
HowTo <http://docs.oclint.org/en/latest/howto/suppress.html#annotations>`__
|
||||
on the topic.
|
||||
|
||||
To ensure your changes conform to the style rules run
|
||||
Ensuring Your Changes Conform to the Style Guides
|
||||
-------------------------------------------------
|
||||
|
||||
The following sections discuss the specific rules for the style that
|
||||
should be used when writing fish code. To ensure your changes conform to
|
||||
the style rules you simply need to run
|
||||
|
||||
::
|
||||
|
||||
build_tools/style.fish
|
||||
|
||||
before committing your change. That will run our autoformatters:
|
||||
|
||||
- ``git-clang-format`` for c++
|
||||
- ``fish_indent`` (shipped with fish) for fish script
|
||||
- ``black`` for python
|
||||
before committing your change. That will run ``git-clang-format`` to
|
||||
rewrite only the lines you’re modifying.
|
||||
|
||||
If you’ve already committed your changes that’s okay since it will then
|
||||
check the files in the most recent commit. This can be useful after
|
||||
|
|
@ -122,6 +108,31 @@ If you want to check the style of the entire code base run
|
|||
That command will refuse to restyle any files if you have uncommitted
|
||||
changes.
|
||||
|
||||
Configuring Your Editor for Fish C++ Code
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Vim
|
||||
^^^
|
||||
|
||||
As of Vim 7.4 it does not recognize triple-slash comments as used by
|
||||
Doxygen and the OS X Xcode IDE to flag comments that explain the
|
||||
following C symbol. This means the ``gq`` key binding to reformat such
|
||||
comments doesn’t behave as expected. You can fix that by adding the
|
||||
following to your vimrc:
|
||||
|
||||
::
|
||||
|
||||
autocmd Filetype c,cpp setlocal comments^=:///
|
||||
|
||||
If you use Vim I recommend the `vim-clang-format
|
||||
plugin <https://github.com/rhysd/vim-clang-format>`__ by
|
||||
[@rhysd](https://github.com/rhysd).
|
||||
|
||||
Emacs
|
||||
^^^^^
|
||||
|
||||
If you use Emacs: TBD
|
||||
|
||||
Configuring Your Editor for Fish Scripts
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
@ -158,6 +169,18 @@ made to run fish_indent via e.g.
|
|||
(add-hook 'fish-mode-hook (lambda ()
|
||||
(add-hook 'before-save-hook 'fish_indent-before-save)))
|
||||
|
||||
Suppressing Reformatting of C++ Code
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
You can tell ``clang-format`` to not reformat a block by enclosing it in
|
||||
comments like this:
|
||||
|
||||
::
|
||||
|
||||
// clang-format off
|
||||
code to ignore
|
||||
// clang-format on
|
||||
|
||||
Fish Script Style Guide
|
||||
-----------------------
|
||||
|
||||
|
|
@ -314,6 +337,8 @@ To install the lint checkers on Mac OS X using Homebrew:
|
|||
|
||||
::
|
||||
|
||||
brew tap oclint/formulae
|
||||
brew install oclint
|
||||
brew install cppcheck
|
||||
|
||||
To install the lint checkers on Debian-based Linux distributions:
|
||||
|
|
@ -321,6 +346,7 @@ To install the lint checkers on Debian-based Linux distributions:
|
|||
::
|
||||
|
||||
sudo apt-get install clang
|
||||
sudo apt-get install oclint
|
||||
sudo apt-get install cppcheck
|
||||
|
||||
Installing the Formatting Tools
|
||||
|
|
@ -420,8 +446,8 @@ Include What You Use
|
|||
You should not depend on symbols being visible to a ``*.cpp`` module
|
||||
from ``#include`` statements inside another header file. In other words
|
||||
if your module does ``#include "common.h"`` and that header does
|
||||
``#include "signals.h"`` your module should not assume the sub-include is
|
||||
present. It should instead directly ``#include "signals.h"`` if it needs
|
||||
``#include "signal.h"`` your module should not assume the sub-include is
|
||||
present. It should instead directly ``#include "signal.h"`` if it needs
|
||||
any symbol from that header. That makes the actual dependencies much
|
||||
clearer. It also makes it easy to modify the headers included by a
|
||||
specific header file without having to worry that will break any module
|
||||
|
|
|
|||
2
COPYING
2
COPYING
|
|
@ -1,7 +1,7 @@
|
|||
Fish is a smart and user-friendly command line shell.
|
||||
|
||||
Copyright (C) 2005-2009 Axel Liljencrantz
|
||||
Copyright (C) 2009-2023 fish-shell contributors
|
||||
Copyright (C) 2009-2022 fish-shell contributors
|
||||
|
||||
fish is free software.
|
||||
|
||||
|
|
|
|||
18
README.rst
18
README.rst
|
|
@ -1,8 +1,4 @@
|
|||
.. |Cirrus CI| image:: https://api.cirrus-ci.com/github/fish-shell/fish-shell.svg?branch=master
|
||||
:target: https://cirrus-ci.com/github/fish-shell/fish-shell
|
||||
:alt: Cirrus CI Build Status
|
||||
|
||||
`fish <https://fishshell.com/>`__ - the friendly interactive shell |Build Status| |Cirrus CI|
|
||||
`fish <https://fishshell.com/>`__ - the friendly interactive shell |Build Status|
|
||||
=================================================================================
|
||||
|
||||
fish is a smart and user-friendly command line shell for macOS, Linux,
|
||||
|
|
@ -10,7 +6,8 @@ and the rest of the family. fish includes features like syntax
|
|||
highlighting, autosuggest-as-you-type, and fancy tab completions that
|
||||
just work, with no configuration required.
|
||||
|
||||
For downloads, screenshots and more, go to https://fishshell.com/.
|
||||
For more on fish’s design philosophy, see the `design
|
||||
document <https://fishshell.com/docs/current/design.html>`__.
|
||||
|
||||
Quick Start
|
||||
-----------
|
||||
|
|
@ -37,8 +34,6 @@ fish can be installed:
|
|||
- using the `installer from fishshell.com <https://fishshell.com/>`__
|
||||
- as a `standalone app from fishshell.com <https://fishshell.com/>`__
|
||||
|
||||
Note: The minimum supported macOS version is 10.10 "Yosemite".
|
||||
|
||||
Packages for Linux
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
@ -100,7 +95,7 @@ Running fish requires:
|
|||
The following optional features also have specific requirements:
|
||||
|
||||
- builtin commands that have the ``--help`` option or print usage
|
||||
messages require ``nroff`` or ``mandoc`` for
|
||||
messages require ``ul`` and either ``nroff`` or ``mandoc`` for
|
||||
display
|
||||
- automated completion generation from manual pages requires Python 3.5+
|
||||
- the ``fish_config`` web configuration tool requires Python 3.5+ and a web browser
|
||||
|
|
@ -148,11 +143,10 @@ Dependencies
|
|||
|
||||
Compiling fish requires:
|
||||
|
||||
- Rust (version 1.67 or later)
|
||||
- a C++11 compiler (g++ 4.8 or later, or clang 3.3 or later)
|
||||
- CMake (version 3.5 or later)
|
||||
- a curses implementation such as ncurses (headers and libraries)
|
||||
- PCRE2 (headers and libraries) - optional, this will be downloaded if missing
|
||||
- PCRE2 (headers and libraries) - a copy is included with fish
|
||||
- gettext (headers and libraries) - optional, for translation support
|
||||
|
||||
Sphinx is also optionally required to build the documentation from a
|
||||
|
|
@ -178,8 +172,6 @@ The install directory can be changed using the
|
|||
Building from source (macOS) - Xcode
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Note: The minimum supported macOS version is 10.10 "Yosemite".
|
||||
|
||||
.. code:: bash
|
||||
|
||||
mkdir build; cd build
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
for i in (seq 1000)
|
||||
for i in (seq 2000)
|
||||
command true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@
|
|||
# so it's best to build two fishes, check out one version of the repo,
|
||||
# and then run this script with both.
|
||||
set -l dir (dirname (status current-filename))
|
||||
for i in (seq 1 10)
|
||||
for i in (seq 1 100)
|
||||
echo $dir/../../**
|
||||
end
|
||||
|
|
|
|||
|
|
@ -21,17 +21,6 @@ quote() {
|
|||
|
||||
for benchmark in "$BENCHMARKS_DIR"/*; do
|
||||
basename "$benchmark"
|
||||
# If we have hyperfine, use it first to warm up the cache
|
||||
if command -v hyperfine >/dev/null 2>&1; then
|
||||
cmd1="$(quote "${FISH_PATH}") --no-config $(quote "$benchmark")"
|
||||
if [ -n "$FISH2_PATH" ]; then
|
||||
cmd2="$(quote "${FISH2_PATH}") --no-config $(quote "$benchmark")"
|
||||
hyperfine --warmup 3 "$cmd1" "$cmd2"
|
||||
else
|
||||
hyperfine --warmup 3 "$cmd1"
|
||||
fi
|
||||
fi
|
||||
|
||||
[ -n "$FISH2_PATH" ] && echo "$FISH_PATH"
|
||||
"${FISH_PATH}" --print-rusage-self "$benchmark" > /dev/null
|
||||
if [ -n "$FISH2_PATH" ]; then
|
||||
|
|
@ -39,5 +28,14 @@ for benchmark in "$BENCHMARKS_DIR"/*; do
|
|||
"${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
|
||||
cmd2="$(quote "${FISH2_PATH}") $(quote "$benchmark") > /dev/null"
|
||||
hyperfine "$cmd1" "$cmd2"
|
||||
else
|
||||
hyperfine "$cmd1"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
|
|||
|
|
@ -9,26 +9,14 @@ set -e
|
|||
# Find the fish directory as two levels up from script directory.
|
||||
FISH_BASE_DIR="$( cd "$( dirname "$( dirname "$0" )" )" && pwd )"
|
||||
DEF_VER=unknown
|
||||
git_permission_failed=0
|
||||
|
||||
# First see if there is a version file (included in release tarballs),
|
||||
# then try git-describe, then default.
|
||||
if test -f version
|
||||
then
|
||||
VN=$(cat version) || VN="$DEF_VER"
|
||||
else
|
||||
if VN=$(git -C "$FISH_BASE_DIR" describe --always --dirty 2>/dev/null); then
|
||||
:
|
||||
else
|
||||
if test $? = 128; then
|
||||
# Current git versions return status 128
|
||||
# when run in a repo owned by another user.
|
||||
# Even for describe and everything.
|
||||
# This occurs for `sudo make install`.
|
||||
git_permission_failed=1
|
||||
fi
|
||||
VN="$DEF_VER"
|
||||
fi
|
||||
elif ! VN=$(git -C "$FISH_BASE_DIR" describe --always --dirty 2>/dev/null); then
|
||||
VN="$DEF_VER"
|
||||
fi
|
||||
|
||||
# If the first param is --stdout, then output to stdout and exit.
|
||||
|
|
@ -42,15 +30,6 @@ fi
|
|||
test -n "$1" && OUTPUT_DIR=$1/ || OUTPUT_DIR=
|
||||
FBVF="${OUTPUT_DIR}FISH-BUILD-VERSION-FILE"
|
||||
|
||||
if test "$VN" = unknown && test -r "$FBVF" && test "$git_permission_failed" = 1
|
||||
then
|
||||
# HACK: Git failed, so we keep the current version file.
|
||||
# This helps in case you built fish as a normal user
|
||||
# and then try to `sudo make install` it.
|
||||
date +%s > ${OUTPUT_DIR}fish-build-version-witness.txt
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if test -r "$FBVF"
|
||||
then
|
||||
VC=$(grep -v '^#' "$FBVF" | tr -d '"' | sed -e 's/^FISH_BUILD_VERSION=//')
|
||||
|
|
|
|||
|
|
@ -2,27 +2,10 @@
|
|||
# the version installed by HomeBrew doesn't have useful mappings for the
|
||||
# system provided headers. This also has mappings for FreeBSD.
|
||||
[
|
||||
{ include: ["<__functional_base>", private, "<functional>", public ] },
|
||||
{ include: ["<__mutex_base>", private, "<mutex>", public ] },
|
||||
{ include: ["@<__algorithm/.*>", "private", "<algorithm>", "public"] },
|
||||
{ include: ["@<__iterator/.*>", "private", "<iterator>", "public"] },
|
||||
{ include: ["@<__functional/.*>", "private", "<functional>", "public"] },
|
||||
{ include: ["@<__memory/.*>", "private", "<memory>", "public"] },
|
||||
{ include: ["@<__utility/.*>", "private", "<utility>", "public"] },
|
||||
{ include: ["@<__chrono/.*>", "private", "<chrono>", "public"] },
|
||||
{ include: ["@<__numeric/.*>", "private", "<numeric>", "public"] },
|
||||
{ include: ["@<__random/.*>", "private", "<random>", "public"] },
|
||||
{ include: ["@<__locale/.*>", "private", "<locale>", "public"] },
|
||||
{ include: ["@<xlocale/.*>", "private", "<xlocale.h>", "public"] },
|
||||
# ratio false positive. See https://groups.google.com/g/include-what-you-use/c/OKVkkWUlx44
|
||||
{ include: ["<ratio>", "public", "<chrono>", "public"] },
|
||||
{ include: ["<__locale>", "private", "<locale>", "public"] },
|
||||
{ include: ["<_ctype.h>", "private", "<ctype.h>", "public"] },
|
||||
{ include: ["<sys/_pthread/_pthread_once_t.h>", "private", "<pthread.h>", "public"] },
|
||||
{ include: ["<sys/_pthread/_pthread_mutex_t.h>", "private", "<pthread.h>", "public"] },
|
||||
{ include: ["<sys/_pthread/_pthread_rwlock_t.h>", "private", "<pthread.h>", "public"] },
|
||||
{ include: ["<sys/_pthread/_pthread_mutexattr_t.h>", "private", "<pthread.h>", "public"] },
|
||||
{ include: ["<sys/_pthread/_pthread_attr_t.h>", "private", "<pthread.h>", "public"] },
|
||||
{ include: ["<sys/_pthread/_pthread_cond_t.h>", "private", "<pthread.h>", "public"] },
|
||||
{ include: ["<sys/_pthread/_pthread_t.h>", "private", "<pthread.h>", "public"] },
|
||||
{ include: ["<sys/_pthread/_pthread_key_t.h>", "private", "<pthread.h>", "public"] },
|
||||
|
|
@ -37,7 +20,7 @@
|
|||
{ include: ["<sys/fcntl.h>", "private", "<fcntl.h>", "public"] },
|
||||
{ include: ["<sys/_types/_seek_set.h>", "private", "<fcntl.h>", "public"] },
|
||||
{ include: ["<sys/_types/_mbstate_t.h>", "private", "<wchar.h>", "public"] },
|
||||
{ include: ["<iosfwd>", "public", "<string>", "public"] },
|
||||
{ include: ["<iosfwd>", "private", "<string>", "public"] },
|
||||
{ include: ["<sys/_stdint.h>", "private", "<stdint.h>", "public"] },
|
||||
{ include: ["<sys/_types/_s_ifmt.h>", "private", "<sys/types.h>", "public"] },
|
||||
{ include: ["<sys/_types/_size_t.h>", "private", "<sys/types.h>", "public"] },
|
||||
|
|
@ -68,6 +51,7 @@
|
|||
{ include: ["<sys/_types/_va_list.h>", "private", "<sys/types.h>", "public"] },
|
||||
{ include: ["<sys/_types/_sigset_t.h>", "private", "<signal.h>", "public"] },
|
||||
{ include: ["<sys/signal.h>", "private", "<signal.h>", "public"] },
|
||||
{ include: ["<strings.h>", "private", "<string.h>", "public"] },
|
||||
{ include: ["<sys/termios.h>", "private", "<termios.h>", "public"] },
|
||||
{ include: ["<sys/_termios.h>", "private", "<termios.h>", "public"] },
|
||||
{ include: ["<sys/ttycom.h>", "private", "<termios.h>", "public"] },
|
||||
|
|
@ -77,7 +61,7 @@
|
|||
{ include: ["<sys/_types/_wint_t.h>", "private", "<stddef.h>", "public"] },
|
||||
{ include: ["<sys/_select.h>", "private", "<select.h>", "public"] },
|
||||
{ include: ["<sys/cdefs.h>", "private", "<unistd.h>", "public"] },
|
||||
{ include: ["<istream>", "public", "<iostream>", "public"] },
|
||||
{ include: ["<istream>", "private", "<iostream>", "public"] },
|
||||
{ include: ["<sys/_endian.h>", "private", "<netinet/in.h>", "public"] },
|
||||
{ include: ["<sys/_types/_timespec.h>", "private", "<time.h>", "public"] },
|
||||
{ include: ["<sys/_timespec.h>", "private", "<time.h>", "public"] },
|
||||
|
|
@ -86,30 +70,22 @@
|
|||
{ include: ["<__mutex_base>", "private", "<mutex>", "public"] },
|
||||
{ include: ["<__hash_table>", "private", "<unordered_map>", "public"] },
|
||||
{ include: ["<__hash_table>", "private", "<unordered_set>", "public"] },
|
||||
{ include: ['"../common.h"', "public", '"common.h"', "public"] },
|
||||
# We provide our own assert. including assert.h/cassert spoils it and redefines the macro
|
||||
{ symbol: ["assert", "private", '"common.h"', "public"] },
|
||||
{ symbol: ["assert", "private", '"../common.h"', "public"] },
|
||||
{ symbol: ["wcstring", "private", '"common.h"', "public"] },
|
||||
{ symbol: ["wcstring", "private", '"../common.h"', "public"] },
|
||||
{ symbol: ["wcstring_list_t", "private", '"common.h"', "public"] },
|
||||
{ symbol: ["wcstring_list_t", "private", '"../common.h"', "public"] },
|
||||
{ symbol: ["wcstring", "private", '"flog.h"', "public"] },
|
||||
{ symbol: ["wcstring_list_t", "private", '"flog.h"', "public"] },
|
||||
# { include: ["<>", "private", "<>", "public"] },
|
||||
|
||||
{ symbol: ["size_t", "private", "<cstddef>", "public"] },
|
||||
{ symbol: ["mutex", "private", "<mutex>", "public"] },
|
||||
{ symbol: ["sig_atomic_t", "private", "<csignal>", "public"] },
|
||||
{ symbol: ["va_end", "private", "<stdarg.h>", "public"] },
|
||||
{ symbol: ["va_list", "private", "<stdarg.h>", "public"] },
|
||||
{ symbol: ["va_start", "private", "<stdarg.h>", "public"] },
|
||||
{ symbol: ["NULL", "private", "<cstddef>", "public"] },
|
||||
{ symbol: ["NULL", "private", "<stddef.h>", "public"] },
|
||||
{ symbol: ["NULL", "private", "<stdlib.h>", "public"] },
|
||||
{ symbol: ["NULL", "private", "<stdio.h>", "public"] },
|
||||
{ symbol: ["NULL", "private", "<unistd.h>", "public"] },
|
||||
{ symbol: ["off_t", "private", "<unistd.h>", "public"] },
|
||||
{ symbol: ["off_t", "private", "<sys/types.h>", "public"] },
|
||||
{ symbol: ["size_t", "private", "<cstddef>", "public"] },
|
||||
{ symbol: ["ssize_t", "private", "<cstddef>", "public"] },
|
||||
{ symbol: ["size_t", "private", "<stddef.h>", "public"] },
|
||||
{ symbol: ["ssize_t", "private", "<stddef.h>", "public"] },
|
||||
{ symbol: ["intptr_t", "private", "<unistd.h>", "public"] },
|
||||
{ symbol: ["gid_t", "private", "<unistd.h>", "public"] },
|
||||
{ symbol: ["uid_t", "private", "<unistd.h>", "public"] },
|
||||
|
|
@ -118,54 +94,16 @@
|
|||
{ symbol: ["uid_t", "private", "<sys/types.h>", "public"] },
|
||||
{ symbol: ["gid_t", "private", "<sys/types.h>", "public"] },
|
||||
{ symbol: ["timeval", "private", "<sys/time.h>", "public"] },
|
||||
{ symbol: ["__uint32_t", "private", "<cstdint>", "public"] },
|
||||
{ symbol: ["uint32_t", "private", "<cstdint>", "public"] },
|
||||
{ symbol: ["intptr_t", "private", "<cstdint>", "public"] },
|
||||
{ symbol: ["__uint32_t", "private", "<stdint.h>", "public"] },
|
||||
{ symbol: ["uint32_t", "private", "<stdint.h>", "public"] },
|
||||
{ symbol: ["intptr_t", "private", "<stdint.h>", "public"] },
|
||||
{ symbol: ["tparm", "private", "<ncurses.h>", "public"] },
|
||||
{ symbol: ["tigetflag", "private", "<ncurses.h>", "public"] },
|
||||
{ symbol: ["ERR", "private", "<ncurses.h>", "public"] },
|
||||
{ symbol: ["OK", "private", "<ncurses.h>", "public"] },
|
||||
{ symbol: ["select", "private", "<sys/select.h>", "public"] },
|
||||
{ symbol: ["_LIBCPP_VERSION", "private", "<cstddef>", "public"] },
|
||||
{ symbol: ["_LIBCPP_VERSION", "private", "<stddef.h>", "public"] },
|
||||
{ symbol: ["_LIBCPP_VERSION", "private", "<unistd.h>", "public"] },
|
||||
{ symbol: ["MB_CUR_MAX", "private", "<cstdlib>", "public"] },
|
||||
{ symbol: ["MB_LEN_MAX", "private", "<cstdlib>", "public"] },
|
||||
{ symbol: ["WEOF", "private", "<cwctype>", "public"] },
|
||||
{ symbol: [ "std::declval", private, "<utility>", public ] },
|
||||
{ symbol: [ "std::forward", private, "<utility>", public ] },
|
||||
{ symbol: [ "std::move", private, "<utility>", public ] },
|
||||
{ symbol: [ "std::nullptr_t", private, "<cstddef>", public ] },
|
||||
{ symbol: [ "std::string", private, "<string>", public ] },
|
||||
{ symbol: [ "std::isalnum", private, "<locale>", public ] },
|
||||
{ symbol: [ "std::toupper", private, "<locale>", public ] },
|
||||
{ symbol: [ "sem_t", private, "<semaphore.h>", public ] },
|
||||
{ symbol: [ "sem_post", private, "<semaphore.h>", public ] },
|
||||
{ symbol: [ "sem_wait", private, "<semaphore.h>", public ] },
|
||||
{ symbol: [ "sem_init", private, "<semaphore.h>", public ] },
|
||||
{ symbol: [ "sem_destroy", private, "<semaphore.h>", public ] },
|
||||
{ symbol: [ "FD_SETSIZE", private, "<sys/select.h>", public ] },
|
||||
{ symbol: [ "locale_t", private, "<locale>", public ] },
|
||||
{ include: [ "<assert.h>", public, "<cassert>", public ] },
|
||||
{ include: [ "<complex.h>", public, "<ccomplex>", public ] },
|
||||
{ include: [ "<ctype.h>", public, "<cctype>", public ] },
|
||||
{ include: [ "<errno.h>", public, "<cerrno>", public ] },
|
||||
{ include: [ "<fenv.h>", public, "<cfenv>", public ] },
|
||||
{ include: [ "<float.h>", public, "<cfloat>", public ] },
|
||||
{ include: [ "<inttypes.h>", public, "<cinttypes>", public ] },
|
||||
{ include: [ "<iso646.h>", public, "<ciso646>", public ] },
|
||||
{ include: [ "<limits.h>", public, "<climits>", public ] },
|
||||
{ include: [ "<locale.h>", public, "<clocale>", public ] },
|
||||
{ include: [ "<math.h>", public, "<cmath>", public ] },
|
||||
{ include: [ "<setjmp.h>", public, "<csetjmp>", public ] },
|
||||
{ include: [ "<signal.h>", public, "<csignal>", public ] },
|
||||
{ include: [ "<stdalign.h>", public, "<cstdalign>", public ] },
|
||||
{ include: [ "<stdarg.h>", public, "<cstdarg>", public ] },
|
||||
{ include: [ "<stdbool.h>", public, "<cstdbool>", public ] },
|
||||
{ include: [ "<stddef.h>", public, "<cstddef>", public ] },
|
||||
{ include: [ "<stdlib.h>", public, "<cstdlib>", public ] },
|
||||
{ include: [ "<string.h>", public, "<cstring>", public ] },
|
||||
{ include: [ "<tgmath.h>", public, "<ctgmath>", public ] },
|
||||
{ include: [ "<time.h>", public, "<ctime>", public ] },
|
||||
{ include: [ "<uchar.h>", public, "<cuchar>", public ] },
|
||||
{ include: [ "<wchar.h>", public, "<cwchar>", public ] },
|
||||
{ include: [ "<wctype.h>", public, "<cwctype>", public ] },
|
||||
{ include: [ "<_xlocale.h>", private, "<xlocale.h>", public ] },
|
||||
|
||||
{ symbol: ["MB_CUR_MAX", "private", "<xlocale.h>", "public"] },
|
||||
{ symbol: ["MB_CUR_MAX", "private", "<stdlib.h>", "public"] },
|
||||
]
|
||||
|
|
|
|||
|
|
@ -96,6 +96,8 @@ def esc(m):
|
|||
map = {
|
||||
"\n": "\\n",
|
||||
"\\": "\\\\",
|
||||
"'": "\\'",
|
||||
'"': '\\"',
|
||||
"\a": "\\a",
|
||||
"\b": "\\b",
|
||||
"\f": "\\f",
|
||||
|
|
@ -200,7 +202,6 @@ class TestFailure(object):
|
|||
self.diff = diff
|
||||
self.lines = lines
|
||||
self.checks = checks
|
||||
self.signal = None
|
||||
|
||||
def message(self):
|
||||
fields = self.testrun.config.colors()
|
||||
|
|
@ -225,11 +226,6 @@ class TestFailure(object):
|
|||
)
|
||||
filemsg = "" if self.testrun.config.progress else " in {name}"
|
||||
fmtstrs = ["{RED}Failure{RESET}" + filemsg + ":", ""]
|
||||
if self.signal:
|
||||
fmtstrs += [
|
||||
" Process was killed by signal {BOLD}" + self.signal + "{RESET}",
|
||||
""
|
||||
]
|
||||
if self.line and self.check:
|
||||
fmtstrs += [
|
||||
" The {check_type} on line {input_lineno} wants:",
|
||||
|
|
@ -302,11 +298,11 @@ class TestFailure(object):
|
|||
)
|
||||
if b:
|
||||
bstr = (
|
||||
"on line "
|
||||
+ str(b.line.number)
|
||||
+ ": {BLUE}"
|
||||
"'{BLUE}"
|
||||
+ b.line.escaped_text(for_formatting=True)
|
||||
+ "{RESET}"
|
||||
+ "{RESET}'"
|
||||
+ " on line "
|
||||
+ str(b.line.number)
|
||||
)
|
||||
lastcheckline = b.line.number
|
||||
|
||||
|
|
@ -437,12 +433,6 @@ class TestRun(object):
|
|||
for i in checkq[::-1]:
|
||||
usedchecks.append(i)
|
||||
|
||||
# If we have no more output, there's no reason to give
|
||||
# SCREENFULS of text.
|
||||
# So we truncate the check list.
|
||||
if len(usedchecks) > len(usedlines):
|
||||
usedchecks = usedchecks[:len(usedlines) + 5]
|
||||
|
||||
# Do a SequenceMatch! This gives us a diff-like thing.
|
||||
diff = SequenceMatcher(a=usedlines, b=usedchecks, autojunk=False)
|
||||
# If there's a mismatch or still lines or checkers, we have a failure.
|
||||
|
|
@ -511,34 +501,7 @@ class TestRun(object):
|
|||
# Trim a trailing newline
|
||||
if outfail.error_annotation_lines[-1].text == "\n":
|
||||
del outfail.error_annotation_lines[-1]
|
||||
failure = outfail if outfail else errfail
|
||||
|
||||
if failure and status < 0:
|
||||
# Process was killed by a signal and failed,
|
||||
# add a message.
|
||||
import signal
|
||||
# Unfortunately strsignal only exists in python 3.8+,
|
||||
# and signal.signals is 3.5+.
|
||||
if hasattr(signal, "Signals"):
|
||||
try:
|
||||
sig = signal.Signals(-status)
|
||||
failure.signal = sig.name + " (" + signal.strsignal(sig.value) + ")"
|
||||
except ValueError:
|
||||
failure.signal = str(-status)
|
||||
else:
|
||||
# No easy way to get the full list,
|
||||
# make up a dict.
|
||||
signals = {
|
||||
signal.SIGABRT: "SIGABRT",
|
||||
signal.SIGBUS: "SIGBUS",
|
||||
signal.SIGFPE: "SIGFPE",
|
||||
signal.SIGILL: "SIGILL",
|
||||
signal.SIGSEGV: "SIGSEGV",
|
||||
signal.SIGTERM: "SIGTERM",
|
||||
}
|
||||
failure.signal = signals.get(-status, str(-status))
|
||||
|
||||
return failure
|
||||
return outfail if outfail else errfail
|
||||
|
||||
|
||||
class CheckCmd(object):
|
||||
|
|
@ -760,8 +723,6 @@ def main():
|
|||
subs["s"] = path
|
||||
starttime = datetime.datetime.now()
|
||||
ret = check_path(path, subs, config, TestFailure.print_message)
|
||||
if ret is SKIP:
|
||||
skip_count += 1
|
||||
if not ret:
|
||||
failed = True
|
||||
elif config.progress:
|
||||
|
|
@ -770,6 +731,7 @@ def main():
|
|||
reason = "ok"
|
||||
color = "{GREEN}"
|
||||
if ret is SKIP:
|
||||
skip_count += 1
|
||||
reason = "SKIPPED"
|
||||
color = "{BLUE}"
|
||||
print(
|
||||
|
|
|
|||
|
|
@ -1,22 +1,80 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Helper to notarize an .app.zip or .pkg file.
|
||||
# Based on https://www.logcg.com/en/archives/3222.html
|
||||
|
||||
set -e
|
||||
|
||||
die() { echo "$*" 1>&2 ; exit 1; }
|
||||
|
||||
check_status() {
|
||||
echo "STATUS" $1
|
||||
}
|
||||
|
||||
test "$#" -ge 1 || die "No paths specified."
|
||||
get_req_uuid() {
|
||||
RESPONSE=$(</dev/stdin)
|
||||
if echo "$RESPONSE" | egrep -q "RequestUUID"; then
|
||||
echo "$RESPONSE" | egrep RequestUUID | awk '{print $3'}
|
||||
elif echo "$RESPONSE" | egrep -q "The upload ID is "; then
|
||||
echo "$RESPONSE" | egrep -p "The upload ID is [-a-z0-9]+" | awk '{print $5}'
|
||||
else
|
||||
die "Could not get Request UUID"
|
||||
fi
|
||||
}
|
||||
|
||||
for INPUT in "$@"; do
|
||||
echo "Processing $INPUT"
|
||||
test -f "$INPUT" || die "Not a file: $INPUT"
|
||||
ext="${INPUT##*.}"
|
||||
(test "$ext" = "zip" || test "$ext" = "pkg") || die "Unrecognized extension: $ext"
|
||||
INPUT=$1
|
||||
AC_USER=$2
|
||||
|
||||
xcrun notarytool submit "$INPUT" --keychain-profile AC_PASSWORD --wait
|
||||
test -z "$AC_USER" && die "AC_USER not specified as second param"
|
||||
test -z "$INPUT" && die "No path specified"
|
||||
test -f "$INPUT" || die "Not a file: $INPUT"
|
||||
|
||||
ext="${INPUT##*.}"
|
||||
(test "$ext" = "zip" || test "$ext" = "pkg") || die "Unrecognized extension: $ext"
|
||||
|
||||
LOGFILE=$(mktemp -t mac_notarize_log)
|
||||
AC_PASS="@keychain:AC_PASSWORD"
|
||||
echo "Logs at $LOGFILE"
|
||||
|
||||
NOTARIZE_UUID=$(xcrun altool --notarize-app \
|
||||
--primary-bundle-id "com.ridiculousfish.fish-shell" \
|
||||
--username "$AC_USER" \
|
||||
--password "$AC_PASS" \
|
||||
--file "$INPUT" 2>&1 |
|
||||
tee -a "$LOGFILE" |
|
||||
get_req_uuid)
|
||||
|
||||
test -z "$NOTARIZE_UUID" && cat "$LOGFILE" && die "Could not get RequestUUID"
|
||||
echo "RequestUUID: $NOTARIZE_UUID"
|
||||
|
||||
# notarization-info doesn't always know about our request immediately.
|
||||
echo "Giving notarization-info a chance to catch up..."
|
||||
sleep 15
|
||||
|
||||
success=0
|
||||
for i in $(seq 20); do
|
||||
echo "Checking progress..."
|
||||
PROGRESS=$(xcrun altool --notarization-info "${NOTARIZE_UUID}" \
|
||||
-u "$AC_USER" \
|
||||
-p "$AC_PASS" 2>&1 |
|
||||
tee -a "$LOGFILE")
|
||||
echo "${PROGRESS}" | tail -n 1
|
||||
|
||||
if [ $? -ne 0 ] || [[ "${PROGRESS}" =~ "Invalid" ]] ; then
|
||||
echo "Error with notarization. Exiting"
|
||||
break
|
||||
fi
|
||||
|
||||
if ! [[ "${PROGRESS}" =~ "in progress" ]]; then
|
||||
success=1
|
||||
break
|
||||
else
|
||||
echo "Not completed yet. Sleeping for 30 seconds."
|
||||
fi
|
||||
sleep 30
|
||||
done
|
||||
|
||||
if [ $success -eq 1 ] ; then
|
||||
if test "$ext" = "zip"; then
|
||||
TMPDIR=$(mktemp -d)
|
||||
echo "Extracting to $TMPDIR"
|
||||
|
|
@ -37,9 +95,9 @@ for INPUT in "$@"; do
|
|||
cd "$(dirname "$STAPLE_TARGET")"
|
||||
zip -r -q "$INPUT_FULL" $(basename "$STAPLE_TARGET")
|
||||
fi
|
||||
echo "Processed $INPUT"
|
||||
fi
|
||||
echo "Processed $INPUT"
|
||||
|
||||
if test "$ext" = "zip"; then
|
||||
spctl -a -v "$STAPLE_TARGET"
|
||||
fi
|
||||
done
|
||||
if test "$ext" = "zip"; then
|
||||
spctl -a -v "$STAPLE_TARGET"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -27,10 +27,7 @@ SRC_DIR=$PWD
|
|||
OUTPUT_PATH=${FISH_ARTEFACT_PATH:-~/fish_built}
|
||||
|
||||
mkdir -p "$PKGDIR/build" "$PKGDIR/root" "$PKGDIR/intermediates" "$PKGDIR/dst"
|
||||
|
||||
# Pass FISH_USE_SYSTEM_PCRE2=OFF because a system PCRE2 on macOS will not be signed by fish,
|
||||
# and will probably not be built universal, so the package will fail to validate/run on other systems.
|
||||
{ cd "$PKGDIR/build" && cmake -DMAC_INJECT_GET_TASK_ALLOW=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_GETTEXT=OFF -DFISH_USE_SYSTEM_PCRE2=OFF -DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' -DMAC_CODESIGN_ID="${MAC_CODESIGN_ID}" "$SRC_DIR" && make VERBOSE=1 -j 12 && env DESTDIR="$PKGDIR/root/" make install; }
|
||||
{ cd "$PKGDIR/build" && cmake -DMAC_INJECT_GET_TASK_ALLOW=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_GETTEXT=OFF -DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' -DMAC_CODESIGN_ID="${MAC_CODESIGN_ID}" "$SRC_DIR" && make VERBOSE=1 -j 12 && env DESTDIR="$PKGDIR/root/" make install; }
|
||||
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"
|
||||
|
||||
|
|
@ -40,4 +37,4 @@ productsign --sign "${MAC_PRODUCTSIGN_ID}" "$OUTPUT_PATH/fish-$VERSION.pkg" "$OU
|
|||
# Make the app
|
||||
{ cd "$PKGDIR/build" && make -j 12 signed_fish_macapp && zip -r "$OUTPUT_PATH/fish-$VERSION.app.zip" fish.app; }
|
||||
|
||||
rm -rf "$PKGDIR"
|
||||
rm -r "$PKGDIR"
|
||||
|
|
|
|||
|
|
@ -14,14 +14,6 @@ set -e
|
|||
# but to get the documentation in, we need to make a symlink called "fish-VERSION"
|
||||
# and tar from that, so that the documentation gets the right prefix
|
||||
|
||||
# Use Ninja if available, as it automatically paralellises
|
||||
BUILD_TOOL="make"
|
||||
BUILD_GENERATOR="Unix Makefiles"
|
||||
if command -v ninja >/dev/null; then
|
||||
BUILD_TOOL="ninja"
|
||||
BUILD_GENERATOR="Ninja"
|
||||
fi
|
||||
|
||||
# We need GNU tar as that supports the --mtime and --transform options
|
||||
TAR=notfound
|
||||
for try in tar gtar gnutar; do
|
||||
|
|
@ -59,8 +51,8 @@ git archive --format=tar --prefix="$prefix"/ HEAD > "$path"
|
|||
PREFIX_TMPDIR=$(mktemp -d)
|
||||
cd "$PREFIX_TMPDIR"
|
||||
echo "$VERSION" > version
|
||||
cmake -G "$BUILD_GENERATOR" "$wd"
|
||||
$BUILD_TOOL doc
|
||||
cmake "$wd"
|
||||
make doc
|
||||
|
||||
TAR_APPEND="$TAR --append --file=$path --mtime=now --owner=0 --group=0 \
|
||||
--mode=g+w,a+rX --transform s/^/$prefix\//"
|
||||
|
|
|
|||
|
|
@ -48,13 +48,8 @@ def get_callsite():
|
|||
"""Return a triple (filename, line_number, line_text) of the call site location."""
|
||||
callstack = inspect.getouterframes(inspect.currentframe())
|
||||
for f in callstack:
|
||||
# Skip call sites from this file.
|
||||
if inspect.getmodule(f.frame) is Message.MODULE:
|
||||
continue
|
||||
# Skip functions which have a truthy callsite_skip attribute.
|
||||
if getattr(f.function, "callsite_skip", False):
|
||||
continue
|
||||
return (os.path.basename(f.filename), f.lineno, f.code_context)
|
||||
if inspect.getmodule(f.frame) is not Message.MODULE:
|
||||
return (os.path.basename(f.filename), f.lineno, f.code_context)
|
||||
return ("Unknown", -1, "")
|
||||
|
||||
|
||||
|
|
@ -341,25 +336,3 @@ class SpawnedProc(object):
|
|||
"LIGHTCYAN": ansic(96),
|
||||
"WHITE": ansic(97),
|
||||
}
|
||||
|
||||
|
||||
def control(char: str) -> str:
|
||||
""" Returns the char sent when control is pressed along the given key. """
|
||||
assert len(char) == 1
|
||||
char = char.lower()
|
||||
if ord("a") <= ord(char) <= ord("z"):
|
||||
return chr(ord(char) - ord("a") + 1)
|
||||
return chr({
|
||||
"@": 0,
|
||||
"`": 0,
|
||||
"[": 27,
|
||||
"{": 27,
|
||||
"\\": 28,
|
||||
"|": 28,
|
||||
"]": 29,
|
||||
"}": 29,
|
||||
"^": 30,
|
||||
"~": 30,
|
||||
"_": 31,
|
||||
"?": 127,
|
||||
}[char])
|
||||
|
|
|
|||
|
|
@ -23,11 +23,9 @@ if test $all = yes
|
|||
set -l files (git status --porcelain --short --untracked-files=all | sed -e 's/^ *[^ ]* *//')
|
||||
if set -q files[1]
|
||||
echo
|
||||
echo 'You have uncommitted changes. Are you sure you want to restyle?'
|
||||
read -P 'y/N? ' -n1 -l ans
|
||||
if not string match -qi "y" -- $ans
|
||||
exit 1
|
||||
end
|
||||
echo You have uncommitted changes. Cowardly refusing to restyle the entire code base.
|
||||
echo
|
||||
exit 1
|
||||
end
|
||||
set c_files src/*.h src/*.cpp src/*.c
|
||||
set fish_files share/**.fish
|
||||
|
|
@ -74,20 +72,13 @@ if set -q c_files[1]
|
|||
else if type -q clang-format
|
||||
echo === Running "$red"clang-format"$normal"
|
||||
for file in $c_files
|
||||
if clang-format --dry-run -Werror $file
|
||||
# file was clean, remove it from the list
|
||||
set -e c_files[(contains -i $file $c_files)]
|
||||
end
|
||||
end
|
||||
if set -q c_files[1]
|
||||
printf "Reformat those %d files?\n" (count $c_files)
|
||||
read -P 'y/N? ' -n1 -l ans
|
||||
if string match -qi "y" -- $ans
|
||||
clang-format -i --verbose $c_files
|
||||
else if string match -qi "n" -- $ans
|
||||
echo Skipping
|
||||
else # like they ctrl-C'd or something.
|
||||
exit 1
|
||||
cp $file $file.new # preserves mode bits
|
||||
clang-format $file >$file.new
|
||||
if cmp --quiet $file $file.new
|
||||
rm $file.new
|
||||
else
|
||||
echo $file was NOT correctly formatted
|
||||
mv $file.new $file
|
||||
end
|
||||
end
|
||||
else
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
# This is the case for at least Cygwin and Newlib.
|
||||
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE=1)
|
||||
include(CheckCXXCompilerFlag)
|
||||
include(CMakePushCheckState)
|
||||
|
||||
if(APPLE)
|
||||
check_cxx_compiler_flag("-Werror=unguarded-availability" REQUIRES_UNGUARDED_AVAILABILITY)
|
||||
|
|
@ -32,32 +31,6 @@ if (HAS_REDUNDANT_MOVE)
|
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wredundant-move")
|
||||
endif()
|
||||
|
||||
# Defeat bogus warnings about missing field initializers for `var{}` initialization.
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
cmake_push_check_state()
|
||||
list(APPEND CMAKE_REQUIRED_FLAGS "-W")
|
||||
check_cxx_source_compiles("
|
||||
struct sr_t { int x; };
|
||||
int main(void) {
|
||||
sr_t sr{};
|
||||
return sr.x;
|
||||
}"
|
||||
EMPTY_VALUE_INIT_ACCEPTED
|
||||
FAIL_REGEX "-Wmissing-field-initializers"
|
||||
)
|
||||
if (NOT EMPTY_VALUE_INIT_ACCEPTED)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers")
|
||||
endif()
|
||||
cmake_pop_check_state()
|
||||
endif()
|
||||
|
||||
# Disable static destructors if we can.
|
||||
check_cxx_compiler_flag("-fno-c++-static-destructors" DISABLE_STATIC_DESTRUCTORS)
|
||||
if (DISABLE_STATIC_DESTRUCTORS)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-c++-static-destructors")
|
||||
endif()
|
||||
|
||||
|
||||
# Try using CMake's own logic to locate curses/ncurses
|
||||
find_package(Curses)
|
||||
if(NOT ${CURSES_FOUND})
|
||||
|
|
@ -99,6 +72,7 @@ include(CheckIncludeFiles)
|
|||
include(CheckStructHasMember)
|
||||
include(CheckCXXSourceCompiles)
|
||||
include(CheckTypeSize)
|
||||
include(CMakePushCheckState)
|
||||
check_cxx_symbol_exists(backtrace_symbols execinfo.h HAVE_BACKTRACE_SYMBOLS)
|
||||
|
||||
# workaround for lousy mtime precision on a Linux kernel
|
||||
|
|
@ -115,6 +89,7 @@ check_struct_has_member("struct dirent" d_type dirent.h HAVE_STRUCT_DIRENT_D_TYP
|
|||
check_cxx_symbol_exists(dirfd "sys/types.h;dirent.h" HAVE_DIRFD)
|
||||
check_include_file_cxx(execinfo.h HAVE_EXECINFO_H)
|
||||
check_cxx_symbol_exists(flock sys/file.h HAVE_FLOCK)
|
||||
check_cxx_symbol_exists(getifaddrs ifaddrs.h HAVE_GETIFADDRS)
|
||||
check_cxx_symbol_exists(getpwent pwd.h HAVE_GETPWENT)
|
||||
check_cxx_symbol_exists(getrusage sys/resource.h HAVE_GETRUSAGE)
|
||||
check_cxx_symbol_exists(gettext libintl.h HAVE_GETTEXT)
|
||||
|
|
@ -152,12 +127,20 @@ 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)
|
||||
check_cxx_symbol_exists(wcscasecmp wchar.h HAVE_WCSCASECMP)
|
||||
check_cxx_symbol_exists(wcsdup wchar.h HAVE_WCSDUP)
|
||||
check_cxx_symbol_exists(wcslcpy wchar.h HAVE_WCSLCPY)
|
||||
check_cxx_symbol_exists(wcsncasecmp wchar.h HAVE_WCSNCASECMP)
|
||||
check_cxx_symbol_exists(wcsndup wchar.h HAVE_WCSNDUP)
|
||||
|
||||
# These are for compatibility with Solaris 10, which places the following
|
||||
# in the std namespace.
|
||||
if(NOT HAVE_WCSNCASECMP)
|
||||
check_cxx_symbol_exists(std::wcscasecmp wchar.h HAVE_STD__WCSCASECMP)
|
||||
endif()
|
||||
if(NOT HAVE_WCSDUP)
|
||||
check_cxx_symbol_exists(std::wcsdup wchar.h HAVE_STD__WCSDUP)
|
||||
endif()
|
||||
if(NOT HAVE_WCSNCASECMP)
|
||||
check_cxx_symbol_exists(std::wcsncasecmp wchar.h HAVE_STD__WCSNCASECMP)
|
||||
endif()
|
||||
|
||||
|
|
@ -173,9 +156,10 @@ check_cxx_symbol_exists(wcstod_l "${WCSTOD_L_INCLUDES}" HAVE_WCSTOD_L)
|
|||
check_cxx_symbol_exists(uselocale "locale.h;xlocale.h" HAVE_USELOCALE)
|
||||
|
||||
cmake_push_check_state()
|
||||
check_struct_has_member("struct winsize" ws_row "termios.h;sys/ioctl.h" _HAVE_WINSIZE)
|
||||
set(CMAKE_EXTRA_INCLUDE_FILES termios.h sys/ioctl.h)
|
||||
check_type_size("struct winsize" STRUCT_WINSIZE LANGUAGE CXX)
|
||||
check_cxx_symbol_exists("TIOCGWINSZ" "termios.h;sys/ioctl.h" HAVE_TIOCGWINSZ)
|
||||
if(_HAVE_WINSIZE EQUAL 1 AND HAVE_TIOCGWINSZ EQUAL 1)
|
||||
if(STRUCT_WINSIZE GREATER -1 AND HAVE_TIOCGWINSZ EQUAL 1)
|
||||
set(HAVE_WINSIZE 1)
|
||||
endif()
|
||||
cmake_pop_check_state()
|
||||
|
|
@ -267,29 +251,16 @@ int main () {
|
|||
check_cxx_source_compiles("
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
std::atomic<uint8_t> n8 (0);
|
||||
std::atomic<uint64_t> n64 (0);
|
||||
std::atomic<uint64_t> x (0);
|
||||
int main() {
|
||||
uint8_t i = n8.load(std::memory_order_relaxed);
|
||||
uint64_t j = n64.load(std::memory_order_relaxed);
|
||||
return std::atomic_is_lock_free(&n8)
|
||||
& std::atomic_is_lock_free(&n64);
|
||||
uint64_t i = x.load(std::memory_order_relaxed);
|
||||
return std::atomic_is_lock_free(&x);
|
||||
}"
|
||||
LIBATOMIC_NOT_NEEDED)
|
||||
IF (NOT LIBATOMIC_NOT_NEEDED)
|
||||
set(ATOMIC_LIBRARY "atomic")
|
||||
endif()
|
||||
|
||||
check_cxx_source_compiles("
|
||||
#include <sys/wait.h>
|
||||
|
||||
int main() {
|
||||
static_assert(WEXITSTATUS(0x007f) == 0x7f, \"This is our message we need to add because C++ is terrible\");
|
||||
return 0;
|
||||
}
|
||||
"
|
||||
HAVE_WAITSTATUS_SIGNAL_RET)
|
||||
|
||||
IF (APPLE)
|
||||
# Check if mbrtowc implementation attempts to encode invalid UTF-8 sequences
|
||||
# Known culprits: at least some versions of macOS (confirmed Snow Leopard and Yosemite)
|
||||
|
|
|
|||
|
|
@ -158,6 +158,8 @@ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/user_doc/html/ # Trailing slash is
|
|||
DESTINATION ${docdir} OPTIONAL)
|
||||
install(FILES CHANGELOG.rst DESTINATION ${docdir})
|
||||
|
||||
install(FILES share/lynx.lss DESTINATION ${rel_datadir}/fish/)
|
||||
|
||||
# These files are built by cmake/gettext.cmake, but using GETTEXT_PROCESS_PO_FILES's
|
||||
# INSTALL_DESTINATION leads to them being installed as ${lang}.gmo, not fish.mo
|
||||
# The ${languages} array comes from cmake/gettext.cmake
|
||||
|
|
|
|||
|
|
@ -28,44 +28,16 @@ else()
|
|||
endif()
|
||||
|
||||
set(FISH_USE_SYSTEM_PCRE2 ${USE_SYS_PCRE2_DEFAULT} CACHE BOOL
|
||||
"Use PCRE2 from the system, instead of fetching and building it")
|
||||
"Use PCRE2 from the system, instead of bundled with fish")
|
||||
|
||||
if(FISH_USE_SYSTEM_PCRE2)
|
||||
set(PCRE2_LIB "${SYS_PCRE2_LIB}")
|
||||
set(PCRE2_INCLUDE_DIR "${SYS_PCRE2_INCLUDE_DIR}")
|
||||
message(STATUS "Using system PCRE2 library ${PCRE2_INCLUDE_DIR}")
|
||||
else()
|
||||
include(FetchContent RESULT_VARIABLE HAVE_FetchContent)
|
||||
if (${HAVE_FetchContent} STREQUAL "NOTFOUND")
|
||||
message(FATAL_ERROR "Please install PCRE2 headers, or CMake >= 3.11 so I can download PCRE")
|
||||
endif()
|
||||
set(CMAKE_TLS_VERIFY true)
|
||||
set(PCRE2_REPO "https://github.com/PCRE2Project/pcre2.git")
|
||||
|
||||
message(STATUS "Fetching and configuring PCRE2 from ${PCRE2_REPO}")
|
||||
Set(FETCHCONTENT_QUIET FALSE)
|
||||
FetchContent_Declare(
|
||||
pcre2
|
||||
GIT_REPOSITORY ${PCRE2_REPO}
|
||||
GIT_TAG "72669190cb947f0cac1d038a8bb1820da59ef447" # tag: pcre2-10.36
|
||||
GIT_SHALLOW ON
|
||||
GIT_PROGRESS TRUE
|
||||
)
|
||||
# Don't try FetchContent_MakeAvailable, there's no way to add EXCLUDE_FROM_ALL
|
||||
# so we end up installing all of PCRE2 including its headers, man pages, etc.
|
||||
FetchContent_GetProperties(pcre2)
|
||||
if (NOT pcre2_POPULATED)
|
||||
# If GIT_WORK_TREE is set (by user or by git itself with e.g. git rebase), it
|
||||
# will override the git directory which CMake tries to apply in FetchContent_Populate,
|
||||
# resulting in a failed checkout.
|
||||
# Ensure it is not set.
|
||||
unset(ENV{GIT_WORK_TREE})
|
||||
unset(ENV{GIT_DIR})
|
||||
FetchContent_Populate(pcre2)
|
||||
add_subdirectory(${pcre2_SOURCE_DIR} ${pcre2_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
set(PCRE2_INCLUDE_DIR ${pcre2_BINARY_DIR})
|
||||
message(STATUS "Using bundled PCRE2 library")
|
||||
add_subdirectory(pcre2 EXCLUDE_FROM_ALL)
|
||||
set(PCRE2_INCLUDE_DIR ${CMAKE_BINARY_DIR}/pcre2)
|
||||
set(PCRE2_LIB pcre2-${PCRE2_WIDTH})
|
||||
|
||||
# Disable -Wunused-macros inside PCRE2, as it is noisy.
|
||||
|
|
|
|||
|
|
@ -1,59 +0,0 @@
|
|||
include(FetchContent)
|
||||
|
||||
# Don't let Corrosion's tests interfere with ours.
|
||||
set(CORROSION_TESTS OFF CACHE BOOL "" FORCE)
|
||||
|
||||
FetchContent_Declare(
|
||||
Corrosion
|
||||
GIT_REPOSITORY https://github.com/mqudsi/corrosion
|
||||
GIT_TAG fish
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(Corrosion)
|
||||
|
||||
set(fish_rust_target "fish-rust")
|
||||
|
||||
set(fish_autocxx_gen_dir "${CMAKE_BINARY_DIR}/fish-autocxx-gen/")
|
||||
|
||||
if(NOT DEFINED CARGO_FLAGS)
|
||||
# Corrosion doesn't like an empty string as FLAGS. This is basically a no-op alternative.
|
||||
# See https://github.com/corrosion-rs/corrosion/issues/356
|
||||
set(CARGO_FLAGS "--config" "foo=0")
|
||||
endif()
|
||||
if(DEFINED ASAN)
|
||||
list(APPEND CARGO_FLAGS "-Z" "build-std")
|
||||
endif()
|
||||
|
||||
corrosion_import_crate(
|
||||
MANIFEST_PATH "${CMAKE_SOURCE_DIR}/fish-rust/Cargo.toml"
|
||||
FEATURES "fish-ffi-tests"
|
||||
FLAGS "${CARGO_FLAGS}"
|
||||
)
|
||||
|
||||
# We need the build dir because cxx puts our headers in there.
|
||||
# Corrosion doesn't expose the build dir, so poke where we shouldn't.
|
||||
if (Rust_CARGO_TARGET)
|
||||
set(rust_target_dir "${CMAKE_BINARY_DIR}/cargo/build/${_CORROSION_RUST_CARGO_TARGET}")
|
||||
else()
|
||||
set(rust_target_dir "${CMAKE_BINARY_DIR}/cargo/build/${_CORROSION_RUST_CARGO_HOST_TARGET}")
|
||||
corrosion_set_hostbuild(${fish_rust_target})
|
||||
endif()
|
||||
|
||||
# Tell Cargo where our build directory is so it can find config.h.
|
||||
corrosion_set_env_vars(${fish_rust_target} "FISH_BUILD_DIR=${CMAKE_BINARY_DIR}" "FISH_AUTOCXX_GEN_DIR=${fish_autocxx_gen_dir}" "FISH_RUST_TARGET_DIR=${rust_target_dir}")
|
||||
|
||||
target_include_directories(${fish_rust_target} INTERFACE
|
||||
"${rust_target_dir}/cxxbridge/${fish_rust_target}/src/"
|
||||
"${fish_autocxx_gen_dir}/include/"
|
||||
)
|
||||
|
||||
# Tell fish what extra C++ files to compile.
|
||||
define_property(
|
||||
TARGET PROPERTY fish_extra_cpp_files
|
||||
BRIEF_DOCS "Extra C++ files to compile for fish."
|
||||
FULL_DOCS "Extra C++ files to compile for fish."
|
||||
)
|
||||
|
||||
set_property(TARGET ${fish_rust_target} PROPERTY fish_extra_cpp_files
|
||||
"${fish_autocxx_gen_dir}/cxx/gen0.cxx"
|
||||
)
|
||||
|
|
@ -159,7 +159,6 @@ foreach(CHECK ${FISH_CHECKS})
|
|||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests
|
||||
)
|
||||
set_tests_properties(${CHECK_NAME} PROPERTIES SKIP_RETURN_CODE ${SKIP_RETURN_CODE})
|
||||
set_tests_properties(${CHECK_NAME} PROPERTIES ENVIRONMENT FISH_FORCE_COLOR=1)
|
||||
add_test_target("${CHECK_NAME}")
|
||||
endforeach(CHECK)
|
||||
|
||||
|
|
@ -172,37 +171,5 @@ foreach(PEXPECT ${PEXPECTS})
|
|||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests
|
||||
)
|
||||
set_tests_properties(${PEXPECT} PROPERTIES SKIP_RETURN_CODE ${SKIP_RETURN_CODE})
|
||||
set_tests_properties(${PEXPECT} PROPERTIES ENVIRONMENT FISH_FORCE_COLOR=1)
|
||||
add_test_target("${PEXPECT}")
|
||||
endforeach(PEXPECT)
|
||||
|
||||
# Rust stuff.
|
||||
if(DEFINED ASAN)
|
||||
# Rust w/ -Zsanitizer=address requires explicitly specifying the --target triple or else linker
|
||||
# errors pertaining to asan symbols will ensue.
|
||||
if(NOT DEFINED Rust_CARGO_TARGET)
|
||||
message(FATAL_ERROR "ASAN requires defining the CMake variable Rust_CARGO_TARGET to the
|
||||
intended target triple")
|
||||
endif()
|
||||
set(cargo_target_opt "--target" ${Rust_CARGO_TARGET})
|
||||
endif()
|
||||
|
||||
# cargo-test is failing to link w/ ASAN enabled. For some reason it is picking up autocxx ffi
|
||||
# dependencies, even though `carg test` is supposed to be for rust-only code w/ no ffi dependencies.
|
||||
# TODO: Figure this out and fix it.
|
||||
if(NOT DEFINED ASAN)
|
||||
add_test(
|
||||
NAME "cargo-test"
|
||||
COMMAND cargo test ${CARGO_FLAGS} --target-dir target ${cargo_target_opt}
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/fish-rust"
|
||||
)
|
||||
set_tests_properties("cargo-test" PROPERTIES SKIP_RETURN_CODE ${SKIP_RETURN_CODE})
|
||||
add_test_target("cargo-test")
|
||||
endif()
|
||||
|
||||
add_test(
|
||||
NAME "cargo-test-widestring"
|
||||
COMMAND cargo test ${CARGO_FLAGS} --target-dir target ${cargo_target_opt}
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/fish-rust/widestring-suffix/"
|
||||
)
|
||||
add_test_target("cargo-test-widestring")
|
||||
|
|
|
|||
|
|
@ -4,22 +4,12 @@ include(FeatureSummary)
|
|||
|
||||
option(WITH_GETTEXT "translate messages if gettext is available" ON)
|
||||
if(WITH_GETTEXT)
|
||||
if(APPLE)
|
||||
# Fix for https://github.com/fish-shell/fish-shell/issues/5244
|
||||
# via https://gitlab.kitware.com/cmake/cmake/-/issues/18921
|
||||
set(CMAKE_FIND_FRAMEWORK_OLD ${CMAKE_FIND_FRAMEWORK})
|
||||
set(CMAKE_FIND_FRAMEWORK NEVER)
|
||||
endif()
|
||||
find_package(Intl QUIET)
|
||||
find_package(Gettext)
|
||||
if(GETTEXT_FOUND)
|
||||
set(HAVE_GETTEXT 1)
|
||||
include_directories(${Intl_INCLUDE_DIR})
|
||||
endif()
|
||||
if(APPLE)
|
||||
set(CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_OLD})
|
||||
unset(CMAKE_FIND_FRAMEWORK_OLD)
|
||||
endif()
|
||||
endif()
|
||||
add_feature_info(gettext GETTEXT_FOUND "translate messages with gettext")
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@
|
|||
/* Define to 1 if you have the `flock' function. */
|
||||
#cmakedefine HAVE_FLOCK 1
|
||||
|
||||
/* Define to 1 if you have the `getifaddrs' function. */
|
||||
#cmakedefine HAVE_GETIFADDRS 1
|
||||
|
||||
/* Define to 1 if you have the `getpwent' function. */
|
||||
#cmakedefine HAVE_GETPWENT 1
|
||||
|
||||
|
|
@ -61,6 +64,9 @@
|
|||
/* Define to 1 if you have the `std::wcscasecmp' function. */
|
||||
#cmakedefine HAVE_STD__WCSCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the `std::wcsdup' function. */
|
||||
#cmakedefine HAVE_STD__WCSDUP 1
|
||||
|
||||
/* Define to 1 if you have the `std::wcsncasecmp' function. */
|
||||
#cmakedefine HAVE_STD__WCSNCASECMP 1
|
||||
|
||||
|
|
@ -91,15 +97,21 @@
|
|||
/* Define to 1 if you have the `wcscasecmp' function. */
|
||||
#cmakedefine HAVE_WCSCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the `wcsdup' function. */
|
||||
#cmakedefine HAVE_WCSDUP 1
|
||||
|
||||
/* Define to 1 if you have the `wcslcpy' function. */
|
||||
#cmakedefine HAVE_WCSLCPY 1
|
||||
|
||||
/* Define to 1 if you have the `wcsncasecmp' function. */
|
||||
#cmakedefine HAVE_WCSNCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the `wcsndup' function. */
|
||||
#cmakedefine HAVE_WCSNDUP 1
|
||||
|
||||
/* Define to 1 if you have the `wcstod_l' function. */
|
||||
#cmakedefine HAVE_WCSTOD_L 1
|
||||
|
||||
/* Define to 1 if the status that wait returns and WEXITSTATUS expects is signal and then ret instead of the other way around. */
|
||||
#cmakedefine HAVE_WAITSTATUS_SIGNAL_RET 1
|
||||
|
||||
/* Define to 1 if the winsize struct and TIOCGWINSZ macro exist */
|
||||
#cmakedefine HAVE_WINSIZE 1
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ Uploaders: David Adam <zanchey@ucc.gu.uwa.edu.au>
|
|||
# Debhelper should be bumped to >= 10 once Ubuntu Xenial is no longer supported
|
||||
Build-Depends: debhelper (>= 9.20160115), libncurses5-dev, cmake (>= 3.5.0), gettext, libpcre2-dev,
|
||||
# Test dependencies
|
||||
locales-all, python3, rustc (>= 1.67) | rustc-mozilla (>= 1.67)
|
||||
locales-all, python3
|
||||
Standards-Version: 4.1.5
|
||||
Homepage: https://fishshell.com/
|
||||
Vcs-Git: https://github.com/fish-shell/fish-shell.git
|
||||
|
|
@ -15,7 +15,7 @@ Vcs-Browser: https://github.com/fish-shell/fish-shell
|
|||
Package: fish
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, passwd (>= 4.0.3-10), gettext-base, man-db,
|
||||
procps, python3 (>=3.5)
|
||||
python3 (>=3.5)
|
||||
Conflicts: fish-common
|
||||
Recommends: xsel (>=1.2.0)
|
||||
Suggests: xdg-utils
|
||||
|
|
|
|||
|
|
@ -1,79 +0,0 @@
|
|||
These is a proposed port of fish-shell from C++ to Rust, and from CMake to cargo or related. This document is high level - see the [Development Guide] for more details.
|
||||
|
||||
## Why Port
|
||||
|
||||
- Gain access to more contributors and enable easier contributions. C++ is becoming a legacy language.
|
||||
- Free us from the annoyances of C++/CMake, and old toolchains.
|
||||
- Ensure fish continues to be perceived as modern and relevant.
|
||||
- Unlock concurrent mode (see below).
|
||||
|
||||
## Why Rust
|
||||
|
||||
- Rust is a systems programming language with broad platform support, a large community, and a relatively high probability of still being relevant in a decade.
|
||||
- Rust has a unique strength in its thread safety features, which is the missing piece to enable concurrent mode - see below.
|
||||
- Other languages considered:
|
||||
- Java, Python and the scripting family are ruled out for startup latency and memory usage reasons.
|
||||
- Go would be an awkward fit. fork is [quite the problem](https://stackoverflow.com/questions/28370646/how-do-i-fork-a-go-process/28371586#28371586) in Go.
|
||||
- Other system languages (D, Nim, Zig...) are too niche: fewer contributors, higher risk of the language becoming irrelevant.
|
||||
|
||||
## Risks
|
||||
|
||||
- Large amount of work with possible introduction of new bugs.
|
||||
- Long period of complicated builds.
|
||||
- Existing contributors will have to learn Rust.
|
||||
- As of yet unknown compatibility story for Tier 2+ platforms (Cygwin, etc).
|
||||
|
||||
## Approach
|
||||
|
||||
We will do an **incremental port** in the span of one release. We will have a period of using both C++ and Rust, and both cargo and CMake, leveraging FFI tools (see below).
|
||||
|
||||
The work will **proceed on master**: no long-lived branches. Tests and CI continue to pass at every commit for recent Linux and Mac. Centos7, \*BSD, etc may be temporarily disabled if they prove problematic.
|
||||
|
||||
The Rust code will initially resemble the replaced C++. Fidelity to existing code is more important than Rust idiomaticity, to aid review and bisecting. But don't take this to extremes - use judgement.
|
||||
|
||||
The port will proceed "outside in." We'll start with leaf components (e.g. builtins) and proceed towards the core. Some components will have both a Rust and C++ implementation (e.g. FLOG), in other cases we'll change the existing C++ to invoke the new Rust implementations (builtins).
|
||||
|
||||
After porting the C++, we'll replace CMake.
|
||||
|
||||
We will continue to use wide chars, locales, gettext, printf format strings, and PCRE2. We will not change the fish scripting language at all. We will _not_ use this as an opportunity to fix existing design flaws, with a few carefully chosen exceptions. See [Strings](#strings).
|
||||
|
||||
We will not use tokio, serde, async, or other fancy Rust frameworks initially.
|
||||
|
||||
### FFI
|
||||
|
||||
Rust/C++ interop will use [autocxx](https://github.com/google/autocxx), [Cxx](https://cxx.rs), and possibly [bindgen](https://rust-lang.github.io/rust-bindgen/). I've forked these for fish (see the [Development Guide]). Once the port is done, we will stop using them, except perhaps bindgen for PCRE2.
|
||||
|
||||
We will use [corrosion](https://github.com/corrosion-rs/corrosion) for CMake integration.
|
||||
|
||||
Inefficiencies (e.g. extra string copying) at the FFI layer are fine, since it will all get thrown away.
|
||||
|
||||
Tests can stay in fish_tests.cpp or be moved into Rust .rs files; either is fine.
|
||||
|
||||
### Strings
|
||||
|
||||
Rust's `String` / `&str` types cannot represent non-UTF8 filenames or data using the default encoding scheme. That's why all string conversions must go through fish's encoding scheme (using the private-use area to encode invalid sequences). For example, fish cannot use `File::open` with a `&str` because the decoding will be incorrect.
|
||||
|
||||
So instead of `String`, fish will use its own string type, and manage encoding and decoding as it does today. However we will make some specific changes:
|
||||
|
||||
1. Drop the nul-terminated requirement. When passing `const wchar_t*` back to C++, we will allocate and copy into a nul-terminated buffer.
|
||||
2. Drop support for 16-bit wchar. fish will use UTF32 on all platforms, and manage conversions itself.
|
||||
|
||||
After the port we can consider moving to UTF-8, for memory usage reasons.
|
||||
|
||||
See the [Rust Development Guide][Development Guide] for more on strings.
|
||||
|
||||
### Thread Safety
|
||||
|
||||
Allowing [background functions](https://github.com/fish-shell/fish-shell/issues/238) and concurrent functions has been a goal for many years. I have been nursing [a long-lived branch](https://github.com/ridiculousfish/fish-shell/tree/concurrent_even_simpler) which allows full threaded execution. But though the changes are small, I have been reluctant to propose them, because they will make reasoning about the shell internals too complex: it is difficult in C++ to check and enforce what crosses thread boundaries.
|
||||
|
||||
This is Rust's bread and butter: we will encode thread requirements into our types, making it explicit and compiler-checked, via Send and Sync. Rust will allow turning on concurrent mode in a safe way, with a manageable increase in complexity, finally enabling this feature.
|
||||
|
||||
## Timeline
|
||||
|
||||
Handwaving, 6 months? Frankly unknown - there's 102 remaining .cpp files of various lengths. It'll go faster as we get better at it. Peter (ridiculous_fish) is motivated to work on this, other current contributors have some Rust as well, and we may also get new contributors from the Rust community. Part of the point is to make contribution easier.
|
||||
|
||||
## Links
|
||||
|
||||
- [Packaging Rust projects](https://wiki.archlinux.org/title/Rust_package_guidelines) from Arch Linux
|
||||
|
||||
[Development Guide]: rust-devel.md
|
||||
|
|
@ -1,173 +0,0 @@
|
|||
# fish-shell Rust Development Guide
|
||||
|
||||
This describes how to get started building fish-shell in its partial Rust state, and how to contribute to the port.
|
||||
|
||||
## Overview
|
||||
|
||||
fish is in the process of transitioning from C++ to Rust. The fish project has a Rust crate embedded at path `fish-rust`. This crate builds a Rust library `libfish_rust.a` which is linked with the C++ `libfish.a`. Existing C++ code will be incrementally migrated to this crate; then CMake will be replaced with cargo and other Rust-native tooling.
|
||||
|
||||
Important tools used during this transition:
|
||||
|
||||
1. [Corrosion](https://github.com/corrosion-rs/corrosion) to invoke cargo from CMake.
|
||||
2. [cxx](http://cxx.rs) for basic C++ <-> Rust interop.
|
||||
3. [autocxx](https://google.github.io/autocxx/) for using C++ types in Rust.
|
||||
|
||||
We use forks of the last two - see the [FFI section](#ffi) below. No special action is required to obtain these packages. They're downloaded by cargo.
|
||||
|
||||
## Building
|
||||
|
||||
### Build Dependencies
|
||||
|
||||
fish-shell currently depends on Rust 1.67 or later. To install Rust, follow https://rustup.rs.
|
||||
|
||||
### Build via CMake
|
||||
|
||||
It is recommended to build inside `fish-shell/build`. This will make it easier for Rust to find the `config.h` file.
|
||||
|
||||
Build via CMake as normal (use any generator, here we use Ninja):
|
||||
|
||||
```shell
|
||||
$ cd fish-shell
|
||||
$ mkdir build && cd build
|
||||
$ cmake -G Ninja ..
|
||||
$ ninja
|
||||
```
|
||||
|
||||
This will create the usual fish executables.
|
||||
|
||||
### Build just libfish_rust.a with Cargo
|
||||
|
||||
The directory `fish-rust` contains the Rust sources. These require that CMake has been run to produce `config.h` which is necessary for autocxx to succeed.
|
||||
|
||||
Follow the "Build from CMake" steps above, and then:
|
||||
|
||||
```shell
|
||||
$ cd fish-shell/fish-rust
|
||||
$ cargo build
|
||||
```
|
||||
|
||||
This will build only the library, not a full working fish, but it allows faster iteration for Rust development. That is, after running `cmake` you can open the `fish-rust` as the root of a Rust crate, and tools like rust-analyzer will work.
|
||||
|
||||
## Development
|
||||
|
||||
The basic development loop for this port:
|
||||
|
||||
1. Pick a .cpp (or in some cases .h) file to port, say `util.cpp`.
|
||||
2. Add the corresponding `util.rs` file to `fish-rust/`.
|
||||
3. Reimplement it in Rust, along with its dependencies as needed. Match the existing C++ code where practical, including propagating any relevant comments.
|
||||
- Do this even if it results in less idiomatic Rust, but avoid being super-dogmatic either way.
|
||||
- One technique is to paste the C++ into the Rust code, commented out, and go line by line.
|
||||
4. Decide whether any existing C++ callers should invoke the Rust implementation, or whether we should keep the C++ one.
|
||||
- Utility functions may have both a Rust and C++ implementation. An example is `FLOG` where interop is too hard.
|
||||
- Major components (e.g. builtin implementations) should _not_ be duplicated; instead the Rust should call C++ or vice-versa.
|
||||
5. Remember to run `cargo fmt` and `cargo clippy` to keep the codebase somewhat clean (otherwise CI will fail). If you use rust-analyzer, you can run clippy automatically by setting `rust-analyzer.checkOnSave.command = "clippy"`.
|
||||
|
||||
You will likely run into limitations of [`autocxx`](https://google.github.io/autocxx/) and to a lesser extent [`cxx`](https://cxx.rs/). See the [FFI sections](#ffi) below.
|
||||
|
||||
## Type Mapping
|
||||
|
||||
### Constants & Type Aliases
|
||||
|
||||
The FFI does not support constants (`#define` or `static const`) or type aliases (`typedef`, `using`). Duplicate them using their Rust equivalent (`pub const` and `type`/`struct`/`enum`).
|
||||
|
||||
### Non-POD types
|
||||
|
||||
Many types cannot currently be passed across the language boundary by value or occur in shared structs. As a workaround, use references, raw pointers or smart pointers (`cxx` provides `SharedPtr` and `UniquePtr`). Try to keep workarounds on the C++ side and the FFI layer of the Rust code. This ensures we will get rid of the workarounds as we peel off the FFI layer.
|
||||
|
||||
### Strings
|
||||
|
||||
Fish will mostly _not_ use Rust's `String/&str` types as these cannot represent non-UTF8 data using the default encoding.
|
||||
|
||||
fish's primary string types will come from the [`widestring` crate](https://docs.rs/widestring). The two main string types are `WString` and `&wstr`, which are renamed [Utf32String](https://docs.rs/widestring/latest/widestring/utfstring/struct.Utf32String.html) and [Utf32Str](https://docs.rs/widestring/latest/widestring/utfstr/struct.Utf32Str.html). `WString` is an owned, heap-allocated UTF32 string, `&wstr` a borrowed UTF32 slice.
|
||||
|
||||
In general, follow this mapping when porting from C++:
|
||||
|
||||
- `wcstring` -> `WString`
|
||||
- `const wcstring &` -> `&wstr`
|
||||
- `const wchar_t *` -> `&wstr`
|
||||
|
||||
None of the Rust string types are nul-terminated. We're taking this opportunity to drop the nul-terminated aspect of wide string handling.
|
||||
|
||||
#### Creating strings
|
||||
|
||||
One may create a `&wstr` from a string literal using the `wchar::L!` macro:
|
||||
|
||||
```rust
|
||||
use crate::wchar::{wstr, L!}
|
||||
|
||||
fn get_shell_name() -> &'static wstr {
|
||||
L!("fish")
|
||||
}
|
||||
```
|
||||
|
||||
There is also a `widestrs` proc-macro which enables L as a _suffix_, to reduce the noise. This can be applied to any block, including modules and individual functions:
|
||||
|
||||
```rust
|
||||
use crate::wchar::{wstr, widestrs}
|
||||
|
||||
#[widestrs]
|
||||
fn get_shell_name() -> &'static wstr {
|
||||
"fish"L // equivalent to L!("fish")
|
||||
}
|
||||
```
|
||||
|
||||
### Strings for FFI
|
||||
|
||||
`WString` and `&wstr` are the common strings used by Rust components. At the FII boundary there are some additional strings for interop. _All of these are temporary for the duration of the port._
|
||||
|
||||
- `CxxWString` is the Rust binding of `std::wstring`. It is the wide-string analog to [`CxxString`](https://cxx.rs/binding/cxxstring.html) and is [added in our fork of cxx](https://github.com/ridiculousfish/cxx/blob/fish/src/cxx_wstring.rs). This is useful for functions which return e.g. `const wcstring &`.
|
||||
- `W0String` is renamed [U32CString](https://docs.rs/widestring/latest/widestring/ucstring/struct.U32CString.html). This is basically `WString` except it _is_ nul-terminated. This is useful for getting a nul-terminated `const wchar_t *` to pass to C++ implementations.
|
||||
- `wcharz_t` is an annoying C++ struct which merely wraps a `const wchar_t *`, used for passing these pointers from C++ to Rust. We would prefer to use `const wchar_t *` directly but `autocxx` refuses to generate bindings for types such as `std::vector<const wchar_t *>` so we wrap it in this silly struct.
|
||||
|
||||
Note C++ `wchar_t`, Rust `char`, and `u32` are effectively interchangeable: you can cast pointers to them back and forth (except we check upon u32->char conversion). However be aware of which types are nul-terminated.
|
||||
|
||||
These types should be confined to the FFI modules, in particular `wchar_ffi`. They should not "leak" into other modules. See the `wchar_ffi` module.
|
||||
|
||||
### Format strings
|
||||
|
||||
Rust's builtin `std::fmt` modules do not accept runtime-provided format strings, so we mostly won't use them, except perhaps for FLOG / other non-translated text.
|
||||
|
||||
Instead we'll continue to use printf-style strings, with a Rust printf implementation.
|
||||
|
||||
### Vectors
|
||||
|
||||
See [`Vec`](https://cxx.rs/binding/vec.html) and [`CxxVector`](https://cxx.rs/binding/cxxvector.html).
|
||||
|
||||
In many cases, `autocxx` refuses to allow vectors of certain types. For example, autocxx supports `std::vector` and `std::shared_ptr` but NOT `std::vector<std::shared_ptr<...>>`. To work around this one can create a helper (pointer, length) struct. Example:
|
||||
|
||||
```cpp
|
||||
struct RustFFIJobList {
|
||||
std::shared_ptr<job_t> *jobs;
|
||||
size_t count;
|
||||
};
|
||||
```
|
||||
|
||||
This is just a POD (plain old data) so autocxx can generate bindings for it. Then it is trivial to convert it to a Rust slice:
|
||||
|
||||
```
|
||||
pub fn get_jobs(ffi_jobs: &ffi::RustFFIJobList) -> &[SharedPtr<job_t>] {
|
||||
unsafe { slice::from_raw_parts(ffi_jobs.jobs, ffi_jobs.count) }
|
||||
}
|
||||
```
|
||||
|
||||
Another workaround is to define a struct that contains the shared pointer, and create a vector of that struct.
|
||||
|
||||
## Development Tooling
|
||||
|
||||
The [autocxx guidance](https://google.github.io/autocxx/workflow.html#how-can-i-see-what-bindings-autocxx-has-generated) is helpful:
|
||||
|
||||
1. Install cargo expand (`cargo install cargo-expand`). Then you can use `cargo expand` to see the generated Rust bindings for C++. In particular this is useful for seeing failed expansions for C++ types that autocxx cannot handle.
|
||||
2. In rust-analyzer, enable Proc Macro and Proc Macro Attributes.
|
||||
|
||||
## FFI
|
||||
|
||||
The boundary between Rust and C++ is referred to as the Foreign Function Interface, or FFI.
|
||||
|
||||
`autocxx` and `cxx` both are designed for long-term interop: C++ and Rust coexisting for years. To this end, both emphasize safety: requiring lots of `unsafe`, `Pin`, etc.
|
||||
|
||||
fish plans to use them only temporarily, with a focus on getting things working. To this end, both cxx and autocxx have been forked to support fish:
|
||||
|
||||
1. Relax the requirement that all functions taking pointers are `unsafe` (this just added noise).
|
||||
2. Add support for `wchar_t` as a recognized type, and `CxxWString` analogous to `CxxString`.
|
||||
|
||||
See the `Cargo.toml` file for the locations of the forks.
|
||||
|
|
@ -8,150 +8,96 @@ Synopsis
|
|||
|
||||
.. synopsis::
|
||||
|
||||
abbr --add NAME [--position command | anywhere] [-r | --regex PATTERN]
|
||||
[--set-cursor[=MARKER]] ([-f | --function FUNCTION] | EXPANSION)
|
||||
abbr --erase NAME ...
|
||||
abbr --rename OLD_WORD NEW_WORD
|
||||
abbr --add [SCOPE] WORD EXPANSION
|
||||
abbr --erase WORD ...
|
||||
abbr --rename [SCOPE] OLD_WORD NEW_WORD
|
||||
abbr --show
|
||||
abbr --list
|
||||
abbr --query NAME ...
|
||||
abbr --query WORD ...
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
``abbr`` manages abbreviations - user-defined words that are replaced with longer phrases when entered.
|
||||
|
||||
.. note::
|
||||
Only typed-in commands use abbreviations. Abbreviations are not expanded in scripts.
|
||||
``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.
|
||||
To avoid expanding something that looks like an abbreviation, the default :kbd:`Control`\ +\ :kbd:`Space` binding inserts a space without expanding.
|
||||
|
||||
An abbreviation may match a literal word, or it may match a pattern given by a regular expression. When an abbreviation matches a word, that word is replaced by new text, called its *expansion*. This expansion may be a fixed new phrase, or it can be dynamically created via a fish function. This expansion occurs after pressing space or enter.
|
||||
Options
|
||||
-------
|
||||
|
||||
Combining these features, it is possible to create custom syntaxes, where a regular expression recognizes matching tokens, and the expansion function interprets them. See the `Examples`_ section.
|
||||
The following options are available:
|
||||
|
||||
.. versionchanged:: 3.6.0
|
||||
Previous versions of this allowed saving abbreviations in universal variables.
|
||||
That's no longer possible. Existing variables will still be imported and ``abbr --erase`` will also erase the variables.
|
||||
We recommend adding abbreviations to :ref:`config.fish <configuration>` by just adding the ``abbr --add`` command.
|
||||
When you run ``abbr``, you will see output like this
|
||||
**-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*
|
||||
|
||||
> abbr
|
||||
abbr -a -- foo bar # imported from a universal variable, see `help abbr`
|
||||
**-s** or **--show**
|
||||
Show all abbreviations in a manner suitable for import and export
|
||||
|
||||
In that case you should take the part before the ``#`` comment and save it in :ref:`config.fish <configuration>`,
|
||||
then you can run ``abbr --erase`` to remove the universal variable::
|
||||
**-l** or **--list**
|
||||
Lists all abbreviated words
|
||||
|
||||
> abbr >> ~/.config/fish/config.fish
|
||||
> abbr --erase (abbr --list)
|
||||
|
||||
**-e** *WORD* or **--erase** *WORD* ...
|
||||
Erase the given abbreviations
|
||||
|
||||
"add" subcommand
|
||||
--------------------
|
||||
**-q** or **--query**
|
||||
Return 0 (true) if one of the *WORD* is an abbreviation.
|
||||
|
||||
.. synopsis::
|
||||
**-h** or **--help**
|
||||
Displays help about using this command.
|
||||
|
||||
abbr [-a | --add] NAME [--position command | anywhere] [-r | --regex PATTERN]
|
||||
[--set-cursor[=MARKER]] ([-f | --function FUNCTION] | EXPANSION)
|
||||
In addition, when adding or renaming abbreviations, one of the following **SCOPE** options can be used:
|
||||
|
||||
``abbr --add`` creates a new abbreviation. With no other options, the string **NAME** is replaced by **EXPANSION**.
|
||||
**-g** or **--global**
|
||||
Use a global variable
|
||||
|
||||
With **--position command**, the abbreviation will only expand when it is positioned as a command, not as an argument to another command. With **--position anywhere** the abbreviation may expand anywhere in the command line. The default is **command**.
|
||||
|
||||
With **--regex**, the abbreviation matches using the regular expression given by **PATTERN**, instead of the literal **NAME**. The pattern is interpreted using PCRE2 syntax and must match the entire token. If multiple abbreviations match the same token, the last abbreviation added is used.
|
||||
|
||||
With **--set-cursor=MARKER**, the cursor is moved to the first occurrence of **MARKER** in the expansion. The **MARKER** value is erased. The **MARKER** may be omitted (i.e. simply ``--set-cursor``), in which case it defaults to ``%``.
|
||||
|
||||
With **-f FUNCTION** or **--function FUNCTION**, **FUNCTION** is treated as the name of a fish function instead of a literal replacement. When the abbreviation matches, the function will be called with the matching token as an argument. If the function's exit status is 0 (success), the token will be replaced by the function's output; otherwise the token will be left unchanged. No **EXPANSION** may be given separately.
|
||||
**-U** or **--universal**
|
||||
Use a universal variable (default)
|
||||
|
||||
See the "Internals" section for more on them.
|
||||
|
||||
Examples
|
||||
########
|
||||
--------
|
||||
|
||||
::
|
||||
|
||||
abbr --add gco git checkout
|
||||
abbr -a -g gco git checkout
|
||||
|
||||
Add a new abbreviation where ``gco`` will be replaced with ``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).
|
||||
|
||||
::
|
||||
|
||||
abbr -a --position anywhere -- -C --color
|
||||
abbr -a -U l less
|
||||
|
||||
Add a new abbreviation where ``-C`` will be replaced with ``--color``. The ``--`` allows ``-C`` to be treated as the name of the abbreviation, instead of an option.
|
||||
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.
|
||||
|
||||
::
|
||||
|
||||
abbr -a L --position anywhere --set-cursor "% | less"
|
||||
|
||||
Add a new abbreviation where ``L`` will be replaced with ``| less``, placing the cursor before the pipe.
|
||||
abbr -r gco gch
|
||||
|
||||
Renames an existing abbreviation from ``gco`` to ``gch``.
|
||||
|
||||
::
|
||||
|
||||
function last_history_item
|
||||
echo $history[1]
|
||||
end
|
||||
abbr -a !! --position anywhere --function last_history_item
|
||||
abbr -e gco
|
||||
|
||||
This first creates a function ``last_history_item`` which outputs the last entered command. It then adds an abbreviation which replaces ``!!`` with the result of calling this function. Taken together, this is similar to the ``!!`` history expansion feature of bash.
|
||||
Erase the ``gco`` abbreviation.
|
||||
|
||||
::
|
||||
|
||||
function vim_edit
|
||||
echo vim $argv
|
||||
end
|
||||
abbr -a vim_edit_texts --position command --regex ".+\.txt" --function vim_edit
|
||||
ssh another_host abbr -s | source
|
||||
|
||||
This first creates a function ``vim_edit`` which prepends ``vim`` before its argument. It then adds an abbreviation which matches commands ending in ``.txt``, and replaces the command with the result of calling this function. This allows text files to be "executed" as a command to open them in vim, similar to the "suffix alias" feature in zsh.
|
||||
Import the abbreviations defined on another_host over SSH.
|
||||
|
||||
::
|
||||
|
||||
abbr 4DIRS --set-cursor=! "$(string join \n -- 'for dir in */' 'cd $dir' '!' 'cd ..' 'end')"
|
||||
|
||||
This creates an abbreviation "4DIRS" which expands to a multi-line loop "template." The template enters each directory and then leaves it. The cursor is positioned ready to enter the command to run in each directory, at the location of the ``!``, which is itself erased.
|
||||
|
||||
Other subcommands
|
||||
--------------------
|
||||
|
||||
|
||||
::
|
||||
|
||||
abbr --rename OLD_NAME NEW_NAME
|
||||
|
||||
Renames an abbreviation, from *OLD_NAME* to *NEW_NAME*
|
||||
|
||||
::
|
||||
|
||||
abbr [-s | --show]
|
||||
|
||||
Show all abbreviations in a manner suitable for import and export
|
||||
|
||||
::
|
||||
|
||||
abbr [-l | --list]
|
||||
|
||||
Prints the names of all abbreviation
|
||||
|
||||
::
|
||||
|
||||
abbr [-e | --erase] NAME
|
||||
|
||||
Erases the abbreviation with the given name
|
||||
|
||||
::
|
||||
|
||||
abbr -q or --query [NAME...]
|
||||
|
||||
Return 0 (true) if one of the *NAME* is an abbreviation.
|
||||
|
||||
::
|
||||
|
||||
abbr -h or --help
|
||||
|
||||
Displays help for the `abbr` command.
|
||||
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.
|
||||
|
||||
Abbreviations created with the **--universal** flag will be visible to other fish sessions, whilst **--global** will be limited to the current session.
|
||||
|
|
|
|||
|
|
@ -16,9 +16,7 @@ Synopsis
|
|||
Description
|
||||
-----------
|
||||
|
||||
``alias`` is a simple wrapper for the ``function`` builtin, which creates a function wrapping a command. It has similar syntax to POSIX shell ``alias``. For other uses, it is recommended to define a :doc:`function <function>`.
|
||||
|
||||
If you want to ease your interactive use, to save typing, consider using an :doc:`abbreviation <abbr>` instead.
|
||||
``alias`` is a simple wrapper for the ``function`` builtin, which creates a function wrapping a command. It has similar syntax to POSIX shell ``alias``. For other uses, it is recommended to define a :ref:`function <cmd-function>`.
|
||||
|
||||
``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``.
|
||||
|
||||
|
|
@ -33,7 +31,7 @@ The following options are available:
|
|||
Displays help about using this command.
|
||||
|
||||
**-s** or **--save**
|
||||
Saves the function created by the alias into your fish configuration directory using :doc:`funcsave <funcsave>`.
|
||||
Saves the function created by the alias into your fish configuration directory using :ref:`funcsave <cmd-funcsave>`.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
|
@ -57,6 +55,6 @@ The following code will create ``rmi``, which runs ``rm`` with additional argume
|
|||
See more
|
||||
--------
|
||||
|
||||
1. The :doc:`function <function>` command this builds on.
|
||||
1. The :ref:`function <cmd-function>` command this builds on.
|
||||
2. :ref:`Functions <syntax-function>`.
|
||||
3. :ref:`Defining aliases <syntax-aliases>`.
|
||||
3. :ref:`Function wrappers <syntax-function-wrappers>`.
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ Description
|
|||
|
||||
``and`` is used to execute a command if the previous command was successful (returned a status of 0).
|
||||
|
||||
``and`` statements may be used as part of the condition in an :doc:`while <while>` or :doc:`if <if>` block.
|
||||
``and`` statements may be used as part of the condition in an :ref:`while <cmd-while>` or :ref:`if <cmd-if>` block.
|
||||
|
||||
``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 <variables-status>` variable.
|
||||
|
||||
|
|
@ -33,5 +33,5 @@ The following code runs the ``make`` command to build a program. If the build su
|
|||
See Also
|
||||
--------
|
||||
|
||||
- :doc:`or <or>` command
|
||||
- :doc:`not <not>` command
|
||||
- :ref:`or <cmd-or>` command
|
||||
- :ref:`not <cmd-not>` command
|
||||
|
|
|
|||
|
|
@ -64,11 +64,10 @@ If ``$argv`` is empty then there is nothing to parse and ``argparse`` returns ze
|
|||
|
||||
The ``or return`` means that the function returns ``argparse``'s status if it failed, so if it goes on ``argparse`` succeeded.
|
||||
|
||||
The ``--`` argument is required. You do not have to include any option specifications or arguments after the ``--`` but you must include the ``--``. For example, this is acceptable::
|
||||
The ``--`` argument is required. You do not have to include any arguments after the ``--`` but you must include the ``--``. For example, this is acceptable::
|
||||
|
||||
set -l argv foo
|
||||
set -l argv
|
||||
argparse 'h/help' 'n/name' -- $argv
|
||||
argparse --min-args=1 -- $argv
|
||||
|
||||
But this is not::
|
||||
|
||||
|
|
@ -98,7 +97,7 @@ Each option specification consists of:
|
|||
|
||||
- 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 <flag-value-validation>` for more information.
|
||||
|
||||
See the :doc:`fish_opt <fish_opt>` command for a friendlier but more verbose way to create option specifications.
|
||||
See the :ref:`fish_opt <cmd-fish_opt>` command for a friendlier but more verbose way to create option specifications.
|
||||
|
||||
If a flag is not seen when parsing the arguments then the corresponding _flag_X var(s) will not be set.
|
||||
|
||||
|
|
@ -163,25 +162,14 @@ The script should write any error messages to stdout, not stderr. It should retu
|
|||
|
||||
Fish ships with a ``_validate_int`` function that accepts a ``--min`` and ``--max`` flag. Let's say your command accepts a ``-m`` or ``--max`` flag and the minimum allowable value is zero and the maximum is 5. You would define the option like this: ``m/max=!_validate_int --min 0 --max 5``. The default if you just call ``_validate_int`` without those flags is to simply check that the value is a valid integer with no limits on the min or max value allowed.
|
||||
|
||||
Here are some examples of flag validations::
|
||||
|
||||
# validate that a path is a directory
|
||||
argparse 'p/path=!test -d "$_flag_value"' -- --path $__fish_config_dir
|
||||
# validate that a function does not exist
|
||||
argparse 'f/func=!not functions -q "$_flag_value"' -- -f alias
|
||||
# validate that a string matches a regex
|
||||
argparse 'c/color=!string match -rq \'^#?[0-9a-fA-F]{6}$\' "$_flag_value"' -- -c 'c0ffee'
|
||||
# validate with a validator function
|
||||
argparse 'n/num=!_validate_int --min 0 --max 99' -- --num 42
|
||||
|
||||
Example OPTION_SPECs
|
||||
--------------------
|
||||
|
||||
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 however either flag was seen, as many times as it was seen. So it could be set to ``-h``, ``-h`` and ``--help``, and ``count $_flag_h`` would yield "3".
|
||||
- ``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.
|
||||
|
||||
- ``help`` means that only ``--help`` is valid. The flag is a boolean and can be used more than once. If it is used then ``_flag_help`` will be set as above. Also ``h-help`` (with an arbitrary short letter) for backwards compatibility.
|
||||
- ``help`` means that only ``--help`` is valid. The flag is a boolean and can be used more than once. If it is used then ``_flag_help`` will be set to the count of how many times the long flag was seen. Also ``h-help`` (with an arbitrary short letter) for backwards compatibility.
|
||||
|
||||
- ``longonly=`` is a flag ``--longonly`` that requires an option, there is no short flag or even short flag variable.
|
||||
|
||||
|
|
@ -191,7 +179,7 @@ Some *OPTION_SPEC* examples:
|
|||
|
||||
- ``name=+`` means that only ``--name`` is valid. It requires a value and can be used more than once. If the flag is seen then ``_flag_name`` will be set with the values associated with each occurrence.
|
||||
|
||||
- ``x`` means that only ``-x`` is valid. It is a boolean that can be used more than once. If it is seen then ``_flag_x`` will be set as above.
|
||||
- ``x`` means that only ``-x`` is valid. It is a boolean that can be used more than once. If it is seen then ``_flag_x`` will be set to the count of how many times the flag was seen.
|
||||
|
||||
- ``x=``, ``x=?``, and ``x=+`` are similar to the n/name examples above but there is no long flag alternative to the short flag ``-x``.
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ Description
|
|||
|
||||
A background job is executed simultaneously with fish, and does not have access to the keyboard. If no job is specified, the last job to be used is put in the background. If ``PID`` is specified, the jobs containing the specified process IDs are put in the background.
|
||||
|
||||
For compatibility with other shells, job expansion syntax is supported for ``bg``. A PID of the format ``%1`` will be interpreted as the PID of job 1. Job numbers can be seen in the output of :doc:`jobs <jobs>`.
|
||||
For compatibility with other shells, job expansion syntax is supported for ``bg``. A PID of the format ``%1`` will be interpreted as the PID of job 1. Job numbers can be seen in the output of :ref:`jobs <cmd-jobs>`.
|
||||
|
||||
When at least one of the arguments isn't a valid job specifier,
|
||||
``bg`` will print an error without backgrounding anything.
|
||||
|
|
|
|||
|
|
@ -27,21 +27,21 @@ The generic key binding that matches if no other binding does can be set by spec
|
|||
|
||||
If the ``-k`` switch is used, the name of a key (such as 'down', 'up' or 'backspace') is used instead of a sequence. The names used are the same as the corresponding curses variables, but without the 'key\_' prefix. (See ``terminfo(5)`` for more information, or use ``bind --key-names`` for a list of all available named keys). Normally this will print an error if the current ``$TERM`` entry doesn't have a given key, unless the ``-s`` switch is given.
|
||||
|
||||
To find out what sequence a key combination sends, you can use :doc:`fish_key_reader <fish_key_reader>`.
|
||||
To find out what sequence a key combination sends, you can use :ref:`fish_key_reader <cmd-fish_key_reader>`.
|
||||
|
||||
``COMMAND`` can be any fish command, but it can also be one of a set of special input functions. These include functions for moving the cursor, operating on the kill-ring, performing tab completion, etc. Use ``bind --function-names`` for a complete list of these input functions.
|
||||
|
||||
When ``COMMAND`` is a shellscript command, it is a good practice to put the actual code into a :ref:`function <syntax-function>` and simply bind to the function name. This way it becomes significantly easier to test the function while editing, and the result is usually more readable as well.
|
||||
|
||||
If a script produces output, it should finish by calling ``commandline -f repaint`` to tell fish that a repaint is in order.
|
||||
|
||||
.. note::
|
||||
Special input functions cannot be combined with ordinary shell script commands. The commands must be entirely a sequence of special input functions (from ``bind -f``) or all shell script commands (i.e., valid fish script). To run special input functions from regular fish script, use ``commandline -f`` (see also :doc:`commandline <commandline>`). If a script produces output, it should finish by calling ``commandline -f repaint`` to tell fish that a repaint is in order.
|
||||
Note that special input functions cannot be combined with ordinary shell script commands. The commands must be entirely a sequence of special input functions (from ``bind -f``) or all shell script commands (i.e., valid fish script).
|
||||
|
||||
If no ``SEQUENCE`` is provided, all bindings (or just the bindings in the given ``MODE``) are printed. If ``SEQUENCE`` is provided but no ``COMMAND``, just the binding matching that sequence is printed.
|
||||
|
||||
To save custom key bindings, put the ``bind`` statements into :ref:`config.fish <configuration>`. Alternatively, fish also automatically executes a function called ``fish_user_key_bindings`` if it exists.
|
||||
To save custom keybindings, put the ``bind`` statements into :ref:`config.fish <configuration>`. Alternatively, fish also automatically executes a function called ``fish_user_key_bindings`` if it exists.
|
||||
|
||||
Key bindings may use "modes", which mimics Vi's modal input behavior. The default mode is "default". Every key binding applies to a single mode; you can specify which one with ``-M MODE``. If the key binding should change the mode, you can specify the new mode with ``-m NEW_MODE``. The mode can be viewed and changed via the ``$fish_bind_mode`` variable. If you want to change the mode from inside a fish function, use ``set fish_bind_mode MODE``.
|
||||
Key bindings may use "modes", which mimics Vi's modal input behavior. The default mode is "default", and every bind applies to a single mode. The mode can be viewed/changed with the ``$fish_bind_mode`` variable.
|
||||
|
||||
Options
|
||||
-------
|
||||
|
|
@ -81,9 +81,6 @@ The following options are available:
|
|||
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``).
|
||||
|
||||
**-s** or **--silent**
|
||||
Silences some of the error messages, including for unknown key names and unbound sequences.
|
||||
|
||||
**-h** or **--help**
|
||||
Displays help about using this command.
|
||||
|
||||
|
|
@ -196,9 +193,6 @@ The following special input functions are available:
|
|||
move one word to the right; or if at the end of the commandline, accept one word
|
||||
from the current autosuggestion.
|
||||
|
||||
``history-pager``
|
||||
invoke the searchable pager on history (incremental search); or if the history pager is already active, search further backwards in time.
|
||||
|
||||
``history-search-backward``
|
||||
search the history for the previous match
|
||||
|
||||
|
|
@ -236,10 +230,7 @@ The following special input functions are available:
|
|||
move the selected text to the killring
|
||||
|
||||
``kill-whole-line``
|
||||
move the line (including the following newline) to the killring. If the line is the last line, its preceeding newline is also removed
|
||||
|
||||
``kill-inner-line``
|
||||
move the line (without the following newline) to the killring
|
||||
move the line to the killring
|
||||
|
||||
``kill-word``
|
||||
move the next word to the killring
|
||||
|
|
@ -249,10 +240,10 @@ The following special input functions are available:
|
|||
or if at the end of the commandline, accept one word from the current autosuggestion.
|
||||
|
||||
``or``
|
||||
only execute the next function if the previous did not succeed (note: only some functions report failure)
|
||||
only execute the next function if the previous succeeded (note: only some functions report success)
|
||||
|
||||
``pager-toggle-search``
|
||||
toggles the search field if the completions pager is visible; or if used after ``history-pager``, search forwards in time.
|
||||
toggles the search field if the completions pager is visible.
|
||||
|
||||
``prevd-or-backward-word``
|
||||
if the commandline is empty, then move backward in the directory history, otherwise move one word to the left
|
||||
|
|
@ -261,7 +252,7 @@ The following special input functions are available:
|
|||
reexecutes the prompt functions and redraws the prompt (also ``force-repaint`` for backwards-compatibility)
|
||||
|
||||
``repaint-mode``
|
||||
reexecutes the :doc:`fish_mode_prompt <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.
|
||||
reexecutes the :ref:`fish_mode_prompt <cmd-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.
|
||||
|
||||
``self-insert``
|
||||
inserts the matching sequence into the command line
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ Synopsis
|
|||
Description
|
||||
-----------
|
||||
|
||||
``block`` prevents events triggered by ``fish`` or the :doc:`emit <emit>` command from being delivered and acted upon while the block is in place.
|
||||
``block`` prevents events triggered by ``fish`` or the :ref:`emit <cmd-emit>` command from being delivered and acted upon while the block is in place.
|
||||
|
||||
In functions, ``block`` can be useful while performing work that should not be interrupted by the shell.
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ Synopsis
|
|||
Description
|
||||
-----------
|
||||
|
||||
``break`` halts a currently running loop (*LOOP_CONSTRUCT*), such as a :doc:`for <for>` or :doc:`while <while>` loop. It is usually added inside of a conditional block such as an :doc:`if <if>` block.
|
||||
``break`` halts a currently running loop (*LOOP_CONSTRUCT*), such as a :ref:`switch <cmd-switch>`, :ref:`for <cmd-for>` or :ref:`while <cmd-while>` loop. It is usually added inside of a conditional block such as an :ref:`if <cmd-if>` block.
|
||||
|
||||
There are no parameters for ``break``.
|
||||
|
||||
|
|
@ -37,4 +37,4 @@ The following code searches all .c files for "smurf", and halts at the first occ
|
|||
See Also
|
||||
--------
|
||||
|
||||
- the :doc:`continue <continue>` command, to skip the remainder of the current iteration of the current inner loop
|
||||
- the :ref:`continue <cmd-continue>` command, to skip the remainder of the current iteration of the current inner loop
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ The following options are available:
|
|||
Lists the names of all defined builtins.
|
||||
|
||||
**-q** or **--query** *BUILTIN*
|
||||
Tests if any of the specified builtins exist. If any exist, it returns 0, 1 otherwise.
|
||||
Tests if any of the specified builtins exist.
|
||||
|
||||
**-h** or **--help**
|
||||
Displays help about using this command.
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ It is recommended to keep **.** as the first element of :envvar:`CDPATH`, or :en
|
|||
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 :doc:`prevd <prevd>`.
|
||||
See also :ref:`prevd <cmd-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.
|
||||
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@ You can also press :kbd:`Tab` to use the completion pager to select an item from
|
|||
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 :envvar:`dirprev` and :envvar:`dirnext` variables, which this command manipulates.
|
||||
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
|
||||
--------
|
||||
|
||||
- the :doc:`dirh <dirh>` command to print the directory history
|
||||
- the :doc:`prevd <prevd>` command to move backward
|
||||
- the :doc:`nextd <nextd>` command to move forward
|
||||
- the :ref:`dirh <cmd-dirh>` command to print the directory history
|
||||
- the :ref:`prevd <cmd-prevd>` command to move backward
|
||||
- the :ref:`nextd <cmd-nextd>` command to move forward
|
||||
|
|
|
|||
|
|
@ -26,16 +26,10 @@ The following options are available:
|
|||
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.
|
||||
|
||||
**-B** or **--selection-start**
|
||||
Get current position of the selection start in the buffer.
|
||||
|
||||
**-E** or **--selection-end**
|
||||
Get current position of the selection end in the 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 :doc:`bind <bind>` for a list of input functions.
|
||||
See :ref:`bind <cmd-bind>` for a list of input functions.
|
||||
|
||||
**-h** or **--help**
|
||||
Displays help about using this command.
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@ The following options are available:
|
|||
Adds a short option to the completions list.
|
||||
|
||||
**-l** or **--long-option** *LONG_OPTION*
|
||||
Adds a GNU-style long option to the completions list.
|
||||
Adds a GNU style long option to the completions list.
|
||||
|
||||
**-o** or **--old-option** *OPTION*
|
||||
Adds an old-style short or long option (see below for details).
|
||||
**-o** or **--old-option** *LONG_OPTION*
|
||||
Adds an old style long option to the completions list (see below for details).
|
||||
|
||||
**-a** or **--arguments** *ARGUMENTS*
|
||||
Adds the specified option arguments to the completions list.
|
||||
|
|
@ -61,7 +61,7 @@ The following options are available:
|
|||
Causes the specified command to inherit completions from *WRAPPED_COMMAND* (see below for details).
|
||||
|
||||
**-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. If multiple conditions are specified, fish will try them in the order they are specified until one fails or all succeeded.
|
||||
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.
|
||||
|
|
@ -76,9 +76,9 @@ Command specific tab-completions in ``fish`` are based on the notion of options
|
|||
|
||||
- Short options, like ``-a``. Short options are a single character long, are preceded by a single hyphen and can be grouped together (like ``-la``, which is equivalent to ``-l -a``). Option arguments may be specified by appending the option with the value (``-w32``), or, if ``--require-parameter`` is given, in the following parameter (``-w 32``).
|
||||
|
||||
- Old-style options, long like ``-Wall`` or ``-name`` or even short like ``-a``. Old-style options can be more than one character long, are preceded by a single hyphen and may not be grouped together. Option arguments are specified by default following a space (``-foo null``) or after ``=`` (``-foo=null``).
|
||||
- Old style long options, like ``-Wall`` or ``-name``. Old style long options can be more than one character long, are preceded by a single hyphen and may not be grouped together. Option arguments are specified in the following parameter (``-ao null``) or after a ``=`` (``-ao=null``).
|
||||
|
||||
- GNU-style long options, like ``--colors``. GNU-style long options can be more than one character long, are preceded by two hyphens, and can't be grouped together. Option arguments may be specified after a ``=`` (``--quoting-style=shell``), or, if ``--require-parameter`` is given, in the following parameter (``--quoting-style shell``).
|
||||
- GNU style long options, like ``--colors``. GNU style long options can be more than one character long, are preceded by two hyphens, and can't be grouped together. Option arguments may be specified after a ``=`` (``--quoting-style=shell``), or, if ``--require-parameter`` is given, in the following parameter (``--quoting-style shell``).
|
||||
|
||||
Multiple commands and paths can be given in one call to define the same completions for multiple commands.
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ Multiple command switches and wrapped commands can also be given to define multi
|
|||
|
||||
Invoking ``complete`` multiple times for the same command adds the new definitions on top of any existing completions defined for the command.
|
||||
|
||||
When ``-a`` or ``--arguments`` is specified in conjunction with long, short, or old-style options, the specified arguments are only completed as arguments for any of the specified options. If ``-a`` or ``--arguments`` is specified without any long, short, or old-style options, the specified arguments are used when completing non-option arguments to the command (except when completing an option argument that was specified with ``-r`` or ``--require-parameter``).
|
||||
When ``-a`` or ``--arguments`` is specified in conjunction with long, short, or old style options, the specified arguments are only completed as arguments for any of the specified options. If ``-a`` or ``--arguments`` is specified without any long, short, or old style options, the specified arguments are used when completing non-option arguments to the command (except when completing an option argument that was specified with ``-r`` or ``--require-parameter``).
|
||||
|
||||
Command substitutions found in ``ARGUMENTS`` should return a newline-separated list of arguments, and each argument may optionally have a tab character followed by the argument description. Description given this way override a description given with ``-d`` or ``--description``.
|
||||
|
||||
|
|
@ -101,14 +101,14 @@ When ``complete`` is called without anything that would define or erase completi
|
|||
Examples
|
||||
--------
|
||||
|
||||
The short-style option ``-o`` for the ``gcc`` command needs a file argument:
|
||||
The short style option ``-o`` for the ``gcc`` command needs a file argument:
|
||||
|
||||
::
|
||||
|
||||
complete -c gcc -s o -r
|
||||
|
||||
|
||||
The short-style option ``-d`` for the ``grep`` command requires one of ``read``, ``skip`` or ``recurse``:
|
||||
The short style option ``-d`` for the ``grep`` command requires one of ``read``, ``skip`` or ``recurse``:
|
||||
|
||||
::
|
||||
|
||||
|
|
@ -148,6 +148,4 @@ Now hub inherits all of the completions from git. Note this can also be specifie
|
|||
|
||||
complete -c git
|
||||
|
||||
Shows all completions for ``git``.
|
||||
|
||||
Any command ``foo`` that doesn't support grouping multiple short options in one string (not supporting ``-xf`` as short for ``-x -f``) or a short option and its value in one string (not supporting ``-d9`` instead of ``-d 9``) should be specified as a single-character old-style option instead of as a short-style option; for example, ``complete -c foo -o s; complete -c foo -o v`` would never suggest ``foo -ov`` but rather ``foo -o -v``.
|
||||
Show all completions for ``git``.
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ Synopsis
|
|||
Description
|
||||
-----------
|
||||
|
||||
``continue`` skips the remainder of the current iteration of the current inner loop, such as a :doc:`for <for>` loop or a :doc:`while <while>` loop. It is usually added inside of a conditional block such as an :doc:`if <if>` statement or a :doc:`switch <switch>` statement.
|
||||
``continue`` skips the remainder of the current iteration of the current inner loop, such as a :ref:`for <cmd-for>` loop or a :ref:`while <cmd-while>` loop. It is usually added inside of a conditional block such as an :ref:`if <cmd-if>` statement or a :ref:`switch <cmd-switch>` statement.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
|
@ -35,4 +35,4 @@ The following code removes all tmp files that do not contain the word smurf.
|
|||
See Also
|
||||
--------
|
||||
|
||||
- the :doc:`break <break>` command, to stop the current inner loop
|
||||
- the :ref:`break <cmd-break>` command, to stop the current inner loop
|
||||
|
|
|
|||
|
|
@ -17,11 +17,11 @@ Description
|
|||
|
||||
``dirh`` does not accept any parameters.
|
||||
|
||||
Note that the :doc:`cd <cd>` command limits directory history to the 25 most recently visited directories. The history is stored in the ``$dirprev`` and ``$dirnext`` variables.
|
||||
Note that the :ref:`cd <cmd-cd>` command limits directory history to the 25 most recently visited directories. The history is stored in the ``$dirprev`` and ``$dirnext`` variables.
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
||||
- the :doc:`cdh <cdh>` command to display a prompt to quickly navigate the history
|
||||
- the :doc:`prevd <prevd>` command to move backward
|
||||
- the :doc:`nextd <nextd>` command to move forward
|
||||
- the :ref:`cdh <cmd-cdh>` command to display a prompt to quickly navigate the history
|
||||
- the :ref:`prevd <cmd-prevd>` command to move backward
|
||||
- the :ref:`nextd <cmd-nextd>` command to move forward
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ Synopsis
|
|||
Description
|
||||
-----------
|
||||
|
||||
``dirs`` prints the current :ref:`directory stack <directory-stack>`, as created by :doc:`pushd <pushd>` and modified by :doc:`popd <popd>`.
|
||||
``dirs`` prints the current :ref:`directory stack <directory-stack>`, as created by :ref:`pushd <cmd-pushd>` and modified by :ref:`popd <cmd-popd>`.
|
||||
|
||||
The following options are available:
|
||||
|
||||
|
|
@ -28,4 +28,4 @@ The following options are available:
|
|||
See Also
|
||||
--------
|
||||
|
||||
- the :doc:`cdh <cdh>` command, which provides a more intuitive way to navigate to recently visited directories.
|
||||
- the :ref:`cdh <cmd-cdh>` command, which provides a more intuitive way to navigate to recently visited directories.
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ Description
|
|||
|
||||
Jobs in the list of jobs are sent a hang-up signal when fish terminates, which usually causes the job to terminate; ``disown`` allows these processes to continue regardless.
|
||||
|
||||
If no process is specified, the most recently-used job is removed (like :doc:`bg <bg>` and :doc:`fg <fg>`). If one or more PIDs are specified, jobs with the specified process IDs are removed from the job list. Invalid jobs are ignored and a warning is printed.
|
||||
If no process is specified, the most recently-used job is removed (like :ref:`bg <cmd-bg>` and :ref:`fg <cmd-fg>`). If one or more PIDs are specified, jobs with the specified process IDs are removed from the job list. Invalid jobs are ignored and a warning is printed.
|
||||
|
||||
If a job is stopped, it is sent a signal to continue running, and a warning is printed. It is not possible to use the :doc:`bg <bg>` builtin to continue a job once it has been disowned.
|
||||
If a job is stopped, it is sent a signal to continue running, and a warning is printed. It is not possible to use the :ref:`bg <cmd-bg>` builtin to continue a job once it has been disowned.
|
||||
|
||||
``disown`` returns 0 if all specified jobs were disowned successfully, and 1 if any problems were encountered.
|
||||
|
||||
|
|
@ -30,4 +30,4 @@ Example
|
|||
|
||||
``firefox &; disown`` will start the Firefox web browser in the background and remove it from the job list, meaning it will not be closed when the fish process is closed.
|
||||
|
||||
``disown (jobs -p)`` removes all :doc:`jobs <jobs>` from the job list without terminating them.
|
||||
``disown (jobs -p)`` removes all :ref:`jobs <cmd-jobs>` from the job list without terminating them.
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ Description
|
|||
|
||||
The following options are available:
|
||||
|
||||
**-n**
|
||||
- **-n**
|
||||
Do not output a newline.
|
||||
|
||||
**-s**
|
||||
|
|
@ -78,4 +78,4 @@ Example
|
|||
See Also
|
||||
--------
|
||||
|
||||
- the :doc:`printf <printf>` command, for more control over output formatting
|
||||
- the :ref:`printf <cmd-printf>` command, for more control over output formatting
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ Synopsis
|
|||
Description
|
||||
-----------
|
||||
|
||||
:doc:`if <if>` will execute the command *CONDITION**.
|
||||
:ref:`if <cmd-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.
|
||||
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@ Description
|
|||
|
||||
The **end** keyword ends a block of commands started by one of the following commands:
|
||||
|
||||
- :doc:`begin <begin>` to start a block of commands
|
||||
- :doc:`function <function>` to define a function
|
||||
- :doc:`if <if>`, :doc:`switch <switch>` to conditionally execute commands
|
||||
- :doc:`while <while>`, :doc:`for <for>` to perform commands multiple times
|
||||
- :ref:`begin <cmd-begin>` to start a block of commands
|
||||
- :ref:`function <cmd-function>` to define a function
|
||||
- :ref:`if <cmd-if>`, :ref:`switch <cmd-switch>` to conditionally execute commands
|
||||
- :ref:`while <cmd-while>`, :ref:`for <cmd-for>` to perform commands multiple times
|
||||
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ 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.
|
||||
|
||||
If the command does not need access to stdin, consider using :doc:`source <source>` instead.
|
||||
If the command does not need access to stdin, consider using :ref:`source <cmd-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.
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,6 @@ Description
|
|||
**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 :doc:`source <source>` builtin) the rest of the file will be skipped, but the shell itself will not exit.
|
||||
If exit is called while sourcing a file (using the :ref:`source <cmd-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.
|
||||
|
|
|
|||
|
|
@ -18,5 +18,5 @@ Description
|
|||
See Also
|
||||
--------
|
||||
|
||||
- :doc:`true <true>` command
|
||||
- :ref:`true <cmd-true>` command
|
||||
- :ref:`$status <variables-status>` variable
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ 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 :doc:`jobs <jobs>`.
|
||||
Job numbers can be seen in the output of :ref:`jobs <cmd-jobs>`.
|
||||
|
||||
The **--help** or **-h** option displays help about using this command.
|
||||
|
||||
|
|
|
|||
|
|
@ -16,15 +16,15 @@ Synopsis
|
|||
Description
|
||||
-----------
|
||||
|
||||
:program:`fish_add_path` is a simple way to add more components to fish's :envvar:`PATH`. It does this by adding the components either to $fish_user_paths or directly to :envvar:`PATH` (if the ``--path`` switch is given).
|
||||
:program:`fish_add_path` is a simple way to add more components to fish's :envvar:`PATH`. It does this by adding the components either to $fish_user_paths or directly to $PATH (if the ``--path`` switch is given).
|
||||
|
||||
It is (by default) safe to use :program:`fish_add_path` in config.fish, or it can be used once, interactively, and the paths will stay in future because of :ref:`universal variables <variables-universal>`. This is a "do what I mean" style command, if you need more control, consider modifying the variable yourself.
|
||||
|
||||
Components are normalized by :doc:`realpath <realpath>`. Trailing slashes are ignored and relative paths are made absolute (but symlinks are not resolved). If a component already exists, it is not added again and stays in the same place unless the ``--move`` switch is given.
|
||||
Components are normalized by :ref:`realpath <cmd-realpath>`. Trailing slashes are ignored and relative paths are made absolute (but symlinks are not resolved). If a component already exists, it is not added again and stays in the same place unless the ``--move`` switch is given.
|
||||
|
||||
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 :envvar:`PATH`, so they still stay ahead of the system paths).
|
||||
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 (:envvar:`fish_user_paths` or :envvar:`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.
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ Options
|
|||
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 :doc:`set <set>` command used.
|
||||
Print the :ref:`set <cmd-set>` command used.
|
||||
|
||||
**-n** or **--dry-run**
|
||||
Print the ``set`` command that would be used without executing it.
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ Synopsis
|
|||
Description
|
||||
-----------
|
||||
|
||||
``fish_breakpoint_prompt`` is the prompt function when asking for input in response to a :doc:`breakpoint <breakpoint>` command.
|
||||
``fish_breakpoint_prompt`` is the prompt function when asking for input in response to a :ref:`breakpoint <cmd-breakpoint>` command.
|
||||
|
||||
The exit status of commands within ``fish_breakpoint_prompt`` will not modify the value of :ref:`$status <variables-status>` outside of the ``fish_breakpoint_prompt`` function.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,36 +0,0 @@
|
|||
.. _cmd-fish_clipboard_copy:
|
||||
|
||||
fish_clipboard_copy - copy text to the system's clipboard
|
||||
==============================================================
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
|
||||
fish_clipboard_copy
|
||||
|
||||
foo | fish_clipboard_copy
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
The ``fish_clipboard_copy`` function copies text to the system clipboard.
|
||||
|
||||
If stdin is not a terminal (see :doc:`isatty <isatty>`), it will read all input from there and copy it. If it is, it will use the current commandline, or the current selection if there is one.
|
||||
|
||||
It is bound to :kbd:`Control`\ +\ :kbd:`X` by default.
|
||||
|
||||
``fish_clipboard_copy`` works by calling a system-specific backend. If it doesn't appear to work you may need to install yours.
|
||||
|
||||
Currently supported are:
|
||||
|
||||
- ``pbcopy``
|
||||
- ``wl-copy`` using wayland
|
||||
- ``xsel`` and ``xclip`` for X11
|
||||
- ``clip.exe`` on Windows.
|
||||
|
||||
See also
|
||||
--------
|
||||
|
||||
- :doc:`fish_clipboard_paste` which does the inverse.
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
.. _cmd-fish_clipboard_paste:
|
||||
|
||||
fish_clipboard_paste - get text from the system's clipboard
|
||||
==============================================================
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
|
||||
fish_clipboard_paste
|
||||
|
||||
fish_clipboard_paste | foo
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
The ``fish_clipboard_paste`` function copies text from the system clipboard.
|
||||
|
||||
If its stdout is not a terminal (see :doc:`isatty <isatty>`), it will output everything there, as-is, without any additional newlines. If it is, it will put the text in the commandline instead.
|
||||
|
||||
If it outputs to the commandline, it will automatically escape the output if the cursor is currently inside single-quotes so it is suitable for single-quotes (meaning it escapes ``'`` and ``\\``).
|
||||
|
||||
It is bound to :kbd:`Control`\ +\ :kbd:`V` by default.
|
||||
|
||||
``fish_clipboard_paste`` works by calling a system-specific backend. If it doesn't appear to work you may need to install yours.
|
||||
|
||||
Currently supported are:
|
||||
|
||||
- ``pbpaste``
|
||||
- ``wl-paste`` using wayland
|
||||
- ``xsel`` and ``xclip`` for X11
|
||||
- ``powershell.exe`` on Windows (this backend has encoding limitations and uses windows line endings that ``fish_clipboard_paste`` undoes)
|
||||
|
||||
See also
|
||||
--------
|
||||
|
||||
- :doc:`fish_clipboard_copy` which does the inverse.
|
||||
|
|
@ -27,7 +27,7 @@ Available subcommands for the ``prompt`` command:
|
|||
|
||||
- ``choose`` loads a sample prompt in the current session.
|
||||
- ``list`` lists the names of the available sample prompts.
|
||||
- ``save`` saves the current prompt to a file (via :doc:`funcsave <funcsave>`).
|
||||
- ``save`` saves the current prompt to a file (via :ref:`funcsave <cmd-funcsave>`).
|
||||
- ``show`` shows what the given sample prompts (or all) would look like.
|
||||
|
||||
With the ``theme`` command ``fish_config`` can be used to view and choose a theme (meaning a color scheme) inside the terminal.
|
||||
|
|
@ -38,7 +38,7 @@ Available subcommands for the ``theme`` command:
|
|||
- ``demo`` displays some sample text in the current theme.
|
||||
- ``dump`` prints the current theme in a loadable format.
|
||||
- ``list`` lists the names of the available sample themes.
|
||||
- ``save`` saves the given theme to :ref:`universal variables <variables-universal>`.
|
||||
- ``save`` saves the current prompt to :ref:`universal variables <variables-universal>`.
|
||||
- ``show`` shows what the given sample theme (or all) would look like.
|
||||
|
||||
The themes are loaded from the theme directory shipped with fish or a ``themes`` directory in the fish configuration directory (typically ``~/.config/fish/themes``).
|
||||
|
|
|
|||
|
|
@ -1,81 +0,0 @@
|
|||
fish_delta - compare functions and completions to the default
|
||||
==============================================================
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
|
||||
fish_delta name ...
|
||||
fish_delta [-f | --no-functions] [-c | --no-completions] [-C | --no-config] [-d | --no-diff] [-n | --new] [-V | --vendor=]
|
||||
fish_delta [-h | --help]
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
The ``fish_delta`` function tells you, at a glance, which of your functions and completions differ from the set that fish ships.
|
||||
|
||||
It does this by going through the relevant variables (:envvar:`fish_function_path` for functions and :envvar:`fish_complete_path` for completions) and comparing the files against fish's default directories.
|
||||
|
||||
If any names are given, it will only compare files by those names (plus a ".fish" extension).
|
||||
|
||||
By default, it will also use ``diff`` to display the difference between the files. If ``diff`` is unavailable, it will skip it, but in that case it also cannot figure out if the files really differ.
|
||||
|
||||
The exit status is 1 if there was a difference and 2 for other errors, otherwise 0.
|
||||
|
||||
Options
|
||||
-------
|
||||
|
||||
The following options are available:
|
||||
|
||||
**-f** or **--no-functions**
|
||||
Stops checking functions
|
||||
|
||||
**-c** or **--no-completions**
|
||||
Stops checking completions
|
||||
|
||||
**-C** or **--no-config**
|
||||
Stops checking configuration files like config.fish or snippets in the conf.d directories.
|
||||
|
||||
**-d** or **--no-diff**
|
||||
Removes the diff display (this happens automatically if ``diff`` can't be found)
|
||||
|
||||
**-n** or **--new**
|
||||
Also prints new files (i.e. those that can't be found in fish's default directories).
|
||||
|
||||
**-Vvalue** or **--vendor=value**
|
||||
Determines how the vendor directories are counted. Valid values are:
|
||||
|
||||
- "default" - counts vendor files as belonging to the defaults. Any changes in other directories will be counted as changes over them. This is the default.
|
||||
- "user" - counts vendor files as belonging to the user files. Any changes in them will be counted as new or changed files.
|
||||
- "ignore" - ignores vendor directories. Files of the same name will be counted as "new" if no file of the same name in fish's default directories exists.
|
||||
|
||||
**-h** or **--help**
|
||||
Prints ``fish_delta``'s help (this).
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
Running just::
|
||||
|
||||
fish_delta
|
||||
|
||||
will give you a list of all your changed functions and completions, including diffs (if you have the ``diff`` command).
|
||||
|
||||
It might look like this::
|
||||
|
||||
> fish_delta
|
||||
New: /home/alfa/.config/fish/functions/battery.fish
|
||||
Changed: /home/alfa/.config/fish/test/completions/cargo.fish
|
||||
--- /home/alfa/.config/fish/test/completions/cargo.fish 2022-09-02 12:57:55.579229959 +0200
|
||||
+++ /usr/share/fish/completions/cargo.fish 2022-09-25 17:51:53.000000000 +0200
|
||||
# the output of `diff` follows
|
||||
|
||||
The options are there to select which parts of the output you want. With ``--no-completions`` you can compare just functions, and with ``--no-diff`` you can turn off the ``diff`` display.
|
||||
|
||||
To only compare your ``fish_git_prompt``, you might use::
|
||||
|
||||
fish_delta --no-completions fish_git_prompt
|
||||
|
||||
which will only compare files called "fish_git_prompt.fish".
|
||||
|
|
@ -24,18 +24,13 @@ The ``fish_git_prompt`` function displays information about the current git repo
|
|||
|
||||
`Git <https://git-scm.com>`_ must be installed.
|
||||
|
||||
There are numerous customization options, which can be controlled with git options or fish variables. git options, where available, take precedence over the fish variable with the same function. git options can be set on a per-repository or global basis. git options can be set with the ``git config`` command, while fish variables can be set as usual with the :doc:`set <set>` command.
|
||||
There are numerous customization options, which can be controlled with git options or fish variables. git options, where available, take precedence over the fish variable with the same function. git options can be set on a per-repository or global basis. git options can be set with the ``git config`` command, while fish variables can be set as usual with the :ref:`set <cmd-set>` command.
|
||||
|
||||
Boolean options (those which enable or disable something) understand "1", "yes" or "true" to mean true and every other value to mean false.
|
||||
- ``$__fish_git_prompt_show_informative_status`` or the git option ``bash.showInformativeStatus`` can be set to enable the "informative" display, which will show a large amount of information - the number of untracked files, dirty files, unpushed/unpulled commits, and more. In large repositories, this can take a lot of time, so it you may wish to disable it in these repositories with ``git config --local bash.showInformativeStatus false``. It also changes the characters the prompt uses to less plain ones (``✚`` instead of ``*`` for the dirty state for example) , and if you are only interested in that, set ``$__fish_git_prompt_use_informative_chars`` instead.
|
||||
|
||||
- ``$__fish_git_prompt_show_informative_status`` or the git option ``bash.showInformativeStatus`` can be set to 1, true or yes to enable the "informative" display, which will show a large amount of information - the number of dirty files, unpushed/unpulled commits, and more.
|
||||
In large repositories, this can take a lot of time, so you may wish to disable it in these repositories with ``git config --local bash.showInformativeStatus false``. It also changes the characters the prompt uses to less plain ones (``✚`` instead of ``*`` for the dirty state for example) , and if you are only interested in that, set ``$__fish_git_prompt_use_informative_chars`` instead.
|
||||
- ``$__fish_git_prompt_showdirtystate`` or the git option ``bash.showDirtyState`` can be set to show if the repository is "dirty", i.e. has uncommitted changes.
|
||||
|
||||
Because counting untracked files requires a lot of time, the number of untracked files is only shown if enabled via ``$__fish_git_prompt_showuntrackedfiles`` or the git option ``bash.showUntrackedFiles``.
|
||||
|
||||
- ``$__fish_git_prompt_showdirtystate`` or the git option ``bash.showDirtyState`` can be set to 1, true or yes to show if the repository is "dirty", i.e. has uncommitted changes.
|
||||
|
||||
- ``$__fish_git_prompt_showuntrackedfiles`` or the git option ``bash.showUntrackedFiles`` can be set to 1, true or yes to show if the repository has untracked files (that aren't ignored).
|
||||
- ``$__fish_git_prompt_showuntrackedfiles`` or the git option ``bash.showUntrackedFiles`` can be set to show if the repository has untracked files (that aren't ignored).
|
||||
|
||||
- ``$__fish_git_prompt_showupstream`` can be set to a list of values to determine how changes between HEAD and upstream are shown:
|
||||
|
||||
|
|
@ -54,7 +49,7 @@ Boolean options (those which enable or disable something) understand "1", "yes"
|
|||
``none``
|
||||
disables (useful with informative status)
|
||||
|
||||
- ``$__fish_git_prompt_showstashstate`` can be set to 1, true or yes to display the state of the stash.
|
||||
- ``$__fish_git_prompt_showstashstate`` can be set to display the state of the stash.
|
||||
|
||||
- ``$__fish_git_prompt_shorten_branch_len`` can be set to the number of characters that the branch name will be shortened to.
|
||||
|
||||
|
|
@ -71,7 +66,7 @@ Boolean options (those which enable or disable something) understand "1", "yes"
|
|||
|
||||
If none of these apply, the commit SHA shortened to 8 characters is used.
|
||||
|
||||
- ``$__fish_git_prompt_showcolorhints`` can be set to 1, true or yes to enable coloring for the branch name and status symbols.
|
||||
- ``$__fish_git_prompt_showcolorhints`` can be set to enable coloring for the branch name and status symbols.
|
||||
|
||||
A number of variables set characters and color used as indicators. Many of these have a different default if used with informative status enabled, or ``$__fish_git_prompt_use_informative_chars`` set. The usual default is given first, then the informative default (if it is different). If no default for the colors is given, they default to ``$__fish_git_prompt_color``.
|
||||
|
||||
|
|
@ -82,8 +77,10 @@ A number of variables set characters and color used as indicators. Many of these
|
|||
- ``$__fish_git_prompt_color_bare`` - the color to use for a bare repository - one without a working tree
|
||||
- ``$__fish_git_prompt_color_merging`` - the color when a merge/rebase/revert/bisect or cherry-pick is in progress
|
||||
|
||||
- ``$__fish_git_prompt_char_cleanstate`` (✔ in informative mode) - the character to be used when nothing else applies
|
||||
- ``$__fish_git_prompt_color_cleanstate`` (no default)
|
||||
Some variables are only used in some modes, like when informative status is enabled:
|
||||
|
||||
- ``$__fish_git_prompt_char_cleanstate`` (✔) - the character to be used when nothing else applies
|
||||
- ``$__fish_git_prompt_color_cleanstate``
|
||||
|
||||
Variables used with ``showdirtystate``:
|
||||
|
||||
|
|
@ -115,15 +112,13 @@ Variables used with ``showupstream`` (also implied by informative status):
|
|||
|
||||
Colors used with ``showcolorhints``:
|
||||
|
||||
- ``$__fish_git_prompt_color_branch`` (green) - the color of the branch if nothing else applies
|
||||
- ``$__fish_git_prompt_color_branch`` (green) - the color of the branch
|
||||
- ``$__fish_git_prompt_color_branch_detached`` (red) the color of the branch if it's detached (e.g. a commit is checked out)
|
||||
- ``$__fish_git_prompt_color_branch_dirty`` (no default) the color of the branch if it's dirty and not detached
|
||||
- ``$__fish_git_prompt_color_branch_staged`` (no default) the color of the branch if it just has something staged and is otherwise clean
|
||||
- ``$__fish_git_prompt_color_flags`` (--bold blue) - the default color for dirty/staged/stashed/untracked state
|
||||
|
||||
Note that all colors can also have a corresponding ``_done`` color. For example, the contents of ``$__fish_git_prompt_color_upstream_done`` is printed right _after_ the upstream.
|
||||
|
||||
See also :doc:`fish_vcs_prompt <fish_vcs_prompt>`, which will call all supported version control prompt functions, including git, Mercurial and Subversion.
|
||||
See also :ref:`fish_vcs_prompt <cmd-fish_vcs_prompt>`, which will call all supported version control prompt functions, including git, Mercurial and Subversion.
|
||||
|
||||
Example
|
||||
--------
|
||||
|
|
|
|||
|
|
@ -29,12 +29,6 @@ While you could also just put ``echo`` calls into config.fish, fish_greeting tak
|
|||
Example
|
||||
-------
|
||||
|
||||
To just empty the text, with the default greeting function::
|
||||
|
||||
set -U fish_greeting
|
||||
|
||||
or ``set -g fish_greeting`` in :ref:`config.fish <configuration>`.
|
||||
|
||||
A simple greeting:
|
||||
|
||||
::
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ The status symbols themselves:
|
|||
|
||||
Finally, ``$fish_prompt_hg_status_order``, which can be used to change the order the status symbols appear in. It defaults to ``added modified copied deleted untracked unmerged``.
|
||||
|
||||
See also :doc:`fish_vcs_prompt <fish_vcs_prompt>`, which will call all supported version control prompt functions, including git, Mercurial and Subversion.
|
||||
See also :ref:`fish_vcs_prompt <cmd-fish_vcs_prompt>`, which will call all supported version control prompt functions, including git, Mercurial and Subversion.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ The following options are available:
|
|||
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 <debugging-fish>` in :doc:`fish <fish>` (1) for details.
|
||||
Enable debug output and specify a pattern for matching debug categories. See :ref:`Debugging <debugging-fish>` in :ref:`fish <cmd-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 standard error.
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ Synopsis
|
|||
Description
|
||||
-----------
|
||||
|
||||
:program:`fish_key_reader` is used to explain how you would bind a certain key sequence. By default, it prints the :doc:`bind <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 <cmd-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 standard error.
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ You can also define an empty ``fish_mode_prompt`` function to remove the Vi mode
|
|||
function fish_mode_prompt; end
|
||||
funcsave fish_mode_prompt
|
||||
|
||||
``fish_mode_prompt`` will be executed when the vi mode changes. If it produces any output, it is displayed and used. If it does not, the other prompt functions (:doc:`fish_prompt <fish_prompt>` and :doc:`fish_right_prompt <fish_right_prompt>`) will be executed as well in case they contain a mode display.
|
||||
``fish_mode_prompt`` will be executed when the vi mode changes. If it produces any output, it is displayed and used. If it does not, the other prompt functions (:ref:`fish_prompt <cmd-fish_prompt>` and :ref:`fish_right_prompt <cmd-fish_right_prompt>`) will be executed as well in case they contain a mode display.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ Synopsis
|
|||
Description
|
||||
-----------
|
||||
|
||||
This command provides a way to produce option specifications suitable for use with the :doc:`argparse <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.
|
||||
This command provides a way to produce option specifications suitable for use with the :ref:`argparse <cmd-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:
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ A number of variables control the symbol ("display") and color ("color") for the
|
|||
- :envvar:`__fish_svn_prompt_char_token_broken_display`
|
||||
- :envvar:`__fish_svn_prompt_char_token_broken_color`
|
||||
|
||||
See also :doc:`fish_vcs_prompt <fish_vcs_prompt>`, which will call all supported version control prompt functions, including git, Mercurial and Subversion.
|
||||
See also :ref:`fish_vcs_prompt <cmd-fish_vcs_prompt>`, which will call all supported version control prompt functions, including git, Mercurial and Subversion.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
|
|
|||
|
|
@ -23,13 +23,13 @@ The ``fish_vcs_prompt`` function displays information about the current version
|
|||
|
||||
It calls out to VCS-specific functions. The currently supported systems are:
|
||||
|
||||
- :doc:`fish_git_prompt <fish_git_prompt>`
|
||||
- :doc:`fish_hg_prompt <fish_hg_prompt>`
|
||||
- :doc:`fish_svn_prompt <fish_svn_prompt>`
|
||||
- :ref:`fish_git_prompt <cmd-fish_git_prompt>`
|
||||
- :ref:`fish_hg_prompt <cmd-fish_hg_prompt>`
|
||||
- :ref:`fish_svn_prompt <cmd-fish_svn_prompt>`
|
||||
|
||||
If a VCS isn't installed, the respective function does nothing.
|
||||
|
||||
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 :doc:`funced <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 <cmd-funced>`.
|
||||
|
||||
For more information, see the documentation for each of the functions above.
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ 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.
|
||||
|
||||
Much like :doc:`set <set>`, **for** does not modify $status, but the evaluation of its subordinate commands can.
|
||||
Much like :ref:`set <cmd-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.
|
||||
|
||||
|
|
|
|||
|
|
@ -48,4 +48,4 @@ When you're done, use::
|
|||
|
||||
>_ funcsave fish_prompt
|
||||
|
||||
For more, see :doc:`funcsave <funcsave>`.
|
||||
For more, see :ref:`funcsave <cmd-funcsave>`.
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ Description
|
|||
|
||||
``funcsave`` saves a function to a file in the fish configuration directory. This function will be :ref:`automatically loaded <syntax-function-autoloading>` 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 :doc:`functions <functions>`'s ``--erase`` option, ``funcsave`` will remove the saved function definition.
|
||||
If you have erased a function using :ref:`functions <cmd-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 <event>` until they are run or otherwise sourced. To activate an event handler for every new shell, add the function to the :ref:`configuration file <configuration>` instead of using ``funcsave``.
|
||||
|
||||
This is often used after :doc:`funced <funced>`, which opens the function in ``$EDITOR`` or ``$VISUAL`` and loads it into the current session afterwards.
|
||||
This is often used after :ref:`funced <cmd-funced>`, which opens the function in ``$EDITOR`` or ``$VISUAL`` and loads it into the current session afterwards.
|
||||
|
|
|
|||
|
|
@ -21,19 +21,19 @@ A function is a list of commands that will be executed when the name of the func
|
|||
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*. These are the same arguments given in :envvar:`argv`, and are still available there. See also :ref:`Argument Handling <variables-argv>`.
|
||||
Assigns the value of successive command-line arguments to the names given in *NAMES*.
|
||||
|
||||
**-d** *DESCRIPTION* or **--description** *DESCRIPTION*
|
||||
A description of what the function does, suitable as a completion description.
|
||||
|
||||
**-w** *WRAPPED_COMMAND* or **--wraps** *WRAPPED_COMMAND*
|
||||
Inherit completions from the given *WRAPPED_COMMAND*. See the documentation for :doc:`complete <complete>` for more information.
|
||||
Inherit completions from the given *WRAPPED_COMMAND*. See the documentation for :ref:`complete <cmd-complete>` for more information.
|
||||
|
||||
**-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 :doc:`emit <emit>` command.
|
||||
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 <cmd-emit>` command.
|
||||
|
||||
**-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).
|
||||
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*
|
||||
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.
|
||||
|
|
@ -42,7 +42,7 @@ The following options are available:
|
|||
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** *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. Observing a signal will prevent fish from exiting in response to that signal.
|
||||
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.
|
||||
|
|
@ -52,9 +52,21 @@ The following options are available:
|
|||
**-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.
|
||||
|
||||
The event handler switches (``on-event``, ``on-variable``, ``on-job-exit``, ``on-process-exit`` and ``on-signal``) cause a function to run automatically at specific events. New named events for ``--on-event`` can be fired using the :doc:`emit <emit>` builtin. Fish already generates a few events, see :ref:`event` for more.
|
||||
If the user enters any additional arguments after the function, they are inserted into the environment :ref:`variable list <variables-lists>` ``$argv``. If the ``--argument-names`` option is provided, the arguments are also assigned to names specified in that option.
|
||||
|
||||
Functions may not be named the same as a reserved keyword. These are elements of fish syntax or builtin commands which are essential for the operations of the shell. Current reserved words are ``[``, ``_``, ``and``, ``argparse``, ``begin``, ``break``, ``builtin``, ``case``, ``command``, ``continue``, ``else``, ``end``, ``eval``, ``exec``, ``for``, ``function``, ``if``, ``not``, ``or``, ``read``, ``return``, ``set``, ``status``, ``string``, ``switch``, ``test``, ``time``, and ``while``.
|
||||
By using one of the event handler switches, a function can be made to run automatically at specific events. The user may generate new events using the :ref:`emit <cmd-emit>` builtin. Fish generates the following named events:
|
||||
|
||||
- ``fish_prompt``, which is emitted whenever a new fish prompt is about to be displayed.
|
||||
|
||||
- ``fish_preexec``, which is emitted right before executing an interactive command. The commandline is passed as the first parameter. Not emitted if command is empty.
|
||||
|
||||
- ``fish_posterror``, which is emitted right after executing a command with syntax errors. The commandline is passed as the first parameter.
|
||||
|
||||
- ``fish_postexec``, which is emitted right after executing an interactive command. The commandline is passed as the first parameter. Not emitted if command is empty.
|
||||
|
||||
- ``fish_exit`` is emitted right before fish exits.
|
||||
|
||||
- ``fish_cancel``, which is emitted when a commandline is cleared (used for terminal-shell integration).
|
||||
|
||||
Example
|
||||
-------
|
||||
|
|
|
|||
|
|
@ -31,13 +31,13 @@ The following options are available:
|
|||
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 in the current session. Use :doc:`funcsave <funcsave>` to remove the saved copy.
|
||||
Causes the specified functions to be erased. This also means that it is prevented from autoloading in the current session. Use :ref:`funcsave <cmd-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 standard input, **-** if the function was created via :doc:`source <source>`, and ``n/a`` if the function isn't available. (Functions created via :doc:`alias <alias>` will return **-**, because ``alias`` uses ``source`` internally. Copied functions will return where the function was copied.) If the **--verbose** option is also specified then five lines are written:
|
||||
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 <cmd-source>`, and ``n/a`` if the function isn't available. (Functions created via :ref:`alias <cmd-alias>` will return **-**, because ``alias`` uses ``source`` internally.) If the **--verbose** option is also specified then five lines are written:
|
||||
|
||||
- the path name as already described,
|
||||
- if the function was copied, the path name to where the function was originally defined, otherwise ``autoloaded``, ``not-autoloaded`` or ``n/a``,
|
||||
- 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 or has no description.
|
||||
|
|
|
|||
|
|
@ -19,15 +19,15 @@ If a *SECTION* is specified, the help for that command is shown.
|
|||
|
||||
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.
|
||||
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, you can set ``$fish_help_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 :doc:`fg <fg>` builtin.
|
||||
``help fg`` shows the documentation for the :ref:`fg <cmd-fg>` builtin.
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ Synopsis
|
|||
Description
|
||||
-----------
|
||||
|
||||
``if`` will execute the command ``CONDITION``. If the condition's exit status is 0, the commands ``COMMANDS_TRUE`` will execute. If the exit status is not 0 and :doc:`else <else>` is given, ``COMMANDS_FALSE`` will be executed.
|
||||
``if`` will execute the command ``CONDITION``. If the condition's exit status is 0, the commands ``COMMANDS_TRUE`` will execute. If the exit status is not 0 and :ref:`else <cmd-else>` is given, ``COMMANDS_FALSE`` will be executed.
|
||||
|
||||
You can use :doc:`and <and>` or :doc:`or <or>` in the condition. See the second example below.
|
||||
You can use :ref:`and <cmd-and>` or :ref:`or <cmd-or>` in the condition. See the second example below.
|
||||
|
||||
The exit status of the last foreground command to exit can always be accessed using the :ref:`$status <variables-status>` variable.
|
||||
|
||||
|
|
@ -29,6 +29,8 @@ Example
|
|||
|
||||
The following code will print ``foo.txt exists`` if the file foo.txt exists and is a regular file, otherwise it will print ``bar.txt exists`` if the file bar.txt exists and is a regular file, otherwise it will print ``foo.txt and bar.txt do not exist``.
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
if test -f foo.txt
|
||||
|
|
@ -42,6 +44,7 @@ The following code will print ``foo.txt exists`` if the file foo.txt exists and
|
|||
|
||||
The following code will print "foo.txt exists and is readable" if foo.txt is a regular file and readable
|
||||
|
||||
|
||||
::
|
||||
|
||||
if test -f foo.txt
|
||||
|
|
@ -49,15 +52,3 @@ The following code will print "foo.txt exists and is readable" if foo.txt is a r
|
|||
echo "foo.txt exists and is readable"
|
||||
end
|
||||
|
||||
|
||||
See also
|
||||
--------
|
||||
|
||||
``if`` is only as useful as the command used as the condition.
|
||||
|
||||
Fish ships a few:
|
||||
|
||||
- :doc:`test` can compare numbers, strings and check paths
|
||||
- :doc:`string` can perform string operations including wildcard and regular expression matches
|
||||
- :doc:`path` can check paths for permissions, existence or type
|
||||
- :doc:`contains` can check if an element is in a list
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ Synopsis
|
|||
|
||||
.. synopsis::
|
||||
|
||||
isatty [FILE_DESCRIPTOR]
|
||||
isatty [FILE DESCRIPTOR]
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ Description
|
|||
**-h** or **--help**
|
||||
Displays help about using this command.
|
||||
|
||||
On systems that support 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\%.
|
||||
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.
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ The following options are available:
|
|||
**-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 truncated, not rounded. Any non-integer component is thrown away.
|
||||
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.
|
||||
|
|
@ -64,8 +64,6 @@ Syntax
|
|||
For numbers, ``.`` is always the radix character regardless of locale - ``2.5``, not ``2,5``.
|
||||
Scientific notation (``10e5``) and hexadecimal (``0xFF``) are also available.
|
||||
|
||||
``math`` allows you to use underscores as visual separators for digit grouping. For example, you can write ``1_000_000``, ``0x_89_AB_CD_EF``, and ``1.234_567_e89``.
|
||||
|
||||
Operators
|
||||
---------
|
||||
|
||||
|
|
@ -76,15 +74,17 @@ Operators
|
|||
``-``
|
||||
for subtraction
|
||||
``*`` or ``x``
|
||||
for multiplication. ``*`` 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 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.
|
||||
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``.
|
||||
|
||||
|
|
@ -120,23 +120,9 @@ Functions
|
|||
arc tangent of two variables
|
||||
``bitand``, ``bitor`` and ``bitxor``
|
||||
perform bitwise operations.
|
||||
These will throw away any non-integer parts and interpret the rest as an int.
|
||||
|
||||
Note: ``bitnot`` and ``bitnand`` don't exist. This is because numbers in math don't really have a *width* in terms of bits,
|
||||
and these operations necessarily care about leading zeroes.
|
||||
|
||||
If you need to negate a specific number you can do it with an xor with a mask, e.g.::
|
||||
|
||||
> math --base=hex bitxor 0x0F, 0xFF
|
||||
0xF0
|
||||
|
||||
> math --base=hex bitxor 0x2, 0x3
|
||||
# Here we mask with 0x3 == 0b111, so our number is 3 bits wide
|
||||
# Only the 1 bit isn't set.
|
||||
0x1
|
||||
|
||||
These will throw away any non-integer parts andd interpret the rest as an int.
|
||||
``ceil``
|
||||
round number up to the nearest integer
|
||||
round number up to nearest integer
|
||||
``cos``
|
||||
the cosine
|
||||
``cosh``
|
||||
|
|
@ -146,7 +132,7 @@ Functions
|
|||
``fac``
|
||||
factorial - also known as ``x!`` (``x * (x - 1) * (x - 2) * ... * 1``)
|
||||
``floor``
|
||||
round number down to the nearest integer
|
||||
round number down to nearest integer
|
||||
``ln``
|
||||
the base-e logarithm
|
||||
``log`` or ``log10``
|
||||
|
|
@ -154,9 +140,9 @@ Functions
|
|||
``log2``
|
||||
the base-2 logarithm
|
||||
``max``
|
||||
returns the largest of the given numbers - this takes an arbitrary number of arguments (but at least one)
|
||||
returns the larger of two numbers
|
||||
``min``
|
||||
returns the smallest of the given numbers - this takes an arbitrary number of arguments (but at least one)
|
||||
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``
|
||||
|
|
@ -205,8 +191,6 @@ Examples
|
|||
|
||||
``math 'ncr(49,6)'`` prints 13983816 - that's the number of possible picks in 6-from-49 lotto.
|
||||
|
||||
``math max 5,2,3,1`` prints 5.
|
||||
|
||||
Compatibility notes
|
||||
-------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,6 @@ Example
|
|||
See Also
|
||||
--------
|
||||
|
||||
- the :doc:`cdh <cdh>` command to display a prompt to quickly navigate the history
|
||||
- the :doc:`dirh <dirh>` command to print the directory history
|
||||
- the :doc:`prevd <prevd>` command to move backward
|
||||
- the :ref:`cdh <cmd-cdh>` command to display a prompt to quickly navigate the history
|
||||
- the :ref:`dirh <cmd-dirh>` command to print the directory history
|
||||
- the :ref:`prevd <cmd-prevd>` command to move backward
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ Description
|
|||
|
||||
``or`` is used to execute a command if the previous command was not successful (returned a status of something other than 0).
|
||||
|
||||
``or`` statements may be used as part of the condition in an :doc:`if <if>` or :doc:`while <while>` block.
|
||||
``or`` statements may be used as part of the condition in an :ref:`and <cmd-if>` or :ref:`while <cmd-while>` block.
|
||||
|
||||
``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 <variables-status>` variable.
|
||||
|
||||
|
|
@ -33,4 +33,4 @@ The following code runs the ``make`` command to build a program. If the build su
|
|||
See Also
|
||||
--------
|
||||
|
||||
- :doc:`and <and>` command
|
||||
- :ref:`and <cmd-and>` command
|
||||
|
|
|
|||
|
|
@ -1,442 +0,0 @@
|
|||
.. _cmd-path:
|
||||
|
||||
path - manipulate and check paths
|
||||
=================================
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
|
||||
path basename GENERAL_OPTIONS [PATH ...]
|
||||
path dirname GENERAL_OPTIONS [PATH ...]
|
||||
path extension GENERAL_OPTIONS [PATH ...]
|
||||
path filter GENERAL_OPTIONS [-v | --invert]
|
||||
[-d] [-f] [-l] [-r] [-w] [-x]
|
||||
[(-t | --type) TYPE] [(-p | --perm) PERMISSION] [PATH ...]
|
||||
path is GENERAL_OPTIONS [(-v | --invert)] [(-t | --type) TYPE]
|
||||
[-d] [-f] [-l] [-r] [-w] [-x]
|
||||
[(-p | --perm) PERMISSION] [PATH ...]
|
||||
path mtime GENERAL_OPTIONS [(-R | --relative)] [PATH ...]
|
||||
path normalize GENERAL_OPTIONS [PATH ...]
|
||||
path resolve GENERAL_OPTIONS [PATH ...]
|
||||
path change-extension GENERAL_OPTIONS EXTENSION [PATH ...]
|
||||
path sort GENERAL_OPTIONS [-r | --reverse]
|
||||
[-u | --unique] [--key=basename|dirname|path] [PATH ...]
|
||||
|
||||
GENERAL_OPTIONS
|
||||
[-z | --null-in] [-Z | --null-out] [-q | --quiet]
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
``path`` performs operations on paths.
|
||||
|
||||
PATH 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 PATH per line. It is an error to supply PATH arguments on both the command line and on standard input.
|
||||
|
||||
Arguments starting 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.
|
||||
|
||||
When a path starts with ``-``, ``path filter`` and ``path normalize`` will prepend ``./`` on output to avoid it being interpreted as an option otherwise, so it's safe to pass path's output to other commands that can handle relative paths.
|
||||
|
||||
All 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.
|
||||
|
||||
All subcommands also accept a ``-Z`` or ``--null-out`` switch, which makes them print output separated with NUL instead of newlines. This is for further processing, e.g. passing to another ``path``, or ``xargs -0``. This is not recommended when the output goes to the terminal or a command substitution.
|
||||
|
||||
All subcommands also accept a ``-z`` or ``--null-in`` switch, which makes them accept arguments from stdin separated with NULL-bytes. Since Unix paths can't contain NULL, that makes it possible to handle all possible paths and read input from e.g. ``find -print0``. If arguments are given on the commandline this has no effect. This should mostly be unnecessary since ``path`` automatically starts splitting on NULL if one appears in the first PATH_MAX bytes, PATH_MAX being the operating system's maximum length for a path plus a NULL byte.
|
||||
|
||||
Some subcommands operate on the paths as strings and so work on nonexistent paths, while others need to access the paths themselves and so filter out nonexistent paths.
|
||||
|
||||
The following subcommands are available.
|
||||
|
||||
.. _cmd-path-basename:
|
||||
|
||||
"basename" subcommand
|
||||
---------------------
|
||||
|
||||
::
|
||||
|
||||
path basename [-z | --null-in] [-Z | --null-out] [-q | --quiet] [PATH ...]
|
||||
|
||||
``path basename`` returns the last path component of the given path, by removing the directory prefix and removing trailing slashes. In other words, it is the part that is not the dirname. For files you might call it the "filename".
|
||||
|
||||
It returns 0 if there was a basename, i.e. if the path wasn't empty or just slashes.
|
||||
|
||||
Examples
|
||||
^^^^^^^^
|
||||
|
||||
::
|
||||
|
||||
>_ path basename ./foo.mp4
|
||||
foo.mp4
|
||||
|
||||
>_ path basename ../banana
|
||||
banana
|
||||
|
||||
>_ path basename /usr/bin/
|
||||
bin
|
||||
|
||||
>_ path basename /usr/bin/*
|
||||
# This prints all files in /usr/bin/
|
||||
# A selection:
|
||||
cp
|
||||
fish
|
||||
grep
|
||||
rm
|
||||
|
||||
"dirname" subcommand
|
||||
--------------------
|
||||
|
||||
::
|
||||
|
||||
path dirname [-z | --null-in] [-Z | --null-out] [-q | --quiet] [PATH ...]
|
||||
|
||||
``path dirname`` returns the dirname for the given path. This is the part before the last "/", discounting trailing slashes. In other words, it is the part that is not the basename (discounting superfluous slashes).
|
||||
|
||||
It returns 0 if there was a dirname, i.e. if the path wasn't empty or just slashes.
|
||||
|
||||
Examples
|
||||
^^^^^^^^
|
||||
|
||||
::
|
||||
|
||||
>_ path dirname ./foo.mp4
|
||||
.
|
||||
|
||||
>_ path dirname ../banana
|
||||
..
|
||||
|
||||
>_ path dirname /usr/bin/
|
||||
/usr
|
||||
|
||||
"extension" subcommand
|
||||
-----------------------
|
||||
|
||||
::
|
||||
|
||||
path extension [-z | --null-in] [-Z | --null-out] [-q | --quiet] [PATH ...]
|
||||
|
||||
``path extension`` returns the extension of the given path. This is the part after (and including) the last ".", unless that "." followed a "/" or the basename is "." or "..", in which case there is no extension and an empty line is printed.
|
||||
|
||||
If the filename ends in a ".", only a "." is printed.
|
||||
|
||||
It returns 0 if there was an extension.
|
||||
|
||||
Examples
|
||||
^^^^^^^^
|
||||
|
||||
::
|
||||
|
||||
>_ path extension ./foo.mp4
|
||||
.mp4
|
||||
|
||||
>_ path extension ../banana
|
||||
# an empty line, status 1
|
||||
|
||||
>_ path extension ~/.config
|
||||
# an empty line, status 1
|
||||
|
||||
>_ path extension ~/.config.d
|
||||
.d
|
||||
|
||||
>_ path extension ~/.config.
|
||||
.
|
||||
|
||||
>_ set -l path (path change-extension '' ./foo.mp4)
|
||||
>_ set -l extension (path extension ./foo.mp4)
|
||||
> echo $path$extension
|
||||
# reconstructs the original path again.
|
||||
./foo.mp4
|
||||
|
||||
.. _cmd-path-filter:
|
||||
|
||||
"filter" subcommand
|
||||
--------------------
|
||||
|
||||
::
|
||||
|
||||
path filter [-z | --null-in] [-Z | --null-out] [-q | --quiet] \
|
||||
[-d] [-f] [-l] [-r] [-w] [-x] \
|
||||
[-v | --invert] [(-t | --type) TYPE] [(-p | --perm) PERMISSION] [PATH ...]
|
||||
|
||||
``path filter`` returns all of the given paths that match the given checks. In all cases, the paths need to exist, nonexistent paths are always filtered.
|
||||
|
||||
The available filters are:
|
||||
|
||||
- ``-t`` or ``--type`` with the options: "dir", "file", "link", "block", "char", "fifo" and "socket", in which case the path needs to be a directory, file, link, block device, character device, named pipe or socket, respectively.
|
||||
- ``-d``, ``-f`` and ``-l`` are short for ``--type=dir``, ``--type=file`` and ``--type=link``, respectively. There are no shortcuts for the other types.
|
||||
|
||||
- ``-p`` or ``--perm`` with the options: "read", "write", and "exec", as well as "suid", "sgid", "user" (referring to the path owner) and "group" (referring to the path's group), in which case the path needs to have all of the given permissions for the current user.
|
||||
- ``-r``, ``-w`` and ``-x`` are short for ``--perm=read``, ``--perm=write`` and ``--perm=exec``, respectively. There are no shortcuts for the other permissions.
|
||||
|
||||
Note that the path needs to be *any* of the given types, but have *all* of the given permissions. This is because having a path that is both writable and executable makes sense, but having a path that is both a directory and a file doesn't. Links will count as the type of the linked-to file, so links to files count as files, links to directories count as directories.
|
||||
|
||||
The filter options can either be given as multiple options, or comma-separated - ``path filter -t dir,file`` or ``path filter --type dir --type file`` are equivalent.
|
||||
|
||||
With ``--invert``, the meaning of the filtering is inverted - any path that wouldn't pass (including by not existing) passes, and any path that would pass fails.
|
||||
|
||||
When a path starts with ``-``, ``path filter`` will prepend ``./`` to avoid it being interpreted as an option otherwise.
|
||||
|
||||
It returns 0 if at least one path passed the filter.
|
||||
|
||||
``path is`` is shorthand for ``path filter -q``, i.e. just checking without producing output, see :ref:`The is subcommand <cmd-path-is>`.
|
||||
|
||||
Examples
|
||||
^^^^^^^^
|
||||
|
||||
::
|
||||
|
||||
>_ path filter /usr/bin /usr/argagagji
|
||||
# The (hopefully) nonexistent argagagji is filtered implicitly:
|
||||
/usr/bin
|
||||
|
||||
>_ path filter --type file /usr/bin /usr/bin/fish
|
||||
# Only fish is a file
|
||||
/usr/bin/fish
|
||||
|
||||
>_ path filter --type file,dir --perm exec,write /usr/bin/fish /home/me
|
||||
# fish is a file, which passes, and executable, which passes,
|
||||
# but probably not writable, which fails.
|
||||
#
|
||||
# $HOME is a directory and both writable and executable, typically.
|
||||
# So it passes.
|
||||
/home/me
|
||||
|
||||
>_ path filter -fdxw /usr/bin/fish /home/me
|
||||
# This is the same as above: "-f" is "--type=file", "-d" is "--type=dir",
|
||||
# "-x" is short for "--perm=exec" and "-w" short for "--perm=write"!
|
||||
/home/me
|
||||
|
||||
>_ path filter -fx $PATH/*
|
||||
# Prints all possible commands - the first entry of each name is what fish would execute!
|
||||
|
||||
.. _cmd-path-is:
|
||||
|
||||
"is" subcommand
|
||||
--------------------
|
||||
|
||||
::
|
||||
|
||||
path is [-z | --null-in] [-Z | --null-out] [-q | --quiet] \
|
||||
[-d] [-f] [-l] [-r] [-w] [-x] \
|
||||
[-v | --invert] [(-t | --type) TYPE] [(-p | --perm) PERMISSION] [PATH ...]
|
||||
|
||||
``path is`` is short for ``path filter -q``. It returns true if any of the given files passes the filter, but does not produce any output.
|
||||
|
||||
``--quiet`` can still be passed for compatibility but is redundant. The options are the same as for ``path filter``.
|
||||
|
||||
Examples
|
||||
^^^^^^^^
|
||||
|
||||
::
|
||||
|
||||
>_ path is /usr/bin /usr/argagagji
|
||||
# /usr/bin exists, so this returns a status of 0 (true). It prints nothing.
|
||||
>_ path is /usr/argagagji
|
||||
# /usr/argagagji does not, so this returns a status of 1 (false). It also prints nothing.
|
||||
>_ path is -fx /bin/sh
|
||||
# /bin/sh is usually an executable file, so this returns true.
|
||||
|
||||
"mtime" subcommand
|
||||
-----------------------
|
||||
|
||||
::
|
||||
|
||||
path mtime [-z | --null-in] [-Z | --null-out] [-q | --quiet] [-R | --relative] [PATH ...]
|
||||
|
||||
``path mtime`` returns the last modification time ("mtime" in unix jargon) of the given paths, in seconds since the unix epoch (the beginning of the 1st of January 1970).
|
||||
|
||||
With ``--relative`` (or ``-R``), it prints the number of seconds since the modification time. It only reads the current time once at start, so in case multiple paths are given the times are all relative to the *start* of ``path mtime -R`` running.
|
||||
|
||||
If you want to know if a file is newer or older than another file, consider using ``test -nt`` instead. See :doc:`the test documentation <test>`.
|
||||
|
||||
It returns 0 if reading mtime for any path succeeded.
|
||||
|
||||
Examples
|
||||
^^^^^^^^
|
||||
|
||||
::
|
||||
|
||||
>_ date +%s
|
||||
# This prints the current time as seconds since the epoch
|
||||
1657217847
|
||||
|
||||
>_ path mtime /etc/
|
||||
1657213796
|
||||
|
||||
>_ path mtime -R /etc/
|
||||
4078
|
||||
# So /etc/ on this system was last modified a little over an hour ago
|
||||
|
||||
# This is the same as
|
||||
>_ math (date +%s) - (path mtime /etc/)
|
||||
|
||||
"normalize" subcommand
|
||||
-----------------------
|
||||
|
||||
::
|
||||
|
||||
path normalize [-z | --null-in] [-Z | --null-out] [-q | --quiet] [PATH ...]
|
||||
|
||||
``path normalize`` returns the normalized versions of all paths. That means it squashes duplicate "/" (except for two leading "//"), collapses "../" with earlier components and removes "." components.
|
||||
|
||||
Unlike ``realpath`` or ``path resolve``, it does not make the paths absolute. It also does not resolve any symlinks. As such it can operate on non-existent paths.
|
||||
|
||||
Because it operates on paths as strings and doesn't resolve symlinks, it works sort of like ``pwd -L`` and ``cd``. E.g. ``path normalize link/..`` will return ``.``, just like ``cd link; cd ..`` would return to the current directory. For a physical view of the filesystem, see ``path resolve``.
|
||||
|
||||
Leading "./" components are usually removed. But when a path starts with ``-``, ``path normalize`` will add it instead to avoid confusion with options.
|
||||
|
||||
It returns 0 if any normalization was done, i.e. any given path wasn't in canonical form.
|
||||
|
||||
Examples
|
||||
^^^^^^^^
|
||||
|
||||
::
|
||||
|
||||
>_ path normalize /usr/bin//../../etc/fish
|
||||
# The "//" is squashed and the ".." components neutralize the components before
|
||||
/etc/fish
|
||||
|
||||
>_ path normalize /bin//bash
|
||||
# The "//" is squashed, but /bin isn't resolved even if your system links it to /usr/bin.
|
||||
/bin/bash
|
||||
|
||||
>_ path normalize ./my/subdirs/../sub2
|
||||
my/sub2
|
||||
|
||||
>_ path normalize -- -/foo
|
||||
./-/foo
|
||||
|
||||
"resolve" subcommand
|
||||
--------------------
|
||||
|
||||
::
|
||||
|
||||
path resolve [-z | --null-in] [-Z | --null-out] [-q | --quiet] [PATH ...]
|
||||
|
||||
``path resolve`` returns the normalized, physical and absolute versions of all paths. That means it resolves symlinks and does what ``path normalize`` does: it squashes duplicate "/", collapses "../" with earlier components and removes "." components. Then it turns that path into the absolute path starting from the filesystem root "/".
|
||||
|
||||
It is similar to ``realpath``, as it creates the "real", canonical version of the path. However, for paths that can't be resolved, e.g. if they don't exist or form a symlink loop, it will resolve as far as it can and normalize the rest.
|
||||
|
||||
Because it resolves symlinks, it works sort of like ``pwd -P``. E.g. ``path resolve link/..`` will return the parent directory of what the link points to, just like ``cd link; cd (pwd -P)/..`` would go to it. For a logical view of the filesystem, see ``path normalize``.
|
||||
|
||||
It returns 0 if any normalization or resolution was done, i.e. any given path wasn't in canonical form.
|
||||
|
||||
Examples
|
||||
^^^^^^^^
|
||||
|
||||
::
|
||||
|
||||
>_ path resolve /bin//sh
|
||||
# The "//" is squashed, and /bin is resolved if your system links it to /usr/bin.
|
||||
# sh here is bash (this is common on linux systems)
|
||||
/usr/bin/bash
|
||||
|
||||
>_ path resolve /bin/foo///bar/../baz
|
||||
# Assuming /bin exists and is a symlink to /usr/bin, but /bin/foo doesn't.
|
||||
# This resolves the /bin/ and normalizes the nonexistent rest:
|
||||
/usr/bin/foo/baz
|
||||
|
||||
"change-extension" subcommand
|
||||
-----------------------------
|
||||
|
||||
::
|
||||
|
||||
path change-extension [-z | --null-in] [-Z | --null-out] \
|
||||
[-q | --quiet] EXTENSION [PATH ...]
|
||||
|
||||
``path change-extension`` returns the given paths, with their extension changed to the given new extension. The extension is the part after (and including) the last ".", unless that "." followed a "/" or the basename is "." or "..", in which case there is no previous extension and the new one is simply added.
|
||||
|
||||
If the extension is empty, any previous extension is stripped, along with the ".". This is, of course, the inverse of ``path extension``.
|
||||
|
||||
One leading dot on the extension is ignored, so ".mp3" and "mp3" are treated the same.
|
||||
|
||||
It returns 0 if it was given any paths.
|
||||
|
||||
Examples
|
||||
^^^^^^^^
|
||||
|
||||
::
|
||||
|
||||
>_ path change-extension mp4 ./foo.wmv
|
||||
./foo.mp4
|
||||
|
||||
>_ path change-extension .mp4 ./foo.wmv
|
||||
./foo.mp4
|
||||
|
||||
>_ path change-extension '' ../banana
|
||||
../banana
|
||||
# but status 1, because there was no extension.
|
||||
|
||||
>_ path change-extension '' ~/.config
|
||||
/home/alfa/.config
|
||||
# status 1
|
||||
|
||||
>_ path change-extension '' ~/.config.d
|
||||
/home/alfa/.config
|
||||
# status 0
|
||||
|
||||
>_ path change-extension '' ~/.config.
|
||||
/home/alfa/.config
|
||||
# status 0
|
||||
|
||||
"sort" subcommand
|
||||
-----------------------------
|
||||
|
||||
::
|
||||
|
||||
path sort [-z | --null-in] [-Z | --null-out] \
|
||||
[-q | --quiet] [-r | --reverse] \
|
||||
[--key=basename|dirname|path] [PATH ...]
|
||||
|
||||
|
||||
``path sort`` returns the given paths in sorted order. They are sorted in the same order as globs - alphabetically, but with runs of numerical digits compared numerically.
|
||||
|
||||
With ``--reverse`` or ``-r`` the sort is reversed.
|
||||
|
||||
With ``--key=`` only the given part of the path is compared, e.g. ``--key=dirname`` causes only the dirname to be compared, ``--key=basename`` only the basename and ``--key=path`` causes the entire path to be compared (this is the default).
|
||||
|
||||
With ``--unique`` or ``-u`` the sort is deduplicated, meaning only the first of a run that have the same key is kept. So if you are sorting by basename, then only the first of each basename is used.
|
||||
|
||||
The sort used is stable, so sorting first by basename and then by dirname works and causes the files to be grouped according to directory.
|
||||
|
||||
It currently returns 0 if it was given any paths.
|
||||
|
||||
Examples
|
||||
^^^^^^^^
|
||||
|
||||
::
|
||||
|
||||
>_ path sort 10-foo 2-bar
|
||||
2-bar
|
||||
10-foo
|
||||
|
||||
>_ path sort --reverse 10-foo 2-bar
|
||||
10-foo
|
||||
2-bar
|
||||
|
||||
>_ path sort --unique --key=basename $fish_function_path/*.fish
|
||||
# prints a list of all function files fish would use, sorted by name.
|
||||
|
||||
|
||||
Combining ``path``
|
||||
-------------------
|
||||
|
||||
``path`` is meant to be easy to combine with itself, other tools and fish.
|
||||
|
||||
This is why
|
||||
|
||||
- ``path``'s output is automatically split by fish if it goes into a command substitution, so just doing ``(path ...)`` handles all paths, even those containing newlines, correctly
|
||||
- ``path`` has ``--null-in`` to handle null-delimited input (typically automatically detected!), and ``--null-out`` to pass on null-delimited output
|
||||
|
||||
Some examples of combining ``path``::
|
||||
|
||||
# Expand all paths in the current directory, leave only executable files, and print their resolved path
|
||||
path filter -zZ -xf -- * | path resolve -z
|
||||
|
||||
# The same thing, but using find (note -maxdepth needs to come first or find will scream)
|
||||
# (this also depends on your particular version of find)
|
||||
# Note the `-z` is unnecessary for any sensible version of find - if `path` sees a NULL,
|
||||
# it will split on NULL automatically.
|
||||
find . -maxdepth 1 -type f -executable -print0 | path resolve -z
|
||||
|
||||
set -l paths (path filter -p exec $PATH/fish -Z | path resolve)
|
||||
|
|
@ -13,7 +13,7 @@ Synopsis
|
|||
Description
|
||||
-----------
|
||||
|
||||
``popd`` removes the top directory from the :ref:`directory stack <directory-stack>` and changes the working directory to the new top directory. Use :doc:`pushd <pushd>` to add directories to the stack.
|
||||
``popd`` removes the top directory from the :ref:`directory stack <directory-stack>` and changes the working directory to the new top directory. Use :ref:`pushd <cmd-pushd>` to add directories to the stack.
|
||||
|
||||
The **-h** or **--help** option displays help about using this command.
|
||||
|
||||
|
|
@ -37,5 +37,5 @@ Example
|
|||
See Also
|
||||
--------
|
||||
|
||||
- the :doc:`dirs <dirs>` command to print the directory stack
|
||||
- the :doc:`cdh <cdh>` command which provides a more intuitive way to navigate to recently visited directories.
|
||||
- the :ref:`dirs <cmd-dirs>` command to print the directory stack
|
||||
- the :ref:`cdh <cmd-cdh>` command which provides a more intuitive way to navigate to recently visited directories.
|
||||
|
|
|
|||
|
|
@ -41,6 +41,6 @@ Example
|
|||
See Also
|
||||
--------
|
||||
|
||||
- the :doc:`cdh <cdh>` command to display a prompt to quickly navigate the history
|
||||
- the :doc:`dirh <dirh>` command to print the directory history
|
||||
- the :doc:`nextd <nextd>` command to move forward
|
||||
- the :ref:`cdh <cmd-cdh>` command to display a prompt to quickly navigate the history
|
||||
- the :ref:`dirh <cmd-dirh>` command to print the directory history
|
||||
- the :ref:`nextd <cmd-nextd>` command to move forward
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ Description
|
|||
|
||||
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 :doc:`echo <echo>`, ``printf`` does not append a new line unless it is specified as part of the string.
|
||||
Unlike :ref:`echo <cmd-echo>`, ``printf`` does not append a new line unless it is specified as part of the string.
|
||||
|
||||
It doesn't support any options, so there is no need for a ``--`` separator, which makes it easier to use for arbitrary input than ``echo``. [#]_
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ Will print "Number of bananas in my pocket: 42", `without` a newline.
|
|||
See Also
|
||||
--------
|
||||
|
||||
- the :doc:`echo <echo>` command, for simpler output
|
||||
- the :ref:`echo <cmd-echo>` command, for simpler output
|
||||
|
||||
Footnotes
|
||||
---------
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ Description
|
|||
|
||||
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 :envvar:`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 :envvar:`PWD`.
|
||||
If any positional arguments are given, ``prompt_pwd`` shortens them instead of $PWD.
|
||||
|
||||
Options
|
||||
-------
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ Synopsis
|
|||
Description
|
||||
-----------
|
||||
|
||||
The ``pushd`` function adds *DIRECTORY* to the top of the :ref:`directory stack <directory-stack>` and makes it the current working directory. :doc:`popd <popd>` will pop it off and return to the original directory.
|
||||
The ``pushd`` function adds *DIRECTORY* to the top of the :ref:`directory stack <directory-stack>` and makes it the current working directory. :ref:`popd <cmd-popd>` will pop it off and return to the original directory.
|
||||
|
||||
Without arguments, it exchanges the top two directories in the stack.
|
||||
|
||||
|
|
@ -49,5 +49,5 @@ Example
|
|||
See Also
|
||||
--------
|
||||
|
||||
- the :doc:`dirs <dirs>` command to print the directory stack
|
||||
- the :doc:`cdh <cdh>` command which provides a more intuitive way to navigate to recently visited directories.
|
||||
- the :ref:`dirs <cmd-dirs>` command to print the directory stack
|
||||
- the :ref:`cdh <cmd-cdh>` command which provides a more intuitive way to navigate to recently visited directories.
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ The following options are available:
|
|||
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-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 :doc:`echo <echo>` command.
|
||||
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 <cmd-echo>` 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.
|
||||
|
|
@ -98,29 +98,26 @@ is set to empty and the exit status is set to 122. This limit can be altered wit
|
|||
Example
|
||||
-------
|
||||
|
||||
``read`` has a few separate uses.
|
||||
The following code stores the value 'hello' in the shell variable :envvar:`$foo`.
|
||||
|
||||
|
||||
The following code stores the value 'hello' in the shell variable :envvar:`foo`.
|
||||
|
||||
::
|
||||
|
||||
echo hello|read foo
|
||||
|
||||
While this is a neat way to handle command output line-by-line::
|
||||
|
||||
# This is a neat way to handle command output by-line:
|
||||
printf '%s\n' line1 line2 line3 line4 | while read -l foo
|
||||
echo "This is another line: $foo"
|
||||
end
|
||||
|
||||
Delimiters given via "-d" are taken as one string::
|
||||
|
||||
# Delimiters given via "-d" are taken as one string
|
||||
echo a==b==c | read -d == -l a b c
|
||||
echo $a # a
|
||||
echo $b # b
|
||||
echo $c # c
|
||||
|
||||
``--tokenize`` honors quotes and escaping like the shell's argument passing::
|
||||
|
||||
# --tokenize honors quotes and escaping like the shell's argument passing:
|
||||
echo 'a\ b' | read -t first second
|
||||
echo $first # outputs "a b", $second is empty
|
||||
|
||||
|
|
@ -128,5 +125,3 @@ Delimiters given via "-d" are taken as one string::
|
|||
echo $a # outputs 'afoo bar' (without the quotes)
|
||||
echo $b # outputs '(command echo wurst)* {a,b}' (without the quotes)
|
||||
echo $c # nothing
|
||||
|
||||
For an example on interactive use, see :ref:`Querying for user input <user-input>`.
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ Description
|
|||
To see the documentation on the ``realpath`` command you might have,
|
||||
use ``command man realpath``.
|
||||
|
||||
:program:`realpath` follows all symbolic links encountered for the provided :envvar:`PATH`, printing the absolute path resolved. :doc:`fish <fish>` provides a :command:`realpath`-alike builtin intended to enrich systems where no such command is installed by default.
|
||||
:program:`realpath` follows all symbolic links encountered for the provided :envvar:`PATH`, printing the absolute path resolved. :ref:`fish <cmd-fish>` provides a :command:`realpath`-alike builtin intended to be enrich systems where no such command is installed by default.
|
||||
|
||||
If a :command:`realpath` command exists, that will be preferred.
|
||||
``builtin realpath`` will explicitly use the fish implementation of :command:`realpath`.
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ Description
|
|||
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 :doc:`if <if>` statement or a :doc:`switch <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.
|
||||
It is often added inside of a conditional block such as an :ref:`if <cmd-if>` statement or a :ref:`switch <cmd-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.
|
||||
|
||||
If at the top level of a script, it exits with the given status, like :doc:`exit <exit>`.
|
||||
If at the top level of a script, it exits with the given status, like :ref:`exit <cmd-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.
|
||||
|
|
|
|||
|
|
@ -8,99 +8,76 @@ Synopsis
|
|||
|
||||
.. synopsis::
|
||||
|
||||
set
|
||||
set (-f | --function) (-l | local) (-g | --global) (-U | --universal)
|
||||
set [-Uflg] NAME [VALUE ...]
|
||||
set [-Uflg] NAME[[INDEX ...]] [VALUE ...]
|
||||
set (-a | --append) [-flgU] NAME VALUE ...
|
||||
set (-q | --query) (-e | --erase) [-flgU] [NAME][[INDEX]] ...]
|
||||
set (-S | --show) [NAME ...]
|
||||
set [SCOPE_OPTIONS]
|
||||
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 <variables>`.
|
||||
|
||||
If both *NAME* and *VALUE* are provided, ``set`` assigns any values to variable *NAME*.
|
||||
Variables in fish are :ref:`lists <variables-lists>`, multiple values are allowed.
|
||||
One or more variable *INDEX* can be specified including ranges (not for all options.)
|
||||
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 <variables-lists>`, multiple values are allowed.
|
||||
|
||||
If no *VALUE* is given, the variable will be set to the empty list i.e. ``''``.
|
||||
If only a variable name has been given, ``set`` sets the variable to the empty list.
|
||||
|
||||
If ``set`` is ran without arguments, it prints the names and values of all shell variables in sorted order.
|
||||
Passing :ref:`scope <variables-scope>` or :ref:`export <variables-export>` flags allows filtering this to only matching variables, so ``set --local`` would only show local variables.
|
||||
If ``set`` is called with no arguments, it prints the names and values of all shell variables in sorted order. Passing :ref:`scope <variables-scope>` or :ref:`export <variables-export>` flags allows filtering this to only matching variables, so ``set --local`` would only show local variables.
|
||||
|
||||
With ``--erase`` and optionally a scope flag ``set`` will erase the matching variable (or the variable of that name in the smallest possible scope).
|
||||
|
||||
With ``--show``, ``set`` will describe the given variable names, explaining how they have been defined - in which scope with which values and options.
|
||||
|
||||
The following scope control variable scope:
|
||||
|
||||
**-U** or **--universal**
|
||||
Sets a universal variable.
|
||||
The variable will be immediately available to all the user's ``fish`` instances on the machine, and will be persist across restarts of the shell.
|
||||
The following options control variable scope:
|
||||
|
||||
**-f** or **--function**
|
||||
Sets a variable scoped to the executing function.
|
||||
It is erased when the function ends.
|
||||
Scopes the variable to the currently executing function. It is erased when the function ends.
|
||||
|
||||
**-l** or **--local**
|
||||
Sets a locally-scoped variable in this block.
|
||||
It is erased when the block ends.
|
||||
Outside of a block, this is the same as **--function**.
|
||||
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**
|
||||
Sets a globally-scoped variable.
|
||||
Global variables are available to all functions running in the same shell.
|
||||
They can be modified or erased.
|
||||
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.
|
||||
|
||||
These options modify how variables operate:
|
||||
**-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.
|
||||
|
||||
**--export** or **-x**
|
||||
Causes the specified shell variable to be exported to child processes (making it an "environment variable").
|
||||
These options control additional variable options:
|
||||
|
||||
**--unexport** or **-u**
|
||||
Causes the specified shell variable to NOT be exported to child processes.
|
||||
**-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
|
||||
|
||||
**--path**
|
||||
Treat specified variable as a :ref:`path variable <variables-path>`; variable will be split on colons (``:``) and will be displayed joined by colons colons when quoted (``echo "$PATH"``) or exported.
|
||||
Causes the specified variable to be treated as a :ref:`path variable <variables-path>`, meaning it will automatically be split on colons, and joined using colons when quoted (``echo "$PATH"``) or exported.
|
||||
|
||||
**--unpath**
|
||||
Causes variable to no longer be tred as a :ref:`path variable <variables-path>`.
|
||||
Note: variables ending in "PATH" are automatically path variables.
|
||||
Causes the specified variable to not be treated as a :ref:`path variable <variables-path>`. Variables with a name ending in "PATH" are automatically path variables, so this can be used to treat such a variable normally.
|
||||
|
||||
Further options:
|
||||
The following other options are available:
|
||||
|
||||
**-a** or **--append** *NAME* *VALUE* ...
|
||||
Appends *VALUES* to the current set of values for variable **NAME**.
|
||||
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** *NAME* *VALUE* ...
|
||||
Prepends *VALUES* to the current set of values for variable **NAME**.
|
||||
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** *NAME*[*INDEX*]
|
||||
Causes the specified shell variables to be erased.
|
||||
Supports erasing from multiple scopes at once.
|
||||
Individual items in a variable at *INDEX* in brackets can be specified.
|
||||
**-e** or **--erase**
|
||||
Causes the specified shell variables to be erased
|
||||
|
||||
**-q** or **--query** *NAME*[*INDEX*]
|
||||
Test if the specified variable names are defined.
|
||||
If an *INDEX* is provided, check for items at that slot.
|
||||
Does not output anything, but the shell status is set to 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.
|
||||
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.
|
||||
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.
|
||||
|
|
@ -108,48 +85,38 @@ Further options:
|
|||
**-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.
|
||||
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.
|
||||
|
||||
If the variable name is one or more list elements, such as ``PATH[1 3 7]``, only those list elements specified will be changed.
|
||||
If you specify a negative index when expanding or assigning to a list variable, the index will be calculated from the end of the list.
|
||||
For example, the index -1 means the last index of a list.
|
||||
If the variable name is one or more list elements, such as ``PATH[1 3 7]``, only those list elements specified will be changed. If you specify a negative index when expanding or assigning to a list variable, the index will be calculated from the end of the list. For example, the index -1 means the last index of a list.
|
||||
|
||||
The scoping rules when creating or updating a variable are:
|
||||
|
||||
- Variables may be explicitly set as universal, global, function, or local.
|
||||
Variables with the same name but in a different scope will not be changed.
|
||||
- Variables may be explicitly set to universal, global or local. Variables with the same name in different scopes will not be changed.
|
||||
|
||||
- If the scope of a variable is not explicitly set *but a variable by that name has been previously defined*, the scope of the existing variable is used.
|
||||
If the variable is already defined in multiple scopes, the variable with the narrowest scope will be updated.
|
||||
- If a variable is not explicitly set to be either universal, global or local, but has been previously defined, the previous variable scope is used.
|
||||
|
||||
- If a variable's scope is not explicitly set and there is no existing variable by that name, the variable will be local to the currently executing function.
|
||||
Note that this is different from using the ``-l`` or ``--local`` flag, in which case the variable will be local to the most-inner currently executing block, while without them the variable will be local to the function as a whole.
|
||||
If no function is executing, the variable will be set in the global scope.
|
||||
- If a variable is not explicitly set to be either universal, global or local and has never before been defined, the variable will be local to the currently executing function. Note that this is different from using the ``-l`` or ``--local`` flag. If one of those flags is used, the variable will be local to the most inner currently executing block, while without these the variable will be local to the function. If no function is executing, the variable will be global.
|
||||
|
||||
|
||||
The exporting rules when creating or updating a variable are identical to the scoping rules for variables:
|
||||
|
||||
- Variables may be explicitly set to either exported or not exported.
|
||||
When an exported variable goes out of scope, it is unexported.
|
||||
- Variables may be explicitly set to either exported or not exported. When an exported variable goes out of scope, it is unexported.
|
||||
|
||||
- If a variable is not explicitly set to be exported or not exported, but has been previously defined, the previous exporting rule for the variable is kept.
|
||||
|
||||
- If a variable is not explicitly set to be either exported or unexported and has never before been defined, the variable will not be exported.
|
||||
|
||||
In query mode, the scope to be examined can be specified.
|
||||
Whether the variable has to be a path variable or exported can also be specified.
|
||||
|
||||
In query mode, the scope to be examined can be specified. Whether the variable has to be a path variable or exported can also be specified.
|
||||
|
||||
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 :envvar:`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 :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 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.
|
||||
|
||||
|
|
@ -159,58 +126,49 @@ In erase mode, ``set`` exits with a zero exit status in case of success, with a
|
|||
Examples
|
||||
--------
|
||||
|
||||
Print all global, exported variables::
|
||||
::
|
||||
|
||||
> set -gx
|
||||
# Prints all global, exported variables.
|
||||
set -xg
|
||||
|
||||
Set the value of the variable _$foo_ to be 'hi'.::
|
||||
# Sets the value of the variable $foo to be 'hi'.
|
||||
set foo hi
|
||||
|
||||
> set foo hi
|
||||
# Appends the value "there" to the variable $foo.
|
||||
set -a foo there
|
||||
|
||||
Append the value "there" to the variable $foo::
|
||||
# Does the same thing as the previous two commands the way it would be done pre-fish 3.0.
|
||||
set foo hi
|
||||
set foo $foo there
|
||||
|
||||
> set -a foo there
|
||||
# Removes the variable $smurf
|
||||
set -e smurf
|
||||
|
||||
Remove _$smurf_ from the scope::
|
||||
|
||||
> set -e smurf
|
||||
|
||||
Remove _$smurf_ from the global and universal scopes::
|
||||
|
||||
> set -e -Ug smurf
|
||||
|
||||
Change the fourth element of the $PATH list to ~/bin::
|
||||
|
||||
> set PATH[4] ~/bin
|
||||
|
||||
Outputs the path to Python if ``type -p`` returns true::
|
||||
# Changes the fourth element of the $PATH list to ~/bin
|
||||
set PATH[4] ~/bin
|
||||
|
||||
# Outputs the path to Python if ``type -p`` returns true.
|
||||
if set python_path (type -p python)
|
||||
echo "Python is at $python_path"
|
||||
end
|
||||
|
||||
Setting a variable doesn't modify $status; a command substitution still will, though::
|
||||
# Setting a variable doesn't modify $status!
|
||||
false
|
||||
set foo bar
|
||||
echo $status # prints 1, because of the "false" above.
|
||||
|
||||
> echo $status
|
||||
0
|
||||
> false
|
||||
> set foo bar
|
||||
> echo $status
|
||||
1
|
||||
> true
|
||||
> set foo banana (false)
|
||||
> echo $status
|
||||
1
|
||||
|
||||
``VAR=VALUE command`` sets a variable for just one command, like other shells.
|
||||
This runs fish with a temporary home directory::
|
||||
|
||||
> HOME=(mktemp -d) fish
|
||||
|
||||
(which is essentially the same as)::
|
||||
|
||||
> begin; set -lx HOME (mktemp -d); fish; end
|
||||
true
|
||||
set foo banana (false)
|
||||
echo $status # prints 1, because of the "(false)" above.
|
||||
|
||||
# Like other shells, pass a variable to just one command:
|
||||
# Run fish with a temporary home directory.
|
||||
HOME=(mktemp -d) fish
|
||||
# Which is essentially the same as:
|
||||
begin; set -lx HOME (mktemp -d); fish; end
|
||||
|
||||
Notes
|
||||
-----
|
||||
- Fish versions prior to 3.0 supported the syntax ``set PATH[1] PATH[4] /bin /sbin``, which worked like ``set PATH[1 4] /bin /sbin``.
|
||||
|
||||
Fish versions prior to 3.0 supported the syntax ``set PATH[1] PATH[4] /bin /sbin``, which worked like
|
||||
``set PATH[1 4] /bin /sbin``. This syntax was not widely used, and was ambiguous and inconsistent.
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ Synopsis
|
|||
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 an 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:
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ The following options are available:
|
|||
Sets the background color.
|
||||
|
||||
**-c** or **--print-colors**
|
||||
Prints the given colors or a colored list of the 16 named colors.
|
||||
Prints a list of the 16 named colors.
|
||||
|
||||
**-o** or **--bold**
|
||||
Sets bold mode.
|
||||
|
|
@ -87,9 +87,9 @@ In particular it will:
|
|||
|
||||
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 :envvar:`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 -d term_support`` will include diagnostic messages that indicate the color support mode in use.
|
||||
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.
|
||||
|
||||
The ``set_color`` command uses the terminfo database to look up how to change terminal colors on whatever terminal is in use. Some systems have old and incomplete terminfo databases, and lack color information for terminals that support it. Fish assumes that all terminals can use the [ANSI X3.64](https://en.wikipedia.org/wiki/ANSI_escape_code) escape sequences if the terminfo definition indicates a color below 16 is not supported.
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ Synopsis
|
|||
status is-full-job-control
|
||||
status is-interactive-job-control
|
||||
status current-command
|
||||
status current-commandline
|
||||
status filename
|
||||
status basename
|
||||
status dirname
|
||||
|
|
@ -44,7 +43,7 @@ The following operations (subcommands) are available:
|
|||
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 :doc:`breakpoint <breakpoint>` command. See also the :doc:`fish_breakpoint_prompt <fish_breakpoint_prompt>` function.
|
||||
Returns 0 if fish is currently showing a prompt in the context of a :ref:`breakpoint <cmd-breakpoint>` command. See also the :ref:`fish_breakpoint_prompt <cmd-fish_breakpoint_prompt>` function.
|
||||
|
||||
**is-interactive**, **-i** or **--is-interactive**
|
||||
Returns 0 if fish is interactive - that is, connected to a keyboard.
|
||||
|
|
@ -64,11 +63,8 @@ The following operations (subcommands) are available:
|
|||
**current-command**
|
||||
Prints the name of the currently-running function or command, like the deprecated :envvar:`_` variable.
|
||||
|
||||
**current-commandline**
|
||||
Prints the entirety of the currently-running commandline, inclusive of all jobs and operators.
|
||||
|
||||
**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 :doc:`source <source>`, then this will return ``-``.
|
||||
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 <cmd-source>`, then this will return ``-``.
|
||||
|
||||
**basename**
|
||||
Prints just the filename of the running script, without any path components before.
|
||||
|
|
@ -77,7 +73,7 @@ The following operations (subcommands) are available:
|
|||
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. This is a best-effort attempt and the exact output is down to what the platform gives fish. In some cases you might only get "fish".
|
||||
Prints the absolute path to the currently executing instance of fish.
|
||||
|
||||
**function** or **current-function**
|
||||
Prints the name of the currently called function if able, when missing displays "Not a function" (or equivalent translated string).
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ Synopsis
|
|||
|
||||
.. synopsis::
|
||||
|
||||
string collect [-a | --allow-empty] [-N | --no-trim-newlines] [STRING ...]
|
||||
string collect [-N | --no-trim-newlines] [STRING ...]
|
||||
|
||||
.. END SYNOPSIS
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue