mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
Merge branch 'master' into history-glob-search
This commit is contained in:
commit
e99f137356
65 changed files with 2079 additions and 1808 deletions
2
.gitattributes
vendored
2
.gitattributes
vendored
|
@ -22,6 +22,8 @@
|
|||
# for linguist; let github identify our project as C++ instead of C due to pcre2
|
||||
/pcre2-10.22/ linguist-vendored
|
||||
/pcre2-10.22/* linguist-vendored
|
||||
/muparser-2.2.5/ linguist-vendored
|
||||
/muparser-2.2.5/* linguist-vendored
|
||||
angular.js linguist-vendored
|
||||
/doc_src/* linguist-documentation
|
||||
*.fish linguist-language=fish
|
||||
|
|
|
@ -24,11 +24,11 @@ matrix:
|
|||
- lib32ncurses5-dev
|
||||
- g++-multilib
|
||||
env:
|
||||
- CXXFLAGS="-g -m32" CFLAGS="-g -m32"
|
||||
- CXXFLAGS="-g -O2 -m32" CFLAGS="-g -m32"
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env:
|
||||
- CXXFLAGS="-g -fno-omit-frame-pointer -fsanitize=address" ASAN_OPTIONS=check_initialization_order=1:detect_stack_use_after_return=1:detect_leaks=1
|
||||
- CXXFLAGS="-g -O2 -fno-omit-frame-pointer -fsanitize=address" ASAN_OPTIONS=check_initialization_order=1:detect_stack_use_after_return=1:detect_leaks=1
|
||||
before_install: export CXX=clang++-3.8
|
||||
addons:
|
||||
apt:
|
||||
|
@ -49,7 +49,7 @@ matrix:
|
|||
- brew install pcre2 # use system PCRE2
|
||||
- brew outdated xctool || brew upgrade xctool # for xcode... soon.
|
||||
env:
|
||||
- CXXFLAGS="-g -lstdc++"
|
||||
- CXXFLAGS="-g -O2 -lstdc++"
|
||||
fast_finish: true
|
||||
|
||||
script:
|
||||
|
|
22
BSDmakefile
22
BSDmakefile
|
@ -1,9 +1,17 @@
|
|||
warn:
|
||||
@echo "Error: BSD Make not supported"
|
||||
@echo "Please use GNU Make (gmake) to build fish. Refer to README.md for detailed build instructions."
|
||||
JARG =
|
||||
GMAKE = "gmake"
|
||||
.if "$(.MAKE.JOBS)" != ""
|
||||
JARG = -j$(.MAKE.JOBS)
|
||||
.endif
|
||||
|
||||
all: warn
|
||||
install: warn
|
||||
test: warn
|
||||
#by default bmake will cd into ./obj first
|
||||
.OBJDIR: ./
|
||||
|
||||
.DONE .DEFAULT: .SILENT
|
||||
$(GMAKE) $(.TARGETS:S,.DONE,,) $(JARG)
|
||||
|
||||
.ERROR: .SILENT
|
||||
if ! which $(GMAKE) > /dev/null; then \
|
||||
echo "GNU Make is required!"; \
|
||||
fi
|
||||
|
||||
.PHONY: warn all install test
|
||||
|
|
38
CHANGELOG.md
38
CHANGELOG.md
|
@ -21,9 +21,14 @@ This section is for changes merged to the `major` branch that are not also merge
|
|||
- Using a read-only variable in a for loop is now an error. Note that this never worked. It simply failed to set the for loop var and thus silently produced incorrect results (#4342).
|
||||
- `math` is now a builtin rather than a wrapper around `bc` (#3157).
|
||||
- `history search` supports globs for wildcard searching (#3136).
|
||||
- `bind` has a new `--silent` option to ignore bind requests for named keys not available under the current `$TERMINAL` (#4188, #4431)
|
||||
|
||||
## Other significant changes
|
||||
- Command substitution output is now limited to 10 MB by default (#3822).
|
||||
- Added completions for
|
||||
- `j` (autojump #4344)
|
||||
- Improved completions for
|
||||
- `git` (#4395, #4396)
|
||||
|
||||
|
||||
# fish 2.7b1
|
||||
|
@ -35,8 +40,8 @@ This section is for changes merged to the `major` branch that are not also merge
|
|||
- Invalid array indexes are now silently ignored (#826, #4127).
|
||||
- `string escape` has a new `--style=xxx` flag where `xxx` can be `script`, `var`, or `url` (#4150).
|
||||
- `string unescape` has been implemented to reverse the effects of `string escape` (#3543).
|
||||
- The history file can now be specified by setting the `FISH_HISTORY` variable (#102).
|
||||
- Read history is now controlled by the `FISH_HISTORY` variable rather than the `--mode-name` flag (#1504).
|
||||
- The history file can now be specified by setting the `fish_history` variable (#102).
|
||||
- Read history is now controlled by the `fish_history` variable rather than the `--mode-name` flag (#1504).
|
||||
- Implement a `cdh` (change directory using recent history) command to provide a more friendly alternative to prevd/nextd and pushd/popd (#2847).
|
||||
- `command` now supports a `-a` flag to report all directories with the command. This means that `which -a $cmd` is no longer necessary (#2778).
|
||||
- `--init-command`/`-C` added to the command line switches, to allow execution of commands before starting the interactive shell (#4164).
|
||||
|
@ -59,10 +64,35 @@ This section is for changes merged to the `major` branch that are not also merge
|
|||
- Option completion for `apt list` now works properly (#4350).
|
||||
- Added completions for:
|
||||
- `as` (#4130)
|
||||
- `cdh` (#2847)
|
||||
- `dhcpd`
|
||||
- `ezjail-admin` (#4324)
|
||||
- `fab` (fabric, #4153)
|
||||
- `grub-file` (#4119)
|
||||
- `grub-install` (#4119)
|
||||
- `jest` (#4142)
|
||||
- `kdeconnect-cli`
|
||||
- `magneto` (#4043, #4108)
|
||||
- `mdadm` (#4198)
|
||||
- `s3cmd` (#4332)
|
||||
- `sbt` (#4347)
|
||||
- `subl` (Sublime Text 3 editor, #4277)
|
||||
- `snap` (#4215)
|
||||
- `subl` (Sublime Text 3 editor, #4277)
|
||||
|
||||
- Improved completions for:
|
||||
- `apt`
|
||||
- `cd` (#4061)
|
||||
- `composer` (#4295)
|
||||
- `git` (#4117, #4147, #4329, #4368)
|
||||
- `gphoto2`
|
||||
- `killall` (#4052)
|
||||
- `ln`
|
||||
- `npm` (#4241)
|
||||
- `ssh` (#4377)
|
||||
- `tail`
|
||||
- `xdg-mime` (#4333)
|
||||
- `zypper` (#4325)
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
@ -105,7 +135,7 @@ If you are upgrading from version 2.5.0 or before, please also review the releas
|
|||
- `status` supports a new `current-function` subcommand to print the current function name (#1743).
|
||||
- `string` supports a new `repeat` subcommand (#3864). `string match` supports a new `--entire` option to emit the entire line matched by a pattern (#3957). `string replace` supports a new `--filter` option to only emit lines which underwent a replacement (#3348).
|
||||
- `test` supports the `-k` option to test for sticky bits (#733).
|
||||
- `umask` understands symbolic modes (#738).
|
||||
- `umask` understands symbolic modes (#738).
|
||||
- Empty components in the `CDPATH`, `MANPATH` and `PATH` variables are now converted to "." (#2106, #3914).
|
||||
- New versions of ncurses (6.0 and up) wipe terminal scrollback buffers with certain commands; the `C-l` binding tries to avoid this (#2855).
|
||||
- Some systems' `su` implementations do not set the `USER` environment variable; it is now reset for root users (#3916).
|
||||
|
|
|
@ -648,13 +648,13 @@ install: all install-force | check-legacy-binaries
|
|||
@echo
|
||||
@if type chsh >/dev/null 2>&1; then \
|
||||
echo To use fish as your login shell:; \
|
||||
grep -q -- "$(DESTDIR)$(bindir)/fish" /etc/shells || echo \* add the line \'$(DESTDIR)$(bindir)/fish\' to the file \'/etc/shells\'; \
|
||||
echo " * run $(yellow)chsh -s $(DESTDIR)$(bindir)/fish$(sgr0)"; \
|
||||
grep -q -- "$(DESTDIR)$(bindir)/fish" /etc/shells || echo \ \* add the line \'$(DESTDIR)$(bindir)/fish\' to the file \'/etc/shells\'; \
|
||||
echo " * run '$(yellow)chsh -s $(DESTDIR)$(bindir)/fish$(sgr0)'"; \
|
||||
echo; \
|
||||
fi;
|
||||
@if type chcon >/dev/null 2>&1; then \
|
||||
echo If you have SELinux enabled, you may need to manually update the security policy:; \
|
||||
echo \* use the command \'chcon -t shell_exec_t $(DESTDIR)$(bindir)/fish\'.; \
|
||||
echo \ \* use the command \'chcon -t shell_exec_t $(DESTDIR)$(bindir)/fish\'; \
|
||||
echo; \
|
||||
fi;
|
||||
@echo "To set your colors, run $(green)$(bo)fish_config$(sgr0)"
|
||||
|
@ -727,6 +727,8 @@ install-force: all install-translations install-doc | show-datadir show-sysconfd
|
|||
$(INSTALL) -m 644 $$i $(DESTDIR)$(mandir)/man1/; \
|
||||
true; \
|
||||
done;
|
||||
@echo "Installing miscellaneous helper resources";
|
||||
$v $(INSTALL) -m 644 share/lynx.lss $(DESTDIR)$(datadir)/fish/
|
||||
.PHONY: install-force
|
||||
|
||||
#
|
||||
|
|
18
README.md
18
README.md
|
@ -99,9 +99,9 @@ If you wish to use fish as your default shell, use the following command:
|
|||
|
||||
chsh -s /usr/local/bin/fish
|
||||
|
||||
chsh will prompt you for your password, and change your default shell. Substitute "/usr/local/bin/fish" with whatever path to fish is in your /etc/shells file.
|
||||
chsh will prompt you for your password, and change your default shell. Substitute `/usr/local/bin/fish` with whatever path to fish is in your `/etc/shells` file.
|
||||
|
||||
Use the following command if you didn't already add your fish path to /etc/shells.
|
||||
Use the following command if you didn't already add your fish path to `/etc/shells`.
|
||||
|
||||
echo /usr/local/bin/fish | sudo tee -a /etc/shells
|
||||
|
||||
|
@ -109,7 +109,7 @@ To switch your default shell back, you can run:
|
|||
|
||||
chsh -s /bin/bash
|
||||
|
||||
Substitute /bin/bash with /bin/tcsh or /bin/zsh as appropriate.
|
||||
Substitute `/bin/bash` with `/bin/tcsh` or `/bin/zsh` as appropriate.
|
||||
|
||||
You may need to logout/login for the change (chsh) to take effect.
|
||||
|
||||
|
@ -133,12 +133,14 @@ Compiling from git (that is, not a released tarball) also requires:
|
|||
* automake 1.13 or later
|
||||
* Doxygen (1.8.7 or later) - optional, for documentation
|
||||
|
||||
### Autotools Build
|
||||
### Building from source
|
||||
|
||||
autoreconf --no-recursive [if building from Git]
|
||||
./configure
|
||||
make [gmake on BSD]
|
||||
sudo make install [sudo gmake install on BSD]
|
||||
```bash
|
||||
autoreconf --no-recursive #if building from Git
|
||||
./configure
|
||||
make
|
||||
sudo make install
|
||||
```
|
||||
|
||||
### Xcode Development Build
|
||||
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
#!/bin/sh
|
||||
# Reminder of how to run Include What You Use
|
||||
|
||||
make iwyu
|
|
@ -3,7 +3,7 @@
|
|||
\subsection bind-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
bind [(-M | --mode) MODE] [(-m | --sets-mode) NEW_MODE]
|
||||
[(-k | --key)] SEQUENCE COMMAND [COMMAND...]
|
||||
[(-s | --silent)] [(-k | --key)] SEQUENCE COMMAND [COMMAND...]
|
||||
bind [(-M | --mode) MODE] [(-k | --key)] SEQUENCE
|
||||
bind (-K | --key-names) [(-a | --all)]
|
||||
bind (-f | --function-names)
|
||||
|
@ -20,7 +20,7 @@ SEQUENCE is the character sequence to bind to. These should be written as <a hre
|
|||
|
||||
The default key binding can be set by specifying a `SEQUENCE` of the empty string (that is, ```''``` ). It will be used whenever no other binding matches. For most key bindings, it makes sense to use the `self-insert` function (i.e. ```bind '' self-insert```) as the default keybinding. This will insert any keystrokes not specifically bound to into the editor. Non- printable characters are ignored by the editor, so this will not result in control sequences being printable.
|
||||
|
||||
If the `-k` switch is used, the name of the 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.)
|
||||
If the `-k` switch is used, the name of the 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.) If used in conjunction with the `-s` switch, `bind` will silently ignore bindings to named keys that are not found in termcap for the current `$TERMINAL`, otherwise a warning is emitted.
|
||||
|
||||
`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.
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@ The following options are available:
|
|||
|
||||
- `-a` or `--all` returns all the external commands that are found in `$PATH` in the order they are found.
|
||||
|
||||
- `-q` or `--quiet`, in conjunction with `-s`, silences the output and prints nothing, setting only the exit code.
|
||||
|
||||
- `-s` or `--search` returns the name of the external command that would be executed, or nothing if no file with the specified name could be found in the `$PATH`.
|
||||
|
||||
With the `-s` option, `command` treats every argument as a separate command to look up and sets the exit status to 0 if any of the specified commands were found, or 1 if no commands could be found. Additionally passing a `-q` or `--quiet` option prevents any paths from being printed, like the `type -q`, for testing only the exit status.
|
||||
|
|
|
@ -107,7 +107,6 @@ end
|
|||
|
||||
See the documentation for <a href="commands.html#test">`test`</a> and <a href="commands.html#if">`if`</a> for more information.
|
||||
|
||||
Use the <a href="commands.html#fish_update_completions">`fish_update_completions`</a> command.
|
||||
<hr>
|
||||
\section faq-single-env How do I set an environment variable for just one command?
|
||||
|
||||
|
|
|
@ -66,9 +66,9 @@ history delete --prefix "foo"
|
|||
|
||||
By default interactive commands are logged to `$XDG_DATA_HOME/fish/fish_history` (typically `~/.local/share/fish/fish_history`).
|
||||
|
||||
You can set the `FISH_HISTORY` variable to another name for the current shell session. The default value (when the variable is unset) is `fish` which corresponds to `$XDG_DATA_HOME/fish/fish_history`. If you set it to e.g. `fun`, the history would be written to `$XDG_DATA_HOME/fish/fun_history`. An empty string means history will not be stored at all. This is similar to the private session features in web browsers.
|
||||
You can set the `fish_history` variable to another name for the current shell session. The default value (when the variable is unset) is `fish` which corresponds to `$XDG_DATA_HOME/fish/fish_history`. If you set it to e.g. `fun`, the history would be written to `$XDG_DATA_HOME/fish/fun_history`. An empty string means history will not be stored at all. This is similar to the private session features in web browsers.
|
||||
|
||||
You can change `FISH_HISTORY` at any time (by using `set -x FISH_HISTORY "session_name"`) and it will take effect right away. If you set it to `"default"`, it will use the default session name (which is `"fish"`).
|
||||
You can change `fish_history` at any time (by using `set -x fish_history "session_name"`) and it will take effect right away. If you set it to `"default"`, it will use the default session name (which is `"fish"`).
|
||||
|
||||
Other shells such as bash and zsh use a variable named `HISTFILE` for a similar purpose. Fish uses a different name to avoid conflicts and signal that the behavior is different (session name instead of a file path). Also, if you set the var to anything other than `fish` or `default` it will inhibit importing the bash history. That's because the most common use case for this feature is to avoid leaking private or sensitive history when giving a presentation.
|
||||
|
||||
|
|
|
@ -695,7 +695,7 @@ After a variable has been set, you can use the value of a variable in the shell
|
|||
|
||||
Example:
|
||||
|
||||
To use the value of the variable `smurf`, write `$` (dollar symbol) followed by the name of the variable, like `echo Smurfs are usually $smurf_color`, which would print the result 'Smurfs are usually blue'.
|
||||
To use the value of the variable `smurf_color`, write `$` (dollar symbol) followed by the name of the variable, like `echo Smurfs are usually $smurf_color`, which would print the result 'Smurfs are usually blue'.
|
||||
|
||||
|
||||
\subsection variables-scope Variable scope
|
||||
|
@ -852,7 +852,7 @@ The user can change the settings of `fish` by changing the values of certain var
|
|||
|
||||
- `history`, an array containing the last commands that were entered.
|
||||
|
||||
- `FISH_HISTORY`: Name of the history session. It defaults to `fish` (which typically means the history will be saved in `~/.local/share/fish/fish_history`). This variable can be changed by the user. It does not have to be an environment variable. You can change it at will within an interactive fish session to change where subsequent commands are logged.
|
||||
- `fish_history`: Name of the history session. It defaults to `fish` (which typically means the history will be saved in `~/.local/share/fish/fish_history`). This variable can be changed by the user. It does not have to be an environment variable. You can change it at will within an interactive fish session to change where subsequent commands are logged.
|
||||
|
||||
- `HOME`, the user's home directory. This variable can be changed by the user.
|
||||
|
||||
|
@ -1137,7 +1137,10 @@ History searches can be aborted by pressing the escape key.
|
|||
|
||||
Prefixing the commandline with a space will prevent the entire line from being stored in the history.
|
||||
|
||||
The command history is stored in the file `~/.local/share/fish/fish_history` (or `$XDG_DATA_HOME/fish/fish_history` if that variable is set) by default. However, you can set the `FISH_HISTORY` environment variable to change the name of the history session (resulting in a `<session>_history` file); both before starting the shell and while the shell is running.
|
||||
The command history is stored in the file `~/.local/share/fish/fish_history` (or
|
||||
`$XDG_DATA_HOME/fish/fish_history` if that variable is set) by default. However, you can set the
|
||||
`fish_history` environment variable to change the name of the history session (resulting in a
|
||||
`<session>_history` file); both before starting the shell and while the shell is running.
|
||||
|
||||
Examples:
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ is set to empty and the exit status is set to 122. This limit can be altered wit
|
|||
|
||||
\subsection read-history Using another read history file
|
||||
|
||||
The `read` command supported the `-m` and `--mode-name` flags in fish versions prior to 2.7.0 to specify an alternative read history file. Those flags are now deprecated and ignored. Instead, set the `FISH_HISTORY` variable to specify a history session ID. That will affect both the `read` history file and the fish command history file. You can set it to an empty string to specify that no history should be read or written. This is useful for presentations where you do not want possibly private or sensitive history to be exposed to the audience but do want history relevant to the presentation to be available.
|
||||
The `read` command supported the `-m` and `--mode-name` flags in fish versions prior to 2.7.0 to specify an alternative read history file. Those flags are now deprecated and ignored. Instead, set the `fish_history` variable to specify a history session ID. That will affect both the `read` history file and the fish command history file. You can set it to an empty string to specify that no history should be read or written. This is useful for presentations where you do not want possibly private or sensitive history to be exposed to the audience but do want history relevant to the presentation to be available.
|
||||
|
||||
\subsection read-example Example
|
||||
|
||||
|
|
|
@ -139,6 +139,22 @@ if test $status -eq 0
|
|||
end
|
||||
\endfish
|
||||
|
||||
The previous test can likewise be inverted:
|
||||
|
||||
\fish
|
||||
if test ! $status -eq 0
|
||||
echo "Previous command failed"
|
||||
end
|
||||
\endfish
|
||||
|
||||
which is logically equivalent to the following:
|
||||
|
||||
\fish
|
||||
if test $status -ne 0
|
||||
echo "Previous command failed"
|
||||
end
|
||||
\endfish
|
||||
|
||||
\subsection test-standards Standards
|
||||
|
||||
`test` implements a subset of the <a href="http://www.unix.com/man-page/POSIX/1/test/">IEEE Std 1003.1-2008 (POSIX.1) standard</a>. The following exceptions apply:
|
||||
|
|
|
@ -117,6 +117,7 @@
|
|||
9C7A557D1DCD71890049C25D /* fish_key_reader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9C7A557C1DCD717C0049C25D /* fish_key_reader.cpp */; };
|
||||
9C7A557E1DCD71CD0049C25D /* print_help.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0A0855613B3ACEE0099B651 /* print_help.cpp */; };
|
||||
9C7A55811DCD739C0049C25D /* fish_key_reader in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9C7A55721DCD71330049C25D /* fish_key_reader */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
9CC8D8C51F7AF0D40095062A /* lynx.lss in Copy Files */ = {isa = PBXBuildFile; fileRef = 9CC8D8C41F7AF0610095062A /* lynx.lss */; };
|
||||
CB0F034C1F156FE3001827D3 /* builtin_argparse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CB0F034A1F156FE3001827D3 /* builtin_argparse.cpp */; };
|
||||
CB0F034D1F156FE3001827D3 /* builtin_argparse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CB0F034A1F156FE3001827D3 /* builtin_argparse.cpp */; };
|
||||
CB0F034E1F156FE3001827D3 /* builtin_argparse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CB0F034A1F156FE3001827D3 /* builtin_argparse.cpp */; };
|
||||
|
@ -641,6 +642,7 @@
|
|||
dstPath = "${INSTALL_PATH}/share/fish";
|
||||
dstSubfolderSpec = 0;
|
||||
files = (
|
||||
9CC8D8C51F7AF0D40095062A /* lynx.lss in Copy Files */,
|
||||
D07D267215E34171009E43F6 /* config.fish in Copy Files */,
|
||||
D07D266C15E33B86009E43F6 /* completions in Copy Files */,
|
||||
D07D266D15E33B86009E43F6 /* functions in Copy Files */,
|
||||
|
@ -689,6 +691,7 @@
|
|||
63A2C0E81CC5F9FB00973404 /* pcre2_find_bracket.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pcre2_find_bracket.c; sourceTree = "<group>"; };
|
||||
9C7A55721DCD71330049C25D /* fish_key_reader */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = fish_key_reader; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
9C7A557C1DCD717C0049C25D /* fish_key_reader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = fish_key_reader.cpp; sourceTree = "<group>"; };
|
||||
9CC8D8C41F7AF0610095062A /* lynx.lss */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = lynx.lss; path = share/lynx.lss; sourceTree = "<group>"; };
|
||||
CB0F034A1F156FE3001827D3 /* builtin_argparse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = builtin_argparse.cpp; sourceTree = "<group>"; };
|
||||
CB0F034B1F156FE3001827D3 /* builtin_argparse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = builtin_argparse.h; sourceTree = "<group>"; };
|
||||
D00769421990137800CA4627 /* fish_tests */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = fish_tests; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
|
@ -1283,6 +1286,7 @@
|
|||
D0D02AAB15985C14008E62BD /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9CC8D8C41F7AF0610095062A /* lynx.lss */,
|
||||
D0879AC616BF9A1A00E98E56 /* fish_term_icon.icns */,
|
||||
D07B247215BCC15700D4ADB4 /* add-shell */,
|
||||
D0CBD586159EF0E10024809C /* launch_fish.scpt */,
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
language = ""
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
|
@ -36,6 +37,7 @@
|
|||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
language = ""
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
language = ""
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
|
@ -36,6 +37,7 @@
|
|||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
language = ""
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
|
|
|
@ -48,6 +48,18 @@ print \"\n\".join(installed_packages)
|
|||
" | python
|
||||
end
|
||||
|
||||
function __fish_composer_scripts
|
||||
test -f composer.json; or return
|
||||
echo "
|
||||
import json
|
||||
json_data = open('composer.json')
|
||||
data = json.load(json_data)
|
||||
json_data.close()
|
||||
if 'scripts' in data and data['scripts']:
|
||||
print \"\n\".join(data['scripts'].keys())
|
||||
" | python
|
||||
end
|
||||
|
||||
#add cmds list
|
||||
set --local composer_cmds 'about' 'archive' 'browse' 'clear-cache' 'clearcache' 'config' 'create-project' 'depends' 'diagnose' 'dump-autoload' 'dumpautoload' 'global' 'help' 'home' 'init' 'install' 'licenses' 'list' 'remove' 'require' 'run-script' 'search' 'self-update' 'selfupdate' 'show' 'status' 'update' 'validate'
|
||||
|
||||
|
@ -65,6 +77,10 @@ complete -f -c composer -n '__fish_composer_using_command why' -a "(__fish_compo
|
|||
complete -f -c composer -n '__fish_composer_using_command why-not' -a "(__fish_composer_installed_packages)"
|
||||
complete -f -c composer -n '__fish_composer_using_command depends' -a "(__fish_composer_installed_packages)"
|
||||
|
||||
# Custom scripts
|
||||
complete -f -c composer -n '__fish_composer_needs_command' -a '(__fish_composer_scripts)' -d 'User script'
|
||||
complete -f -c composer -n '__fish_composer_using_command run-script' -a "(__fish_composer_scripts)"
|
||||
|
||||
#popisky
|
||||
complete -f -c composer -n '__fish_composer_needs_command' -a 'about' -d 'Short information about Composer'
|
||||
complete -f -c composer -n '__fish_composer_needs_command' -a 'archive' -d 'Create an archive of this composer package'
|
||||
|
|
|
@ -30,9 +30,9 @@ complete -f -c flatpak -n "not __fish_seen_subcommand_from $commands" -a build-i
|
|||
complete -f -c flatpak -n "not __fish_seen_subcommand_from $commands" -a build-sign -d 'Sign an application or runtime'
|
||||
complete -f -c flatpak -n "not __fish_seen_subcommand_from $commands" -a build-update-repo -d 'Update the summary file in a repository'
|
||||
|
||||
complete -f -c flatpak -n "__fish_seen_subcommand_from run" -a "(flatpak list --app | string trim)"
|
||||
complete -f -c flatpak -n "__fish_seen_subcommand_from info uninstall" -a "(flatpak list | string trim)"
|
||||
complete -f -c flatpak -n "__fish_seen_subcommand_from remote-ls remote-modify remote-delete" -a "(flatpak remote-list | string trim)"
|
||||
complete -f -c flatpak -n "__fish_seen_subcommand_from run" -a "(flatpak list --app | string trim | string match -r '^\S+')"
|
||||
complete -f -c flatpak -n "__fish_seen_subcommand_from info uninstall" -a "(flatpak list | string trim | string match -r '^\S+')"
|
||||
complete -f -c flatpak -n "__fish_seen_subcommand_from remote-ls remote-modify remote-delete" -a "(flatpak remote-list | string trim | string match -r '^\S+')"
|
||||
|
||||
# Note that "remote-ls" opens an internet connection, so we don't want to complete "install"
|
||||
# Plenty of the other stuff is too free-form to complete (e.g. remote-add).
|
||||
|
|
10
share/completions/j.fish
Normal file
10
share/completions/j.fish
Normal file
|
@ -0,0 +1,10 @@
|
|||
function __history_completions --argument limit
|
||||
if echo $limit | string match -q ""
|
||||
set limit 25
|
||||
end
|
||||
|
||||
set -l tokens (commandline --current-process --tokenize)
|
||||
history --prefix (commandline) | string replace -r \^$tokens[1]\\s\* "" | head -n$limit
|
||||
end
|
||||
|
||||
complete -k -c j -a '(__history_completions 25)' -f
|
|
@ -1,10 +1,13 @@
|
|||
complete -c ninja -f -a '(__fish_print_ninja_targets)' -d Target
|
||||
complete -x -c ninja -s t -x -a "(__fish_print_ninja_tools)" -d Tools
|
||||
complete -x -c ninja -s C -x -a "(__fish_complete_directories (commandline -ct))" -d "Change to DIR"
|
||||
complete -c ninja -s f -x -d "specify build file"
|
||||
complete -c ninja -f -a '(__fish_print_ninja_targets)' -d target
|
||||
complete -x -c ninja -s t -x -a "(__fish_print_ninja_tools)" -d subtool
|
||||
complete -x -c ninja -s C -x -a "(__fish_complete_directories (commandline -ct))" -d "change to specified directory"
|
||||
complete -c ninja -s f -x -d "specify build file [default=build.ninja]"
|
||||
complete -f -c ninja -s n -d "dry run"
|
||||
complete -f -c ninja -s v -d "show all command lines while building"
|
||||
complete -f -c ninja -s j -d "number of jobs"
|
||||
complete -f -c ninja -s l -d "do not start if load > N"
|
||||
complete -f -c ninja -s k -d "keep until N jobs fail"
|
||||
complete -f -c ninja -s h -d "help"
|
||||
complete -f -c ninja -s j -d "number of jobs to run in parallel [default derived from CPUs]"
|
||||
complete -f -c ninja -s l -d "do not start if load average > N"
|
||||
complete -f -c ninja -s k -d "keep going until N jobs fail [default=1]"
|
||||
complete -f -c ninja -s h -d "show help"
|
||||
complete -f -c ninja -s d -d "enable debugging, specify debug mode"
|
||||
complete -f -c ninja -s w -d "adjust warnings, specify flags"
|
||||
complete -f -c ninja -l version -d "print ninja version"
|
||||
|
|
4
share/completions/pip.fish
Normal file
4
share/completions/pip.fish
Normal file
|
@ -0,0 +1,4 @@
|
|||
if command -sq pip
|
||||
pip completion --fish | source
|
||||
end
|
||||
|
7
share/completions/pip2.fish
Normal file
7
share/completions/pip2.fish
Normal file
|
@ -0,0 +1,7 @@
|
|||
if command -sq pip2
|
||||
# pip[2|3] emits (or emitted) completions with the wrong command name
|
||||
# See discussion at https://github.com/fish-shell/fish-shell/pull/4448
|
||||
# and pip bug at https://github.com/pypa/pip/pull/4755
|
||||
# Keep this even after pip fix is upstreamed for users not on the latest pip
|
||||
pip2 completion --fish | string replace -r -- " -c\s+pip\b" " -c pip2" | source
|
||||
end
|
7
share/completions/pip3.fish
Normal file
7
share/completions/pip3.fish
Normal file
|
@ -0,0 +1,7 @@
|
|||
if command -sq pip3
|
||||
# pip[2|3] emits (or emitted) completions with the wrong command name
|
||||
# See discussion at https://github.com/fish-shell/fish-shell/pull/4448
|
||||
# and pip bug at https://github.com/pypa/pip/pull/4755
|
||||
# Keep this even after pip fix is upstreamed for users not on the latest pip
|
||||
pip3 completion --fish | string replace -r -- " -c\s+pip\b" " -c pip3" | source
|
||||
end
|
3
share/completions/pipenv.fish
Normal file
3
share/completions/pipenv.fish
Normal file
|
@ -0,0 +1,3 @@
|
|||
if command -sq pipenv
|
||||
pipenv --completion | source
|
||||
end
|
|
@ -1,5 +1,9 @@
|
|||
set -l systemd_version (systemctl --version | string match "systemd*" | string replace -r "\D*(\d+)" '$1')
|
||||
set -l commands list-units list-sockets start stop reload restart try-restart reload-or-restart reload-or-try-restart isolate kill is-active is-failed status show get-cgroup-attr set-cgroup-attr unset-cgroup-attr set-cgroup help reset-failed list-unit-files enable disable is-enabled reenable preset mask unmask link load list-jobs cancel dump list-dependencies snapshot delete daemon-reload daemon-reexec show-environment set-environment unset-environment default rescue emergency halt poweroff reboot kexec exit suspend hibernate hybrid-sleep switch-root
|
||||
set -l commands list-units list-sockets start stop reload restart try-restart reload-or-restart reload-or-try-restart \
|
||||
isolate kill is-active is-failed status show get-cgroup-attr set-cgroup-attr unset-cgroup-attr set-cgroup help \
|
||||
reset-failed list-unit-files enable disable is-enabled reenable preset mask unmask link load list-jobs cancel dump \
|
||||
list-dependencies snapshot delete daemon-reload daemon-reexec show-environment set-environment unset-environment \
|
||||
default rescue emergency halt poweroff reboot kexec exit suspend hibernate hybrid-sleep switch-root
|
||||
if test $systemd_version -gt 208
|
||||
set commands $commands cat
|
||||
if test $systemd_version -gt 217
|
||||
|
@ -9,29 +13,15 @@ end
|
|||
set -l types services sockets mounts service_paths targets automounts timers
|
||||
|
||||
function __fish_systemd_properties
|
||||
if type -q /usr/lib/systemd/systemd
|
||||
/usr/lib/systemd/systemd --dump-configuration-items | string split -m1 = | while read key value
|
||||
test -n "$value"
|
||||
and echo $key
|
||||
end
|
||||
else if type -q /lib/systemd/systemd # Debian has not merged /lib and /usr/lib
|
||||
/lib/systemd/systemd --dump-configuration-items | string split -m1 = | while read key value
|
||||
test -n "$value"
|
||||
and echo $key
|
||||
end
|
||||
# We need to call the main systemd binary (the thing that is run as PID1).
|
||||
# Unfortunately, it's usually not in $PATH.
|
||||
if test -f /usr/lib/systemd/systemd
|
||||
/usr/lib/systemd/systemd --dump-configuration-items | string replace -rf '(.+)=(.+)$' '$1\t$2'
|
||||
else if test -f /lib/systemd/systemd # Debian has not merged /lib and /usr/lib
|
||||
/lib/systemd/systemd --dump-configuration-items | string replace -rf '(.+)=(.+)$' '$1\t$2'
|
||||
end
|
||||
end
|
||||
|
||||
function __fish_systemctl_failed
|
||||
if __fish_contains_opt user
|
||||
# Without arguments, no "--type=" will be passed
|
||||
systemctl --user list-units --state=failed --no-legend --type=$argv ^/dev/null | cut -f 1 -d ' '
|
||||
else
|
||||
systemctl list-units --state=failed --no-legend --type=$argv ^/dev/null | cut -f 1 -d ' '
|
||||
end
|
||||
end
|
||||
|
||||
complete -f -e -c systemctl
|
||||
# All systemctl commands
|
||||
complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a "$commands"
|
||||
|
||||
|
@ -45,49 +35,13 @@ complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a disab
|
|||
complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a isolate -d 'Start a unit and dependencies and disable all others'
|
||||
complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a set-default -d 'Set the default target to boot into'
|
||||
|
||||
set -l commands_types start stop restart try-restart reload-or-restart reload-or-try-restart is-active is-failed is-enabled reenable mask loaded link list-dependencies show status
|
||||
# Command completion done via argparse.
|
||||
complete -c systemctl -a '(_fish_systemctl)' -f
|
||||
|
||||
if test $systemd_version -gt 208
|
||||
complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a cat -d 'Show a unit'
|
||||
set commands_types $commands_types cat
|
||||
if test $systemd_version -gt 217
|
||||
complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a edit -d 'Edit a unit'
|
||||
set commands_types $commands_types edit
|
||||
end
|
||||
end
|
||||
|
||||
for command in $commands_types
|
||||
for t in $types
|
||||
complete -f -c systemctl -n "__fish_seen_subcommand_from $command" -a "(eval __fish_systemctl_$t)"
|
||||
end
|
||||
end
|
||||
|
||||
# Handle reset-failed specially because it doesn't apply to unit-files (only units that have been tried can have failed) and a second "--state=" argument doesn't override the earlier one.
|
||||
complete -f -c systemctl -n "__fish_seen_subcommand_from reset-failed" -a "(__fish_systemctl_failed)"
|
||||
|
||||
# Enable/Disable: Only show units with matching state
|
||||
for t in services sockets timers service_paths
|
||||
complete -f -c systemctl -n "__fish_seen_subcommand_from enable" -a "(eval __fish_systemctl_$t --state=disabled)"
|
||||
complete -f -c systemctl -n "__fish_seen_subcommand_from disable" -a "(eval __fish_systemctl_$t --state=enabled)"
|
||||
end
|
||||
|
||||
# These are useless for the other commands
|
||||
# .device in particular creates too much noise
|
||||
for t in devices slices scopes swaps
|
||||
for command in status show list-dependencies
|
||||
complete -f -c systemctl -n "__fish_seen_subcommand_from $command" -a "(eval __fish_systemctl_$t)"
|
||||
end
|
||||
end
|
||||
|
||||
complete -f -c systemctl -n "__fish_seen_subcommand_from isolate" -a '(__fish_systemctl_targets)' -d 'Target'
|
||||
complete -f -c systemctl -n "__fish_seen_subcommand_from isolate" -a '(__fish_systemctl_snapshots)' -d 'Snapshot'
|
||||
|
||||
complete -f -c systemctl -n "__fish_seen_subcommand_from set-default" -a '(__fish_systemctl_targets)' -d 'Target'
|
||||
complete -f -c systemctl -n "__fish_seen_subcommand_from set-default" -a '(__fish_systemctl_services)' -d 'Service'
|
||||
|
||||
complete -f -c systemctl -s t -l type -d 'List of unit types' -xa 'service mount socket target slice scope swap snapshot automount timer path'
|
||||
complete -f -c systemctl -l state -d 'List of unit states' -xa 'LOAD, SUB, ACTIVE,'
|
||||
complete -f -c systemctl -s p -l property -d 'Properties displayed in the "show" command' -a '(__fish_systemd_properties)'
|
||||
# These "--x=help" outputs always have lines like "Available unit types:". We use the fact that they end in a ":" to filter them out.
|
||||
complete -f -c systemctl -s t -l type -d 'List of unit types' -xa '(systemctl --type=help --no-legend --no-pager | string match -v "*:")'
|
||||
complete -f -c systemctl -l state -d 'List of unit states' -xa '(systemctl --state=help --no-legend --no-pager | string match -v "*:")'
|
||||
complete -f -c systemctl -s p -l property -a '(__fish_systemd_properties)'
|
||||
complete -f -c systemctl -s a -l all -d 'Show all units or properties'
|
||||
complete -f -c systemctl -s r -l recursive -d 'Show also units of local containers'
|
||||
complete -f -c systemctl -l reverse -d 'Show reverse dependencies between units'
|
||||
|
|
|
@ -475,7 +475,7 @@ set -g ___fish_git_prompt_status_order stagedstate invalidstate dirtystate untra
|
|||
|
||||
function __fish_git_prompt_informative_status
|
||||
|
||||
set -l changedFiles (command git diff --name-status | string match -r \\w)
|
||||
set -l changedFiles (command git diff --name-status ^/dev/null | string match -r \\w)
|
||||
set -l stagedFiles (command git diff --staged --name-status | string match -r \\w)
|
||||
|
||||
set -l x (count $changedFiles)
|
||||
|
|
|
@ -94,10 +94,25 @@ function __fish_print_hostnames -d "Print a list of known hostnames"
|
|||
set known_hosts $known_hosts (string replace -rfi '.*KnownHostsFile\s*' '' <$file)
|
||||
end
|
||||
end
|
||||
for file in $known_hosts
|
||||
# Ignore hosts that are hashed, commented or have custom ports (like [localhost]:2200)
|
||||
test -r $file
|
||||
and string replace -ra '(\S+) .*' '$1' <$file | string match -r '^[^#|[=]+$' | string split ","
|
||||
for file in $known_hosts
|
||||
if test -r $file
|
||||
# Ignore hosts that are hashed, commented or @-marked and strip the key.
|
||||
awk '$1 !~ /[|#@]/ {
|
||||
n=split($1, entries, ",")
|
||||
for (i=1; i<=n; i++) {
|
||||
# Ignore negated/wildcarded hosts.
|
||||
if (!match(entry=entries[i], "[!*?]")) {
|
||||
# Extract hosts with custom port.
|
||||
if (substr(entry, 1, 1) == "[") {
|
||||
if (pos=match(entry, "]:.*$")) {
|
||||
entry=substr(entry, 2, pos-2)
|
||||
}
|
||||
}
|
||||
print entry
|
||||
}
|
||||
}
|
||||
}' $file
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
function __fish_systemctl_automounts
|
||||
if type -q systemctl
|
||||
if __fish_contains_opt user
|
||||
systemctl --user list-unit-files --no-legend --type=automount ^/dev/null | cut -f 1 -d ' '
|
||||
else
|
||||
systemctl list-unit-files --no-legend --type=automount ^/dev/null | cut -f 1 -d ' '
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
function __fish_systemctl_devices
|
||||
if type -q systemctl
|
||||
if __fish_contains_opt user
|
||||
# Devices are usually generated at runtime
|
||||
# Therefore show known _units_, not unit-files
|
||||
systemctl --user list-units --no-legend --type=device ^/dev/null | cut -f 1 -d ' '
|
||||
else
|
||||
systemctl list-units --no-legend --type=device ^/dev/null | cut -f 1 -d ' '
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
function __fish_systemctl_mounts
|
||||
if type -q systemctl
|
||||
if __fish_contains_opt user
|
||||
systemctl --user list-unit-files --no-legend --type=mount ^/dev/null | cut -f 1 -d ' '
|
||||
else
|
||||
systemctl list-unit-files --no-legend --type=mount ^/dev/null | cut -f 1 -d ' '
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
function __fish_systemctl_scopes
|
||||
if type -q systemctl
|
||||
if __fish_contains_opt user
|
||||
# Scopes are usually generated at runtime
|
||||
# Therefore show known _units_, not unit-files
|
||||
systemctl --user list-units --no-legend --type=scope ^/dev/null | cut -f 1 -d ' '
|
||||
else
|
||||
systemctl list-units --no-legend --type=scope ^/dev/null | cut -f 1 -d ' '
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
function __fish_systemctl_service_paths
|
||||
if type -q systemctl
|
||||
if __fish_contains_opt user
|
||||
systemctl --user list-unit-files --no-legend --type=path ^/dev/null $argv | cut -f 1 -d ' '
|
||||
else
|
||||
systemctl list-unit-files --no-legend --type=path ^/dev/null $argv | cut -f 1 -d ' '
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
function __fish_systemctl_slices
|
||||
if type -q systemctl
|
||||
if __fish_contains_opt user
|
||||
# Slices are usually generated at runtime
|
||||
# Therefore show known _units_, not unit-files
|
||||
systemctl --user list-units --no-legend --type=slice ^/dev/null | cut -f 1 -d ' '
|
||||
else
|
||||
systemctl list-units --no-legend --type=slice ^/dev/null | cut -f 1 -d ' '
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,12 +0,0 @@
|
|||
function __fish_systemctl_snapshots
|
||||
if type -q systemctl
|
||||
if __fish_contains_opt user
|
||||
# Snapshots are usually generated at runtime
|
||||
# Therefore show known _units_, not unit-files
|
||||
# They are also often not loaded, so add "--all"
|
||||
systemctl --user list-units --all --no-legend --type=snapshot ^/dev/null | cut -f 1 -d ' '
|
||||
else
|
||||
systemctl list-units --all --no-legend --type=snapshot ^/dev/null | cut -f 1 -d ' '
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
function __fish_systemctl_sockets
|
||||
if type -q systemctl
|
||||
if __fish_contains_opt user
|
||||
systemctl --user list-unit-files --no-legend --type=socket ^/dev/null $argv | cut -f 1 -d ' '
|
||||
else
|
||||
systemctl list-unit-files --no-legend --type=socket ^/dev/null $argv | cut -f 1 -d ' '
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
function __fish_systemctl_swaps
|
||||
if type -q systemctl
|
||||
if __fish_contains_opt user
|
||||
systemctl --user list-unit-files --no-legend --type=swap ^/dev/null | cut -f 1 -d ' '
|
||||
else
|
||||
systemctl list-unit-files --no-legend --type=swap ^/dev/null | cut -f 1 -d ' '
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
function __fish_systemctl_targets
|
||||
if type -q systemctl
|
||||
if __fish_contains_opt user
|
||||
systemctl --user list-unit-files --no-legend --type=target ^/dev/null | cut -f 1 -d ' '
|
||||
else
|
||||
systemctl list-unit-files --no-legend --type=target ^/dev/null | cut -f 1 -d ' '
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
function __fish_systemctl_timers
|
||||
if type -q systemctl
|
||||
if __fish_contains_opt user
|
||||
systemctl --user list-unit-files --no-legend --type=timer ^/dev/null $argv | cut -f 1 -d ' '
|
||||
else
|
||||
systemctl list-unit-files --no-legend --type=timer ^/dev/null $argv | cut -f 1 -d ' '
|
||||
end
|
||||
end
|
||||
end
|
84
share/functions/_fish_systemctl.fish
Normal file
84
share/functions/_fish_systemctl.fish
Normal file
|
@ -0,0 +1,84 @@
|
|||
function _fish_systemctl --description 'Call systemctl with some options from the current commandline'
|
||||
# These options are all global - before or after subcommand/arguments.
|
||||
# There's a bunch of long-only options in here, so we need to be creative with the mandatory short version.
|
||||
set -l opts t/type= s-state= p/property= a/all
|
||||
set opts $opts r/recursive R-reverse A-after B-before
|
||||
set opts $opts l/full V-value S-show-types J-job-mode=
|
||||
set opts $opts F-fail i/ignore-inhibitors q/quiet N-no-block
|
||||
set opts $opts W-wait U-user Y-system I-failed O-no-wall
|
||||
set opts $opts G-global E-reload K-no-ask-password 4-kill-who
|
||||
set opts $opts ü-signal f-force 5-message ö-now ä-root
|
||||
set opts $opts Ü-runtime Ö-preset-mode= n/lines= o/output=
|
||||
set opts $opts Ä-firmware-setup ß-plain H/host= M/machine=
|
||||
set opts $opts 1-no-pager 2-no-legend h/help 3-version
|
||||
|
||||
set -l args $argv
|
||||
set -l cmdline (commandline -opc) (commandline -ct)
|
||||
set -e cmdline[1]
|
||||
argparse $opts -- $cmdline ^/dev/null
|
||||
or return
|
||||
|
||||
# If no subcommand has been given, return so this can be used as a condition.
|
||||
test -n "$argv[1]"
|
||||
or return
|
||||
set -l cmd $argv[1]
|
||||
set -e argv[1]
|
||||
|
||||
# Flags we want to pass on.
|
||||
set -l passflags $_flag_user $_flag_system $_flag_failed
|
||||
switch "$cmd"
|
||||
# These are the normal commands, so just complete all units.
|
||||
# For "restart" et al, also complete non-running ones, since it can be used regardless of state.
|
||||
case reenable status reload {try-,}{reload-or-,}restart is-{active,enabled,failed} show cat \
|
||||
help reset-failed list-dependencies list-units revert add-{wants,requires} edit
|
||||
case enable
|
||||
# This will only work for "list-unit-files", but won't print an error for "list-units".
|
||||
set -q _flag_state; or set _flag_state disabled
|
||||
case disable
|
||||
set -q _flag_state; or set _flag_state enabled
|
||||
case start
|
||||
# Running `start` on an already started unit isn't an _error_, but useless.
|
||||
set -q _flag_state; or set _flag_state dead,failed
|
||||
case mask
|
||||
set -q _flag_state; or set _flag_state loaded
|
||||
case unmask
|
||||
set -q _flag_state; or set _flag_state masked
|
||||
case stop kill
|
||||
# TODO: Is "kill" useful on other unit types?
|
||||
# Running as the catch-all, "mounted" for .mount units, "active" for .target.
|
||||
set -q _flag_state; or set _flag_state running,mounted,active
|
||||
case isolate set-default
|
||||
# These only take one unit.
|
||||
set -q argv[1]; and return
|
||||
case list-sockets
|
||||
set _flag_type socket
|
||||
case list-timers
|
||||
set _flag_type timer
|
||||
case get-default show-environment daemon-{reload,reexec} is-system-running default rescue emergency halt poweroff kexec \
|
||||
suspend hibernate hybrid-sleep
|
||||
# Accept no arguments.
|
||||
return
|
||||
case '*'
|
||||
# Unknown subcommand. Since we don't want to execute just anything, return.
|
||||
# Note that this could also be a partial token, which is completed elsewhere.
|
||||
return
|
||||
end
|
||||
|
||||
# Add the flags back so we can pass them to our systemctl invocations.
|
||||
set -q _flag_type; and set passflags $passflags --type=$_flag_type
|
||||
set -q _flag_state; and set passflags $passflags --state=$_flag_state
|
||||
set -q _flag_property; and set passflags $passflags --property=$_flag_property
|
||||
set -q _flag_machine; and set passflags $passflags --machine=$_flag_machine
|
||||
set -q _flag_host; and set passflags $passflags --host=$_flag_host
|
||||
|
||||
# Output looks like
|
||||
# systemd-tmpfiles-clean.timer [more whitespace] loaded active waiting Daily Cleanup[...]
|
||||
# Use the last part as the description.
|
||||
systemctl --no-legend --no-pager --all list-units $passflags | string replace -r "(?: +(\S+)){4}" \t'$1'
|
||||
# We need this for disabled/static units. Also instance units without an active instance.
|
||||
# Output looks like
|
||||
# systemd-tmpfiles-clean.timer static
|
||||
# Just use the state as the description, since we won't get it here.
|
||||
# This is an issue for units that appear in both.
|
||||
systemctl --no-legend --no-pager --all list-unit-files $passflags | string replace -r "(?: +(\S+)){1}" \t'$1'
|
||||
end
|
|
@ -13,6 +13,8 @@ function export --description 'Set env variable. Alias for `set -gx` for bash co
|
|||
set -l colonized_path (string replace -- "$$v[1]" (string join ":" -- $$v[1]) $v[2])
|
||||
set -gx $v[1] (string split ":" -- $colonized_path)
|
||||
else
|
||||
# status is 1 from the contains check, and `set` does not change the status on success: reset it.
|
||||
true
|
||||
set -gx $v[1] $v[2]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,6 +18,11 @@ function fish_default_key_bindings -d "Default (Emacs-like) key bindings for fis
|
|||
end
|
||||
end
|
||||
|
||||
# Silence warnings about unavailable keys. See #4431, 4188
|
||||
if not contains -- -s $argv
|
||||
set argv "-s" $argv
|
||||
end
|
||||
|
||||
# These are shell-specific bindings that we share with vi mode.
|
||||
__fish_shared_key_bindings $argv
|
||||
or return # protect against invalid $argv
|
||||
|
|
|
@ -17,6 +17,11 @@ function fish_vi_key_bindings --description 'vi-like key bindings for fish'
|
|||
bind --erase --all # clear earlier bindings, if any
|
||||
end
|
||||
|
||||
# Silence warnings about unavailable keys. See #4431, 4188
|
||||
if not contains -- -s $argv
|
||||
set argv "-s" $argv
|
||||
end
|
||||
|
||||
# Allow just calling this function to correctly set the bindings.
|
||||
# Because it's a rather discoverable name, users will execute it
|
||||
# and without this would then have subtly broken bindings.
|
||||
|
|
|
@ -55,8 +55,9 @@ function help --description 'Show help for the fish shell'
|
|||
# If the OS appears to be Windows (graphical), try to use cygstart
|
||||
if type -q cygstart
|
||||
set fish_browser cygstart
|
||||
# If xdg-open is available, just use that
|
||||
else if type -q xdg-open
|
||||
# If xdg-open is available, just use that
|
||||
# but only if an X session is running
|
||||
else if type -q xdg-open; and set -q -x DISPLAY
|
||||
set fish_browser xdg-open
|
||||
end
|
||||
|
||||
|
@ -147,6 +148,12 @@ function help --description 'Show help for the fish shell'
|
|||
end
|
||||
eval "$fish_browser $page_url &"
|
||||
else
|
||||
# Work around lynx bug where <div class="contents"> always has the same formatting as links (unreadable)
|
||||
# by using a custom style sheet. See https://github.com/fish-shell/fish-shell/issues/4170
|
||||
set -l local_file 0
|
||||
if eval $fish_browser --version 2>/dev/null | string match -qr Lynx
|
||||
set fish_browser $fish_browser -lss={$__fish_datadir}/lynx.lss
|
||||
end
|
||||
eval $fish_browser $page_url
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,13 +16,9 @@ end
|
|||
|
||||
function history --description "display or manipulate interactive command history"
|
||||
set -l cmd history
|
||||
|
||||
set -l options --exclusive 'c,e,p' --exclusive 'S,D,M,V,C' --exclusive 't,T'
|
||||
set -l options --exclusive 'c,e,p' --exclusive 'S,D,M,V,C'
|
||||
set -a options 'h/help' 'c/contains' 'e/exact' 'p/prefix'
|
||||
set -a options 'C/case-sensitive' 'R/reverse' 'z/null' 't/show-time=?' 'n#max'
|
||||
# This long option is deprecated and here solely for legacy compatibility. People should use
|
||||
# -t or --show-time now.
|
||||
set -a options 'T-with-time=?'
|
||||
# The following options are deprecated and will be removed in the next major release.
|
||||
# Note that they do not have usable short flags.
|
||||
set -a options 'S-search' 'D-delete' 'M-merge' 'V-save' 'X-clear'
|
||||
|
|
|
@ -34,4 +34,9 @@ else if command ls -G / >/dev/null ^/dev/null
|
|||
function ls --description "List contents of directory"
|
||||
command ls -G $argv
|
||||
end
|
||||
else if command ls --color / >/dev/null 2>/dev/null
|
||||
# Solaris 11's ls command takes a --color flag
|
||||
function ls --description "List contents of directory"
|
||||
command ls --color $argv
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# If seq is not installed, then define a function that invokes __fish_fallback_seq
|
||||
# If seq is not installed, then define a function that invokes __fish_fallback_seq
|
||||
# We can't call type here because that also calls seq
|
||||
|
||||
if not command -sq seq
|
||||
|
@ -33,7 +33,7 @@ if not command -sq seq
|
|||
end
|
||||
|
||||
for i in $from $step $to
|
||||
if not echo $i | grep -E '^-?[0-9]*([0-9]*|\.[0-9]+)$' >/dev/null
|
||||
if not string match -rq '^-?[0-9]*([0-9]*|\.[0-9]+)$' $i
|
||||
printf (_ "%s: '%s' is not a number\n") seq $i
|
||||
return 1
|
||||
end
|
||||
|
|
104
share/lynx.lss
Normal file
104
share/lynx.lss
Normal file
|
@ -0,0 +1,104 @@
|
|||
# Lynx Style Sheet
|
||||
# Used as a custom style sheet (LSS) for the Lynx browser to work around some
|
||||
# poor defaults. Usage: `lynx -lss=style.lss`
|
||||
#
|
||||
# The next line (beginning with "em") means: use bold if mono, otherwise
|
||||
# brightblue on <defaultbackground> (implicit)
|
||||
em:bold:brightblue
|
||||
strong:bold:brightred
|
||||
b:bold:red
|
||||
i:bold:brightblue
|
||||
a:bold:green
|
||||
img:dim:brown
|
||||
fig:normal:gray
|
||||
caption:reverse:brown
|
||||
hr:normal:yellow
|
||||
blockquote:normal:brightblue
|
||||
ul:normal:brown
|
||||
address:normal:magenta
|
||||
title:normal:magenta
|
||||
tt:dim:brightmagenta:default
|
||||
h1:bold:yellow
|
||||
h2:normal:brown
|
||||
h3:normal:green
|
||||
h4:normal:cyan
|
||||
label:normal:magenta
|
||||
q:normal:yellow
|
||||
small:dim:default
|
||||
big:bold:yellow
|
||||
sup:bold:yellow
|
||||
sub:dim:gray
|
||||
lh:bold:yellow
|
||||
li:normal:magenta
|
||||
code:normal:cyan
|
||||
cite:normal:cyan
|
||||
|
||||
table:normal:brightcyan
|
||||
tr:bold:brown
|
||||
td:normal:default
|
||||
br:normal:default
|
||||
|
||||
# Special styles - not corresponding directly to HTML tags
|
||||
# alert - status bar, when message begins "Alert".
|
||||
# alink - active link
|
||||
# normal - default attributes
|
||||
# status - status bar
|
||||
# whereis - whereis search target
|
||||
#
|
||||
#normal:normal:default:blue
|
||||
alink:reverse:yellow
|
||||
status:reverse:yellow
|
||||
alert:bold:yellow:red
|
||||
whereis:reverse+underline:magenta
|
||||
# currently not used
|
||||
#value:normal:green
|
||||
#high:bold:brightmagenta
|
||||
forwbackw.arrow:reverse
|
||||
|
||||
# Styles with classes - <ul class=red> etc.
|
||||
ul.red:underline:brightred
|
||||
ul.blue:bold:brightblue
|
||||
li.red:reverse:red
|
||||
li.blue:bold:blue
|
||||
strong.a:bold:black
|
||||
/* em.a:reverse:black */
|
||||
em.a:bold:bold
|
||||
strong.b:bold:white
|
||||
em.b:reverse:white
|
||||
strong.debug:reverse:green
|
||||
font.letter:normal:default
|
||||
input.submit:normal:cyan
|
||||
tr.baone:bold:yellow
|
||||
tr.batwo:bold:green
|
||||
tr.bathree:bold:red
|
||||
#
|
||||
# Special handling for link.
|
||||
link:normal:white
|
||||
link.green:bold:brightgreen
|
||||
link.red:bold:black
|
||||
link.blue:bold:white
|
||||
link.toc:bold:black:white
|
||||
# Special cases for link - the rel or title is appended after the class.
|
||||
# <link rel=next class=red href="1">
|
||||
link.red.next:bold:red
|
||||
link.red.prev:bold:yellow
|
||||
link.blue.prev:bold:yellow
|
||||
link.blue.next:bold:blue
|
||||
link.green.toc:bold:white
|
||||
#
|
||||
# Define styles that will be used when syntax highlighting is requested
|
||||
# (commandline option -prettysrc).
|
||||
span.htmlsrc_comment:normal:white
|
||||
span.htmlsrc_tag:normal:white
|
||||
#If you don't like that the tag name and attribute name are displayed
|
||||
#in different colors, comment the following line.
|
||||
span.htmlsrc_attrib:normal:cyan
|
||||
span.htmlsrc_attrval:normal:magenta
|
||||
span.htmlsrc_abracket:normal:white
|
||||
span.htmlsrc_entity:normal:white
|
||||
##span.htmlsrc_href:
|
||||
##span.htmlsrc_entire:
|
||||
span.htmlsrc_badseq:normal:red
|
||||
span.htmlsrc_badtag:normal:red
|
||||
span.htmlsrc_badattr:normal:red
|
||||
span.htmlsrc_sgmlspecial:normal:yellow
|
|
@ -20,10 +20,11 @@
|
|||
|
||||
enum { BIND_INSERT, BIND_ERASE, BIND_KEY_NAMES, BIND_FUNCTION_NAMES };
|
||||
struct bind_cmd_opts_t {
|
||||
bool print_help = false;
|
||||
bool all = false;
|
||||
bool bind_mode_given = false;
|
||||
bool list_modes = false;
|
||||
bool all = false;
|
||||
bool print_help = false;
|
||||
bool silent = false;
|
||||
bool use_terminfo = false;
|
||||
int mode = BIND_INSERT;
|
||||
const wchar_t *bind_mode = DEFAULT_BIND_MODE;
|
||||
|
@ -46,7 +47,7 @@ struct bind_cmd_opts_t {
|
|||
|
||||
/// List a single key binding.
|
||||
/// Returns false if no binding with that sequence and mode exists.
|
||||
static bool builtin_bind_list_one(const wcstring &seq, const wcstring &bind_mode,
|
||||
bool builtin_bind_t::list_one(const wcstring &seq, const wcstring &bind_mode,
|
||||
io_streams_t &streams) {
|
||||
std::vector<wcstring> ecmds;
|
||||
wcstring sets_mode;
|
||||
|
@ -93,7 +94,7 @@ static bool builtin_bind_list_one(const wcstring &seq, const wcstring &bind_mode
|
|||
}
|
||||
|
||||
/// List all current key bindings.
|
||||
static void builtin_bind_list(const wchar_t *bind_mode, io_streams_t &streams) {
|
||||
void builtin_bind_t::list(const wchar_t *bind_mode, io_streams_t &streams) {
|
||||
const std::vector<input_mapping_name_t> lst = input_mapping_get_names();
|
||||
|
||||
for (const input_mapping_name_t &binding : lst) {
|
||||
|
@ -101,7 +102,7 @@ static void builtin_bind_list(const wchar_t *bind_mode, io_streams_t &streams) {
|
|||
continue;
|
||||
}
|
||||
|
||||
builtin_bind_list_one(binding.seq, binding.mode, streams);
|
||||
list_one(binding.seq, binding.mode, streams);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,7 +110,7 @@ static void builtin_bind_list(const wchar_t *bind_mode, io_streams_t &streams) {
|
|||
///
|
||||
/// \param all if set, all terminfo key binding names will be printed. If not set, only ones that
|
||||
/// are defined for this terminal are printed.
|
||||
static void builtin_bind_key_names(int all, io_streams_t &streams) {
|
||||
void builtin_bind_t::key_names(int all, io_streams_t &streams) {
|
||||
const wcstring_list_t names = input_terminfo_get_names(!all);
|
||||
for (size_t i = 0; i < names.size(); i++) {
|
||||
const wcstring &name = names.at(i);
|
||||
|
@ -119,7 +120,7 @@ static void builtin_bind_key_names(int all, io_streams_t &streams) {
|
|||
}
|
||||
|
||||
/// Print all the special key binding functions to string buffer used for standard output.
|
||||
static void builtin_bind_function_names(io_streams_t &streams) {
|
||||
void builtin_bind_t::function_names(io_streams_t &streams) {
|
||||
wcstring_list_t names = input_function_get_names();
|
||||
|
||||
for (size_t i = 0; i < names.size(); i++) {
|
||||
|
@ -129,26 +130,28 @@ static void builtin_bind_function_names(io_streams_t &streams) {
|
|||
}
|
||||
|
||||
/// Wraps input_terminfo_get_sequence(), appending the correct error messages as needed.
|
||||
static bool get_terminfo_sequence(const wchar_t *seq, wcstring *out_seq, io_streams_t &streams) {
|
||||
bool builtin_bind_t::get_terminfo_sequence(const wchar_t *seq, wcstring *out_seq, io_streams_t &streams) {
|
||||
if (input_terminfo_get_sequence(seq, out_seq)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
wcstring eseq = escape_string(seq, 0);
|
||||
if (errno == ENOENT) {
|
||||
streams.err.append_format(_(L"%ls: No key with name '%ls' found\n"), L"bind", eseq.c_str());
|
||||
} else if (errno == EILSEQ) {
|
||||
streams.err.append_format(_(L"%ls: Key with name '%ls' does not have any mapping\n"),
|
||||
L"bind", eseq.c_str());
|
||||
} else {
|
||||
streams.err.append_format(_(L"%ls: Unknown error trying to bind to key named '%ls'\n"),
|
||||
L"bind", eseq.c_str());
|
||||
if (!opts->silent) {
|
||||
if (errno == ENOENT) {
|
||||
streams.err.append_format(_(L"%ls: No key with name '%ls' found\n"), L"bind", eseq.c_str());
|
||||
} else if (errno == EILSEQ) {
|
||||
streams.err.append_format(_(L"%ls: Key with name '%ls' does not have any mapping\n"),
|
||||
L"bind", eseq.c_str());
|
||||
} else {
|
||||
streams.err.append_format(_(L"%ls: Unknown error trying to bind to key named '%ls'\n"),
|
||||
L"bind", eseq.c_str());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Add specified key binding.
|
||||
static bool builtin_bind_add(const wchar_t *seq, const wchar_t *const *cmds, size_t cmds_len,
|
||||
bool builtin_bind_t::add(const wchar_t *seq, const wchar_t *const *cmds, size_t cmds_len,
|
||||
const wchar_t *mode, const wchar_t *sets_mode, int terminfo,
|
||||
io_streams_t &streams) {
|
||||
if (terminfo) {
|
||||
|
@ -178,7 +181,7 @@ static bool builtin_bind_add(const wchar_t *seq, const wchar_t *const *cmds, siz
|
|||
/// @param use_terminfo
|
||||
/// Whether to look use terminfo -k name
|
||||
///
|
||||
static bool builtin_bind_erase(wchar_t **seq, int all, const wchar_t *mode, int use_terminfo,
|
||||
bool builtin_bind_t::erase(wchar_t **seq, int all, const wchar_t *mode, int use_terminfo,
|
||||
io_streams_t &streams) {
|
||||
if (all) {
|
||||
const std::vector<input_mapping_name_t> lst = input_mapping_get_names();
|
||||
|
@ -211,16 +214,16 @@ static bool builtin_bind_erase(wchar_t **seq, int all, const wchar_t *mode, int
|
|||
return res;
|
||||
}
|
||||
|
||||
static bool builtin_bind_insert(bind_cmd_opts_t &opts, int optind, int argc, wchar_t **argv,
|
||||
bool builtin_bind_t::insert(int optind, int argc, wchar_t **argv,
|
||||
io_streams_t &streams) {
|
||||
wchar_t *cmd = argv[0];
|
||||
int arg_count = argc - optind;
|
||||
|
||||
if (arg_count == 0) {
|
||||
builtin_bind_list(opts.bind_mode_given ? opts.bind_mode : NULL, streams);
|
||||
list(opts->bind_mode_given ? opts->bind_mode : NULL, streams);
|
||||
} else if (arg_count == 1) {
|
||||
wcstring seq;
|
||||
if (opts.use_terminfo) {
|
||||
if (opts->use_terminfo) {
|
||||
if (!get_terminfo_sequence(argv[optind], &seq, streams)) {
|
||||
// get_terminfo_sequence already printed the error.
|
||||
return true;
|
||||
|
@ -229,20 +232,22 @@ static bool builtin_bind_insert(bind_cmd_opts_t &opts, int optind, int argc, wch
|
|||
seq = argv[optind];
|
||||
}
|
||||
|
||||
if (!builtin_bind_list_one(seq, opts.bind_mode, streams)) {
|
||||
if (!list_one(seq, opts->bind_mode, streams)) {
|
||||
wcstring eseq = escape_string(argv[optind], 0);
|
||||
if (opts.use_terminfo) {
|
||||
streams.err.append_format(_(L"%ls: No binding found for key '%ls'\n"), cmd,
|
||||
eseq.c_str());
|
||||
} else {
|
||||
streams.err.append_format(_(L"%ls: No binding found for sequence '%ls'\n"), cmd,
|
||||
eseq.c_str());
|
||||
if (!opts->silent) {
|
||||
if (opts->use_terminfo) {
|
||||
streams.err.append_format(_(L"%ls: No binding found for key '%ls'\n"), cmd,
|
||||
eseq.c_str());
|
||||
} else {
|
||||
streams.err.append_format(_(L"%ls: No binding found for sequence '%ls'\n"), cmd,
|
||||
eseq.c_str());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (builtin_bind_add(argv[optind], argv + (optind + 1), argc - (optind + 1), opts.bind_mode,
|
||||
opts.sets_bind_mode, opts.use_terminfo, streams)) {
|
||||
if (add(argv[optind], argv + (optind + 1), argc - (optind + 1), opts->bind_mode,
|
||||
opts->sets_bind_mode, opts->use_terminfo, streams)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -251,7 +256,7 @@ static bool builtin_bind_insert(bind_cmd_opts_t &opts, int optind, int argc, wch
|
|||
}
|
||||
|
||||
/// List all current bind modes.
|
||||
static void builtin_bind_list_modes(io_streams_t &streams) {
|
||||
void builtin_bind_t::list_modes(io_streams_t &streams) {
|
||||
const std::vector<input_mapping_name_t> lst = input_mapping_get_names();
|
||||
// A set accomplishes two things for us here:
|
||||
// - It removes duplicates (no twenty "default" entries).
|
||||
|
@ -266,19 +271,20 @@ static void builtin_bind_list_modes(io_streams_t &streams) {
|
|||
}
|
||||
}
|
||||
|
||||
static int parse_cmd_opts(bind_cmd_opts_t &opts, int *optind, //!OCLINT(high ncss method)
|
||||
int parse_cmd_opts(bind_cmd_opts_t &opts, int *optind, //!OCLINT(high ncss method)
|
||||
int argc, wchar_t **argv, parser_t &parser, io_streams_t &streams) {
|
||||
wchar_t *cmd = argv[0];
|
||||
static const wchar_t *short_options = L":aehkKfM:Lm:";
|
||||
static const wchar_t *short_options = L":aehkKfM:Lm:s";
|
||||
static const struct woption long_options[] = {{L"all", no_argument, NULL, 'a'},
|
||||
{L"erase", no_argument, NULL, 'e'},
|
||||
{L"function-names", no_argument, NULL, 'f'},
|
||||
{L"help", no_argument, NULL, 'h'},
|
||||
{L"key", no_argument, NULL, 'k'},
|
||||
{L"key-names", no_argument, NULL, 'K'},
|
||||
{L"mode", required_argument, NULL, 'M'},
|
||||
{L"list-modes", no_argument, NULL, 'L'},
|
||||
{L"mode", required_argument, NULL, 'M'},
|
||||
{L"sets-mode", required_argument, NULL, 'm'},
|
||||
{L"silent", no_argument, NULL, 's'},
|
||||
{NULL, 0, NULL, 0}};
|
||||
|
||||
int opt;
|
||||
|
@ -293,6 +299,10 @@ static int parse_cmd_opts(bind_cmd_opts_t &opts, int *optind, //!OCLINT(high nc
|
|||
opts.mode = BIND_ERASE;
|
||||
break;
|
||||
}
|
||||
case L'f': {
|
||||
opts.mode = BIND_FUNCTION_NAMES;
|
||||
break;
|
||||
}
|
||||
case L'h': {
|
||||
opts.print_help = true;
|
||||
break;
|
||||
|
@ -305,9 +315,9 @@ static int parse_cmd_opts(bind_cmd_opts_t &opts, int *optind, //!OCLINT(high nc
|
|||
opts.mode = BIND_KEY_NAMES;
|
||||
break;
|
||||
}
|
||||
case L'f': {
|
||||
opts.mode = BIND_FUNCTION_NAMES;
|
||||
break;
|
||||
case L'L': {
|
||||
opts.list_modes = true;
|
||||
return STATUS_CMD_OK;
|
||||
}
|
||||
case L'M': {
|
||||
if (!valid_var_name(w.woptarg)) {
|
||||
|
@ -326,9 +336,9 @@ static int parse_cmd_opts(bind_cmd_opts_t &opts, int *optind, //!OCLINT(high nc
|
|||
opts.sets_bind_mode = w.woptarg;
|
||||
break;
|
||||
}
|
||||
case L'L': {
|
||||
opts.list_modes = true;
|
||||
return STATUS_CMD_OK;
|
||||
case L's': {
|
||||
opts.silent = true;
|
||||
break;
|
||||
}
|
||||
case ':': {
|
||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1]);
|
||||
|
@ -350,17 +360,18 @@ static int parse_cmd_opts(bind_cmd_opts_t &opts, int *optind, //!OCLINT(high nc
|
|||
}
|
||||
|
||||
/// The bind builtin, used for setting character sequences.
|
||||
int builtin_bind(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
||||
int builtin_bind_t::builtin_bind(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
||||
wchar_t *cmd = argv[0];
|
||||
int argc = builtin_count_args(argv);
|
||||
bind_cmd_opts_t opts;
|
||||
this->opts = &opts;
|
||||
|
||||
int optind;
|
||||
int retval = parse_cmd_opts(opts, &optind, argc, argv, parser, streams);
|
||||
if (retval != STATUS_CMD_OK) return retval;
|
||||
|
||||
if (opts.list_modes) {
|
||||
builtin_bind_list_modes(streams);
|
||||
list_modes(streams);
|
||||
return STATUS_CMD_OK;
|
||||
}
|
||||
if (opts.print_help) {
|
||||
|
@ -371,24 +382,24 @@ int builtin_bind(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
|||
switch (opts.mode) {
|
||||
case BIND_ERASE: {
|
||||
const wchar_t *bind_mode = opts.bind_mode_given ? opts.bind_mode : NULL;
|
||||
if (builtin_bind_erase(&argv[optind], opts.all, bind_mode, opts.use_terminfo,
|
||||
if (erase(&argv[optind], opts.all, bind_mode, opts.use_terminfo,
|
||||
streams)) {
|
||||
return STATUS_CMD_ERROR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BIND_INSERT: {
|
||||
if (builtin_bind_insert(opts, optind, argc, argv, streams)) {
|
||||
if (insert(optind, argc, argv, streams)) {
|
||||
return STATUS_CMD_ERROR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BIND_KEY_NAMES: {
|
||||
builtin_bind_key_names(opts.all, streams);
|
||||
key_names(opts.all, streams);
|
||||
break;
|
||||
}
|
||||
case BIND_FUNCTION_NAMES: {
|
||||
builtin_bind_function_names(streams);
|
||||
function_names(streams);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
|
|
@ -2,10 +2,38 @@
|
|||
#ifndef FISH_BUILTIN_BIND_H
|
||||
#define FISH_BUILTIN_BIND_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define DEFAULT_BIND_MODE L"default"
|
||||
|
||||
class parser_t;
|
||||
struct io_streams_t;
|
||||
struct bind_cmd_opts_t;
|
||||
|
||||
class builtin_bind_t {
|
||||
public:
|
||||
int builtin_bind(parser_t &parser, io_streams_t &streams, wchar_t **argv);
|
||||
private:
|
||||
bind_cmd_opts_t *opts;
|
||||
|
||||
void list(const wchar_t *bind_mode, io_streams_t &streams);
|
||||
void key_names(int all, io_streams_t &streams);
|
||||
void function_names(io_streams_t &streams);
|
||||
bool add(const wchar_t *seq, const wchar_t *const *cmds, size_t cmds_len,
|
||||
const wchar_t *mode, const wchar_t *sets_mode, int terminfo,
|
||||
io_streams_t &streams);
|
||||
bool erase(wchar_t **seq, int all, const wchar_t *mode, int use_terminfo,
|
||||
io_streams_t &streams);
|
||||
bool get_terminfo_sequence(const wchar_t *seq, wcstring *out_seq, io_streams_t &streams);
|
||||
bool insert(int optind, int argc, wchar_t **argv,
|
||||
io_streams_t &streams);
|
||||
void list_modes(io_streams_t &streams);
|
||||
bool list_one(const wcstring &seq, const wcstring &bind_mode, io_streams_t &streams);
|
||||
};
|
||||
|
||||
inline int builtin_bind(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
||||
builtin_bind_t bind;
|
||||
return bind.builtin_bind(parser, streams, argv);
|
||||
}
|
||||
|
||||
int builtin_bind(parser_t &parser, io_streams_t &streams, wchar_t **argv);
|
||||
#endif
|
||||
|
|
|
@ -48,7 +48,6 @@ static const struct woption long_options[] = {{L"prefix", no_argument, NULL, 'p'
|
|||
{L"contains", no_argument, NULL, 'c'},
|
||||
{L"help", no_argument, NULL, 'h'},
|
||||
{L"show-time", optional_argument, NULL, 't'},
|
||||
{L"with-time", optional_argument, NULL, 't'},
|
||||
{L"exact", no_argument, NULL, 'e'},
|
||||
{L"max", required_argument, NULL, 'n'},
|
||||
{L"null", no_argument, NULL, 'z'},
|
||||
|
|
|
@ -444,6 +444,7 @@ void builtin_printf_state_t::print_direc(const wchar_t *start, size_t length, wc
|
|||
case L'X':
|
||||
case L'd':
|
||||
case L'i':
|
||||
case L'o':
|
||||
case L'u': {
|
||||
fmt.append(L"ll");
|
||||
break;
|
||||
|
|
|
@ -115,7 +115,7 @@ static int parse_cmd_opts(read_cmd_opts_t &opts, int *optind, //!OCLINT(high nc
|
|||
}
|
||||
case L'm': {
|
||||
streams.err.append_format(_(L"%ls: flags '--mode-name' / '-m' are now ignored. "
|
||||
L"Set FISH_HISTORY instead.\n"),
|
||||
L"Set fish_history instead.\n"),
|
||||
cmd);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -61,11 +61,32 @@ static const struct woption long_options[] = {{L"background", required_argument,
|
|||
{L"print-colors", no_argument, NULL, 'c'},
|
||||
{NULL, 0, NULL, 0}};
|
||||
|
||||
#if __APPLE__
|
||||
char sitm_esc[] = "\e[3m";
|
||||
char ritm_esc[] = "\e[23m";
|
||||
char dim_esc[] = "\e[2m";
|
||||
#endif
|
||||
|
||||
/// set_color builtin.
|
||||
int builtin_set_color(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
||||
// By the time this is called we should have initialized the curses subsystem.
|
||||
assert(curses_initialized);
|
||||
|
||||
// Hack in missing italics and dim capabilities omitted from MacOS xterm-256color terminfo
|
||||
// Helps Terminal.app/iTerm
|
||||
#if __APPLE__
|
||||
const auto term_prog = env_get(L"TERM_PROGRAM");
|
||||
if (!term_prog.missing_or_empty() && (term_prog->as_string() == L"Apple_Terminal"
|
||||
|| term_prog->as_string() == L"iTerm.app")) {
|
||||
const auto term = env_get(L"TERM");
|
||||
if (!term.missing_or_empty() && (term->as_string() == L"xterm-256color")) {
|
||||
enter_italics_mode = sitm_esc;
|
||||
exit_italics_mode = ritm_esc;
|
||||
enter_dim_mode = dim_esc;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Variables used for parsing the argument list.
|
||||
wchar_t *cmd = argv[0];
|
||||
int argc = builtin_count_args(argv);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <pthread.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
@ -486,14 +487,14 @@ wchar_t *quote_end(const wchar_t *pos) {
|
|||
}
|
||||
|
||||
void fish_setlocale() {
|
||||
// Use the Unicode "ellipsis" symbol if it can be encoded using the current locale.
|
||||
ellipsis_char = can_be_encoded(L'\x2026') ? L'\x2026' : L'$';
|
||||
|
||||
// Use the Unicode "return" symbol if it can be encoded using the current locale.
|
||||
omitted_newline_char = can_be_encoded(L'\x23CE') ? L'\x23CE' : L'~';
|
||||
|
||||
// solid circle unicode character if it is able, fallback to the hash character
|
||||
obfuscation_read_char = can_be_encoded(L'\u25cf') ? L'\u25cf' : L'#';
|
||||
// Use various Unicode symbols if they can be encoded using the current locale, else a simple
|
||||
// ASCII char alternative. All of the can_be_encoded() invocations should return the same
|
||||
// true/false value since the code points are in the BMP but we're going to be paranoid. This
|
||||
// is also technically wrong if we're not in a Unicode locale but we expect (or hope)
|
||||
// can_be_encoded() will return false in that case.
|
||||
ellipsis_char = can_be_encoded(L'\u2026') ? L'\u2026' : L'$'; // "horizontal ellipsis"
|
||||
omitted_newline_char = can_be_encoded(L'\u23CE') ? L'\u23CE' : L'~'; // "return"
|
||||
obfuscation_read_char = can_be_encoded(L'\u25CF') ? L'\u25CF' : L'#'; // "black circle"
|
||||
}
|
||||
|
||||
long read_blocked(int fd, void *buf, size_t count) {
|
||||
|
|
12
src/common.h
12
src/common.h
|
@ -4,6 +4,7 @@
|
|||
#include "config.h" // IWYU pragma: keep
|
||||
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <pthread.h>
|
||||
#include <stdarg.h> // IWYU pragma: keep
|
||||
#include <stddef.h>
|
||||
|
@ -90,6 +91,17 @@ typedef std::vector<wcstring> wcstring_list_t;
|
|||
#define INPUT_COMMON_BASE (wchar_t)0xF700
|
||||
#define INPUT_COMMON_END (INPUT_COMMON_BASE + 64)
|
||||
|
||||
// NAME_MAX is not defined on Solaris
|
||||
#if !defined(NAME_MAX)
|
||||
#include <sys/param.h>
|
||||
#if defined(MAXNAMELEN)
|
||||
// MAXNAMELEN is defined on Linux, BSD, and Solaris among others
|
||||
#define NAME_MAX MAXNAMELEN
|
||||
#else
|
||||
static_assert(false, "Neither NAME_MAX nor MAXNAMELEN is defined!");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
enum escape_string_style_t { STRING_STYLE_SCRIPT, STRING_STYLE_URL, STRING_STYLE_VAR };
|
||||
|
||||
// Flags for unescape_string functions.
|
||||
|
|
|
@ -847,7 +847,7 @@ static void setup_var_dispatch_table() {
|
|||
var_dispatch_table.emplace(L"LINES", handle_term_size_change);
|
||||
var_dispatch_table.emplace(L"COLUMNS", handle_term_size_change);
|
||||
var_dispatch_table.emplace(L"FISH_READ_BYTE_LIMIT", handle_read_limit_change);
|
||||
var_dispatch_table.emplace(L"FISH_HISTORY", handle_fish_history_change);
|
||||
var_dispatch_table.emplace(L"fish_history", handle_fish_history_change);
|
||||
var_dispatch_table.emplace(L"TZ", handle_tz_change);
|
||||
}
|
||||
|
||||
|
|
|
@ -55,13 +55,6 @@
|
|||
#include <bsd/ifaddrs.h>
|
||||
#endif // Haiku
|
||||
|
||||
// NAME_MAX is not defined on Solaris and suggests the use of pathconf()
|
||||
// There is no obvious sensible pathconf() for shared memory and _XPG_NAME_MAX
|
||||
// seems a reasonable choice.
|
||||
#if !defined(NAME_MAX) && defined(_XOPEN_NAME_MAX)
|
||||
#define NAME_MAX _XOPEN_NAME_MAX
|
||||
#endif
|
||||
|
||||
/// The set command.
|
||||
#define SET_STR L"SET"
|
||||
|
||||
|
|
|
@ -1115,8 +1115,8 @@ void exec_job(parser_t &parser, job_t *j) {
|
|||
// child_set_group() at this point. but we only need to call set_child_group for the
|
||||
// first process in the group. If needs_keepalive is set, this has already been called
|
||||
// for the keepalive process.
|
||||
pid_t pid_status{};
|
||||
int result;
|
||||
int pid_status;
|
||||
while ((result = waitpid(p->pid, &pid_status, WUNTRACED)) == -1 && errno == EINTR) {
|
||||
// This could be a superfluous interrupt or Ctrl+C at the terminal In all cases, it
|
||||
// is OK to retry since the forking code above is specifically designed to never,
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
//
|
||||
// Newlines are replaced by \n. Backslashes are replaced by \\.
|
||||
|
||||
// This is the history session ID we use by default if the user has not set env var FISH_HISTORY.
|
||||
// This is the history session ID we use by default if the user has not set env var fish_history.
|
||||
#define DFLT_FISH_HISTORY_SESSION_ID L"fish"
|
||||
|
||||
// When we rewrite the history, the number of items we keep.
|
||||
|
@ -1837,7 +1837,7 @@ void history_sanity_check() {
|
|||
wcstring history_session_id() {
|
||||
wcstring result = DFLT_FISH_HISTORY_SESSION_ID;
|
||||
|
||||
const auto var = env_get(L"FISH_HISTORY");
|
||||
const auto var = env_get(L"fish_history");
|
||||
if (var) {
|
||||
wcstring session_id = var->as_string();
|
||||
if (session_id.empty()) {
|
||||
|
|
|
@ -328,7 +328,7 @@ void pager_t::measure_completion_infos(comp_info_list_t *infos, const wcstring &
|
|||
|
||||
// fish_wcswidth() can return -1 if it can't calculate the width. So be cautious.
|
||||
int comp_width = fish_wcswidth(comp_strings.at(j).c_str());
|
||||
if (comp_width > 0) comp->comp_width += prefix_len + comp_width;
|
||||
if (comp_width >= 0) comp->comp_width += prefix_len + comp_width;
|
||||
}
|
||||
|
||||
// fish_wcswidth() can return -1 if it can't calculate the width. So be cautious.
|
||||
|
|
|
@ -86,6 +86,13 @@ static bool path_get_path_core(const wcstring &cmd, wcstring *out_path,
|
|||
case ENOTDIR: {
|
||||
break;
|
||||
}
|
||||
//WSL has a bug where access(2) can return EINVAL
|
||||
//See https://github.com/Microsoft/BashOnWindows/issues/2522
|
||||
//The only other way EINVAL can happen is if the wrong
|
||||
//mode was specified, but we have X_OK hard-coded above.
|
||||
case EINVAL: {
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
debug(1, MISSING_COMMAND_ERR_MSG, next_path.c_str());
|
||||
wperror(L"access");
|
||||
|
|
|
@ -92,7 +92,7 @@ bool wreaddir(DIR *dir, wcstring &out_name) {
|
|||
// long when it should be at least NAME_MAX + 1.
|
||||
union {
|
||||
struct dirent d;
|
||||
char c[offsetof(struct dirent, d_name) + NAME_MAX + 1]; /* NAME_MAX is POSIX. */
|
||||
char c[offsetof(struct dirent, d_name) + NAME_MAX + 1];
|
||||
} d_u;
|
||||
struct dirent *result = NULL;
|
||||
|
||||
|
@ -137,18 +137,14 @@ bool wreaddir_for_dirs(DIR *dir, wcstring *out_name) {
|
|||
}
|
||||
|
||||
const wcstring wgetcwd() {
|
||||
wcstring retval;
|
||||
|
||||
char *res = getcwd(NULL, 0);
|
||||
char cwd[PATH_MAX];
|
||||
char *res = getcwd(cwd, sizeof(cwd));
|
||||
if (res) {
|
||||
retval = str2wcstring(res);
|
||||
free(res);
|
||||
} else {
|
||||
debug(0, _(L"getcwd() failed with errno %d/%s"), errno, strerror(errno));
|
||||
retval = wcstring();
|
||||
return str2wcstring(res);
|
||||
}
|
||||
|
||||
return retval;
|
||||
debug(0, _(L"getcwd() failed with errno %d/%s"), errno, strerror(errno));
|
||||
return wcstring();
|
||||
}
|
||||
|
||||
int wchdir(const wcstring &dir) {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
# vim: set filetype=expect:
|
||||
# We're going to use three history files, including the default, to verify
|
||||
# that the FISH_HISTORY variable works as expected.
|
||||
# that the fish_history variable works as expected.
|
||||
set default_histfile "../test/data/fish/fish_history"
|
||||
set my_histfile "../test/data/fish/my_history"
|
||||
set env_histfile "../test/data/fish/env_history"
|
||||
|
||||
# =============
|
||||
# Verify that if we spawn fish with no FISH_HISTORY env var it uses the
|
||||
# Verify that if we spawn fish with no fish_history env var it uses the
|
||||
# default file.
|
||||
# =============
|
||||
set fish_pid [spawn $fish]
|
||||
|
@ -34,7 +34,7 @@ expect_prompt -re "\r\n$hist_line\r\n" {
|
|||
# history file is not written to.
|
||||
set cmd2 "echo $fish_pid my histfile"
|
||||
set hist_line "- cmd: $cmd2"
|
||||
send "set FISH_HISTORY my\r"
|
||||
send "set fish_history my\r"
|
||||
expect_prompt
|
||||
send "$cmd2\r"
|
||||
expect_prompt
|
||||
|
@ -62,7 +62,7 @@ expect_prompt -re "\r\n$hist_line\r\n" {
|
|||
# Switch back to the default history file.
|
||||
set cmd3 "echo $fish_pid default histfile again"
|
||||
set hist_line "- cmd: $cmd3"
|
||||
send "set FISH_HISTORY default\r"
|
||||
send "set fish_history default\r"
|
||||
expect_prompt
|
||||
send "$cmd3\r"
|
||||
expect_prompt
|
||||
|
@ -94,15 +94,15 @@ expect_prompt -re "\r\n$hist_line\r\n" {
|
|||
send "exit\r"
|
||||
close $spawn_id
|
||||
|
||||
# Set the FISH_HISTORY env var.
|
||||
set ::env(FISH_HISTORY) env
|
||||
# Set the fish_history env var.
|
||||
set ::env(fish_history) env
|
||||
|
||||
# Spawn a new shell.
|
||||
set prompt_counter 1
|
||||
set fish_pid [spawn $fish]
|
||||
expect_prompt
|
||||
|
||||
# Verify that the new fish shell is using the FISH_HISTORY value for history.
|
||||
# Verify that the new fish shell is using the fish_history value for history.
|
||||
set cmd4 "echo $fish_pid env histfile"
|
||||
set hist_line "- cmd: $cmd4"
|
||||
send "$cmd4\r"
|
||||
|
|
Loading…
Reference in a new issue