Merge pull request #1662 from MarkGriffiths/documentation-update

Documentation update: Fixes issue #1557
This commit is contained in:
Konrad Borowski 2014-09-12 13:36:26 +02:00
commit 5c25be51ea
90 changed files with 9940 additions and 5723 deletions

5
.gitignore vendored
View file

@ -2,6 +2,7 @@
*~
*.exe
.DS_Store
Makefile
autom4te.cache/
build/
@ -35,3 +36,7 @@ tests/foo.txt
FISH-BUILD-VERSION-FILE
version
messages.pot
lexicon.txt
lexicon_filter
lexicon.log

2418
Doxyfile

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -148,6 +148,11 @@ HDR_FILES := $(HDR_FILES_SRC:.hdr.in=.hdr)
HELP_SRC := $(wildcard doc_src/*.txt)
#
# HTML includes needed for HTML help
#
HTML_SRC := doc_src/user_doc.header.html doc_src/user_doc.footer.html doc_src/user_doc.css
#
# Files in the test directory
@ -252,18 +257,19 @@ prof: all
# Depend on the sources (*.hdr.in) and manually make the
# intermediate *.hdr and doc.h files if needed
# The sed command deletes everything including and after the first -, for simpler version numbers
# Cleans up the user_doc/html directory once Doxygen is done.
user_doc: $(HDR_FILES_SRC) Doxyfile.user user_doc.head.html $(HELP_SRC) doc.h $(HDR_FILES)
(cat Doxyfile.user ; echo PROJECT_NUMBER=$(FISH_BUILD_VERSION) | sed "s/-.*//") | doxygen - && touch user_doc
user_doc: $(HDR_FILES_SRC) Doxyfile.user $(HTML_SRC) $(HELP_SRC) doc.h $(HDR_FILES) lexicon_filter
(cat Doxyfile.user; echo INPUT_FILTER=./lexicon_filter; \
echo PROJECT_NUMBER=$(FISH_BUILD_VERSION) | sed "s/-.*//") | doxygen - && touch user_doc; \
cd user_doc/html && rm -f bc_s.png bdwn.png closed.png ftv2*.png nav*.png open.png sync_*.png tab*.* doxygen.* dynsections.js jquery.js pages.html
#
# Source code documentation. Also includes user documentation.
#
doc: *.h *.cpp doc.h Doxyfile
(cat Doxyfile ; echo PROJECT_NUMBER=$(FISH_BUILD_VERSION)) | doxygen - ;
doc: *.h *.cpp doc.h Doxyfile lexicon_filter
(cat Doxyfile; echo INPUT_FILTER=./lexicon_filter; echo PROJECT_NUMBER=$(FISH_BUILD_VERSION)) | doxygen - ;
#
@ -271,10 +277,9 @@ doc: *.h *.cpp doc.h Doxyfile
#
doc/refman.pdf: doc
cd doc/latex;
make;
cd doc/latex && \
make && \
mv refman.pdf ..;
cd ../..;
rm -r doc/latex;
@ -343,11 +348,67 @@ toc.txt: $(HDR_FILES:index.hdr=index.hdr.in)
doc_src/index.hdr: toc.txt doc_src/index.hdr.in
cat $@.in | awk '{if ($$0 ~ /@toc@/){ system("cat toc.txt");} else{ print $$0;}}' >$@
#
# To enable the lexicon filter, we first need to be aware of what fish
# considers to be a command, function, or external binary. We use
# command_list_toc.txt for the base commands. Scan the share/functions
# directory for other functions, some of which are mentioned in the docs, and
# use /share/completions to find a good selection of binaries. Additionally,
# colour defaults from __fish_config_interactive to set the docs colours when
# used in a 'cli' style context.
#
lexicon.txt: doc_src/commands.hdr $(FUNCTIONS_DIR_FILES) $(COMPLETIONS_DIR_FILES) share/functions/__fish_config_interactive.fish
-rm lexicon.tmp lexicon_catalog.tmp lexicon_catalog.txt $@
# Scan sources for commands/functions/binaries/colours. If GNU sed was portable, this could be much smarter.
sed <command_list_toc.txt >>lexicon.tmp -n \
-e "s|^.*>\([a-z][a-z_]*\)</a>|'\1'|w lexicon_catalog.tmp" \
-e "s|'\(.*\)'|bltn \1|p"; mv lexicon_catalog.tmp lexicon_catalog.txt; \
printf "%s\n" $(COMPLETIONS_DIR_FILES) | sed -n \
-e "s|[^ ]*/\([a-z][a-z_-]*\).fish|'\1'|p" | fgrep -vx -f lexicon_catalog.txt | sed >>lexicon.tmp -n \
-e 'w lexicon_catalog.tmp' \
-e "s|'\(.*\)'|cmnd \1|p"; cat lexicon_catalog.tmp >> lexicon_catalog.txt; \
printf "%s\n" $(FUNCTIONS_DIR_FILES) | sed -n \
-e "s|[^ ]*/\([a-z][a-z_-]*\).fish|'\1'|p" | fgrep -vx -f lexicon_catalog.txt | sed >>lexicon.tmp -n \
-e 'w lexicon_catalog.tmp' \
-e "s|'\(.*\)'|func \1|p"; \
sed <share/functions/__fish_config_interactive.fish >>lexicon.tmp -n \
-e '/set_default/s/.*\(fish_[a-z][a-z_]*\).*$$/clrv \1/p'; \
sed <lexicon_filter.in >>lexicon.tmp -n \
-e '/^#.!#/s/^#.!# \(.... [a-z][a-z_]*\)/\1/p'; \
mv lexicon.tmp lexicon.txt; rm -f lexicon_catalog.tmp lexicon_catalog.txt;
#
# Compile Doxygen Input Filter from the lexicon. This is an executable sed
# script as Doxygen opens it via popen()(3) Input (doc.h) is piped through and
# matching words inside /fish../endfish blocks are marked up, contextually,
# with custom Doxygen commands in the form of @word_type{content}. These are
# trapped by ALIASES in the various Doxyfiles, allowing the content to be
# transformed depending on output type (HTML, man page, developer docs). In
# HTML, a style context can be applied through the /fish{style} block and
# providing suitable CSS in user_doc.css.in
#
lexicon_filter: lexicon.txt lexicon_filter.in
-rm $@.tmp $@
# Clean the filter input comments and set the shebang as sed can reside in
# /bin or /usr/bin and some versions dont allow more than one comment!.
sed <$@.in >$@.tmp -e 's|@sed@|'"`which sed`"'|' -e '/^[ ]*#[^!]/d'
# Scan through the lexicon, transforming each line to something useful to Doxygen.
if echo x | sed "/[[:<:]]x/d" 2>/dev/null; then \
WORDBL='[[:<:]]'; WORDBR='[[:>:]]'; \
else \
WORDBL='\<'; WORDBR='\>'; \
fi; \
sed <lexicon.txt >>$@.tmp -n \
-e "s|^\([a-z][a-z][a-z][a-z]\) \([a-z_-]*\)$$|s,$$WORDBL\2$$WORDBR,@\1{\2},g|p" \
-e '$$G;s/.*\n/b tidy/p'; \
mv $@.tmp $@; if test -x $@; then true; else chmod a+x $@; fi
#
# doc.h is a compilation of the various snipptes of text used both for
# the user documentation and for internal help functions into a single
# file that can be parsed dy Doxygen to generate the user
# file that can be parsed by Doxygen to generate the user
# documentation.
#
@ -445,11 +506,12 @@ common.o: $(COMMON_FILES)
# There ought to be something simpler.
#
share/man: $(HELP_SRC)
share/man: $(HELP_SRC) lexicon_filter
-mkdir share/man
touch share/man
-rm -Rf share/man/man1
PROJECT_NUMBER=`echo $(FISH_BUILD_VERSION)| sed "s/-.*//"` ./build_tools/build_documentation.sh Doxyfile.help ./doc_src ./share
PROJECT_NUMBER=`echo $(FISH_BUILD_VERSION)| sed "s/-.*//"` INPUT_FILTER=./lexicon_filter \
./build_tools/build_documentation.sh Doxyfile.help ./doc_src ./share
#
# The build rules for installing/uninstalling fish
@ -763,6 +825,7 @@ clean:
rm -f $(PROGRAMS) fish_tests key_reader
rm -f command_list.txt command_list_toc.txt toc.txt
rm -f doc_src/index.hdr doc_src/commands.hdr
rm -f lexicon_filter lexicon.txt lexicon.log
rm -f FISH-BUILD-VERSION-FILE
if test "$(HAVE_DOXYGEN)" = 1; then \
rm -rf doc user_doc share/man; \

View file

@ -21,7 +21,7 @@ fish depends on a curses implementation, such as ncurses. The headers and librar
fish requires gettext for translation support.
Building the documentation requires Doxygen 1.5 or newer.
Building the documentation requires Doxygen 1.8 or newer.
### Autotools Build

View file

@ -37,10 +37,12 @@ resolve_path()
# Expand relative paths
DOXYFILE=`resolve_path "$DOXYFILE"`
INPUTDIR=`resolve_path "$INPUTDIR"`
INPUTFILTER=`resolve_path "$INPUT_FILTER"`
OUTPUTDIR=`resolve_path "$OUTPUTDIR"`
echo " doxygen file: $DOXYFILE"
echo " input directory: $INPUTDIR"
echo " input filter: $INPUTFILTER"
echo " output directory: $OUTPUTDIR"
echo " skipping: $CONDEMNED_PAGES"
@ -66,6 +68,12 @@ if test -z "$DOXYGENPATH"; then
exit 0
fi
# Check we have the lexicon filter
if test -z "$INPUT_FILTER"; then
echo >&2 "Lexicon filter is not available. Continuing without."
INPUTFILTER=''
fi
# Determine where our output should go
if ! mkdir -p "${OUTPUTDIR}" ; then
echo "Could not create output directory '${OUTPUTDIR}'"
@ -87,6 +95,7 @@ done
# This prevents doxygen from generating "documentation" for intermediate directories
DOXYPARAMS=$(cat <<EOF
PROJECT_NUMBER=$PROJECT_NUMBER
INPUT_FILTER=$INPUTFILTER
INPUT=.
OUTPUT_DIRECTORY=$OUTPUTDIR
QUIET=YES
@ -100,7 +109,7 @@ find "${OUTPUTDIR}" -name "*.1" -delete
# Run doxygen
cd "$TMPLOC"
(cat "${DOXYFILE}" ; echo "$DOXYPARAMS";) | "$DOXYGENPATH" -
(cat "${DOXYFILE}" ; echo "$DOXYPARAMS";) | "$DOXYGENPATH" -
# Remember errors
RESULT=$?
@ -110,15 +119,16 @@ if test "$RESULT" = 0 ; then
# Postprocess the files
for i in "$INPUTDIR"/*.txt; do
# It would be nice to use -i here for edit in place, but that is not portable
# It would be nice to use -i here for edit in place, but that is not portable
CMD_NAME=`basename "$i" .txt`;
sed -e "s/\(.\)\\.SH/\1/" -e "s/$CMD_NAME *\\\\- *\"\(.*\)\"/\1/" "${CMD_NAME}.1" > "${CMD_NAME}.1.tmp"
sed < ${CMD_NAME}.1 > ${CMD_NAME}.1.tmp \
-e "/.SH \"$CMD_NAME/d" \
-e "s/^$CMD_NAME * \\\- \([^ ]*\) /\\\fB\1\\\fP -/"
mv "${CMD_NAME}.1.tmp" "${CMD_NAME}.1"
done
# Erase condemned pages
rm -f $CONDEMNED_PAGES
fi
# Destroy TMPLOC

View file

@ -146,7 +146,7 @@ AS_IF([test x$local_gettext != xno],
# Build/clean the documentation only if Doxygen is available
#
doxygen_minimum=1.5
doxygen_minimum=1.8.7
AC_ARG_WITH(
doxygen,

262
doc_src/FORMATTING.md Normal file
View file

@ -0,0 +1,262 @@
# Formatting guide for fish docs
The fish documentation has been updated to support Doxygen 1.8.7+, and while the main benefit of this change is extensive Markdown support, the addition of a fish lexicon and syntax filter, combined with semantic markup rules allows for automatic formatting enhancements across the HTML user_docs, the developer docs and the man pages.
Initially my motivation was to fix a problem with long options ([Issue #1557](https://github.com/fish-shell/fish-shell/issues/1557) on GitHub), but as I worked on fixing the issue I realised there was an opportunity to simplify, reinforce and clarify the current documentation, hopefully making further contribution easier and cleaner, while allowing the documentation examples to presented more clearly with less author effort.
While the documentation is pretty robust to variations in the documentation source, adherence to the following style guide will help keep the already excellent documention in good shape moving forward.
## Line breaks and wrapping
Contrary to the rest of the fish source code, the documentation greatly benefits from the use of long lines and soft wrapping. It allows paragraphs to be treated as complete blocks by Doxygen, means that the semantic filter can see complete lines when deciding on how to apply syntax highlighting, and means that man pages will consistently wrap to the width of the users console in advanced pagers, such as 'most'.
## Doxygen special commands and aliases
While Markdown syntax forms the basis of the documentation content, there are some exceptions that require the use of Doxygen special commands. On the whole, Doxygen commands should be avoided, especially inline word formatting such as \\c as this would allow Doxygen to make unhelpful assumptions, such as converting double dashes (\--) to n-dashes ().
### Structure: \\page, \\section and \\subsection
Use of Doxygen sections markers are important, as these determine what will be eventually output as a web page, man page or included in the developer docs.
Currently the make process for the documentation is quite convoluted, but basically the HTML docs are produced from a single, compiled file, doc.h. This contains a number of \\page markers that produce the various pages used in the documentation. The format of a \\page mark is:
\page universally_unique_page_id Page title
The source files that contain the page markers are currently:
- __index.hdr.in__: Core documentation
- __commands.hdr.in__: Individual commands
- __tutorial.hdr__: Tutorial
- __design.hdr__: Design document
- __faq.hdr__: Frequently Asked Questions
- __license.hdr__: Fish and 3rd party licences
Unless there is a _VERY_ good reason and developer consensus, new pages should never be added.
The rest of the documentation is structured using \\section and \\subsection markers. Most of the source files (listed above) contain their full content, the exception being commands, which are separated out into source text files in the doc_src directory. These files are concatenated into one file, so each one starts with a \\section declaration. The synopsis, description and examples (if present) are declared as \\subsections. The format of these marks is practically identical to the page mark.
\section universally_unique_section_id Section title
\subsection universally_unique_subsection_id Subsection title
Each page, section and subsection id _must_ be unique across the whole of the documentation, otherwise Doxygen will issue a warning.
### Semantic markup: the \\fish .. \\endfish block
While Doxygen has support for \\code..\\endcode blocks with enhanced markup and syntax colouring, it only understands the core Doxygen languages: C, C++, Objective C, Java, PHP, Python, Tcl and Fortran. To enhance Fish's syntax presentation, use the special \\fish..\\endfish blocks instead.
Text placed in this block will be parsed by Doxygen using the included lexicon filter (see lexicon_filter.in) as a Doxygen input filter. The filter is built during make so that it can pick up information on builtins, functions and shell commands mentioned in completions and apply markup to keywords found inside the \\fish block.
Basically, preformatted plain text inside the \\fish block is fed through the filter and is returned marked up so that Doxygen aliases can convert it back to a presentable form, according to the output document type.
For instance:
`echo hello world`
is transformed into:
`@cmnd{echo} @args{hello} @args{world}`
which is then transformed by Doxygen into an HTML version (`make user_doc`):
`<span class="command">echo</span> <span class="argument">hello</span> <span class="argument">world</span>`
A man page version (`make share/man`):
__echo__ hello world
And a simple HTML version for the developer docs (`make doc`) and the LATEX/PDF manual (`make doc/refman.pdf`):
`echo hello world`
### Fonts
In older browsers, it was easy to set the fonts used for the three basic type styles (serif, sans-serif and monospace). Modern browsers have removed these options in their respective quests for simplification, assuming the content author will provide suitable styles for the content in the site's CSS, or the end user will provide overriding styles manually. Doxygen's default styling is very simple and most users will just accept this default.
I've tried to use a sensible set of fonts in the documentation's CSS based on 'good' terminal fonts and as a result the firt preference font used throughout the documentation is '[DejaVu](http://dejavu-fonts.org)'. The rationale behaind this is that while DejaVu is getting a little long in the tooth, it still provides the most complete support across serif, sans-serif and monospace styles (giving a well balanced feel and consistent [x-height](http://en.wikipedia.org/wiki/X-height)), has the widest support for extended Unicode characters and has a free, permissive licenses (though it's still incompatible with GPLv2, though arguably less so than the SIL Open Font license, though this is a moot point when using it solely in the docs).
#### Fonts inside \\fish blocks and \`backticks\`
As the point of these contructs is to make fish's syntax clearer to the user, it makes sense to mimic what the user will see in the console, therefore any content is formatted using the monospaced style, specifically monospaced fonts are chosen in the following order:
1. __DejaVu Sans Mono__: Explained above. [[&darr;](http://dejavu-fonts.org)]
2. __Source Code Pro__: Monospaced code font, part of Adobe's free Edge Web Fonts. [[&darr;](https://edgewebfonts.adobe.com)]
3. __Menlo__: Apple supplied variant of DejaVu.
4. __Ubuntu Mono__: Ubuntu Linux's default monospaced font. [[&darr;](http://font.ubuntu.com)]
5. __Consolas__: Modern Microsoft supplied console font.
6. __Monaco__: Apple supplied console font since 1984!
7. __Lucida Console__: Generic mono terminal font, standard in many OS's and distros.
8. __monospace__: Catchall style. Chooses default monospaced font, often Courier.
9. __fixed__: As above, more often used on mobile devices.
#### General Fonts
1. __DejaVu Sans__: As above.[[&darr;](http://dejavu-fonts.org)]
2. __Roboto__: Elegant Google free font and is Doxygen's default [[&darr;](http://www.google.com/fonts/specimen/Roboto)]
3. __Lucida Grande__: Default Apple OS X content font.
4. __Calibri__: Default Microsoft Office font (since 2007).
5. __Verdana__: Good general font found in a lot of OSs.
6. __Helvetica Neue__: Better spaced and balanced Helvetica/Arial variant.
7. __Helvetica__: Standard humanist typeface found almost everywhere.
8. __Arial__: Microsoft's Helvetica.
9. __sans-serif__: Catchall style. Chooses default sans-serif typeface, often Helvetica.
The ordering of the fonts is important as it's designed to allow the documentation to settle into a number of different identities according to the fonts available. If you have the complete DejaVu family installed, then the docs are presented using that, and if your Console is set up to use the same fonts, presentation will be completely consistent.
On OS X, with nothing extra installed, the docs will default to Menlo and Lucida Grande giving a Mac feel. Under Windows, it will default to using Consolas and Calibri on recent versions, giving a modern Windows style.
#### Other sources:
- [Font Squirrel](http://www.fontsquirrel.com): Good source of open source font packages.
### Choosing a CLI style: using a \\fish{style} block
By default, when output as HTML, a \\fish block uses syntax colouring suited to the style of the documentation rather than trying to mimic the terminal. The block has a light, bordered background and a colour scheme that 'suggests' what the user would see in a console.
Additional stying can be applied adding a style declaration:
\fish{additional_style [another_style...]}
...
\endfish
This will translate to classes applied to the `<div>` tag, like so:
<div class="fish additional_style another_style">
...
</div>
The various classes are defined in `doc_src/user_doc.css` and new style can be simply added
The documentation currently defines a couple of additional styles:
- __cli-dark__: Used in the _tutorial_ and _FAQ_ to simulate a dark background terminal, with fish's default colours (slightly tweaked for legibility in the browser).
- __synopsis__: A simple colour theme helpful for displaying the logical 'summary' of a command's syntax, options and structure.
## Markdown
Apart from the exceptions discussed above, the rest of the documentation now supports the use of Markdown. As such the use of Doxygen special commands for HTML tags is unnecessary.
There are a few exceptions and extensions to the Markdown [standard](http://daringfireball.net/projects/markdown/) that are documented in the Doxygen [documentation](http://www.stack.nl/~dimitri/doxygen/manual/markdown.html).
### \`Backticks\`
As is standard in Markdown and 'Github Flavoured Markdown' (GFM), backticks can be used to denote inline technical terms in the documentation, `like so`. In the documentation this will set the font to the monospaced 'console' typeface and will cause the enclosed term to stand out.
However, fenced code blocks using 4 spaces or 3 backticks (\`\`\`) should be avoided as Doxygen will interpret these as \\code blocks and try to apply standard syntax colouring, which doesn't work so well for fish examples. Use `\fish..\endfish` blocks instead.
### Lists
Standard Markdown list rules apply, but as Doxygen will collapse white space on output, combined with the use of long lines, it's a good idea to include an extra new line between long list items to assist future editing.
## Special cases
The following can be used in \\fish blocks to render some fish scenarios. These are mostly used in the tutorial when an interactive situation needs to be displayed.
### Custom formatting tags
- `<s>`: auto\<s\>suggestion\</s\>.
- `<m>`: \<m\>Matched\</m\> items, such as tab completions.
- `<sm>`: Matched items \<sm\>searched\<sm\> for, like grep results.
- `<error>`: \<error\>This would be shown as an error.\</error\>
- `<asis>`: \<asis\>This test will not be parsed for fish markup.\</asis\>
- `<outp>`: \<outp\>This would be rendered as command/script output.\</outp\>
### Prompts and cursors
- `>_`: Display a basic prompt.
- `~>_`: Display a prompt with a the home directory as the current working directory.
- `___` (3 underscores): Display a cursor.
### Keyboard shortcuts: @key{} and @cursor_key{}
Graphical keyboard shortcuts can be defined using the following special commands. These allow for the different text requirements across the html and man pages. The HTML uses CSS to create a keyboard style, whereas the man page would display the key as text.
- `@key{lable}`
Displays a key with a purely textual lable, such as: 'Tab', 'Page Up', 'Page Down', 'Home', 'End', 'F1', 'F19' and so on.
- `@key{modifier,lable}`
Displays a keystroke requiring the use of a 'modifier' key, such as 'Control-A', 'Shift-X', 'Alt-Tab' etc.
- `@key{modifier,entity,lable}`
Displays a keystroke using a graphical entity, such as an arrow symbol for cursor key based shortcuts.
- `@cursor_key{entity,lable}`
A special case for cursor keys, when no modifier is needed. i.e. `@cursor_key{&uarr;,up}` for the up arrow key.
Some useful Unicode/HTML5 entities:
- Up arrow: `&uarr;`
- Down arrow: `&darr;`
- Left arrow: `&larr;`
- Right arrow `&rarr;`
- Shift: `&#8679;`
- Tab: `&rarrb;`
- Mac option: `&#8997;`
- Mac command: `&#8984;`
## Notes
### Doxygen
Tested on:
- Ubuntu 14.04 with Doxygen 1.8.8, built from [GitHub source](https://github.com/doxygen/doxygen.git).
- CentOS 6.5 with Doxygen 1.8.8, built from [GitHub source](https://github.com/doxygen/doxygen.git).
- Mac OS X 10.9 with Homebrew install Doxygen 1.8.7 and 1.8.8.
Graphviz was also installed in all the above testing.
Doxygen 1.8.6 and lower do not have the \\htmlonly[block] directive which fixes a multitude of problems in the rendering of the docs. In Doxygen 1.8.7 the list of understood HTML entities was greatly increased. I tested earlier versions and many little issues returned.
As fish ships with pre-built documentation, I don't see this as an issue.
### Updated Configure/Makefile
- Tested on Ubuntu 14.04, CentOS 6.5 and Mac OS X 10.9.
- Makefile has GNU/BSD sed/grep detection.
### HTML output
- The output HTML is HTML5 compliant, but should quickly and elegantly degrade on older browsers without losing basic structure.
- The CSS avoids the use or browser specific extenstions (i.e. -webkit, -moz etc), using the W3C HTML5 standard instead.
- It's been tested in Chrome 37.0 and Firefox 32.0 on Mac OS X 10.9 (+Safari 7), Windows 8.1 (+Internet Explorer 11) and Ubuntu Desktop 14.04.
- My assumption is basically that if someone cares enough to want to install fish, they'll be keeping a browser current.
### Man page output
- Tested on Ubuntu 14.04, CentOS 6.5 and Mac OS X 10.9.
- Output is substantially cleaner.
- Tested in cat, less, more and most pagers using the following fish script:
```
function manTest --description 'Test manpage' --argument page
set -l pager
for i in $argv
switch $i
case "-l"
set pager -P '/usr/bin/less -is'
case "-m"
set pager -P '/usr/bin/more -s'
case "-c"
set pager -P '/bin/cat'
end
end
man $pager ~/Projects/OpenSource/fish-shell/share/man/man1/$page.1
end
# Assumes 'most' is the default system pager.
# NOT PORTABLE! Paths would be need to be updated on other systems.
```
### Developer docs and LATEX/PDF output
- HTML developer docs tested on Ubuntu 14.04, CentOS 6.5 and Mac OS X 10.9.
- LATEX/PDF reference manual tested on Mac OS X 10.9 using MacTEX. PDF production returns an error (due to Doxygen's use of an outdated 'float' package), but manual PDF output is ok.
### Future changes
1. The documentation creation process would be better if it could be modularised further and moved out of the makefile into a number of supporting scripts. This would allow both the automake and Xcode build processes to use the documentation scripts directly.
2. Remove the Doxygen dependency entirely for the user documentation. This would be very acheivable now that the bulk of the documentation is in Markdown.
3. It would be useful to gauge what parts of the documentation are actually used by users. Judging by the amount of 'missing comment' errors during the developer docs build phase, this aspect of the docs has been rather neglected. If it is not longer used or useful, then this could change the future direction of the documentation and significantly streamline the process.
#### Author: Mark Griffiths [@GitHub](https://github.com/MarkGriffiths)

View file

@ -1,34 +1,34 @@
\section alias alias - create a function
\subsection alias-synopsis Synopsis
<pre>alias NAME DEFINITION
alias NAME=DEFINITION</pre>
\fish{synopsis}
alias NAME DEFINITION
alias NAME=DEFINITION
\endfish
\subsection alias-description Description
\c alias is a simple wrapper for the \c function builtin.
It exists for backwards compatibility with Posix
shells. For other uses, it is recommended to define a <a
href='#function'>function</a>.
`alias` is a simple wrapper for the `function` builtin. It exists for backwards compatibility with Posix shells. For other uses, it is recommended to define a <a href='#function'>function</a>.
\c fish does not keep track of which functions have been defined using
\c alias. They must be erased using <code>functions -e</code>.
`fish` does not keep track of which functions have been defined using `alias`. They must be erased using `functions -e`.
- NAME is the name of the alias
- DEFINITION is the actual command to execute. The string " $argv" will be appended.
- `NAME` is the name of the alias
- `DEFINITION` is the actual command to execute. The string `$argv` will be appended.
You cannot create an alias to a function with the same name.
\subsection alias-example Example
The following code will create \c rmi, which runs \c rm with additional
arguments on every invocation.
The following code will create `rmi`, which runs `rm` with additional arguments on every invocation.
<code>alias rmi "rm -i"</code>
\fish
alias rmi "rm -i"
This is equivalent to entering the following function:
# This is equivalent to entering the following function:
<pre>function rmi
function rmi
rm -i $argv
end</pre>
end
\endfish

View file

@ -1,27 +1,24 @@
\section and and - conditionally execute a command
\subsection and-synopsis Synopsis
<tt>COMMAND1; and COMMAND2</tt>
\fish{synopsis}
COMMAND1; and COMMAND2
\endfish
\subsection and-description Description
\c and is used to execute a command if the current exit
status (as set by the last previous command) is 0.
`and` is used to execute a command if the current exit status (as set by the last previous command) is 0.
\c and does not change the current exit status.
`and` does not change the current exit status.
The exit status of the last foreground command to exit can always be accessed using the <a href="index.html#variables-status">$status</a> variable.
The exit status of the last foreground command to exit can always be
accessed using the <a href="index.html#variables-status">$status</a>
variable.
\subsection and-example Example
The following code runs the \c make command to build a program. If the
build succeeds, <code>make</code>'s exit status is 0, and the program is installed. If either step fails,
the exit status is 1, and <tt>make clean</tt> is run, which removes the files created by the.
build process.
The following code runs the `make` command to build a program. If the build succeeds, `make`'s exit status is 0, and the program is installed. If either step fails, the exit status is 1, and `make clean` is run, which removes the files created by the build process.
<pre>
\fish
make; and make install; or make clean
</pre>
\endfish

BIN
doc_src/ascii_fish.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View file

@ -1,49 +1,45 @@
\section begin begin - start a new block of code
\subsection begin-synopsis Synopsis
<tt>begin; [COMMANDS...;] end</tt>
\fish{synopsis}
begin; [COMMANDS...;] end
\endfish
\subsection begin-description Description
\c begin is used to create a new block of code.
`begin` is used to create a new block of code.
The block
is unconditionally executed. <code>begin; ...; end</tt> is equivalent
to <tt>if true; ...; end</tt>.
The block is unconditionally executed. `begin; ...; end` is equivalent to `if true; ...; end`.
\c begin is used to group a number of commands into a block.
This allows the introduction of a new variable scope, redirection of the input or
output of a set of commands as a group, or to specify precedence when
using the conditional commands like \c and.
`begin` is used to group a number of commands into a block. This allows the introduction of a new variable scope, redirection of the input or output of a set of commands as a group, or to specify precedence when using the conditional commands like `and`.
`begin` does not change the current exit status.
\c begin does not change the current exit status.
\subsection begin-example Example
The following code sets a number of variables inside of a block
scope. Since the variables are set inside the block and have local
scope, they will be automatically deleted when the block ends.
The following code sets a number of variables inside of a block scope. Since the variables are set inside the block and have local scope, they will be automatically deleted when the block ends.
<pre>
\fish
begin
set -l PIRATE Yarrr
...
set -l PIRATE Yarrr
...
end
# This will not output anything, since the PIRATE variable went out
# of scope at the end of the block
echo $PIRATE
</pre>
# This will not output anything, since the PIRATE variable
# went out of scope at the end of the block
\endfish
In the following code, all output is redirected to the file out.html.
<pre>
\fish
begin
echo $xml_header
echo $html_header
if test -e $file
...
end
...
end &gt; out.html
</pre>
echo $xml_header
echo $html_header
if test -e $file
...
end
...
end > out.html
\endfish

View file

@ -1,17 +1,17 @@
\section bg bg - send jobs to background
\subsection bg-synopsis Synopsis
<tt>bg [PID...]</tt>
\fish{synopsis}
bg [PID...]
\endfish
\subsection bg-description Description
\c bg sends <a href="index.html#syntax-job-control">jobs</a> to the background, resuming them if they are stopped. 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 with the specified process group IDs are put in the background.
`bg` sends <a href="index.html#syntax-job-control">jobs</a> to the background, resuming them if they are stopped. 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 with the specified process group IDs are put in the background.
The PID of the desired process is usually found by using <a href="index.html#expand-process">process expansion</a>.
\subsection bg-example Example
<tt>bg \%1</tt> will put the job with job ID 1 in the background.
`bg %1` will put the job with job ID 1 in the background.

View file

@ -1,97 +1,101 @@
\section bind bind - handle fish key bindings
\subsection bind-synopsis Synopsis
<tt>bind [OPTIONS] SEQUENCE COMMAND</tt>
\fish{synopsis}
bind [OPTIONS] SEQUENCE COMMAND
\endfish
\subsection bind-description Description
<tt>bind</tt> adds a binding for the specified key sequence to the
`bind` adds a binding for the specified key sequence to the
specified command.
SEQUENCE is the character sequence to bind to. These should be written as
<a href="index.html#escapes">fish escape sequences</a>. For example, because pressing
the Alt key and another character sends that character prefixed with
an escape character, Alt-based key bindings can be written using the
\c \\e escape. For example, Alt-w can be written as
<tt>\\ew</tt>. The control character can be written in much the same way
using the \c \\c escape, for example Control-x (^X) can be written as
<tt>\\cx</tt>. Note that Alt-based key bindings are case sensitive and
Control-based key bindings are not. This is a constraint of text-based
terminals, not \c fish.
SEQUENCE is the character sequence to bind to. These should be written as <a href="index.html#escapes">fish escape sequences</a>. For example, because pressing the Alt key and another character sends that character prefixed with an escape character, Alt-based key bindings can be written using the `\e` escape. For example, @key{Alt,w} can be written as `\ew`. The control character can be written in much the same way using the `\c` escape, for example @key{Control,X} (^X) can be written as `\cx`. Note that Alt-based key bindings are case sensitive and Control-based key bindings are not. This is a constraint of text-based terminals, not `fish`.
The default key binding can be set by specifying a SEQUENCE of the empty
string (that is, <code>''</code>). It will be used whenever no
other binding matches. For most key bindings, it makes sense to use
the \c self-insert function (i.e. <tt>bind '' self-insert</tt> 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.
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 \c terminfo(5) for more information, or use <tt>bind
--key-names</tt> 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.)
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.
`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 <a href="#function">function</a> 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.
When `COMMAND` is a shellscript command, it is a good practice to put the actual code into a <a href="#function">function</a> 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 such a script produces output, the script needs to finish by
calling 'commandline -f repaint' in order to tell fish that a repaint
is in order.
If such a script produces output, the script needs to finish by calling `commandline -f repaint` in order to tell fish that a repaint is in order.
Key bindings are not saved between sessions by default. To save custom
keybindings, edit the \c fish_user_key_bindings function and insert the
appropriate \c bind statements.
Key bindings are not saved between sessions by default. To save custom keybindings, edit the `fish_user_key_bindings` function and insert the appropriate `bind` statements.
The following parameters are available:
- <tt>-k</tt> or <tt>--key</tt> Specify a key name, such as 'left' or 'backspace' instead of a character sequence
- <tt>-K</tt> or <tt>--key-names</tt> Display a list of available key names
- <tt>-f</tt> or <tt>--function-names</tt> Display a list of available input functions
- `-k` or `--key` Specify a key name, such as 'left' or 'backspace' instead of a character sequence
- `-K` or `--key-names` Display a list of available key names
- `-f` or `--function-names` Display a list of available input functions
The following special input functions are available:
- \c backward-char, moves one character to the left
- \c backward-delete-char, deletes one character of input to the left of the cursor
- \c backward-kill-line, move everything from the beginning of the line to the cursor to the killring
- \c backward-kill-word, move the word to the left of the cursor to the killring
- \c backward-word, move one word to the left
- \c beginning-of-history, move to the beginning of the history
- \c beginning-of-line, move to the beginning of the line
- \c capitalize-word, make the current word begin with a capital letter
- \c complete, guess the remainder of the current token
- \c delete-char, delete one character to the right of the cursor
- \c delete-line, delete the entire line
- \c downcase-word, make the current word lowercase
- \c dump-functions, print a list of all key-bindings
- \c end-of-history, move to the end of the history
- \c end-of-line, move to the end of the line
- \c explain, print a description of possible problems with the current command
- \c forward-char, move one character to the right
- \c forward-word, move one word to the right
- \c history-search-backward, search the history for the previous match
- \c history-search-forward, search the history for the next match
- \c kill-line, move everything from the cursor to the end of the line to the killring
- \c kill-whole-line, move the line to the killring
- \c kill-word, move the next word to the killring
- \c upcase-word, make the current word uppercase
- \c yank, insert the latest entry of the killring into the buffer
- \c yank-pop, rotate to the previous entry of the killring
- `backward-char`, moves one character to the left
- `backward-delete-char`, deletes one character of input to the left of the cursor
- `backward-kill-line`, move everything from the beginning of the line to the cursor to the killring
- `backward-kill-word`, move the word to the left of the cursor to the killring
- `backward-word`, move one word to the left
- `beginning-of-history`, move to the beginning of the history
- `beginning-of-line`, move to the beginning of the line
- `capitalize-word`, make the current word begin with a capital letter
- `complete`, guess the remainder of the current token
- `delete-char`, delete one character to the right of the cursor
- `delete-line`, delete the entire line
- `downcase-word`, make the current word lowercase
- `dump-functions`, print a list of all key-bindings
- `end-of-history`, move to the end of the history
- `end-of-line`, move to the end of the line
- `explain`, print a description of possible problems with the current command
- `forward-char`, move one character to the right
- `forward-word`, move one word to the right
- `history-search-backward`, search the history for the previous match
- `history-search-forward`, search the history for the next match
- `kill-line`, move everything from the cursor to the end of the line to the killring
- `kill-whole-line`, move the line to the killring
- `kill-word`, move the next word to the killring
- `upcase-word`, make the current word uppercase
- `yank`, insert the latest entry of the killring into the buffer
- `yank-pop`, rotate to the previous entry of the killring
\subsection bind-example Examples
<tt>bind \\cd 'exit'</tt> causes \c fish to exit when Control-d is pressed.
\fish
bind \cd 'exit'
\endfish
Causes `fish` to exit when @key{Control,D} is pressed.
<tt>bind -k ppage history-search-backward</tt> performs a history search when the Page Up key is pressed.
\fish
bind -k ppage history-search-backward
\endfish
Performs a history search when the @key{Page Up} key is pressed.

View file

@ -1,40 +1,41 @@
\section block block - temporarily block delivery of events
\subsection block-synopsis Synopsis
<tt>block [OPTIONS...]</tt>
\fish{synopsis}
block [OPTIONS...]
\endfish
\subsection block-description Description
\c block prevents events triggered by \c fish or the
<a href="commands.html#emit"><code>emit</code></a> command from
being delivered and acted upon while the block is in place.
`block` prevents events triggered by `fish` or the <a href="commands.html#emit">`emit`</a> command from being delivered and acted upon while the block is in place.
In functions, \c block can be useful while performing work that
should not be interrupted by the shell.
In functions, `block` can be useful while performing work that should not be interrupted by the shell.
The block can be removed. Any events which triggered while the
block was in place will then be delivered.
The block can be removed. Any events which triggered while the block was in place will then be delivered.
Event blocks should not be confused with code blocks, which are created
with <code>begin</code>, <code>if</code>, <code>while</code> or
<code>for</code>
Event blocks should not be confused with code blocks, which are created with `begin`, `if`, `while` or `for`
The following parameters are available:
- <tt>-l</tt> or <tt>--local</tt> Release the block automatically at the end of the current innermost code block scope
- <tt>-g</tt> or <tt>--global</tt> Never automatically release the lock
- <tt>-e</tt> or <tt>--erase</tt> Release global block
- `-l` or `--local` Release the block automatically at the end of the current innermost code block scope
- `-g` or `--global` Never automatically release the lock
- `-e` or `--erase` Release global block
\subsection block-example Example
<pre>
\fish
# Create a function that listens for events
function --on-event foo foo; echo 'foo fired'; end
# Block the delivery of events
block -g
emit foo
# No output will be produced
block -e
# 'foo fired' will now be printed
</pre>
\endfish

View file

@ -1,22 +1,25 @@
\section break break - stop the current inner loop
\subsection break-synopsis Synopsis
<tt>LOOP_CONSTRUCT; [COMMANDS...] break; [COMMANDS...] end</tt>
\fish{synopsis}
LOOP_CONSTRUCT; [COMMANDS...] break; [COMMANDS...] end
\endfish
\subsection break-description Description
\c break halts a currently running loop, such as a <a href="#for">for</a> loop or a <a href="#while">while</a> loop. It is usually added inside of a conditional block such as an <a href="#if">if</a> statement or a <a href="#switch">switch</a> statement.
`break` halts a currently running loop, such as a <a href="#for">for</a> loop or a <a href="#while">while</a> loop. It is usually added inside of a conditional block such as an <a href="#if">if</a> statement or a <a href="#switch">switch</a> statement.
There are no parameters for `break`.
There are no parameters for <code>break</code>.
\subsection break-example Example
The following code searches all .c files for "smurf", and halts at the first occurrence.
<pre>
\fish
for i in *.c
if grep smurf $i
echo Smurfs are present in $i
break
end
end
</pre>
\endfish

View file

@ -1,14 +1,14 @@
\section breakpoint breakpoint - Launch debug mode
\subsection breakpoint-synopsis Synopsis
<tt>breakpoint</tt>
\fish{synopsis}
breakpoint
\endfish
\subsection breakpoint-description Description
\c breakpoint is used to halt a running script and launch
an interactive debugging prompt.
`breakpoint` is used to halt a running script and launch an interactive debugging prompt.
For more details, see <a href="index.html#debugging">Debugging fish
scripts</a> in the \c fish manual.
For more details, see <a href="index.html#debugging">Debugging fish scripts</a> in the `fish` manual.
There are no parameters for <code>breakpoint</code>.
There are no parameters for `breakpoint`.

View file

@ -1,16 +1,22 @@
\section builtin builtin - run a builtin command
\subsection builtin-synopsis Synopsis
<tt>builtin BUILTINNAME [OPTIONS...]</tt>
\fish{synopsis}
builtin BUILTINNAME [OPTIONS...]
\endfish
\subsection builtin-description Description
\c builtin forces the shell to use a builtin command, rather than a function or program.
`builtin` forces the shell to use a builtin command, rather than a function or program.
The following parameters are available:
- <tt>-n</tt> or <tt>--names</tt> List the names of all defined builtins
- `-n` or `--names` List the names of all defined builtins
\subsection builtin-example Example
<tt>builtin jobs</tt> executes the jobs builtin, even if a function named jobs exists.
\fish
builtin jobs
# executes the jobs builtin, even if a function named jobs exists
\endfish

View file

@ -1,35 +1,27 @@
\section case case - conditionally execute a block of commands
\subsection case-synopsis Synopsis
<tt>switch VALUE; [case [WILDCARD...]; [COMMANDS...]; ...] end</tt>
\fish{synopsis}
switch VALUE; [case [WILDCARD...]; [COMMANDS...]; ...] end
\endfish
\subsection case-description Description
\c switch performs one of several blocks of commands, depending on whether
a specified value equals one of several wildcarded values. \c case is used
together with the \c switch statement in order to determine which block should
be executed.
`switch` performs one of several blocks of commands, depending on whether a specified value equals one of several wildcarded values. `case` is used together with the `switch` statement in order to determine which block should be executed.
Each \c case command is given one or more parameters. The first \c case
command with a parameter that matches the string specified in the
switch command will be evaluated. \c case parameters may contain
wildcards. These need to be escaped or quoted in order to avoid
regular wildcard expansion using filenames.
Each `case` command is given one or more parameters. The first `case` command with a parameter that matches the string specified in the switch command will be evaluated. `case` parameters may contain wildcards. These need to be escaped or quoted in order to avoid regular wildcard expansion using filenames.
Note that fish does not fall through on case statements. Only the
first matching case is executed.
Note that fish does not fall through on case statements. Only the first matching case is executed.
Note that command substitutions in a case statement will be evaluated even if its body is not taken. All substitutions, including command substitutions, must be performed before the value can be compared against the parameter.
Note that command substitutions in a case statement will be
evaluated even if its body is not taken. All substitutions, including
command substitutions, must be performed before the value can be compared
against the parameter.
\subsection case-example Example
If the variable \$animal contains the name of an animal, the following
code would attempt to classify it:
<pre>
\fish
switch $animal
case cat
echo evil
@ -43,8 +35,8 @@ switch $animal
case '*'
echo I have no idea what a $animal is
end
</pre>
\endfish
If the above code was run with \c \$animal set to \c whale, the output
would be \c mammal.
If the above code was run with `$animal` set to `whale`, the output
would be `mammal`.

View file

@ -1,25 +1,26 @@
\section cd cd - change directory
\subsection cd-synopsis Synopsis
<tt>cd [DIRECTORY]</tt>
\fish{synopsis}
cd [DIRECTORY]
\endfish
\subsection cd-description Description
\c cd changes the current working directory.
`cd` changes the current working directory.
If \c DIRECTORY is supplied, it will become the new directory. If no parameter
is given, the contents of the \c HOME environment variable will be used.
If `DIRECTORY` is supplied, it will become the new directory. If no parameter is given, the contents of the `HOME` environment variable will be used.
If \c DIRECTORY is a relative path, the paths found in the
\c CDPATH environment variable array will be tried as prefixes for the specified
path.
If `DIRECTORY` is a relative path, the paths found in the `CDPATH` environment variable array will be tried as prefixes for the specified path.
Note that the shell will attempt to change directory without requiring `cd` if the name of a directory is provided (starting with `.`, `/` or `~`, or ending with `/`).
Note that the shell will attempt to change directory without requiring \c cd
if the name of a directory is provided (starting with '.', '/' or '~', or ending
with '/').
\subsection cd-example Examples
\c cd changes the working directory to your home directory.
\fish
cd
# changes the working directory to your home directory.
<code>cd /usr/src/fish-shell</code> changes the working directory to
<code>/usr/src/fish-shell</code>.
cd /usr/src/fish-shell
# changes the working directory to /usr/src/fish-shell
\endfish

View file

@ -1,22 +1,24 @@
\section command command - run a program
\subsection command-synopsis Synopsis
<tt>command [OPTIONS] COMMANDNAME [ARGS...]</tt>
\fish{synopsis}
command [OPTIONS] COMMANDNAME [ARGS...]
\endfish
\subsection command-description Description
\c command forces the shell to execute the program \c COMMANDNAME and ignore any functions or builtins with the same name.
`command` forces the shell to execute the program `COMMANDNAME` and ignore any functions or builtins with the same name.
The following options are available:
- \c -h or \c --help prints help and then exits.
- \c -s or \c --search returns the name of the disk file that would be executed, or nothing if no file with the specified name could be found in the <tt>$PATH</tt>.
With the \c -s option, \c 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.
- `-s` or `--search` returns the name of the disk file that would be executed, or nothing if no file with the specified name could be found in the `$PATH`.
For basic compatibility with POSIX <tt>command</tt>, the \c -v flag is recognized as an alias for <tt>-s</tt>.
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.
For basic compatibility with POSIX `command`, the `-v` flag is recognized as an alias for `-s`.
\subsection command-example Examples
<tt>command ls</tt> causes fish to execute the \c ls program, even if an 'ls' function exists.
`command ls` causes fish to execute the `ls` program, even if an `ls` function exists.
<tt>command -s ls</tt> returns the path to the \c ls program.
`command -s ls` returns the path to the `ls` program.

View file

@ -1,73 +1,59 @@
\section commandline commandline - set or get the current command line buffer
\subsection commandline-synopsis Synopsis
<tt>commandline [OPTIONS] [CMD]</tt>
\fish{synopsis}
commandline [OPTIONS] [CMD]
\endfish
\subsection commandline-description Description
\c commandline can be used to set or get the current contents of the command
line buffer.
`commandline` can be used to set or get the current contents of the command line buffer.
With no parameters, \c commandline returns the current value of the command
line.
With no parameters, `commandline` returns the current value of the command line.
With \c CMD specified, the command line buffer is erased and replaced with
the contents of \c CMD.
With `CMD` specified, the command line buffer is erased and replaced with the contents of `CMD`.
The following options are available:
- \c -C or \c --cursor set or get the current cursor position, not
the contents of the buffer. If no argument is given, the current
cursor position is printed, otherwise the argument is interpreted
as the new cursor position.
- \c -f or \c --function inject readline functions into the
reader. This option cannot be combined with any other option. It
will cause any additional arguments to be interpreted as readline
functions, and these functions will be injected into the reader, so
that they will be returned to the reader before any additional
actual key presses are read.
- `-C` or `--cursor` set or get the current cursor position, not the contents of the buffer. If no argument is given, the current cursor position is printed, otherwise the argument is interpreted as the new cursor position.
The following options change the way \c commandline updates the
command line buffer:
- `-f` or `--function` inject readline functions into the reader. This option cannot be combined with any other option. It will cause any additional arguments to be interpreted as readline functions, and these functions will be injected into the reader, so that they will be returned to the reader before any additional actual key presses are read.
- \c -a or \c --append do not remove the current commandline, append
the specified string at the end of it
- \c -i or \c --insert do not remove the current commandline, insert
the specified string at the current cursor position
- \c -r or \c --replace remove the current commandline and replace it
with the specified string (default)
The following options change the way `commandline` updates the command line buffer:
The following options change what part of the commandline is printed
or updated:
- `-a` or `--append` do not remove the current commandline, append the specified string at the end of it
- \c -b or \c --current-buffer select the entire buffer (default)
- \c -j or \c --current-job select the current job
- \c -p or \c --current-process select the current process
- \c -t or \c --current-token select the current token.
- `-i` or `--insert` do not remove the current commandline, insert the specified string at the current cursor position
The following options change the way \c commandline prints the current
commandline buffer:
- `-r` or `--replace` remove the current commandline and replace it with the specified string (default)
- \c -c or \c --cut-at-cursor only print selection up until the
current cursor position
- \c -o or \c --tokenize tokenize the selection and print one string-type token per line
The following options change what part of the commandline is printed or updated:
- `-b` or `--current-buffer` select the entire buffer (default)
If \c commandline is called during a call to complete a given string
using <code>complete -C STRING</code>, \c commandline will consider the
specified string to be the current contents of the command line.
- `-j` or `--current-job` select the current job
- `-p` or `--current-process` select the current process
- `-t` or `--current-token` select the current token.
The following options change the way `commandline` prints the current commandline buffer:
- `-c` or `--cut-at-cursor` only print selection up until the current cursor position
- `-o` or `--tokenize` tokenize the selection and print one string-type token per line
If `commandline` is called during a call to complete a given string using `complete -C STRING`, `commandline` will consider the specified string to be the current contents of the command line.
The following options output metadata about the commandline state:
- \c -L or \c --line print the line that the cursor is on, with the topmost
line starting at 1
- \c -S or \c --search-mode evaluates to true if the commandline is performing
a history search
- \c -P or \c --paging-mode evaluates to true if the commandline is showing
pager contents, such as tab completions
- `-L` or `--line` print the line that the cursor is on, with the topmost line starting at 1
- `-S` or `--search-mode` evaluates to true if the commandline is performing a history search
- `-P` or `--paging-mode` evaluates to true if the commandline is showing pager contents, such as tab completions
\subsection commandline-example Example
<tt>commandline -j $history[3]</tt> replaces the job under the cursor with the
third item from the command line history.
`commandline -j $history[3]` replaces the job under the cursor with the third item from the command line history.

View file

@ -1,15 +1,38 @@
/** \page commands Commands bundled with fish
\htmlonly <div class="fish_left_bar fish_left_little"> \endhtmlonly
@command_list_toc@
\htmlonly </div> \endhtmlonly
\htmlonly
<div class="fish_right_bar fish_right_big">
<h1 class="interior_title_borderless">Commands</h1>
Fish ships with a large number of builtin commands, shellscript functions and external commands. These are all described below.
/**
\page commands Commands
\htmlonly[block]
<div class="fish_left_bar">
<div class="logo"></div>
<div class="menu commands_menu">
\endhtmlonly
@command_list@
\htmlonly </div> \endhtmlonly
@command_list_toc@
\htmlonly[block]
</div>
</div>
<div class="commands fish_right_bar">
<h1 class="interior_title">Command reference</h1>
\endhtmlonly
`fish` ships with a large number of builtin commands, shellscript functions and external commands. These are all described below.
Almost all fish commands respond to the `-h` or `--help` options to display their relevant help, also accessible using the `help` and `man` commands, like so:
\fish
echo -h
echo --help
# Prints help to the terminal window
man echo
# Displays the man page in the system pager
# (normally 'less', 'more' or 'most').
help echo
# Open a web browser to show the relevant documentation
\endfish
@command_list@
\htmlonly[block]
</div>
\endhtmlonly
*/

View file

@ -1,7 +1,14 @@
\section complete complete - edit command specific tab-completions
\subsection complete-synopsis Synopsis
<tt>complete (-c|--command|-p|--path) COMMAND [(-s|--short-option) SHORT_OPTION] [(-l|--long-option|-o|--old-option) LONG_OPTION [(-a||--arguments) OPTION_ARGUMENTS] [(-w|--wraps) WRAPPED_COMMAND] [(-d|--description) DESCRIPTION] </tt>
\fish{synopsis}
complete ( -c | --command | -p | --path ) COMMAND
[( -s | --short-option ) SHORT_OPTION]
[( -l | --long-option | -o | --old-option ) LONG_OPTION]
[( -a | --arguments ) OPTION_ARGUMENTS]
[( -w | --wraps ) WRAPPED_COMMAND]
[( -d | --description ) DESCRIPTION]
\endfish
\subsection complete-description Description
@ -9,85 +16,88 @@ For an introduction to specifying completions, see <a
href='index.html#completion-own'>Writing your own completions</a> in
the fish manual.
- <tt>COMMAND</tt> is the name of the command for which to add a completion
- <tt>SHORT_OPTION</tt> is a one character option for the command
- <tt>LONG_OPTION</tt> is a multi character option for the command
- <tt>OPTION_ARGUMENTS</tt> is parameter containing a space-separated list of possible option-arguments, which may contain subshells
- <tt>DESCRIPTION</tt> is a description of what the option and/or option arguments do
- <tt>-C STRING</tt> or <tt>--do-complete=STRING</tt> makes complete try to find all possible completions for the specified string
- <tt>-e</tt> or <tt>--erase</tt> implies that the specified completion should be deleted
- <tt>-f</tt> or <tt>--no-files</tt> specifies that the option specified by this completion may not be followed by a filename
- <tt>-n</tt> or <tt>--condition</tt> specifies a shell command that must return 0 if the completion is to be used. This makes it possible to specify completions that should only be used in some cases.
- <tt>-o</tt> or <tt>--old-option</tt> implies that the command uses old long style options with only one dash
- <tt>-p</tt> or <tt>--path</tt> implies that the string COMMAND is the full path of the command
- <tt>-r</tt> or <tt>--require-parameter</tt> specifies that the option specified by this completion always must have an option argument, i.e. may not be followed by another option
- <tt>-u</tt> or <tt>--unauthoritative</tt> implies that there may be more options than the ones specified, and that fish should not assume that options not listed are spelling errors
- <tt>-A</tt> or <tt>--authoritative</tt> implies that there may be no more options than the ones specified, and that fish should assume that options not listed are spelling errors
- <tt>-x</tt> or <tt>--exclusive</tt> implies both <tt>-r</tt> and <tt>-f</tt>
- <tt>-w WRAPPED_COMMAND</tt> or <tt>--wraps=WRAPPED_COMMAND</tt> causes the specified command to inherit completions from the wrapped comamnd.
- `COMMAND` is the name of the command for which to add a completion.
Command specific tab-completions in \c fish are based on the notion
of options and arguments. An option is a parameter which begins with a
hyphen, such as '-h', '-help' or '--help'. Arguments are parameters
that do not begin with a hyphen. Fish recognizes three styles of
options, the same styles as the GNU version of the getopt
library. These styles are:
- `SHORT_OPTION` is a one character option for the command.
- Short options, like '-a'. Short options are a single character long, are preceded by a single hyphen and may be grouped together (like '-la', which is equivalent to '-l -a'). Option arguments may be specified in the following parameter ('-w 32') or by appending the option with the value ('-w32').
- Old style long options, like '-Wall'. 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').
- GNU style long options, like '--colors'. GNU style long options can be more than one character long, are preceded by two hyphens, and may not be grouped together. Option arguments may be specified in the following parameter ('--quoting-style shell') or by appending the option with a '=' and the value ('--quoting-style=shell'). GNU style long options may be abbreviated so long as the abbreviation is unique ('--h' is equivalent to '--help' if help is the only long option beginning with an 'h').
- `LONG_OPTION` is a multi character option for the command.
The options for specifying command name, command path, or command
switches may all be used multiple times to specify multiple commands
which have the same completion or multiple switches accepted by a
command.
- `OPTION_ARGUMENTS` is parameter containing a space-separated list of possible option-arguments, which may contain subshells.
The \c -w or \c --wraps options causes the specified command to inherit
completions from another command. The inheriting command is said to
"wrap" the inherited command. The wrapping command may have its own
completions in addition to inherited ones. A command may wrap multiple
commands, and wrapping is transitive: if A wraps B, and B wraps C,
then A automatically inherits all of C's completions. Wrapping can
be removed using the \c -e or \c --erase options.
- `DESCRIPTION` is a description of what the option and/or option arguments do.
- `-C STRING` or `--do-complete=STRING` makes complete try to find all possible completions for the specified string.
- `-w WRAPPED_COMMAND` or `--wraps=WRAPPED_COMMAND` causes the specified command to inherit completions from the wrapped command.
- `-e` or `--erase` implies that the specified completion should be deleted.
- `-f` or `--no-files` specifies that the option specified by this completion may not be followed by a filename.
- `-n` or `--condition` specifies a shell command that must return 0 if the completion is to be used. This makes it possible to specify completions that should only be used in some cases.
- `-o` or `--old-option` implies that the command uses old long style options with only one dash.
- `-p` or `--path` implies that the string `COMMAND` is the full path of the command.
- `-r` or `--require-parameter` specifies that the option specified by this completion always must have an option argument, i.e. may not be followed by another option.
- `-u` or `--unauthoritative` implies that there may be more options than the ones specified, and that fish should not assume that options not listed are spelling errors.
- `-A` or `--authoritative` implies that there may be no more options than the ones specified, and that fish should assume that options not listed are spelling errors.
- `-x` or `--exclusive` implies both `-r` and `-f`.
Command specific tab-completions in `fish` are based on the notion of options and arguments. An option is a parameter which begins with a hyphen, such as '`-h`', '`-help`' or '`--help`'. Arguments are parameters that do not begin with a hyphen. Fish recognizes three styles of options, the same styles as the GNU version of the getopt library. These styles are:
- Short options, like '`-a`'. Short options are a single character long, are preceded by a single hyphen and may be grouped together (like '`-la`', which is equivalent to '`-l -a`'). Option arguments may be specified in the following parameter ('`-w 32`') or by appending the option with the value ('`-w32`').
- Old style long options, like '`-Wall`'. 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`').
- GNU style long options, like '`--colors`'. GNU style long options can be more than one character long, are preceded by two hyphens, and may not be grouped together. Option arguments may be specified in the following parameter ('`--quoting-style`') or by appending the option with a '`=`' and the value ('`--quoting-style=shell`'). GNU style long options may be abbreviated so long as the abbreviation is unique ('`--h`') is equivalent to '`--help`' if help is the only long option beginning with an 'h').
The options for specifying command name, command path, or command switches may all be used multiple times to specify multiple commands which have the same completion or multiple switches accepted by a command.
The `-w` or `--wraps` options causes the specified command to inherit completions from another command. The inheriting command is said to "wrap" the inherited command. The wrapping command may have its own completions in addition to inherited ones. A command may wrap multiple commands, and wrapping is transitive: if A wraps B, and B wraps C, then A automatically inherits all of C's completions. Wrapping can be removed using the `-e` or `--erase` options.
When erasing completions, it is possible to either erase all completions for a specific command by specifying `complete -e -c COMMAND`, or by specifying a specific completion option to delete by specifying either a long, short or old style option.
When erasing completions, it is possible to either erase all
completions for a specific command by specifying <tt>complete -e -c
COMMAND</tt>, or by specifying a specific completion option to delete
by specifying either a long, short or old style option.
\subsection complete-example Example
The short style option <tt>-o</tt> for the \c gcc command requires
that a file follows it. This can be done using writing <tt>complete
-c gcc -s o -r</tt>.
The short style option `-o` for the `gcc` command requires that a file follows it. This can be done using writing:
The short style option <tt>-d</tt> for the \c grep command requires
that one of the strings 'read', 'skip' or 'recurse' is used. This can
be specified writing <tt>complete -c grep -s d -x -a "read skip
recurse"</tt>.
\fish
complete -c gcc -s o -r
\endfish
The \c su command takes any username as an argument. Usernames are
given as the first colon-separated field in the file /etc/passwd. This
can be specified as: <tt>complete -x -c su -d "Username" -a "(cat
/etc/passwd|cut -d : -f 1)" </tt>.
The short style option `-d` for the `grep` command requires that one of the strings '`read`', '`skip`' or '`recurse`' is used. This can be specified writing:
The \c rpm command has several different modes. If the \c -e or \c
--erase flag has been specified, \c rpm should delete one or more
packages, in which case several switches related to deleting packages
are valid, like the \c nodeps switch.
\fish
complete -c grep -s d -x -a "read skip recurse"
\endfish
The `su` command takes any username as an argument. Usernames are given as the first colon-separated field in the file /etc/passwd. This can be specified as:
\fish
complete -x -c su -d "Username" -a "(cat /etc/passwd | cut -d : -f 1)"
\endfish
The `rpm` command has several different modes. If the `-e` or `--erase` flag has been specified, `rpm` should delete one or more packages, in which case several switches related to deleting packages are valid, like the `nodeps` switch.
This can be written as:
<tt>complete -c rpm -n "__fish_contains_opt -s e erase" -l nodeps -d
"Don't check dependencies"</tt>
\fish
complete -c rpm -n "__fish_contains_opt -s e erase" -l nodeps -d "Don't check dependencies"
\endfish
where \c __fish_contains_opt is a function that checks the commandline
buffer for the presence of a specified set of options.
where `__fish_contains_opt` is a function that checks the commandline buffer for the presence of a specified set of options.
To implement an alias, use the \c -w or \c --wraps option:
To implement an alias, use the `-w` or `--wraps` option:
<tt>complete -c hub -w git</tt>
\fish
complete -c hub -w git
\endfish
Now hub inherits all of the completions from git. Note this can
also be specified in a function declaration.
Now hub inherits all of the completions from git. Note this can also be specified in a function declaration.

View file

@ -1,26 +1,27 @@
\section contains contains - test if a word is present in a list
\subsection contains-synopsis Synopsis
<code>contains [OPTIONS] KEY [VALUES...]</code>
\fish{synopsis}
contains [OPTIONS] KEY [VALUES...]
\endfish
\subsection contains-description Description
\c contains tests whether the set \c VALUES contains the string
<code>KEY</code>. If so, \c contains exits with status 0; if not, it exits
with status 1.
`contains` tests whether the set `VALUES` contains the string `KEY`. If so, `contains` exits with status 0; if not, it exits with status 1.
The following options are available:
- \c -i or \c --index print the word index
- \c -h or \c --help display this message
- `-i` or `--index` print the word index
\subsection contains-example Example
<pre>
for i in ~/bin /usr/local/bin
if not contains \$i \$PATH
set PATH \$PATH \$i
end
end
</pre>
The above code tests if \c ~/bin and \c /usr/local/bin are in the path and adds them if not.
\fish
for i in ~/bin /usr/local/bin
if not contains $i $PATH
set PATH $PATH $i
end
end
\endfish
The above code tests if `~/bin` and `/usr/local/bin` are in the path and adds them if not.

View file

@ -1,19 +1,23 @@
\section continue continue - skip the remainder of the current iteration of the current inner loop
\subsection continue-synopsis Synopsis
<tt>LOOP_CONSTRUCT; [COMMANDS...;] continue; [COMMANDS...;] end</tt>
\fish{synopsis}
LOOP_CONSTRUCT; [COMMANDS...;] continue; [COMMANDS...;] end
\endfish
\subsection continue-description Description
\c continue skips the remainder of the current iteration of the current inner loop, such as a <a href="#for">for</a> loop or a <a href="#while">while</a> loop. It is usually added inside of a conditional block such as an <a href="#if">if</a> statement or a <a href="#switch">switch</a> statement.
`continue` skips the remainder of the current iteration of the current inner loop, such as a <a href="#for">for</a> loop or a <a href="#while">while</a> loop. It is usually added inside of a conditional block such as an <a href="#if">if</a> statement or a <a href="#switch">switch</a> statement.
\subsection continue-example Example
The following code removes all tmp files that do not contain the word smurf.
<pre>
\fish
for i in *.tmp
if grep smurf $i
continue
end
rm $i
end
</pre>
\endfish

View file

@ -1,29 +1,25 @@
\section count count - count the number of elements of an array
\subsection count-synopsis Synopsis
<tt>count $VARIABLE</tt>
\fish{synopsis}
count $VARIABLE
\endfish
\subsection count-description Description
<tt>count</tt> prints the number of arguments that were
passed to it. This is usually used to find out how many elements an
environment variable array contains.
`count` prints the number of arguments that were passed to it. This is usually used to find out how many elements an environment variable array contains.
\c count does not accept any options, including '-h'.
`count` does not accept any options, including `-h` or `--help`.
`count` exits with a non-zero exit status if no arguments were passed to it, and with zero if at least one argument was passed.
\c count exits with a non-zero exit status if no arguments were passed
to it, and with zero if at least one argument was passed.
\subsection count-example Example
<pre>
\fish
count $PATH
</pre>
# Returns the number of directories in the users PATH variable.
returns the number of directories in the users PATH variable.
<pre>
count *.txt
</pre>
returns the number of files in the current working directory ending with the suffix '.txt'.
# Returns the number of files in the current working directory ending with the suffix '.txt'.
\endfish

View file

@ -1,138 +1,110 @@
/** \page design Design document
\htmlonly <div class="fish_only_bar"> \endhtmlonly
/**
\page design Design document
\htmlonly[block]
<div class="fish_only_bar">
<div class="design">
<h1 class="interior_title">Design documentation</h1>
\endhtmlonly
\section design-overview Overview
This is a description of the design principles that have been used to
design fish. The fish design has three high level goals. These are:
This is a description of the design principles that have been used to design fish. The fish design has three high level goals. These are:
-# Everything that can be done in other shell languages should be
possible to do in fish, though fish may rely on external commands in
doing so.
-# Fish should be user friendly, but not at the expense of expressiveness.
Most tradeoffs between power and ease of use can be avoided with careful design.
-# Whenever possible without breaking the above goals, fish should
follow the Posix syntax.
-# Everything that can be done in other shell languages should be possible to do in fish, though fish may rely on external commands in doing so.
-# Fish should be user friendly, but not at the expense of expressiveness. Most tradeoffs between power and ease of use can be avoided with careful design.
-# Whenever possible without breaking the above goals, fish should follow the Posix syntax.
To achieve these high-level goals, the fish design relies on a number of more specific design principles. These are presented below, together with a rationale and a few examples for each.
To achieve these high-level goals, the fish design relies on a number
of more specific design principles. These are presented below,
together with a rationale and a few examples for each.
\section ortho The law of orthogonality
The shell language should have a small set of orthogonal features. Any
situation where two features are related but not identical, one of them
should be removed, and the other should be made powerful and general
enough to handle all common use cases of either feature.
The shell language should have a small set of orthogonal features. Any situation where two features are related but not identical, one of them should be removed, and the other should be made powerful and general enough to handle all common use cases of either feature.
Rationale:
Related features make the language larger, which makes it harder to
learn. It also increases the size of the source code, making the
program harder to maintain and update.
Related features make the language larger, which makes it harder to learn. It also increases the size of the source code, making the program harder to maintain and update.
Examples:
- Here documents are too similar to using echo inside of a pipeline.
- Subshells, command substitution and process substitution are strongly related. \c fish only supports command substitution, the others can be achieved either using a block or the psub shellscript function.
- Having both aliases and functions is confusing, especially since both of them have limitations and problems. \c fish functions have none of the drawbacks of either syntax.
- The many Posix quoting styles are silly, especially \$''.
\section sep The law of responsiveness
- Subshells, command substitution and process substitution are strongly related. `fish` only supports command substitution, the others can be achieved either using a block or the psub shellscript function.
- Having both aliases and functions is confusing, especially since both of them have limitations and problems. `fish` functions have none of the drawbacks of either syntax.
- The many Posix quoting styles are silly, especially $''.
\section design-response The law of responsiveness
The shell should attempt to remain responsive to the user at all times, even in the face of contended or unresponsive filesystems. It is only acceptable to block in response to a user initiated action, such as running a command.
Rationale:
Bad performance increases user-facing complexity, because it trains users to recognize and route around slow use cases. It is also incredibly frustrating.
Examples:
- Features like syntax highlighting and autosuggestions must perform all of their disk I/O asynchronously.
- Startup should minimize forks and disk I/O, so that fish can be started even if the system is under load.
\section conf Configurability is the root of all evil
\section design-configurability Configurability is the root of all evil
Every configuration option in a program is a place where the program
is too stupid to figure out for itself what the user really wants, and
should be considered a failure of both the program and the programmer
who implemented it.
Every configuration option in a program is a place where the program is too stupid to figure out for itself what the user really wants, and should be considered a failure of both the program and the programmer who implemented it.
Rationale:
Different configuration options are a nightmare to maintain, since the
number of potential bugs caused by specific configuration combinations
quickly becomes an issue. Configuration options often imply
assumptions about the code which change when reimplementing the code,
causing issues with backwards compatibility. But mostly, configuration
options should be avoided since they simply should not exist, as the
program should be smart enough to do what is best, or at least a good
enough approximation of it.
Different configuration options are a nightmare to maintain, since the number of potential bugs caused by specific configuration combinations quickly becomes an issue. Configuration options often imply assumptions about the code which change when reimplementing the code, causing issues with backwards compatibility. But mostly, configuration options should be avoided since they simply should not exist, as the program should be smart enough to do what is best, or at least a good enough approximation of it.
Examples:
- Fish allows the user to set various syntax highlighting colors. This is needed because fish does not know what colors the terminal uses by default, which might make some things unreadable. The proper solution would be for text color preferences to be defined centrally by the user for all programs, and for the terminal emulator to send these color properties to fish.
- Fish does not allow you to set the history filename, the number of history entries, different language substyles or any number of other common shell configuration options.
A special note on the evils of configurability is the long list of
very useful features found in some shells, that are not turned on by
default. Both zsh and bash support command-specific completions, but
no such completions are shipped with bash by default, and they are
turned off by default in zsh. Other features that zsh supports that are
disabled by default include tab-completion of strings containing
wildcards, a sane completion pager and a history file.
A special note on the evils of configurability is the long list of very useful features found in some shells, that are not turned on by default. Both zsh and bash support command-specific completions, but no such completions are shipped with bash by default, and they are turned off by default in zsh. Other features that zsh supports that are disabled by default include tab-completion of strings containing wildcards, a sane completion pager and a history file.
\section user The law of user focus
When designing a program, one should first think about how to make a
intuitive and powerful program. Implementation issues should only be
considered once a user interface has been designed.
When designing a program, one should first think about how to make a intuitive and powerful program. Implementation issues should only be considered once a user interface has been designed.
Rationale:
This design rule is different than the others, since it describes how
one should go about designing new features, not what the features
should be. The problem with focusing on what can be done, and what is
easy to do, is that too much of the implementation is exposed. This
means that the user must know a great deal about the underlying system
to be able to guess how the shell works, it also means that the
language will often be rather low-level.
This design rule is different than the others, since it describes how one should go about designing new features, not what the features should be. The problem with focusing on what can be done, and what is easy to do, is that too much of the implementation is exposed. This means that the user must know a great deal about the underlying system to be able to guess how the shell works, it also means that the language will often be rather low-level.
Examples:
- There should only be one type of input to the shell, lists of commands. Loops, conditionals and variable assignments are all performed through regular commands.
- The differences between built-in commands and shellscript functions should be made as small as possible. Built-ins and shellscript functions should have exactly the same types of argument expansion as other commands, should be possible to use in any position in a pipeline, and should support any I/O redirection.
- Instead of forking when performing command substitution to provide a fake variable scope, all fish commands are performed from the same process, and fish instead supports true scoping.
- All blocks end with the \c end built-in.
- All blocks end with the `end` built-in.
\section disc The law of discoverability
A program should be designed to make its features as
easy as possible to discover for the user.
A program should be designed to make its features as easy as possible to discover for the user.
Rationale:
A program whose features are discoverable turns a new user into an expert in a shorter span of time, since the user will become an expert on the program simply by using it.
A program whose features are discoverable turns a new user into an
expert in a shorter span of time, since the user will become an expert
on the program simply by using it.
The main benefit of a graphical program over a command-line-based
program is discoverability. In a graphical program, one can discover
all the common features by simply looking at the user interface and
guessing what the different buttons, menus and other widgets do. The
traditional way to discover features in command-line programs is
through manual pages. This requires both that the user starts to use a
different program, and then she/he remembers the new information
until the next time she/he uses the same program.
The main benefit of a graphical program over a command-line-based program is discoverability. In a graphical program, one can discover all the common features by simply looking at the user interface and guessing what the different buttons, menus and other widgets do. The traditional way to discover features in command-line programs is through manual pages. This requires both that the user starts to use a different program, and then she/he remembers the new information until the next time she/he uses the same program.
Examples:
- Everything should be tab-completable, and every tab completion should have a description.
- Every syntax error and error in a built-in command should contain an error message describing what went wrong and a relevant help page. Whenever possible, errors should be flagged red by the syntax highlighter.
- The help manual should be easy to read, easily available from the shell, complete and contain many examples
- The language should be uniform, so that once the user understands the command/argument syntax, she/he will know the whole language, and be able to use tab-completion to discover new features.
*/
\htmlonly </div> \endhtmlonly
\htmlonly[block]
</div>
</div>
\endhtmlonly
*/

View file

@ -1,12 +1,12 @@
\section dirh dirh - print directory history
\subsection dirh-synopsis Synopsis
<tt>dirh</tt>
\fish{synopsis}
dirh
\endfish
\subsection dirh-description Description
<tt>dirh</tt> prints the current directory history. The current position in the
history is highlighted using the color defined in the
<tt>fish_color_history_current</tt> environment variable.
`dirh` prints the current directory history. The current position in the history is highlighted using the color defined in the `fish_color_history_current` environment variable.
\c dirh does not accept any parameters.
`dirh` does not accept any parameters.

View file

@ -1,10 +1,12 @@
\section dirs dirs - print directory stack
\subsection dirs-synopsis Synopsis
<tt>dirs</tt>
\fish{synopsis}
dirs
\endfish
\subsection dirs-description Description
<tt>dirs</tt> prints the current directory stack, as created by the
<code><a href="#pushd">pushd</a></code> command.
\c dirs does not accept any parameters.
`dirs` prints the current directory stack, as created by the <a href="#pushd">`pushd`</a> command.
`dirs` does not accept any parameters.

View file

@ -1,39 +1,58 @@
\section echo echo - display a line of text
\subsection echo-synopsis Synopsis
<tt>echo [STRING]</tt>
\fish{synopsis}
echo [OPTIONS] [STRING]
\endfish
\subsection echo-description Description
\c echo displays a string of text.
`echo` displays a string of text.
The following options are available:
- \c -n, \c Do not output a newline
- \c -s, \c Do not separate arguments with spaces
- \c -E, \c Disable interpretation of backslash escapes (default)
- \c -e, \c Enable interpretation of backslash escapes
- \c -h, \c --help Display this help
- `-n`, Do not output a newline
- `-s`, Do not separate arguments with spaces
- `-E`, Disable interpretation of backslash escapes (default)
- `-e`, Enable interpretation of backslash escapes
\subsection echo-escapes Escape Sequences
If \c -e is used, the following sequences are recognized:
If `-e` is used, the following sequences are recognized:
- \c \\\\ \c backslash
- \\a alert (BEL)
- \\b backspace
- \\c produce no further output
- \\e escape
- \\f form feed
- \\n new line
- \\r carriage return
- \\t horizontal tab
- \\v vertical tab
- \\0NNN byte with octal value NNN (1 to 3 digits)
- \\xHH byte with hexadecimal value HH (1 to 2 digits)
- `\` backslash
- `\a` alert (BEL)
- `\b` backspace
- `\c` produce no further output
- `\e` escape
- `\f` form feed
- `\n` new line
- `\r` carriage return
- `\t` horizontal tab
- `\v` vertical tab
- `\0NNN` byte with octal value NNN (1 to 3 digits)
- `\xHH` byte with hexadecimal value HH (1 to 2 digits)
\subsection echo-example Example
<tt>echo 'Hello World'</tt> Print hello world to stdout
\fish
echo 'Hello World'
# Print hello world to stdout
<tt>echo -e 'Top\\nBottom'</tt> Print Top and Bottom on separate lines, using an escape sequence
echo -e 'Top\nBottom'
# Print Top and Bottom on separate lines, using an escape sequence
\endfish

View file

@ -1,21 +1,23 @@
\section else else - execute command if a condition is not met
\subsection else-synopsis Synopsis
<tt>if CONDITION; COMMANDS_TRUE...; [else; COMMANDS_FALSE...;] end</tt>
\fish{synopsis}
if CONDITION; COMMANDS_TRUE...; [else; COMMANDS_FALSE...;] end
\endfish
\subsection else-description Description
<tt>if</tt> will execute the command \c CONDITION. If the condition's exit
status is 0, the commands \c COMMANDS_TRUE will execute. If it is not 0 and
<tt>else</tt> is given, \c 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 it is not 0 and `else` is given, `COMMANDS_FALSE` will be executed.
\subsection else-example Example
The following code tests whether a file \c foo.txt exists as a regular file.
The following code tests whether a file `foo.txt` exists as a regular file.
<pre>
\fish
if test -f foo.txt
echo foo.txt exists
else
echo foo.txt does not exist
end
</pre>
\endfish

View file

@ -1,20 +1,23 @@
\section emit emit - Emit a generic event
\subsection block-synopsis Synopsis
<tt>emit EVENT_NAME [ARGUMENTS...]</tt>
\subsection emit-synopsis Synopsis
\fish{synopsis}
emit EVENT_NAME [ARGUMENTS...]
\endfish
\subsection emit-description Description
\c emit emits, or fires, an event. Events are delivered to, or caught by, special functions called event handlers. The arguments are passed to the event handlers as function arguments.
`emit` emits, or fires, an event. Events are delivered to, or caught by, special functions called event handlers. The arguments are passed to the event handlers as function arguments.
\subsection emit-example Example
The following code first defines an event handler for the generic
event named 'test_event', and then emits an event of that type.
The following code first defines an event handler for the generic event named 'test_event', and then emits an event of that type.
<pre>function event_test --on-event test_event
\fish
function event_test --on-event test_event
echo event test: $argv
end
emit test_event something
</pre>
\endfish

View file

@ -1,19 +1,19 @@
\section end end - end a block of commands.
\subsection end-synopsis Synopsis
<pre>
\fish{synopsis}
begin; [COMMANDS...] end
if CONDITION; COMMANDS_TRUE...; [else; COMMANDS_FALSE...;] end
while CONDITION; COMMANDS...; end
for VARNAME in [VALUES...]; COMMANDS...; end
switch VALUE; [case [WILDCARD...]; [COMMANDS...]; ...] end
</pre>
\endfish
\subsection end-description Description
<tt>end</tt> ends a block of commands.
`end` ends a block of commands.
For more information, read the
documentation for the block constructs, such as \c if, \c for and \c
while.
documentation for the block constructs, such as `if`, `for` and `while`.
The \c end command does not change the current exit status.
The `end` command does not change the current exit status.

View file

@ -1,19 +1,20 @@
\section eval eval - evaluate the specified commands
\subsection eval-synopsis Synopsis
<tt>eval [COMMANDS...]</tt>
\fish{synopsis}
eval [COMMANDS...]
\endfish
\subsection eval-description Description
<tt>eval</tt> evaluates the specified parameters as a command. If more than one parameter is specified, all parameters will be joined using a space character as a separator.
`eval` evaluates the specified parameters as a command. If more than one parameter is specified, all parameters will be joined using a space character as a separator.
\subsection eval-example Example
The following code will call the ls command. Note that \c fish does not
support the use of shell variables as direct commands; \c eval can
be used to work around this.
The following code will call the ls command. Note that `fish` does not support the use of shell variables as direct commands; `eval` can be used to work around this.
<pre>
\fish
set cmd ls
eval $cmd
</pre>
\endfish

View file

@ -1,15 +1,15 @@
\section exec exec - execute command in current process
\subsection exec-synopsis Synopsis
<tt>exec COMMAND [OPTIONS...]</tt>
\fish{synopsis}
exec COMMAND [OPTIONS...]
\endfish
\subsection exec-description Description
\c exec replaces the currently running shell with a new command.
On successful completion, \c exec never returns. \c exec cannot be used
inside a pipeline.
`exec` replaces the currently running shell with a new command. On successful completion, `exec` never returns. `exec` cannot be used inside a pipeline.
\subsection exec-example Example
<tt>exec emacs</tt> starts up the emacs text editor, and exits \c fish.
When emacs exits, the session will terminate.
`exec emacs` starts up the emacs text editor, and exits `fish`. When emacs exits, the session will terminate.

View file

@ -1,14 +1,12 @@
\section exit exit - exit the shell
\subsection exit-synopsis Synopsis
<tt>exit [STATUS]</tt>
\fish{synopsis}
exit [STATUS]
\endfish
\subsection exit-description Description
\c exit causes fish to exit. If <tt>STATUS</tt> is
supplied, it will be converted to an integer and used as the exit
code. Otherwise, the exit code will be that of the last command executed.
`exit` causes fish to exit. If `STATUS` is supplied, it will be converted to an integer and used as the exit code. Otherwise, the exit code will be that of the last command executed.
If exit is called while sourcing a file (using the <a
href="#source">.</a> 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 <a href="#source">.</a> builtin) the rest of the file will be skipped, but the shell itself will not exit.

View file

@ -1,9 +1,14 @@
/** \page faq Frequently asked questions
/**
\page faq Frequently asked questions
\htmlonly[block]
<div class="fish_left_bar">
<div class="logo"></div>
<div class="menu faq_menu">
\htmlonly <div class="fish_left_bar fish_left_big"> \endhtmlonly
\endhtmlonly
- <a href='#faq-envvar'>How do I set or clear an environment variable?</a>
- <a href='#faq-login-cmd'>How do I run a command every login? What's fish's equivalent to <tt>.bashrc</tt>?</a>
- <a href='#faq-login-cmd'>How do I run a command every login? What's fish's equivalent to `.bashrc`?</a>
- <a href='#faq-prompt'>How do I set my prompt?</a>
- <a href='#faq-cmd-history'>How do I run a command from history?</a>
- <a href='#faq-subcommand'>How do I run a subcommand? The backtick doesn't work!</a>
@ -20,257 +25,198 @@
- <a href='#faq-history'>Why doesn't history substitution ("!$" etc.) work?</a>
- <a href='#faq-uninstalling'>How do I uninstall fish?</a>
\htmlonly
\htmlonly[block]
</div>
<div class="fish_right_bar fish_right_little">
</div>
<div class="faq fish_right_bar">
<h1 class="interior_title">Frequently Asked Questions</h1>
\endhtmlonly
\section faq-envvar How do I set or clear an environment variable?
Use the <a href="commands.html#set"><code>set</code></a> command:
Use the <a href="commands.html#set">`set`</a> command:
<pre>set -x key value
set -e key</pre>
\fish{cli-dark}
set -x key value
set -e key
\endfish
<hr>
\section faq-login-cmd How do I run a command every login? What's fish's equivalent to .bashrc?
Edit the file <tt>~/.config/fish/config.fish</tt>, creating it if it does not
exist. (Note the leading period.)
Edit the file `~/.config/fish/config.fish`, creating it if it does not exist (Note the leading period).
<hr>
\section faq-prompt How do I set my prompt?
The prompt is the output of the \c fish_prompt function. Put it in
<tt>~/.config/fish/functions/fish_prompt.fish</tt>. For example, a simple
prompt is:
<pre>function fish_prompt
set_color $fish_color_cwd
echo -n (prompt_pwd)
set_color normal
echo -n ' > '
end</pre>
The prompt is the output of the `fish_prompt` function. Put it in `~/.config/fish/functions/fish_prompt.fish`. For example, a simple prompt is:
You can also use the Web configuration tool,
<a href="commands.html#fish_config"><code>fish_config</code></a>, to preview
and choose from a gallery of sample prompts.
\fish{cli-dark}
function fish_prompt
set_color $fish_color_cwd
echo -n (prompt_pwd)
set_color normal
echo -n ' > '
end
\endfish
You can also use the Web configuration tool, <a href="commands.html#fish_config">`fish_config`</a>, to preview and choose from a gallery of sample prompts.
<hr>
\section faq-cmd-history How do I run a command from history?
Type some part of the command, and then hit the up or down arrow keys to
navigate through history matches.
Type some part of the command, and then hit the @cursor_key{&uarr;,up} or @cursor_key{&darr;,down} arrow keys to navigate through history matches.
<hr>
\section faq-subcommand How do I run a subcommand? The backtick doesn't work!
\c fish uses parentheses for subcommands. For example:
`fish` uses parentheses for subcommands. For example:
<pre>for i in (ls)
echo $i
end</pre>
\fish{cli-dark}
for i in (ls)
echo $i
end
\endfish
<hr>
\section faq-exit-status How do I get the exit status of a command?
Use the \c $status variable. This replaces the \c $? variable used in some
other shells.
Use the `$status` variable. This replaces the `$?` variable used in some other shells.
<hr>
\section faq-single-env How do I set an environment variable for just one command?
<i><tt>SOME_VAR=1 command</tt> produces an error: <tt>Unknown command "SOME_VAR=1"</tt>.</i>
<i>`SOME_VAR=1 command` produces an error: `Unknown command "SOME_VAR=1"`.</i>
Use the \c env command.
Use the `env` command.
<tt>env SOME_VAR=1 command</tt>
`env SOME_VAR=1 command`
You can also declare a local variable in a block:
<pre>begin
set -lx SOME_VAR 1
command
end</pre>
\fish{cli-dark}
begin
set -lx SOME_VAR 1
command
end
\endfish
<hr>
\section faq-customize-colors How do I customize my syntax highlighting colors?
Use the web configuration tool,
<a href="commands.html#fish_config"><code>fish_config</code></a>, or alter the
<a href="index.html#variables-color">\c fish_color family of environment variables</a>.
Use the web configuration tool, <a href="commands.html#fish_config">`fish_config`</a>, or alter the <a href="index.html#variables-color">`fish_color` family of environment variables</a>.
<hr>
\section faq-update-manpage-completions How do I update man page completions?
Use the
<a href="commands.html#fish_update_completions"><tt>fish_update_completions</tt></a>
command.
Use the <a href="commands.html#fish_update_completions">`fish_update_completions`</a> command.
<hr>
\section faq-cwd-symlink Why does cd, $PWD and and various fish commands always resolve symlinked directories to their canonical path?
<i>
For example if ~/images is a symlink to ~/Documents/Images, if I write
'cd images', my prompt will say ~/D/Images, not ~/images.
</i>
<i>For example if `~/images` is a symlink to `~/Documents/Images`, if I write '`cd images`', my prompt will say `~/D/Images`, not `~/images`.</i>
Because it is impossible to consistently keep symlinked directories
unresolved. It is indeed possible to do this partially, and many other
shells do so. But it was felt there are enough serious corner cases
that this is a bad idea. Most such issues have to do with how '..' is
handled, and are varitations of the following example:
Because it is impossible to consistently keep symlinked directories unresolved. It is indeed possible to do this partially, and many other shells do so. But it was felt there are enough serious corner cases that this is a bad idea. Most such issues have to do with how '..' is handled, and are varitations of the following example:
Writing <code>cd images; ls ..</code> given the above directory
structure would list the contents of ~/Documents, not of ~, even
though using <code>cd ..</code> changes the current directory to ~,
and the prompt, the pwd builtin and many other directory information
sources suggest that the current directory is ~/images and its
parent is ~. This issue is not possible to fix without either making
every single command into a builtin, breaking Unix semantics or
implementing kludges in every single command.
Writing `cd images; ls ..` given the above directory structure would list the contents of `~/Documents`, not of `~`, even though using `cd ..` changes the current directory to `~`, and the prompt, the `pwd` builtin and many other directory information sources suggest that the current directory is `~/images` and its parent is `~`. This issue is not possible to fix without either making every single command into a builtin, breaking Unix semantics or implementing kludges in every single command. This issue can also be seen when doing IO redirection.
This issue can also be seen when doing IO redirection.
Another related issue is that many programs that operate on recursive
directory trees, like the find command, silently ignore symlinked
directories. For example, <code>find $PWD -name '*.txt'</code>
silently fails in shells that don't resolve symlinked paths.
Another related issue is that many programs that operate on recursive directory trees, like the find command, silently ignore symlinked directories. For example, ```find $PWD -name '*.txt'``` silently fails in shells that don't resolve symlinked paths.
<hr>
\section faq-cd-implicit I accidentally entered a directory path and fish changed directory. What happened?
If fish is unable to locate a command with a given name, and it starts with '.', '/' or '~', fish will
test if a directory of that name exists. If it does, it is implicitly
assumed that you want to change working directory. For example, the
fastest way to switch to your home directory is to simply press
<code>~</code> and enter.
If fish is unable to locate a command with a given name, and it starts with '`.`', '`/`' or '`~`', fish will test if a directory of that name exists. If it does, it is implicitly assumed that you want to change working directory. For example, the fastest way to switch to your home directory is to simply press `~` and enter.
<hr>
\section faq-open The open command doesn't work.
The \c open command uses the MIME type database and the <code>.desktop</code> files
used by Gnome and KDE to identify filetypes and default actions. If
at least one of these environments is installed, but the open command is
not working, this probably means that the relevant files are installed
in a non-standard location. Consider <a href="index.html#more-help">asking for
more help</a>.
The `open` command uses the MIME type database and the `.desktop` files used by Gnome and KDE to identify filetypes and default actions. If at least one of these environments is installed, but the open command is not working, this probably means that the relevant files are installed in a non-standard location. Consider <a href="index.html#more-help">asking for more help</a>.
<hr>
\section faq-default How do I make fish my default shell?
If you installed fish manually (e.g. by compiling it, not by using a
package manager), you first need to add fish to the list of shells by
executing the following command (assuming you installed fish in
/usr/local) as root:
If you installed fish manually (e.g. by compiling it, not by using a package manager), you first need to add fish to the list of shells by executing the following command (assuming you installed fish in /usr/local) as root:
\fish{cli-dark}
echo /usr/local/bin/fish >>/etc/shells
\endfish
<code>echo /usr/local/bin/fish >>/etc/shells</code>
If you installed a prepackaged version of fish, the package manager
should have already done this for you.
If you installed a prepackaged version of fish, the package manager should have already done this for you.
In order to change your default shell, type:
<code>chsh -s /usr/local/bin/fish</code>
\fish{cli-dark}
chsh -s /usr/local/bin/fish
\endfish
You may need to adjust the above path to e.g. \c /usr/bin/fish. Use the command <code>which fish</code> if you are unsure of where fish is installed.
You may need to adjust the above path to e.g. `/usr/bin/fish`. Use the command `which fish` if you are unsure of where fish is installed.
Unfortunately, there is no way to make the changes take effect at once.
You will need to log out and back in again.
Unfortunately, there is no way to make the changes take effect at once. You will need to log out and back in again.
<hr>
\section faq-titlebar I'm seeing weird output before each prompt when using screen. What's wrong?
Quick answer:
Run the following command in fish:
<pre>
echo 'function fish_title;end' &gt; ~/.config/fish/config.fish
</pre>
\fish{cli-dark}
echo 'function fish_title;end' > ~/.config/fish/config.fish
\endfish
Problem solved!
The long answer:
Fish is trying to set the titlebar message of your terminal. While
screen itself supports this feature, your terminal does
not. Unfortunately, when the underlying terminal doesn't support
setting the titlebar, screen simply passes through the escape codes
and text to the underlying terminal instead of ignoring them. It is
impossible detect and resolve this problem from inside fish since fish
has no way of knowing what the underlying terminal type is. For now,
the only way to fix this is to unset the titlebar message, as
suggested above.
Fish is trying to set the titlebar message of your terminal. While screen itself supports this feature, your terminal does not. Unfortunately, when the underlying terminal doesn't support setting the titlebar, screen simply passes through the escape codes and text to the underlying terminal instead of ignoring them. It is impossible detect and resolve this problem from inside fish since fish has no way of knowing what the underlying terminal type is. For now, the only way to fix this is to unset the titlebar message, as suggested above.
Note that fish has a default titlebar message, which will be used if
the fish_title function is undefined. So simply unsetting the
fish_title function will not work.
Note that fish has a default titlebar message, which will be used if the fish_title function is undefined. So simply unsetting the fish_title function will not work.
<hr>
\section faq-greeting How do I change the greeting message?
Change the value of the variable \c fish_greeting or create a \c fish_greeting
function. For example, to remove the greeting use:
Change the value of the variable `fish_greeting` or create a `fish_greeting` function. For example, to remove the greeting use:
<pre>
\fish{cli-dark}
set fish_greeting
</pre>
\endfish
<hr>
\section faq-history Why doesn't history substitution ("!$" etc.) work?
Because history substitution is an awkward interface that was invented before
interactive line editing was even possible. Fish drops it in favor of
perfecting the interactive history recall interface. Switching requires a
small change of habits: if you want to modify an old line/word, first recall
it, then edit. E.g. don't type "sudo !!" - first press Up, then Home, then
type "sudo ".
Because history substitution is an awkward interface that was invented before interactive line editing was even possible. Fish drops it in favor of perfecting the interactive history recall interface. Switching requires a small change of habits: if you want to modify an old line/word, first recall it, then edit. E.g. don't type "sudo !!" - first press Up, then Home, then type "sudo ".
Fish history recall is very simple yet effective:
- As in any modern shell, the Up arrow recalls whole lines, starting from the last line executed. A single press replaces "!!", later presses replace "!-3" and the like.
- If the line you want is far back in the history, type any part of the line and then press Up one or more times. This will constrain the recall to lines that include this text, and you will get to the line you want much faster. This replaces "!vi", "!?bar.c" and the like.
- Alt+Up recalls individual arguments, starting from the last argument in the last line executed. A single press replaces "!$", later presses replace "!!:4" and the like.
- If the argument you want is far back in history (e.g. 2 lines back - that's a lot of words!), type any part of it and then press Alt+Up. This will show only arguments containing that part and you will get what you want much faster. Try it out, this is very convenient!
- If you want to reuse several arguments from the same line ("!!:3*" and the like), consider recalling the whole line and removing what you don't need (Alt+D and Alt+Backspace are your friends).
- As in any modern shell, the Up arrow, @cursor_key{&uarr;,Up} recalls whole lines, starting from the last line executed. A single press replaces "!!", later presses replace "!-3" and the like.
- If the line you want is far back in the history, type any part of the line and then press Up one or more times. This will constrain the recall to lines that include this text, and you will get to the line you want much faster. This replaces "!vi", "!?bar.c" and the like.
- @key{Alt,&uarr;,Up} recalls individual arguments, starting from the last argument in the last line executed. A single press replaces "!$", later presses replace "!!:4" and the like.
- If the argument you want is far back in history (e.g. 2 lines back - that's a lot of words!), type any part of it and then press @key{Alt,&uarr;,Up}. This will show only arguments containing that part and you will get what you want much faster. Try it out, this is very convenient!
- If you want to reuse several arguments from the same line ("!!:3*" and the like), consider recalling the whole line and removing what you don't need (@key{Alt,D} and @key{Alt,Backspace} are your friends).
See <a href='index.html#editor'>documentation</a> for more details about line editing in fish.
<hr>
\section faq-uninstalling Uninstalling fish
Should you wish to uninstall fish, first ensure fish is not set as your shell. Run <code>chsh -s /bin/bash</code> if you are not sure.
Should you wish to uninstall fish, first ensure fish is not set as your shell. Run `chsh -s /bin/bash` if you are not sure.
Next, do the following (assuming fish was installed to /usr/local):
<pre>
\fish{cli-dark}
rm -Rf /usr/local/etc/fish /usr/local/share/fish ~/.config/fish
rm /usr/local/share/man/man1/fish*.1
cd /usr/local/bin
rm -f fish mimedb fishd fish_indent
</pre>
\endfish
*/
\htmlonly
\htmlonly[block]
</div>
\endhtmlonly
*/

View file

@ -1,14 +1,17 @@
\section fg fg - bring job to foreground
\subsection fg-synopsis Synopsis
<tt>fg [PID]</tt>
\fish{synopsis}
fg [PID]
\endfish
\subsection fg-description Description
\c fg brings the specified <a href="index.html#syntax-job-control">job</a> to the foreground, resuming it if it is stopped. While a foreground job is
executed, fish is suspended. If no job is specified, the last job to be used is put in the foreground. If PID is specified, the job with the specified group ID is put in the foreground.
`fg` brings the specified <a href="index.html#syntax-job-control">job</a> to the foreground, resuming it if it is stopped. While a foreground job is executed, fish is suspended. If no job is specified, the last job to be used is put in the foreground. If PID is specified, the job with the specified group ID is put in the foreground.
The PID of the desired process is usually found by using <a href="index.html#expand-process">process expansion</a>.
\subsection fg-example Example
<tt>fg \%1</tt> will put the job with job ID 1 in the foreground.
`fg %1` will put the job with job ID 1 in the foreground.

View file

@ -1,25 +1,28 @@
\section fish fish - the friendly interactive shell
\subsection fish-synopsis Synopsis
fish [-h] [-v] [-c command] [FILE [ARGUMENTS...]]
\fish{synopsis}
fish [OPTIONS] [-c command] [FILE [ARGUMENTS...]]
\endfish
\subsection fish-description Description
\c fish is a command-line shell written mainly with interactive use in mind. The
full manual is available <a href='index.html'>in HTML</a> by using the
<a href='#help'>help</a> command from inside fish.
`fish` is a command-line shell written mainly with interactive use in mind. The full manual is available <a href='index.html'>in HTML</a> by using the <a href='#help'>help</a> command from inside fish.
The following options are available:
- <code>-c</code> or <code>--command=COMMANDS</code> evaluate the specified commands instead of reading from the commandline
- <code>-d</code> or <code>--debug-level=DEBUG_LEVEL</code> specify the verbosity level of fish. A higher number means higher verbosity. The default level is 1.
- <code>-h</code> or <code>--help</code> display help and exit
- <code>-i</code> or <code>--interactive</code> specify that fish is to run in interactive mode
- <code>-l</code> or <code>--login</code> specify that fish is to run as a login shell
- <code>-n</code> or <code>--no-execute</code> do not execute any commands, only perform syntax checking
- <code>-p</code> or <code>--profile=PROFILE_FILE</code> when fish exits, output timing information on all executed commands to the specified file
- <code>-v</code> or <code>--version</code> display version and exit
- `-c` or `--command=COMMANDS` evaluate the specified commands instead of reading from the commandline
The fish exit status is generally the exit status of the last
foreground command. If fish is exiting because of a parse error, the
exit status is 127.
- `-d` or `--debug-level=DEBUG_LEVEL` specify the verbosity level of fish. A higher number means higher verbosity. The default level is 1.
- `-i` or `--interactive` specify that fish is to run in interactive mode
- `-l` or `--login` specify that fish is to run as a login shell
- `-n` or `--no-execute` do not execute any commands, only perform syntax checking
- `-p` or `--profile=PROFILE_FILE` when fish exits, output timing information on all executed commands to the specified file
- `-v` or `--version` display version and exit
The fish exit status is generally the exit status of the last foreground command. If fish is exiting because of a parse error, the exit status is 127.

View file

@ -2,21 +2,17 @@
\subsection fish_config-description Description
\c fish_config starts the web-based configuration interface.
`fish_config` starts the web-based configuration interface.
The web interface allows you to view your functions, variables and history, and
to make changes to your prompt and color configuration.
The web interface allows you to view your functions, variables and history, and to make changes to your prompt and color configuration.
\c fish_config starts a local web server and then opens a web browser window; when
you have finished, close the browser window and then press the Enter key to
terminate the configuration session.
`fish_config` starts a local web server and then opens a web browser window; when you have finished, close the browser window and then press the Enter key to terminate the configuration session.
<code>fish_config</code> optionally accepts name of the initial configuration tab. For e.g. <code>fish_config history</code> will start configuration interface with history tab.
`fish_config` optionally accepts name of the initial configuration tab. For e.g. `fish_config history` will start configuration interface with history tab.
If the `BROWSER` environment variable is set, it will be used as the name of the web browser to open instead of the system default.
If the \c BROWSER environment variable is set, it will be used as the name
of the web browser to open instead of the system default.
\subsection fish_config-example Example
\c fish_config opens a new web browser window and allows you to configure certain
fish settings.
`fish_config` opens a new web browser window and allows you to configure certain fish settings.

View file

@ -1,17 +1,17 @@
\section fish_indent fish_indent - indenter and prettifier
\subsection fish_indent-synopsis Synopsis
<tt>fish_indent [options]</tt>
\fish{synopsis}
fish_indent [OPTIONS]
\endfish
\subsection fish_indent-description Description
\c fish_indent is used to indent a piece of fish
code. \c fish_indent reads commands from standard input and outputs
them to standard output.
`fish_indent` is used to indent a piece of fish code. `fish_indent` reads commands from standard input and outputs them to standard output.
The following options are available:
- <tt>-h</tt> or <tt>--help</tt> displays this help message and then exits
- <tt>-i</tt> or <tt>--no-indent</tt> do not indent commands
- <tt>-v</tt> or <tt>--version</tt> displays the current fish version and then exits
- `-i` or `--no-indent` do not indent commands
- `-v` or `--version` displays the current fish version and then exits

View file

@ -1,28 +1,29 @@
\section fish_prompt fish_prompt - define the appearance of the command line prompt
\subsection fish_prompt-synopsis Synopsis
<pre>function fish_prompt
\fish{synopsis}
function fish_prompt
...
end</pre>
end
\endfish
\subsection fish_prompt-description Description
By defining the \c fish_prompt function, the user can choose a custom
prompt. The \c fish_prompt function is executed when the prompt is to
be shown, and the output is used as a prompt.
By defining the `fish_prompt` function, the user can choose a custom prompt. The `fish_prompt` function is executed when the prompt is to be shown, and the output is used as a prompt.
The exit status of commands within \c fish_prompt will not modify the value of <a href="index.html#variables-status">$status</a> outside of the \c fish_prompt function.
The exit status of commands within `fish_prompt` will not modify the value of <a href="index.html#variables-status">$status</a> outside of the `fish_prompt` function.
`fish` ships with a number of example prompts that can be chosen with the `fish_config` command.
\c fish ships with a number of example prompts that can be chosen with the
\c fish_config command.
\subsection fish_prompt-example Example
A simple prompt:
<pre>
\fish
function fish_prompt -d "Write out the prompt"
printf '\%s\@\%s\%s\%s\%s> ' (whoami) (hostname|cut -d . -f 1) (set_color \$fish_color_cwd) (prompt_pwd) (set_color normal)
printf '%s@%s%s%s%s> ' (whoami) (hostname | cut -d . -f 1) \
(set_color $fish_color_cwd) (prompt_pwd) (set_color normal)
end
</pre>
\endfish

View file

@ -1,23 +1,26 @@
\section fish_right_prompt fish_right_prompt - define the appearance of the right-side command line prompt
\subsection fish_right_prompt-synopsis Synopsis
<pre>function fish_right_prompt
\fish{synopsis}
function fish_right_prompt
...
end</pre>
end
\endfish
\subsection fish_right_prompt-description Description
\c fish_right_prompt is similar to \c fish_prompt, except that it appears on the right side of the terminal window.
`fish_right_prompt` is similar to `fish_prompt`, except that it appears on the right side of the terminal window.
Multiple lines are not supported in \c fish_right_prompt.
Multiple lines are not supported in `fish_right_prompt`.
\subsection fish_prompt-example Example
\subsection fish_right_prompt-example Example
A simple right prompt:
<pre>
\fish
function fish_right_prompt -d "Write out the right prompt"
date "+%m/%d/%y"
end
</pre>
\endfish

View file

@ -2,8 +2,8 @@
\subsection fish_update_completions-description Description
\c fish_update_completions parses manual pages installed on the system, and attempts to create completion files in the \c fish configuration directory.
`fish_update_completions` parses manual pages installed on the system, and attempts to create completion files in the `fish` configuration directory.
This does not overwrite custom completions.
There are no parameters for <code>fish_update_completions</code>.
There are no parameters for `fish_update_completions`.

View file

@ -1,25 +1,21 @@
\section for for - perform a set of commands multiple times.
\subsection for-synopsis Synopsis
<tt>for VARNAME in [VALUES...]; COMMANDS...; end</tt>
\fish{synopsis}
for VARNAME in [VALUES...]; COMMANDS...; end
\endfish
\subsection for-description Description
<tt>for</tt> is a loop construct. It will perform the commands specified by
\c COMMANDS multiple times. On each iteration, the environment variable specified by
\c VARNAME is assigned a new value from \c VALUES. If \c VALUES is empty, \c COMMANDS will
not be executed at all.
`for` is a loop construct. It will perform the commands specified by `COMMANDS` multiple times. On each iteration, the environment variable specified by `VARNAME` is assigned a new value from `VALUES`. If `VALUES` is empty, `COMMANDS` will not be executed at all.
\subsection for-example Example
The command
\fish
for i in foo bar baz; echo $i; end
<tt>for i in foo bar baz; echo $i; end</tt>
would output:
<pre>
# would output:
foo
bar
baz
</pre>
\endfish

View file

@ -1,21 +1,18 @@
\section funced funced - edit a function interactively
\subsection funced-synopsis Synopsis
<code>funced [OPTIONS] NAME</code>
\fish{synopsis}
funced [OPTIONS] NAME
\endfish
\subsection funced-description Description
\c funced provides an interface to edit the definition of the function
<code>NAME</code>.
`funced` provides an interface to edit the definition of the function `NAME`.
If the \c $EDITOR environment variable is set, it will be used as the program
to edit the function. Otherwise, a built-in editor will be used.
If the `$EDITOR` environment variable is set, it will be used as the program to edit the function. Otherwise, a built-in editor will be used.
If there is no function called \c NAME a new function will be created with
the specified name
If there is no function called `NAME` a new function will be created with the specified name
- <code>-e command</code> or <code>--editor command</code> Open the function
body inside the text editor given by the command (for example, "vi"). The
command 'fish' will use the built-in editor.
- <code>-i</code> or <code>--interactive</code> Open function body in the
built-in editor.
- `-e command` or `--editor command` Open the function body inside the text editor given by the command (for example, "vi"). The command 'fish' will use the built-in editor.
- `-i` or `--interactive` Open function body in the built-in editor.

View file

@ -1,13 +1,10 @@
\section funcsave funcsave - save the definition of a function to the user's autoload directory
\subsection funcsave-synopsis Synopsis
<tt>funcsave FUNCTION_NAME</tt>
\fish{synopsis}
funcsave FUNCTION_NAME
\endfish
\subsection funcsave-description Description
\c funcsave saves the current definition of a function to
a file in the fish configuration directory. This function will be automatically
loaded by current and future fish
sessions. This can be useful if you have interactively created a new
function and wish to save it for later use.
`funcsave` saves the current definition of a function to a file in the fish configuration directory. This function will be automatically loaded by current and future fish sessions. This can be useful if you have interactively created a new function and wish to save it for later use.

View file

@ -1,62 +1,69 @@
\section function function - create a function
\subsection function-synopsis Synopsis
<code>function [OPTIONS] NAME; BODY; end </code>
\fish{synopsis}
function [OPTIONS] NAME; BODY; end
\endfish
\subsection function-description Description
\c function creates a new function \c NAME with the body <code>BODY</code>.
`function` creates a new function `NAME` with the body `BODY`.
A function is a list of commands that will be executed when the name of the
function is given as a command.
A function is a list of commands that will be executed when the name of the function is given as a command.
The following options are available:
- <code>-a NAMES</code> or <code>--argument-names NAMES</code> assigns the value of successive command-line arguments to the names given in NAMES.
- <code>-d DESCRIPTION</code> or \c --description=DESCRIPTION is a description of what the function does, suitable as a completion description.
- <code>-w WRAPPED_COMMAND</code> or \c --wraps=WRAPPED_COMMAND causes the function to inherit completions from the given wrapped command. See the documentation for \c complete for more information.
- <code>-e</code> or <code>--on-event EVENT_NAME</code> tells fish to run this function when the specified named event is emitted. Fish internally generates named events e.g. when showing the prompt.
- <code>-j PID</code> or <code> --on-job-exit PID</code> tells fish to run this function when the job with group ID PID exits. Instead of PID, the string 'caller' can be specified. This is only legal when in a command substitution, and will result in the handler being triggered by the exit of the job which created this command substitution.
- <code>-p PID</code> or <code> --on-process-exit PID</code> tells fish to run this function when the fish child process with process ID PID exits.
- <code>-s</code> or <code>--on-signal SIGSPEC</code> tells fish to run this function when the signal SIGSPEC is delivered. SIGSPEC can be a signal number, or the signal name, such as SIGHUP (or just HUP).
- \c -S or \c --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 is independent of the calling function.
- <code>-v</code> or <code>--on-variable VARIABLE_NAME</code> tells fish to run this function when the variable VARIABLE_NAME changes value.
- `-a NAMES` or `--argument-names NAMES` assigns the value of successive command-line arguments to the names given in NAMES.
If the user enters any additional arguments after the function, they
are inserted into the environment <a href="index.html#variables-arrays">variable array</a>
<code>$argv</code>. If the \c --argument-names option is provided, the arguments are
also assigned to names specified in that option.
- `-d DESCRIPTION` or `--description=DESCRIPTION` is a description of what the function does, suitable as a completion description.
- `-w WRAPPED_COMMAND` or `--wraps=WRAPPED_COMMAND` causes the function to inherit completions from the given wrapped command. See the documentation for <a href="#complete">`complete`</a> for more information.
- `-e` or `--on-event EVENT_NAME` tells fish to run this function when the specified named event is emitted. Fish internally generates named events e.g. when showing the prompt.
- `-j PID` or `--on-job-exit PID` tells fish to run this function when the job with group ID PID exits. Instead of PID, the string 'caller' can be specified. This is only legal when in a command substitution, and will result in the handler being triggered by the exit of the job which created this command substitution.
- `-p PID` or `--on-process-exit PID` tells fish to run this function when the fish child process with process ID PID exits.
- `-s` or `--on-signal SIGSPEC` tells fish to run this function when the signal SIGSPEC is delivered. SIGSPEC can be a signal number, or the signal name, such as SIGHUP (or just HUP).
- `-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 is independent of the calling function.
- `-v` or `--on-variable VARIABLE_NAME` tells fish to run this function when the variable VARIABLE_NAME changes value.
If the user enters any additional arguments after the function, they are inserted into the environment <a href="index.html#variables-arrays">variable array</a> `$argv`. If the `--argument-names` option is provided, the arguments are also assigned to names specified in that option.
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 <a href="#emit">emit</a> builtin. Fish generates the following named events:
- \c fish_prompt, which is emitted whenever a new fish prompt is about to be displayed.
- \c fish_command_not_found, which is emitted whenever a command lookup failed.
- `fish_prompt`, which is emitted whenever a new fish prompt is about to be displayed.
- `fish_command_not_found`, which is emitted whenever a command lookup failed.
\subsection function-example Example
<pre>
\fish
function ll
ls -l $argv
ls -l $argv
end
</pre>
\endfish
will run the \c ls command, using the \c -l option, while passing on any additional files and switches to \c ls.
will run the `ls` command, using the `-l` option, while passing on any additional files and switches to `ls`.
<pre>
\fish
function mkdir -d "Create a directory and set CWD"
command mkdir $argv
if test $status = 0
switch $argv[(count $argv)]
case '-*'
command mkdir $argv
if test $status = 0
switch $argv[(count $argv)]
case '-*'
case '*'
cd $argv[(count $argv)]
return
end
end
case '*'
cd $argv[(count $argv)]
return
end
end
end
</pre>
\endfish
will run the mkdir command, and if it is successful, change the
current working directory to the one just created.
This will run the `mkdir` command, and if it is successful, change the current working directory to the one just created.

View file

@ -1,51 +1,52 @@
\section functions functions - print or erase functions
\subsection function-synopsis Synopsis
<pre>functions [-n]
\subsection functions-synopsis Synopsis
\fish{synopsis}
functions [ -a | --all ] [ -n | --names ]
functions -c OLDNAME NEWNAME
functions -d DESCRIPTION FUNCTION
functions [-eq] FUNCTIONS...</pre>
functions [ -e | -q ] FUNCTIONS...
\endfish
\subsection functions-description Description
\c functions prints or erases functions.
`functions` prints or erases functions.
The following options are available:
- <code>-a</code> or <code>--all</code> lists all functions, even those whose name start with an underscore.
- <code>-c OLDNAME NEWNAME</code> or <code>--copy OLDNAME NEWNAME</code> creates a new function named NEWNAME, using the definition of the OLDNAME function.
- <code>-d DESCRIPTION</code> or <code>--description=DESCRIPTION</code> changes the description of this function.
- <code>-e</code> or <code>--erase</code> causes the specified functions to be erased.
- <code>-h</code> or <code>--help</code> displays a help message and exits.
- <code>-n</code> or <code>--names</code> lists the names of all defined functions.
- <code>-q</code> or <code>--query</code> tests if the specified functions exist.
- `-a` or `--all` lists all functions, even those whose name start with an underscore.
The default behavior of <code>functions</code>, when called with no arguments,
is to print the names of all defined functions. Unless the \c -a option is
given, no functions starting with underscores are not included in the output.
- `-c OLDNAME NEWNAME` or `--copy OLDNAME NEWNAME` creates a new function named NEWNAME, using the definition of the OLDNAME function.
If any non-option parameters are given, the definition of the specified
functions are printed.
- `-d DESCRIPTION` or `--description=DESCRIPTION` changes the description of this function.
Automatically loaded functions cannot be removed using <code>functions
-e</code>. Either remove the definition file or change the
$fish_function_path variable to remove autoloaded functions.
- `-e` or `--erase` causes the specified functions to be erased.
Copying a function using \c -c copies only the body of the function, and
does not attach any event notifications from the original function.
- `-n` or `--names` lists the names of all defined functions.
Only one function's description can be changed in a single invocation
of <code>functions -d</code>.
- `-q` or `--query` tests if the specified functions exist.
The default behavior of `functions`, when called with no arguments, is to print the names of all defined functions. Unless the `-a` option is given, no functions starting with underscores are not included in the output.
If any non-option parameters are given, the definition of the specified functions are printed.
Automatically loaded functions cannot be removed using `functions -e`. Either remove the definition file or change the $fish_function_path variable to remove autoloaded functions.
Copying a function using `-c` copies only the body of the function, and does not attach any event notifications from the original function.
Only one function's description can be changed in a single invocation of `functions -d`.
The exit status of `functions` is the number of functions specified in the argument list that do not exist, which can be used in concert with the `-q` option.
The exit status of \c functions is the number of functions
specified in the argument list that do not exist, which can be used in
concert with the \c -q option.
\subsection functions-example Examples
\fish
functions -n
# Displays a list of currently-defined functions
<code>functions -n</code> displays a list of currently-defined functions.
functions -c foo bar
# Copies the 'foo' function to a new function called 'bar'
<code>functions -c foo bar</code> copies the \c foo function to a new function called
<code>bar</code>.
<code>functions -e bar</code> erases the function <code>bar</code>.
functions -e bar
# Erases the function `bar`
\endfish

View file

@ -1,20 +1,21 @@
\section help help - display fish documentation
\subsection help-synopsis Synopsis
<tt>help [SECTION]</tt>
\fish{synopsis}
help [SECTION]
\endfish
\subsection help-description Description
\c help displays the fish help documentation.
`help` displays the fish help documentation.
If a \c SECTION is specified, the help for that command is shown.
If a `SECTION` is specified, the help for that command is shown.
If the BROWSER environment variable is set, it will be used to display the
documentation. Otherwise, fish will search for a suitable browser.
If the BROWSER environment variable is set, it will be used to display the documentation. Otherwise, fish will search for a suitable browser.
Note that most builtin commands display their help in the terminal when given the `--help` option.
Note that most builtin commands display their help in the terminal when
given the <tt>--help</tt> option.
\subsection help-example Example
<tt>help fg</tt> shows the documentation for the \c fg builtin.
`help fg` shows the documentation for the `fg` builtin.

View file

@ -1,47 +1,44 @@
\section history history - Show and manipulate command history
\subsection history-synopsis Synopsis
<pre>
history (--save | --clear | --merge)
history (--search | --delete ) (--prefix "prefix string" | --contains "search string")
</pre>
\fish{synopsis}
history ( --merge | --save | --clear )
history ( --search | --delete ) [ --prefix "prefix string" | --contains "search string" ]
\endfish
\subsection history-description Description
\c history is used to list, search and delete the history of commands used.
`history` is used to list, search and delete the history of commands used.
The following options are available:
- `--merge` immediately incorporates history changes from other sessions. Ordinarily `fish` ignores history changes from sessions started after the current one. This command applies those changes immediately.
- \c --save saves all changes in the history file. The shell automatically
saves the history file; this option is provided for internal use.
- \c --clear clears the history file. A prompt is displayed before the history
is erased.
- \c --merge immediately incorporates history changes from other sessions. Ordinarily
fish ignores history changes from sessions started after the current one. This command
applies those changes immediately.
- \c --search returns history items in keeping with the \c --prefix or
\c --contains options.
- \c --delete deletes history items.
- \c --prefix searches or deletes items in the history that begin with the
specified text string.
- \c --contains searches or deletes items in the history that contain the
specified text string.
- `--save` saves all changes in the history file. The shell automatically saves the history file; this option is provided for internal use.
If \c --search is specified without \c --contains or <code>--prefix</code>,
\c --contains will be assumed.
- `--clear` clears the history file. A prompt is displayed before the history is erased.
- `--search` returns history items in keeping with the `--prefix` or `--contains` options.
- `--delete` deletes history items.
- `--prefix` searches or deletes items in the history that begin with the specified text string.
- `--contains` searches or deletes items in the history that contain the specified text string.
If `--search` is specified without `--contains` or `--prefix`, `--contains` will be assumed.
If `--delete` is specified without `--contains` or `--prefix`, only a history item which exactly matches the parameter will be erased. No prompt will be given. If `--delete` is specified with either of these parameters, an interactive prompt will be displayed before any items are deleted.
If \c --delete is specified without \c --contains or <code>--prefix</code>,
only a history item which exactly matches the parameter will be erased. No
prompt will be given. If \c --delete is specified with either of these
parameters, an interactive prompt will be displayed before any items are
deleted.
\subsection history-examples Example
<code>history --clear</code> deletes all history items
\fish
history --clear
# Deletes all history items
<code>history --search --contains "foo"</code> outputs a list of all previous
commands containing the string "foo".
history --search --contains "foo"
# Outputs a list of all previous commands containing the string "foo".
<code>history --delete --prefix "foo"</code> interactively deletes the record
of previous commands which start with "foo".
history --delete --prefix "foo"
# Interactively deletes the record of previous commands which start with "foo".
\endfish

View file

@ -1,36 +1,32 @@
\section if if - conditionally execute a command
\subsection if-synopsis Synopsis
<tt>if CONDITION; COMMANDS_TRUE...; [else if CONDITION2; COMMANDS_TRUE2...;] [else; COMMANDS_FALSE...;] end</tt>
\fish{synopsis}
if CONDITION; COMMANDS_TRUE...;
[else if CONDITION2; COMMANDS_TRUE2...;]
[else; COMMANDS_FALSE...;]
end
\endfish
\subsection if-description Description
<tt>if</tt> will execute the command \c CONDITION. If the condition's
exit status is 0, the commands \c COMMANDS_TRUE will execute. If the
exit status is not 0 and <tt>else</tt> is given, \c 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 `else` is given, `COMMANDS_FALSE` will be executed.
In order to use the exit status of multiple commands as the condition
of an if block, use <a href="#begin"><tt>begin; ...; end</tt></a> and
the short circuit commands <a href="commands.html#and"><tt>and</tt></a>
and <a href="commands.html#or"><tt>or</tt></a>.
In order to use the exit status of multiple commands as the condition of an if block, use <a href="#begin">`begin; ...; end`</a> and the short circuit commands <a href="commands.html#and">`and`</a> and <a href="commands.html#or">`or`</a>.
The exit status of the last foreground command to exit can always be accessed using the <a href="index.html#variables-status">$status</a> variable.
The exit status of the last foreground command to exit can always be
accessed using the <a href="index.html#variables-status">$status</a>
variable.
\subsection if-example Example
<pre>
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`.
\fish
if test -f foo.txt
echo foo.txt exists
echo foo.txt exists
else if test -f bar.txt
echo bar.txt exists
echo bar.txt exists
else
echo foo.txt and bar.txt do not exist
echo foo.txt and bar.txt do not exist
end
</pre>will print <tt>foo.txt exists</tt> if the file foo.txt
exists and is a regular file, otherwise it will print
<tt>bar.txt exists</tt> if the file bar.txt exists
and is a regular file, otherwise it will print
<tt>foo.txt and bar.txt do not exist</tt>.
\endfish

File diff suppressed because it is too large Load diff

View file

@ -1,29 +1,33 @@
\section isatty isatty - test if a file or file descriptor is a tty.
\subsection isatty-synopsis Synopsis
<tt>isatty [FILE | DEVICE | FILE DESCRIPTOR NUMBER]</tt>
\fish{synopsis}
isatty [FILE | DEVICE | FILE DESCRIPTOR NUMBER]
\endfish
\subsection isatty-description Description
<tt>isatty</tt> tests if a file or file descriptor is a tty.
The argument may be in the form of a file path, device, or file descriptor
number. Without an argument, <tt>standard input</tt> is implied.
`isatty` tests if a file or file descriptor is a tty. The argument may be in the form of a file path, device, or file descriptor number. Without an argument, `standard input` is implied.
If the resolved file descriptor is a tty, the command returns zero. Otherwise, the command exits one. No messages are printed to standard error.
\subsection isatty-examples Examples
From an interactive shell, the commands below exit with a return value of zero:
<pre>
\fish
isatty
isatty stdout
isatty 2
echo | isatty /dev/fd/1
</pre>
\endfish
And these will exit non-zero:
<pre>
\fish
echo | isatty
isatty /dev/fd/9
isatty stdout > file
isatty 2 2> file
</pre>
\endfish

View file

@ -1,25 +1,27 @@
\section jobs jobs - print currently running jobs
\subsection jobs-synopsis Synopsis
<code>jobs [OPTIONS] [PID]</code>
\fish{synopsis}
jobs [OPTIONS] [PID]
\endfish
\subsection jobs-description Description
<code>jobs</code> prints a list of the currently
running <a href="index.html#syntax-job-control">jobs</a> and their status.
`jobs` prints a list of the currently running <a href="index.html#syntax-job-control">jobs</a> and their status.
jobs accepts the following switches:
- <code>-c</code> or <code>--command</code> prints the command name for each process in jobs.
- <code>-g</code> or <code>--group</code> only prints the group ID of each job.
- <code>-h</code> or <code>--help</code> displays a help message and exits.
- <code>-l</code> or <code>--last</code> prints only the last job to be started.
- <code>-p</code> or <code>--pid</code> prints the process ID for each process in all jobs.
- `-c` or `--command` prints the command name for each process in jobs.
- `-g` or `--group` only prints the group ID of each job.
- `-l` or `--last` prints only the last job to be started.
- `-p` or `--pid` prints the process ID for each process in all jobs.
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\%.
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\%.
\subsection jobs-example Example
<code>jobs</code> outputs a summary of the current jobs.
`jobs` outputs a summary of the current jobs.

File diff suppressed because it is too large Load diff

View file

@ -2,25 +2,19 @@
\section math math - Perform mathematics calculations
\subsection math-synopsis Synopsis
<tt>math EXPRESSION</tt>
\fish{synopsis}
math EXPRESSION
\endfish
\subsection math-description Description
\c math is used to perform mathematical calculations. It is a very
thin wrapper for the bc program, which makes it possible to specify an
expression from the command line without using non-standard extensions
or a pipeline.
`math` is used to perform mathematical calculations. It is a very thin wrapper for the bc program, which makes it possible to specify an expression from the command line without using non-standard extensions or a pipeline.
For a description of the syntax supported by math, see the manual for the bc program. Keep in mind that parameter expansion takes place on any expressions before they are evaluated. This can be very useful in order to perform calculations involving shell variables or the output of command substitutions, but it also means that parenthesis have to be escaped.
For a description of the syntax supported by math, see the manual for
the bc program. Keep in mind that parameter expansion takes place on
any expressions before they are evaluated. This can be very useful in
order to perform calculations involving shell variables or the
output of command substitutions, but it also means that parenthesis
have to be escaped.
\subsection math-example Examples
<code>math 1+1</code> outputs 2.
`math 1+1` outputs 2.
<code>math $status-128</code> outputs the numerical exit status of the
last command minus 128.
`math $status-128` outputs the numerical exit status of the last command minus 128.

View file

@ -1,26 +1,28 @@
\section mimedb mimedb - lookup file information via the mime database
\subsection mimedb-synopsis Synopsis
<tt>mimedb [OPTIONS] FILES...</tt>
\fish{synopsis}
mimedb [OPTIONS] FILES...
\endfish
\subsection mimedb-description Description
\c mimedb queries the MIME type database and the \c .desktop files
installed on the system in order to find information on
the files listed in <code>FILES</code>. The information that \c mimedb
can retrieve includes the MIME type for a file, a description of the type,
and the default action that can be performed on the file. \c mimedb can also
be used to launch the default action for this file.
`mimedb` queries the MIME type database and the `.desktop` files installed on the system in order to find information on the files listed in `FILES`. The information that `mimedb` can retrieve includes the MIME type for a file, a description of the type, and the default action that can be performed on the file. `mimedb` can also be used to launch the default action for this file.
The following options are available:
- \c -t, \c --input-file-data determines the files' type both by their filename and by their contents (default behaviour).
- \c -f, \c --input-filename determines the files' type by their filename.
- \c -i, \c --input-mime specifies that the arguments are not files, but MIME types.
- \c -m, \c --output-mime outputs the MIME type of each file (default behaviour).
- \c -f, \c --output-description outputs the description of each MIME type.
- \c -a, \c --output-action outputs the default action of each MIME type.
- \c -l, \c --launch launches the default action for the specified files.
- \c -h, \c --help displays a help message and exit.
- \c -v, \c --version displays the version number and exits.
- `-t`, `--input-file-data` determines the files' type both by their filename and by their contents (default behaviour).
- `-f`, `--input-filename` determines the files' type by their filename.
- `-i`, `--input-mime` specifies that the arguments are not files, but MIME types.
- `-m`, `--output-mime` outputs the MIME type of each file (default behaviour).
- `-f`, `--output-description` outputs the description of each MIME type.
- `-a`, `--output-action` outputs the default action of each MIME type.
- `-l`, `--launch` launches the default action for the specified files.
- `-v`, `--version` displays the version number and exits.

View file

@ -1,24 +1,29 @@
\section nextd nextd - move forward through directory history
\subsection nextd-synopsis Synopsis
<tt>nextd [-l | --list] [POS]</tt>
\fish{synopsis}
nextd [ -l | --list ] [POS]
\endfish
\subsection nextd-description Description
<tt>nextd</tt> moves forwards <tt>POS</tt> positions in the history of visited
directories; if the end of the history has been hit, a warning is printed.
If the <code>-l></code> or <code>--list</code> flag is specified, the current
directory history is also displayed.
`nextd` moves forwards `POS` positions in the history of visited directories; if the end of the history has been hit, a warning is printed.
If the `-l` or `--list` flag is specified, the current directory history is also displayed.
\subsection nextd-example Example
\code
\fish
cd /usr/src
# Working directory is now /usr/src
cd /usr/src/fish-shell
# Working directory is now /usr/src/fish-shell
prevd
# Working directory is now /usr/src
nextd
# Working directory is now /usr/src/fish-shell</pre>
\endcode
# Working directory is now /usr/src/fish-shell
\endfish

View file

@ -1,21 +1,23 @@
\section not not - negate the exit status of a job
\subsection not-synopsis Synopsis
<tt>not COMMAND [OPTIONS...]</tt>
\fish{synopsis}
not COMMAND [OPTIONS...]
\endfish
\subsection not-description Description
\c not negates the exit status of another command. If the exit status
is zero, \c not returns 1. Otherwise, \c not returns 0.
`not` negates the exit status of another command. If the exit status is zero, `not` returns 1. Otherwise, `not` returns 0.
\subsection not-example Example
The following code reports an error and exits if no file named spoon can be found.
<pre>
\fish
if not test -f spoon
echo There is no spoon
exit 1
echo There is no spoon
exit 1
end
</pre>
\endfish

View file

@ -1,12 +1,15 @@
\section open open - open file in its default application
\subsection open-synopsis Synopsis
<tt>open FILES...</tt>
\fish{synopsis}
open FILES...
\endfish
\subsection open-description Description
\c open opens a file in its default application, using the \c xdg-open command if it exists, or else the <a href="commands.html#mimedb">mimedb</a> command.
`open` opens a file in its default application, using the `xdg-open` command if it exists, or else the <a href="commands.html#mimedb">mimedb</a> command.
\subsection open-example Example
<tt>open *.txt</tt> opens all the text files in the current directory using your system's default text editor.
`open *.txt` opens all the text files in the current directory using your system's default text editor.

View file

@ -1,27 +1,23 @@
\section or or - conditionally execute a command
\subsection or-synopsis Synopsis
<tt>COMMAND1; or COMMAND2</tt>
\fish{synopsis}
COMMAND1; or COMMAND2
\endfish
\subsection or-description Description
\c or is used to execute a command if the current exit
status (as set by the last previous command) is not 0.
`or` is used to execute a command if the current exit status (as set by the last previous command) is not 0.
\c or does not change the current exit status.
`or` does not change the current exit status.
The exit status of the last foreground command to exit can always be accessed using the <a href="index.html#variables-status">$status</a> variable.
The exit status of the last foreground command to exit can always be
accessed using the <a href="index.html#variables-status">$status</a>
variable.
\subsection or-example Example
The following code runs the \c make command to build a program. If the
build succeeds, the program is installed. If either step fails,
<tt>make clean</tt> is run, which removes the files created by the
build process.
The following code runs the `make` command to build a program. If the build succeeds, the program is installed. If either step fails, `make clean` is run, which removes the files created by the build process.
<pre>
\fish
make; and make install; or make clean
</pre>
\endfish

View file

@ -1,24 +1,27 @@
\section popd popd - move through directory stack
\subsection popd-synopsis Synopsis
<tt>popd</tt>
\fish{synopsis}
popd
\endfish
\subsection popd-description Description
<tt>popd</tt> removes the top directory from the directory stack and
changes the working directory to the new top directory. Use <a
href="#pushd"><tt>pushd</tt></a> to add directories to the stack.
`popd` removes the top directory from the directory stack and changes the working directory to the new top directory. Use <a href="#pushd">`pushd`</a> to add directories to the stack.
\subsection popd-example Example
<pre>
\fish
pushd /usr/src
# Working directory is now /usr/src
# Directory stack contains /usr/src
pushd /usr/src/fish-shell
# Working directory is now /usr/src/fish-shell
# Directory stack contains /usr/src /usr/src/fish-shell
popd
# Working directory is now /usr/src
# Directory stack contains /usr/src
</pre>
\endfish

View file

@ -1,26 +1,29 @@
\section prevd prevd - move backward through directory history
\subsection prevd-synopsis Synopsis
<tt>prevd [-l | --list] [POS]</tt>
\fish{synopsis}
prevd [ -l | --list ] [POS]
\endfish
\subsection prevd-description Description
<tt>prevd</tt> moves backwards <tt>POS</tt> positions in the history
of visited directories; if the beginning of the history has been hit,
a warning is printed.
`prevd` moves backwards `POS` positions in the history of visited directories; if the beginning of the history has been hit, a warning is printed.
If the `-l` or `--list` flag is specified, the current history is also displayed.
If the <code>-l</code> or <code>--list</code> flag is specified, the current
history is also displayed.
\subsection prevd-example Example
\code
\fish
cd /usr/src
# Working directory is now /usr/src
cd /usr/src/fish-shell
# Working directory is now /usr/src/fish-shell
prevd
# Working directory is now /usr/src
nextd
# Working directory is now /usr/src/fish-shell</pre>
\endcode
# Working directory is now /usr/src/fish-shell
\endfish

View file

@ -1,26 +1,20 @@
\section psub psub - perform process substitution
\subsection psub-synopsis Synopsis
<tt>COMMAND1 (COMMAND2|psub [-f]) </tt>
\fish{synopsis}
COMMAND1 ( COMMAND2 | psub [-f] )
\endfish
\subsection psub-description Description
Posix shells feature a syntax that is a mix between command
substitution and piping, called process substitution. It is used to
send the output of a command into the calling command, much like
command substitution, but with the difference that the output is not
sent through commandline arguments but through a named pipe, with the
filename of the named pipe sent as an argument to the calling
program. \c psub combined with a
regular command substitution provides the same functionality.
Posix shells feature a syntax that is a mix between command substitution and piping, called process substitution. It is used to send the output of a command into the calling command, much like command substitution, but with the difference that the output is not sent through commandline arguments but through a named pipe, with the filename of the named pipe sent as an argument to the calling program. `psub` combined with a regular command substitution provides the same functionality.
If the `-f` or `--file` switch is given to `psub`, `psub` will use a regular file instead of a named pipe to communicate with the calling process. This will cause `psub` to be significantly slower when large amounts of data are involved, but has the advantage that the reading process can seek in the stream.
If the \c -f or \c --file switch is given to <tt>psub</tt>, \c psub will use a
regular file instead of a named pipe to communicate with the calling
process. This will cause \c psub to be significantly slower when large
amounts of data are involved, but has the advantage that the reading
process can seek in the stream.
\subsection psub-example Example
<tt>diff (sort a.txt|psub) (sort b.txt|psub)</tt> shows the difference
between the sorted versions of files a.txt and b.txt.
\fish
diff (sort a.txt | psub) (sort b.txt | psub)
# shows the difference between the sorted versions of files `a.txt` and `b.txt`.
\endfish

View file

@ -1,23 +1,27 @@
\section pushd pushd - push directory to directory stack
\subsection pushd-synopsis Synopsis
<tt>pushd [DIRECTORY]</tt>
\fish{synopsis}
pushd [DIRECTORY]
\endfish
\subsection pushd-description Description
The <tt>pushd</tt> function adds \c DIRECTORY to the top of the directory stack
and makes it the current working directory. <a href="#popd"><tt>popd</tt></a> will pop it off and
return to the original directory.
The `pushd` function adds `DIRECTORY` to the top of the directory stack and makes it the current working directory. <a href="#popd">`popd`</a> will pop it off and return to the original directory.
\subsection pushd-example Example
<pre>
\fish
pushd /usr/src
# Working directory is now /usr/src
# Directory stack contains /usr/src
pushd /usr/src/fish-shell
# Working directory is now /usr/src/fish-shell
# Directory stack contains /usr/src /usr/src/fish-shell
popd
# Working directory is now /usr/src
# Directory stack contains /usr/src
</pre>
\endfish

View file

@ -1,10 +1,12 @@
\section pwd pwd - output the current working directory
\subsection pwd-synopsis Synopsis
<tt>pwd</tt>
\fish{synopsis}
pwd
\endfish
\subsection pwd-description Description
\c pwd outputs (prints) the current working directory.
`pwd` outputs (prints) the current working directory.
Note that \c fish always resolves symbolic links in the current directory path.
Note that `fish` always resolves symbolic links in the current directory path.

View file

@ -1,25 +1,24 @@
\section random random - generate random number
\subsection random-synopsis Synopsis
<tt>random [SEED]</tt>
\fish{synopsis}
random [SEED]
\endfish
\subsection random-description Description
\c random outputs a random number from 0 to 32766, inclusive.
`random` outputs a random number from 0 to 32766, inclusive.
If a `SEED` value is provided, it is used to seed the random number generator, and no output will be produced. This can be useful for debugging purposes, where it can be desirable to get the same random number sequence multiple times. If the random number generator is called without first seeding it, the current time will be used as the seed.
If a \c SEED value is provided, it is used to seed the random number
generator, and no output will be produced. This can be useful for debugging
purposes, where it can be desirable to get the same random number sequence
multiple times. If the random number generator is called without first
seeding it, the current time will be used as the seed.
\subsection random-example Example
The following code will count down from a random number to 1:
<pre>
\fish
for i in (seq (random) -1 1)
echo $i
sleep
echo $i
sleep
end
</pre>
\endfish

View file

@ -1,43 +1,49 @@
\section read read - read line of input into variables
\subsection read-synopsis Synopsis
<tt>read [OPTIONS] [VARIABLES...]</tt>
\fish{synopsis}
read [OPTIONS] [VARIABLES...]
\endfish
\subsection read-description Description
<tt>read</tt> reads one line from standard
input and stores the result in one or more shell variables.
`read` reads one line from standard input and stores the result in one or more shell variables.
The following options are available:
- <tt>-c CMD</tt> or <tt>--command=CMD</tt> sets the initial string in the interactive mode command buffer to <tt>CMD</tt>.
- <tt>-g</tt> or <tt>--global</tt> makes the variables global.
- <tt>-l</tt> or <tt>--local</tt> makes the variables local.
- <tt>-m NAME</tt> or <tt>--mode-name=NAME</tt> specifies that the name NAME should be used to save/load the history file. If NAME is fish, the regular fish history will be available.
- <tt>-n NCHARS</tt> or <tt>--nchars=NCHARS</tt> causes \c read to return after reading NCHARS characters rather than waiting for a complete line of input.
- <tt>-p PROMPT_CMD</tt> or <tt>--prompt=PROMPT_CMD</tt> uses the output of the shell command \c PROMPT_CMD as the prompt for the interactive mode. The default prompt command is <tt>set_color green; echo read; set_color normal; echo "> "</tt>.
- <code>-s</code> or <code>--shell</code> enables syntax highlighting, tab completions and command termination suitable for entering shellscript code in the interactive mode.
- <code>-u</code> or <code>--unexport</code> prevents the variables from being exported to child processes (default behaviour).
- <code>-U</code> or <code>--universal</code> causes the specified shell variable to be made universal.
- <code>-x</code> or <code>--export</code> exports the variables to child processes.
- <code>-a</code> or <code>--array</code> stores the result as an array.
- `-c CMD` or `--command=CMD` sets the initial string in the interactive mode command buffer to `CMD`.
\c read reads a single line of input from stdin, breaks it into tokens
based on the <tt>IFS</tt> shell variable, and then assigns one
token to each variable specified in <tt>VARIABLES</tt>. If there are more
tokens than variables, the complete remainder is assigned to the last variable.
As a special case, if \c IFS is set to the empty string, each character of the
input is considered a separate token.
- `-g` or `--global` makes the variables global.
If \c -a or \c --array is provided, only one variable name is allowed and the
tokens are stored as an array in this variable.
- `-l` or `--local` makes the variables local.
- `-m NAME` or `--mode-name=NAME` specifies that the name NAME should be used to save/load the history file. If NAME is fish, the regular fish history will be available.
- `-n NCHARS` or `--nchars=NCHARS` causes `read` to return after reading NCHARS characters rather than waiting for a complete line of input.
- `-p PROMPT_CMD` or `--prompt=PROMPT_CMD` uses the output of the shell command `PROMPT_CMD` as the prompt for the interactive mode. The default prompt command is <code>set_color green; echo read; set_color normal; echo "> "</code>.
- `-s` or `--shell` enables syntax highlighting, tab completions and command termination suitable for entering shellscript code in the interactive mode.
- `-u` or `--unexport` prevents the variables from being exported to child processes (default behaviour).
- `-U` or `--universal` causes the specified shell variable to be made universal.
- `-x` or `--export` exports the variables to child processes.
- `-a` or `--array` stores the result as an array.
`read` reads a single line of input from stdin, breaks it into tokens based on the `IFS` shell variable, and then assigns one token to each variable specified in `VARIABLES`. If there are more tokens than variables, the complete remainder is assigned to the last variable. As a special case, if `IFS` is set to the empty string, each character of the input is considered a separate token.
If `-a` or `--array` is provided, only one variable name is allowed and the tokens are stored as an array in this variable.
See the documentation for `set` for more details on the scoping rules for variables.
See the documentation for \c set for more details on the scoping rules for
variables.
\subsection read-example Example
The following code stores the value 'hello' in the shell variable
<tt>$foo</tt>.
The following code stores the value 'hello' in the shell variable `$foo`.
<tt>echo hello|read foo</tt>
\fish
echo hello|read foo
\endfish

View file

@ -1,26 +1,25 @@
\section return return - stop the current inner function
\subsection return-synopsis Synopsis
<tt>function NAME; [COMMANDS...;] return [STATUS]; [COMMANDS...;] end</tt>
\fish{synopsis}
function NAME; [COMMANDS...;] return [STATUS]; [COMMANDS...;] end
\endfish
\subsection return-description Description
\c return halts a currently running function. The exit status is set
to \c STATUS if it is given.
`return` halts a currently running function. The exit status is set to `STATUS` if it is given.
It is usually added inside of a conditional block such as an <a href="#if">if</a> statement or a <a href="#switch">switch</a> statement to conditionally stop the executing function and return to the caller, but it can also be used to specify the exit status of a function.
It is usually added inside of a conditional block such as an <a
href="#if">if</a> statement or a <a href="#switch">switch</a>
statement to conditionally stop the executing function and return to
the caller, but it can also be used to specify the exit status of a
function.
\subsection return-example Example
The following code is an implementation of the false command as a fish function
<pre>
\fish
function false
return 1
return 1
end
</pre>
\endfish

View file

@ -1,98 +1,94 @@
\section set set - display and change shell variables.
\subsection set-synopsis Synopsis
<pre>
\fish{synopsis}
set [SCOPE_OPTIONS]
set [OPTIONS] VARIABLE_NAME VALUES...
set [OPTIONS] VARIABLE_NAME[INDICES]... VALUES...
set (-q | --query) [SCOPE_OPTIONS] VARIABLE_NAMES...
set (-e | --erase) [SCOPE_OPTIONS] VARIABLE_NAME
set (-e | --erase) [SCOPE_OPTIONS] VARIABLE_NAME[INDICES]...
</pre>
set ( -q | --query ) [SCOPE_OPTIONS] VARIABLE_NAMES...
set ( -e | --erase ) [SCOPE_OPTIONS] VARIABLE_NAME
set ( -e | --erase ) [SCOPE_OPTIONS] VARIABLE_NAME[INDICES]...
\endfish
\subsection set-description Description
<code>set</code> manipulates <a href="index.html#variables">shell
variables</a>.
`set` manipulates <a href="index.html#variables">shell variables</a>.
If set is called with no arguments, the names and values of all
shell variables are printed. If some of the scope or export
flags have been given, only the variables matching the specified scope
are printed.
If set is called with no arguments, the names and values of all shell variables are printed. If some of the scope or export flags have been given, only the variables matching the specified scope are printed.
With both variable names and values provided, \c set assigns the variable
<code>VARIABLE_NAME</code> the values <code>VALUES...</code>.
With both variable names and values provided, `set` assigns the variable `VARIABLE_NAME` the values `VALUES...`.
The following options control variable scope:
- <code>-l</code> or <code>--local</code> forces the specified shell variable to be given a scope that is local to the current block, even if a variable with the given name exists and is non-local
- <code>-g</code> or <code>--global</code> causes the specified shell variable to be given a global scope. Non-global variables disappear when the block they belong to ends
- <code>-U</code> or <code>--universal</code> 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 users fish instances on the current computer, and will be preserved across restarts of the shell.
- <code>-x</code> or <code>--export</code> causes the specified shell variable to be exported to child processes (making it an "environment variable")
- <code>-u</code> or <code>--unexport</code> causes the specified shell variable to NOT be exported to child processes
- `-l` or `--local` forces the specified shell variable to be given a scope that is local to the current block, even if a variable with the given name exists and is non-local
- `-g` or `--global` causes the specified shell variable to be given a global scope. Non-global variables disappear when the block they belong to ends
- `-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 users fish instances on the current computer, and will be preserved across restarts of the shell.
- `-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
The following options are available:
- <code>-e</code> or <code>--erase</code> causes the specified shell variable to be erased
- <code>-q</code> or <code>--query</code> 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.
- <code>-n</code> or <code>--names</code> List only the names of all defined variables, not their value
- <code>-L</code> or <code>--long</code> do not abbreviate long values when printing set variables
If a variable is set to more than one value, the variable will be an
array with the specified elements. If a variable is set to zero
elements, it will become an array with zero elements.
- `-e` or `--erase` causes the specified shell variable to be erased
If the variable name is one or more array elements, such as
<code>PATH[1 3 7]</code>, only those array elements specified will be
changed. When array indices are specified to \c set, multiple arguments
may be used to specify additional indexes, e.g. <code>set PATH[1]
PATH[4] /bin /sbin</code>. If you specify a negative index when
expanding or assigning to an array variable, the index will be
calculated from the end of the array. For example, the index -1 means
the last index of an array.
- `-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.
- `-n` or `--names` List only the names of all defined variables, not their value
- `-L` or `--long` do not abbreviate long values when printing set variables
If a variable is set to more than one value, the variable will be an array with the specified elements. If a variable is set to zero elements, it will become an array with zero elements.
If the variable name is one or more array elements, such as `PATH[1 3 7]`, only those array elements specified will be changed. When array indices are specified to `set`, multiple arguments may be used to specify additional indexes, e.g. `set PATH[1] PATH[4] /bin /sbin`. If you specify a negative index when expanding or assigning to an array variable, the index will be calculated from the end of the array. For example, the index -1 means the last index of an array.
The scoping rules when creating or updating a variable are:
-# If a variable is explicitly set to either universal, global or local, that setting will be honored. If a variable of the same name exists in a different scope, that variable will not be changed.
-# 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 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 \c -l or \c --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:
-# 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 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:
-# If a variable is explicitly set to either be exported or not exported, that setting will be honored.
-# 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.
In erase mode, if variable indices are specified, only the specified
slices of the array variable will be erased.
In erase mode, if variable indices are specified, only the specified slices of the array variable will be erased.
\c set requires all options to come before any
other arguments. For example, <code>set flags -l</code> will have
the effect of setting the value of the variable <code>flags</code> 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 `flags` to '-l', not making the variable local.
In assignment mode, `set` exits with a non-zero exit status if variable assignments could not be successfully performed. If the variable assignments were performed, the exit status is unchanged. This allows simultaneous capture of the output and exit status of a subcommand, e.g. `if set output (command)`. In query mode, the exit status is the number of variables that were not found. In erase mode, `set` exits with a zero exit status in case of success, with a non-zero exit status if the commandline was invalid, if the variable was write-protected or if the variable did not exist.
In assignment mode, \c set exits with a non-zero exit status if variable
assignments could not be successfully performed. If the variable assignments
were performed, the exit status is unchanged. This allows simultaneous capture
of the output and exit status of a subcommand, e.g. <code>if set output
(command)</code>. In query mode, the exit status is the number of variables that
were not found. In erase mode, \c set exits with a zero exit status in case of
success, with a non-zero exit status if the commandline was invalid, if the
variable was write-protected or if the variable did not exist.
\subsection set-example Example
\fish
set -xg
# Prints all global, exported variables.
<code>set -xg</code> will print all global, exported variables.
set foo hi
# Sets the value of the variable $foo to be 'hi'.
<code>set foo hi</code> sets the value of the variable foo to be hi.
set -e smurf
# Removes the variable $smurf
<code>set -e smurf</code> removes the variable \c smurf.
set PATH[4] ~/bin
# Changes the fourth element of the $PATH array to ~/bin
<code>set PATH[4] ~/bin</code> changes the fourth element of the \c PATH array to \c ~/bin
<pre>if set python_path (which python)
if set python_path (which python)
echo "Python is at $python_path"
end</pre>
The above outputs the path to Python if \c which returns true.
end
# Outputs the path to Python if `which` returns true.
\endfish

View file

@ -1,44 +1,41 @@
\section set_color set_color - set the terminal color
\subsection set_color-synopsis Synopsis
<tt>set_color [-h --help] [-b --background COLOR] [COLOR]</tt>
\fish{synopsis}
set_color [OPTIONS] [COLOR]
\endfish
\subsection set_color-description Description
\c set_color changes the foreground and/or background color of the terminal.
\c COLOR is one of black, red, green, brown, yellow, blue, magenta,
purple, cyan, white and normal.
`set_color` changes the foreground and/or background color of the terminal. `COLOR` is one of black, red, green, brown, yellow, blue, magenta, purple, cyan, white and normal.
If your terminal supports term256 (modern xterms and OS X Lion),
you can specify an RGB value with three or six hex digits, such
as A0FF33 or f2f. \c fish will choose the closest supported color.
If your terminal supports term256 (modern xterms and OS X Lion), you can specify an RGB value with three or six hex digits, such as A0FF33 or f2f. `fish` will choose the closest supported color.
The following options are available:
- \c -b, \c --background \c COLOR sets the background color.
- \c -c, \c --print-colors prints a list of all valid color names.
- \c -h, \c --help displays a help message and exit.
- \c -o, \c --bold sets bold or extra bright mode.
- \c -u, \c --underline sets underlined mode.
- `-b`, `--background` `COLOR` sets the background color.
Calling <tt>set_color normal</tt> will set the terminal color to
the default color of the terminal.
- `-c`, `--print-colors` prints a list of all valid color names.
Some terminals use the --bold escape sequence to switch to a brighter
color set. On such terminals, <code>set_color white</code> will result
in a grey font color, while <code>set_color --bold white</code> will
result in a white font color.
- `-o`, `--bold` sets bold or extra bright mode.
- `-u`, `--underline` sets underlined mode.
Calling `set_color normal` will set the terminal color to the default color of the terminal.
Some terminals use the `--bold` escape sequence to switch to a brighter color set. On such terminals, `set_color white` will result in a grey font color, while `set_color --bold white` will result in a white font color.
Not all terminal emulators support all these features.
\c set_color 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 may lack color information for
terminals that support it.
`set_color` 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 may lack color information for terminals that support it.
\subsection set_color-example Examples
<pre>set_color red; echo "Roses are red"
\fish
set_color red; echo "Roses are red"
set_color blue; echo "Violets are blue"
set_color 62A ; echo "Eggplants are dark purple"
set_color 62A; echo "Eggplants are dark purple"
set_color normal; echo "Normal is nice too"
</pre>
\endfish

View file

@ -1,30 +1,24 @@
\section source source - evaluate contents of file.
\subsection source-synopsis Synopsis
<tt>source FILENAME [ARGUMENTS...]</tt>
\fish{synopsis}
source FILENAME [ARGUMENTS...]
\endfish
\subsection source-description Description
\c source evaluates the commands of the specified file in the current
shell. This is different from starting a new process to perform the
commands (i.e. <tt>fish < FILENAME</tt>) since the commands will be
evaluated by the current shell, which means that changes in
shell variables will affect the current shell. If additional arguments are
specified after the file name, they will be inserted into the $argv
variable.
`source` evaluates the commands of the specified file in the current shell. This is different from starting a new process to perform the commands (i.e. `fish < FILENAME`) since the commands will be evaluated by the current shell, which means that changes in shell variables will affect the current shell. If additional arguments are specified after the file name, they will be inserted into the $argv variable.
If no file is specified, or if the file name '-' is used, stdin will
be read.
If no file is specified, or if the file name '`-`' is used, stdin will be read.
The return status of \c source is the return status of the last job to
execute. If something goes wrong while opening or reading the file,
\c source exits with a non-zero status.
The return status of `source` is the return status of the last job to execute. If something goes wrong while opening or reading the file, `source` exits with a non-zero status.
`.` (a single period) is an alias for the `source` command. The use of `.` is deprecated in favour of `source`, and `.` will be removed in a future version of fish.
\c . (a single period) is an alias for the \c source command. The use of \c .
is deprecated in favour of \c source, and \c . will be removed in a future
version of fish.
\subsection source-example Example
<tt>source ~/.config/fish/config.fish</tt> causes fish to re-read its initialization file.
\fish
source ~/.config/fish/config.fish
# Causes fish to re-read its initialization file.
\endfish

View file

@ -1,21 +1,34 @@
\section status status - query fish runtime information
\subsection status-synopsis Synopsis
<tt>status [OPTION]</tt>
\fish{synopsis}
status [OPTION]
\endfish
\subsection status-description Description
With no arguments, <tt>status</tt> displays a summary of the current login and job control status of the shell.
With no arguments, `status` displays a summary of the current login and job control status of the shell.
The following options are available:
- <tt>-c</tt> or <tt>--is-command-substitution</tt> returns 0 if fish is currently executing a command substitution.
- <tt>-b</tt> or <tt>--is-block</tt> returns 0 if fish is currently executing a block of code.
- <tt>-i</tt> or <tt>--is-interactive</tt> returns 0 if fish is interactive - that is, connected to a keyboard.
- <tt>-l</tt> or <tt>--is-login</tt> returns 0 if fish is a login shell - that is, if fish should perform login tasks such as setting up the PATH.
- <tt>--is-full-job-control</tt> returns 0 if full job control is enabled.
- <tt>--is-interactive-job-control</tt> returns 0 if interactive job control is enabled.
- <tt>--is-no-job-control</tt> returns 0 if no job control is enabled.
- <tt>-f</tt> or <tt>--current-filename</tt> prints the filename of the currently running script.
- <tt>-n</tt> or <tt>--current-line-number</tt> prints the line number of the currently running script.
- <tt>-j CONTROLTYPE</tt> or <tt>--job-control=CONTROLTYPE</tt> sets the job control type, which can be <tt>none</tt>, <tt>full</tt>, or <tt>interactive</tt>.
- <tt>-t</tt> or <tt>--print-stack-trace</tt> prints a stack trace of all function calls on the call stack.
- <tt>-h</tt> or <tt>--help</tt> displays a help message and exit.
- `-c` or `--is-command-substitution` returns 0 if fish is currently executing a command substitution.
- `-b` or `--is-block` returns 0 if fish is currently executing a block of code.
- `-i` or `--is-interactive` returns 0 if fish is interactive - that is, connected to a keyboard.
- `-l` or `--is-login` returns 0 if fish is a login shell - that is, if fish should perform login tasks such as setting up the PATH.
- `--is-full-job-control` returns 0 if full job control is enabled.
- `--is-interactive-job-control` returns 0 if interactive job control is enabled.
- `--is-no-job-control` returns 0 if no job control is enabled.
- `-f` or `--current-filename` prints the filename of the currently running script.
- `-n` or `--current-line-number` prints the line number of the currently running script.
- `-j CONTROLTYPE` or `--job-control=CONTROLTYPE` sets the job control type, which can be `none`, `full`, or `interactive`.
- `-t` or `--print-stack-trace` prints a stack trace of all function calls on the call stack.

View file

@ -1,35 +1,26 @@
\section switch switch - conditionally execute a block of commands
\subsection switch-synopsis Synopsis
<tt>switch VALUE; [case [WILDCARD...]; [COMMANDS...]; ...] end</tt>
\fish{synopsis}
switch VALUE; [case [WILDCARD...]; [COMMANDS...]; ...] end
\endfish
\subsection switch-description Description
\c switch performs one of several blocks of commands, depending on whether
a specified value equals one of several wildcarded values. \c case is used
together with the \c switch statement in order to determine which block should
be executed.
`switch` performs one of several blocks of commands, depending on whether a specified value equals one of several wildcarded values. `case` is used together with the `switch` statement in order to determine which block should be executed.
Each \c case command is given one or more parameters. The first \c case
command with a parameter that matches the string specified in the
switch command will be evaluated. \c case parameters may contain
wildcards. These need to be escaped or quoted in order to avoid
regular wildcard expansion using filenames.
Each `case` command is given one or more parameters. The first `case` command with a parameter that matches the string specified in the switch command will be evaluated. `case` parameters may contain wildcards. These need to be escaped or quoted in order to avoid regular wildcard expansion using filenames.
Note that fish does not fall through on case statements. Only the
first matching case is executed.
Note that fish does not fall through on case statements. Only the first matching case is executed.
Note that command substitutions in a case statement will be evaluated even if its body is not taken. All substitutions, including command substitutions, must be performed before the value can be compared against the parameter.
Note that command substitutions in a case statement will be
evaluated even if its body is not taken. All substitutions, including
command substitutions, must be performed before the value can be compared
against the parameter.
\subsection switch-example Example
If the variable \$animal contains the name of an animal, the following
code would attempt to classify it:
If the variable \$animal contains the name of an animal, the following code would attempt to classify it:
<pre>
\fish
switch $animal
case cat
echo evil
@ -42,8 +33,7 @@ switch $animal
case '*'
echo I have no idea what a $animal is
end
</pre>
If the above code was run with \c \$animal set to \c whale, the output
would be \c mammal.
\endfish
If the above code was run with `$animal` set to `whale`, the output
would be `mammal`.

View file

@ -1,109 +1,126 @@
\section test test - perform tests on files and text
\subsection test-synopsis Synopsis
<tt>test [EXPRESSION]</tt>
\fish{synopsis}
test [EXPRESSION]
\endfish
\subsection test-description Description
Tests the expression given and sets the exit status to 0 if true,
and 1 if false. An expression is made up of one or more operators
and their arguments.
Tests the expression given and sets the exit status to 0 if true, and 1 if false. An expression is made up of one or more operators and their arguments.
The following operators are available to examine files and directories:
- <tt>-b FILE</tt> returns true if \c FILE is a block device.
- <tt>-c FILE</tt> returns true if \c FILE is a character device.
- <tt>-d FILE</tt> returns true if \c FILE is a directory.
- <tt>-e FILE</tt> returns true if \c FILE exists.
- <tt>-f FILE</tt> returns true if \c FILE is a regular file.
- <tt>-g FILE</tt> returns true if \c FILE has the set-group-ID bit set.
- <tt>-G FILE</tt> returns true if \c FILE exists and has the same group ID
as the current user.
- <tt>-L FILE</tt> returns true if \c FILE is a symbolic link.
- <tt>-O FILE</tt> returns true if \c FILE exists and is owned by the current
user.
- <tt>-p FILE</tt> returns true if \c FILE is a named pipe.
- <tt>-r FILE</tt> returns true if \c FILE is marked as readable.
- <tt>-s FILE</tt> returns true if the size of \c FILE is greater than zero.
- <tt>-S FILE</tt> returns true if \c FILE is a socket.
- <tt>-t FD</tt> returns true if the file descriptor \c FD is a terminal (TTY).
- <tt>-u FILE</tt> returns true if \c FILE has the set-user-ID bit set.
- <tt>-w FILE</tt> returns true if \c FILE is marked as writable; note that this does not check if the filesystem is read-only.
- <tt>-x FILE</tt> returns true if \c FILE is marked as executable.
- `-b FILE` returns true if `FILE` is a block device.
- `-c FILE` returns true if `FILE` is a character device.
- `-d FILE` returns true if `FILE` is a directory.
- `-e FILE` returns true if `FILE` exists.
- `-f FILE` returns true if `FILE` is a regular file.
- `-g FILE` returns true if `FILE` has the set-group-ID bit set.
- `-G FILE` returns true if `FILE` exists and has the same group ID as the current user.
- `-L FILE` returns true if `FILE` is a symbolic link.
- `-O FILE` returns true if `FILE` exists and is owned by the current user.
- `-p FILE` returns true if `FILE` is a named pipe.
- `-r FILE` returns true if `FILE` is marked as readable.
- `-s FILE` returns true if the size of `FILE` is greater than zero.
- `-S FILE` returns true if `FILE` is a socket.
- `-t FD` returns true if the file descriptor `FD` is a terminal (TTY).
- `-u FILE` returns true if `FILE` has the set-user-ID bit set.
- `-w FILE` returns true if `FILE` is marked as writable; note that this does not check if the filesystem is read-only.
- `-x FILE` returns true if `FILE` is marked as executable.
The following operators are available to compare and examine text strings:
- <tt>STRING1 = STRING2</tt> returns true if the strings \c STRING1 and
\c STRING2 are identical.
- <tt>STRING1 != STRING2</tt> returns true if the strings \c STRING1 and
\c STRING2 are not identical.
- <tt>-n STRING</tt> returns true if the length of \c STRING is non-zero.
- <tt>-z STRING</tt> returns true if the length of \c STRING is zero.
- `STRING1 = STRING2` returns true if the strings `STRING1` and `STRING2` are identical.
- `STRING1 != STRING2` returns true if the strings `STRING1` and `STRING2` are not identical.
- `-n STRING` returns true if the length of `STRING` is non-zero.
- `-z STRING` returns true if the length of `STRING` is zero.
The following operators are available to compare and examine numbers:
- <tt>NUM1 -eq NUM2</tt> returns true if \c NUM1 and \c NUM2 are numerically equal.
- <tt>NUM1 -ne NUM2</tt> returns true if \c NUM1 and \c NUM2 are not numerically equal.
- <tt>NUM1 -gt NUM2</tt> returns true if \c NUM1 is greater than <tt>NUM2</tt>.
- <tt>NUM1 -ge NUM2</tt> returns true if \c NUM1 is greater than or equal to <tt>NUM2</tt>.
- <tt>NUM1 -lt NUM2</tt> returns true if \c NUM1 is less than <tt>NUM2</tt>.
- <tt>NUM1 -le NUM2</tt> returns true if \c NUM1 is less than or equal to <tt>NUM2</tt>.
Note that only integers are supported. For more complex mathematical
operations, including fractions, the \c env program may be useful. Consult the
documentation for your operating system.
- `NUM1 -eq NUM2` returns true if `NUM1` and `NUM2` are numerically equal.
- `NUM1 -ne NUM2` returns true if `NUM1` and `NUM2` are not numerically equal.
- `NUM1 -gt NUM2` returns true if `NUM1` is greater than `NUM2`.
- `NUM1 -ge NUM2` returns true if `NUM1` is greater than or equal to `NUM2`.
- `NUM1 -lt NUM2` returns true if `NUM1` is less than `NUM2`.
- `NUM1 -le NUM2` returns true if `NUM1` is less than or equal to `NUM2`.
Note that only integers are supported. For more complex mathematical operations, including fractions, the `env` program may be useful. Consult the documentation for your operating system.
Expressions can be combined using the following operators:
- <tt>COND1 -a COND2</tt> returns true if both \c COND1 and \c COND2 are true.
- <tt>COND1 -o COND2</tt> returns true if either \c COND1 or \c COND2 are true.
Expressions can be inverted using the \c ! operator:
- <tt>! EXPRESSION</tt> returns true if \c EXPRESSION is false, and false if
\c EXPRESSION is true.
- `COND1 -a COND2` returns true if both `COND1` and `COND2` are true.
- `COND1 -o COND2` returns true if either `COND1` or `COND2` are true.
Expressions can be inverted using the `!` operator:
- `! EXPRESSION` returns true if `EXPRESSION` is false, and false if `EXPRESSION` is true.
Expressions can be grouped using parentheses.
- <tt>( EXPRESSION )</tt> returns the value of <tt>EXPRESSION</tt>.
Note that parentheses will usually require escaping with <tt>\\(</tt> to avoid
being interpreted as a command substitution.
- `( EXPRESSION )` returns the value of `EXPRESSION`.
Note that parentheses will usually require escaping with `\(` to avoid being interpreted as a command substitution.
\subsection test-example Examples
If the \c /tmp directory exists, copy the \c /etc/motd file to it:
If the `/tmp` directory exists, copy the `/etc/motd` file to it:
<pre>
\fish
if test -d /tmp
cp /etc/motd /tmp/motd
end
</pre>
\endfish
If the variable \c MANPATH is defined and not empty, print the contents.
(If \c MANPATH is not defined, then it will expand to zero arguments, unless
quoted.)
If the variable `MANPATH` is defined and not empty, print the contents. (If `MANPATH` is not defined, then it will expand to zero arguments, unless quoted.)
<pre>
\fish
if test -n "$MANPATH"
echo $MANPATH
end
</pre>
\endfish
Parentheses and the \c -o and \c -a operators can be combined to produce
more complicated expressions. In this example, success is printed if there is
a \c /foo or \c /bar file as well as a \c /baz or \c /bat file.
Parentheses and the `-o` and `-a` operators can be combined to produce more complicated expressions. In this example, success is printed if there is a `/foo` or `/bar` file as well as a `/baz` or `/bat` file.
<pre>
if test \\( -f /foo -o -f /bar \\) -a \\( -f /baz -o -f /bat \\)
\fish
if test \( -f /foo -o -f /bar \) -a \( -f /baz -o -f /bat \)
echo Success.
end.
</pre>
\endfish
\subsection test-standards Standards
\c 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:
- The \c < and \c > operators for comparing strings are not implemented.
- Because this test is a shell builtin and not a standalone utility, using
the -c flag on a special file descriptors like standard input and output
may not return the same result when invoked from within a pipe as one
would expect when invoking the \c test utility in another shell.
In cases such as this, one can use \c command \c test to explicitly
use the system's standalone \c test rather than this \c builtin \c test.
`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:
- The `<` and `>` operators for comparing strings are not implemented.
- Because this test is a shell builtin and not a standalone utility, using the -c flag on a special file descriptors like standard input and output may not return the same result when invoked from within a pipe as one would expect when invoking the `test` utility in another shell.
In cases such as this, one can use `command` `test` to explicitly use the system's standalone `test` rather than this `builtin` `test`.

View file

@ -1,43 +1,37 @@
\section trap trap - perform an action when the shell receives a signal
\subsection trap-synopsis Synopsis
<tt>trap [OPTIONS] [[ARG] SIGSPEC ... ]</tt>
\fish{synopsis}
trap [OPTIONS] [[ARG] SIGSPEC ... ]
\endfish
\subsection trap-description Description
\c trap is a wrapper around the fish event delivery
framework. It exists for backwards compatibility with POSIX
shells. For other uses, it is recommended to define an <a
href='index.html#event'>event handler</a>.
`trap` is a wrapper around the fish event delivery framework. It exists for backwards compatibility with POSIX shells. For other uses, it is recommended to define an <a href='index.html#event'>event handler</a>.
The following parameters are available:
- \c ARG is the command to be executed on signal delivery.
- \c SIGSPEC is the name of the signal to trap.
- \c -h or \c --help displays help and exits.
- \c -l or \c --list-signals prints a list of signal names.
- \c -p or \c --print prints all defined signal handlers.
- `ARG` is the command to be executed on signal delivery.
If \c ARG and \c SIGSPEC are both specified, \c ARG is the command to be
executed when the signal specified by \c SIGSPEC is delivered.
- `SIGSPEC` is the name of the signal to trap.
If \c ARG is absent (and there is a single SIGSPEC) or -, each specified
signal is reset to its original disposition (the value it had upon
entrance to the shell). If \c ARG is the null string the signal
specified by each \c SIGSPEC is ignored by the shell and by the commands
it invokes.
- `-l` or `--list-signals` prints a list of signal names.
If \c ARG is not present and \c -p has been supplied, then the trap commands
associated with each \c SIGSPEC are displayed. If no arguments are
supplied or if only \c -p is given, \c trap prints the list of commands
associated with each signal.
- `-p` or `--print` prints all defined signal handlers.
Signal names are case insensitive and the \c SIG prefix is optional.
If `ARG` and `SIGSPEC` are both specified, `ARG` is the command to be executed when the signal specified by `SIGSPEC` is delivered.
The return status is 1 if any \c SIGSPEC is invalid; otherwise trap
returns 0.
If `ARG` is absent (and there is a single SIGSPEC) or -, each specified signal is reset to its original disposition (the value it had upon entrance to the shell). If `ARG` is the null string the signal specified by each `SIGSPEC` is ignored by the shell and by the commands it invokes.
If `ARG` is not present and `-p` has been supplied, then the trap commands associated with each `SIGSPEC` are displayed. If no arguments are supplied or if only `-p` is given, `trap` prints the list of commands associated with each signal.
Signal names are case insensitive and the `SIG` prefix is optional.
The return status is 1 if any `SIGSPEC` is invalid; otherwise trap returns 0.
\subsection trap-example Example
<code>trap "status --print-stack-trace" SIGUSR1</code> prints a stack trace
each time the \c SIGUSR1 signal is sent to the shell.
\fish
trap "status --print-stack-trace" SIGUSR1
# Prints a stack trace each time the SIGUSR1 signal is sent to the shell.
\endfish

File diff suppressed because it is too large Load diff

View file

@ -1,25 +1,32 @@
\section type type - indicate how a command would be interpreted
\subsection type-synopsis Synopsis
<tt>type [OPTIONS] NAME [NAME ...]</tt>
\fish{synopsis}
type [OPTIONS] NAME [NAME ...]
\endfish
\subsection type-description Description
With no options, \c type indicates how each \c NAME would be interpreted if used as a command name.
With no options, `type` indicates how each `NAME` would be interpreted if used as a command name.
The following options are available:
- \c -h or \c --help prints help and then exits.
- \c -a or \c --all prints all of possible definitions of the specified names.
- \c -f or \c --no-functions suppresses function and builtin lookup.
- \c -t or \c --type prints <tt>function</tt>, <tt>builtin</tt>, or <tt>file</tt> if \c NAME is a shell function, builtin, or disk file, respectively.
- \c -p or \c --path returns the name of the disk file that would be executed, or nothing if 'type -t name' would not return 'file'.
- \c -P or \c --force-path returns the name of the disk file that would be executed, or nothing if no file with the specified name could be found in the <tt>$PATH</tt>.
- \c -q or \c --quiet suppresses all output; this is useful when testing the exit status.
- `-a` or `--all` prints all of possible definitions of the specified names.
- `-f` or `--no-functions` suppresses function and builtin lookup.
- `-t` or `--type` prints `function`, `builtin`, or `file` if `NAME` is a shell function, builtin, or disk file, respectively.
- `-p` or `--path` returns the name of the disk file that would be executed, or nothing if `type -t name` would not return `file`.
- `-P` or `--force-path` returns the name of the disk file that would be executed, or nothing if no file with the specified name could be found in the <tt>$PATH</tt>.
- `-q` or `--quiet` suppresses all output; this is useful when testing the exit status.
\c type sets the exit status to 0 if the specified command was found,
and 1 if it could not be found.
\subsection type-example Example
<tt>type fg</tt> outputs the string 'fg is a shell builtin'.
\fish
type fg
# Outputs the string 'fg is a shell builtin'.
\endfish

View file

@ -1,66 +1,64 @@
\section ulimit ulimit - set or get resource usage limits
\subsection ulimit-synopsis Synopsis
<tt>ulimit [OPTIONS] [LIMIT]</tt>
\fish{synopsis}
ulimit [OPTIONS] [LIMIT]
\endfish
\subsection ulimit-description Description
\c ulimit builtin sets or outputs the resource usage limits of the
shell and any processes spawned by it. If a new limit value is
omitted, the current value of the limit of the resource is printed; otherwise,
the specified limit is set to the new value.
`ulimit` builtin sets or outputs the resource usage limits of the shell and any processes spawned by it. If a new limit value is omitted, the current value of the limit of the resource is printed; otherwise, the specified limit is set to the new value.
Use one of the following switches to specify which resource limit to set or report:
- <code>-c</code> or <code>--core-size</code>: the maximum size of core files created. By setting this limit to zero, core dumps can be disabled.
- <code>-d</code> or <code>--data-size</code>: the maximum size of a process' data segment.
- <code>-f</code> or <code>--file-size</code>: the maximum size of files created by the shell.
- <code>-l</code> or <code>--lock-size</code>: the maximum size that may be locked into memory.
- <code>-m</code> or <code>--resident-set-size</code>: the maximum resident set size.
- <code>-n</code> or <code>--file-descriptor-count</code>: the maximum number of open file descriptors (most systems do not allow this value to be set).
- <code>-s</code> or <code>--stack-size</code>: the maximum stack size.
- <code>-t</code> or <code>--cpu-time</code>: the maximum amount of CPU time in seconds.
- <code>-u</code> or <code>--process-count</code>: the maximum number of processes available to a single user.
- <code>-v</code> or <code>--virtual-memory-size</code> The maximum amount of virtual memory available to the shell.
- `-c` or `--core-size`: the maximum size of core files created. By setting this limit to zero, core dumps can be disabled.
- `-d` or `--data-size`: the maximum size of a process' data segment.
- `-f` or `--file-size`: the maximum size of files created by the shell.
- `-l` or `--lock-size`: the maximum size that may be locked into memory.
- `-m` or `--resident-set-size`: the maximum resident set size.
- `-n` or `--file-descriptor-count`: the maximum number of open file descriptors (most systems do not allow this value to be set).
- `-s` or `--stack-size`: the maximum stack size.
- `-t` or `--cpu-time`: the maximum amount of CPU time in seconds.
- `-u` or `--process-count`: the maximum number of processes available to a single user.
- `-v` or `--virtual-memory-size` The maximum amount of virtual memory available to the shell.
Note that not all these limits are available in all operating systems.
The value of limit can be a number in the unit specified for
the resource or one of the special values <tt>hard</tt>, <tt>soft</tt>, or <tt>unlimited</tt>,
which stand for the current hard limit, the current soft limit, and no
limit, respectively.
The value of limit can be a number in the unit specified for the resource or one of the special values `hard`, `soft`, or `unlimited`, which stand for the current hard limit, the current soft limit, and no limit, respectively.
If limit is given, it is the new value of the specified resource. If
no option is given, then \c -f is assumed. Values are in kilobytes,
except for \c -t, which is in seconds and \c -n and \c -u, which are unscaled
values. The return status is 0 unless an invalid option or argument is
supplied, or an error occurs while setting a new limit.
If limit is given, it is the new value of the specified resource. If no option is given, then `-f` is assumed. Values are in kilobytes, except for `-t`, which is in seconds and `-n` and `-u`, which are unscaled values. The return status is 0 unless an invalid option or argument is supplied, or an error occurs while setting a new limit.
\c ulimit also accepts the following switches that determine what type of
limit to set:
`ulimit` also accepts the following switches that determine what type of limit to set:
- <code>-H</code> or <code>--hard</code> sets hard resource limit
- <code>-S</code> or <code>--soft</code> sets soft resource limit
- `-H` or `--hard` sets hard resource limit
A hard limit can only be decreased. Once it is set it cannot be
increased; a soft limit may be increased up to the value of the hard
limit. If neither -H nor -S is specified, both the soft and hard
limits are updated when assigning a new limit value, and the soft
limit is used when reporting the current value.
- `-S` or `--soft` sets soft resource limit
The following additional options are also understood by <tt>ulimit</tt>:
A hard limit can only be decreased. Once it is set it cannot be increased; a soft limit may be increased up to the value of the hard limit. If neither -H nor -S is specified, both the soft and hard limits are updated when assigning a new limit value, and the soft limit is used when reporting the current value.
- <code>-a</code> or <code>--all</code> prints all current limits
- <code>-h</code> or <code>--help</code> displays help and exits.
The following additional options are also understood by `ulimit`:
The \c fish implementation of \c ulimit should behave identically to the
implementation in bash, except for these differences:
- `-a` or `--all` prints all current limits
The `fish` implementation of `ulimit` should behave identically to the implementation in bash, except for these differences:
- Fish `ulimit` supports GNU-style long options for all switches
- Fish `ulimit` does not support the `-p` option for getting the pipe size. The bash implementation consists of a compile-time check that empirically guesses this number by writing to a pipe and waiting for SIGPIPE. Fish does not do this because it this method of determining pipe size is unreliable. Depending on bash version, there may also be further additional limits to set in bash that do not exist in fish.
- Fish `ulimit` does not support getting or setting multiple limits in one command, except reporting all values using the -a switch
- Fish \c ulimit supports GNU-style long options for all switches
- Fish \c ulimit does not support the \c -p option for getting the pipe size. The bash implementation consists of a compile-time check that empirically guesses this number by writing to a pipe and waiting for SIGPIPE. Fish does not do this because it this method of determining pipe size is unreliable. Depending on bash version, there may also be further additional limits to set in bash that do not exist in fish.
- Fish \c ulimit does not support getting or setting multiple limits in one command, except reporting all values using the -a switch
\subsection ulimit-example Example
<tt>ulimit -Hs 64</tt> sets the hard stack size limit to 64 kB.
`ulimit -Hs 64` sets the hard stack size limit to 64 kB.

View file

@ -1,58 +1,41 @@
\section umask umask - set or get the file creation mode mask
\subsection umask-synopsis Synopsis
<code>umask [OPTIONS] [MASK]</code>
\fish{synopsis}
umask [OPTIONS] [MASK]
\endfish
\subsection umask-description Description
\c umask displays and manipulates the "umask", or file creation mode mask,
which is used to restrict the default access to files.
`umask` displays and manipulates the "umask", or file creation mode mask, which is used to restrict the default access to files.
The umask may be expressed either as an octal number, which represents
the rights that will be removed by default, or symbolically, which represents
the only rights that will be granted by default.
The umask may be expressed either as an octal number, which represents the rights that will be removed by default, or symbolically, which represents the only rights that will be granted by default.
Access rights are explained in the manual page for the \c chmod(1) program.
Access rights are explained in the manual page for the `chmod`(1) program.
With no parameters, the current file creation mode mask is printed as
an octal number.
With no parameters, the current file creation mode mask is printed as an octal number.
- <code>-h</code> or <code>--help</code> prints this message.
- <code>-S</code> or <code>--symbolic</code> prints the umask in symbolic form instead of octal form.
- <code>-p</code> or <code>--as-command</code> outputs the umask in a form that may be reused as input
- `-h` or `--help` prints this message.
If a numeric mask is specified as a parameter, the current shell's umask
will be set to that value, and the rights specified by that mask will be
removed from new files and directories by default.
- `-S` or `--symbolic` prints the umask in symbolic form instead of octal form.
If a symbolic mask is specified, the desired permission bits, and
not the inverse, should be specified. A symbolic mask is a comma
separated list of rights. Each right consists of three parts:
- `-p` or `--as-command` outputs the umask in a form that may be reused as input
- The first part specifies to whom this set of right applies, and can
be one of \c u, \c g, \c o or \c a, where \c u specifies the user who
owns the file, \c g specifies the group owner of the file, \c o
specific other users rights and \c a specifies all three should be
changed.
- The second part of a right specifies the mode, and can be one of \c
=, \c + or \c -, where \c = specifies that the rights should be set to
the new value, \c + specifies that the specified right should be added
to those previously specified and \c - specifies that the specified
rights should be removed from those previously specified.
- The third part of a right specifies what rights should be changed
and can be any combination of \c r, \c w and \c x, representing
read, write and execute rights.
If a numeric mask is specified as a parameter, the current shell's umask will be set to that value, and the rights specified by that mask will be removed from new files and directories by default.
If the first and second parts are skipped, they are assumed to be \c a
and \c =, respectively. As an example, <code>r,u+w</code> means all
users should have read access and the file owner should also have
write access.
If a symbolic mask is specified, the desired permission bits, and not the inverse, should be specified. A symbolic mask is a comma separated list of rights. Each right consists of three parts:
- The first part specifies to whom this set of right applies, and can be one of `u`, `g`, `o` or `a`, where `u` specifies the user who owns the file, `g` specifies the group owner of the file, `o` specific other users rights and `a` specifies all three should be changed.
- The second part of a right specifies the mode, and can be one of `=`, `+` or `-`, where `=` specifies that the rights should be set to the new value, `+` specifies that the specified right should be added to those previously specified and `-` specifies that the specified rights should be removed from those previously specified.
- The third part of a right specifies what rights should be changed and can be any combination of `r`, `w` and `x`, representing read, write and execute rights.
If the first and second parts are skipped, they are assumed to be `a` and `=`, respectively. As an example, `r,u+w` means all users should have read access and the file owner should also have write access.
Note that symbolic masks currently do not work as intended.
\subsection umask-example Example
<code>umask 177</code> or <code>umask u=rw</code> sets the file
creation mask to read and write for the owner and no permissions at
all for any other users.
`umask 177` or `umask u=rw` sets the file creation mask to read and write for the owner and no permissions at all for any other users.

274
doc_src/user_doc.css Normal file
View file

@ -0,0 +1,274 @@
* {
margin: 0;
box-sizing: border-box;
}
html { font-size: 62.5%; }
html, body {
min-height: 100%;
background: #fff;
color: #111;
}
body {
text-rendering: optimizeLegibility;
overflow: hidden;
}
.logo {
width: 210px;
height: 147px;
margin-left: 2rem;
margin-bottom: -3rem;
background-image: url(ascii_fish.png);
}
/*Top site index*/
.qindex {
font: 500 1.4rem/3.6rem DejaVuSansCondensed, DejaVuSans, Roboto, "Lucida Grande", Calibri, Verdana, "Helvetica Neue", Helvetica, Arial, sans-serif;
border: none;
color: white;
text-align: center;
position: relative;
background-color: #1f2d53;
width: 100%;
height: 3.6rem;
}
/* Don't show the header */
.header { display: none; }
/*Substructure*/
.contents {
margin: 0;
min-width: 570px;
}
.fish_left_bar, .fish_right_bar, .fish_only_bar {
position: absolute;
top: 3.6rem;
bottom: 0;
overflow-y: scroll;
-webkit-overflow-scrolling: touch; /* necessary for momentum scrolling */
font: 400 1.3rem/2.1rem DejaVuSans, Roboto, "Lucida Grande", Calibri, Verdana, "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.fish_left_bar {
width: 25rem;
color: white;
font-family: DejaVuSansCondensed, DejaVuSans, Roboto, "Lucida Grande", Calibri, Verdana, "Helvetica Neue", Helvetica, Arial, sans-serif;
background-color: #1f2d53;
}
.fish_right_bar {
margin-left: 25rem;
margin-right: 0;
padding: 0 3rem;
box-shadow: -0.3rem 0.3rem 1rem #000818;
}
.fish_only_bar {
width: 100%;
padding-bottom: 3rem;
}
hr {
height: 0;
border: none;
border-top: 1px solid #AAA;
}
/*Interaction*/
a { color: #3d5cb3; }
.qindex a {
color: white;
text-decoration: none;
}
.qindex a:hover { text-decoration: underline; }
.fish_left_bar a {
color: white;
text-decoration: none;
}
.fish_left_bar a:visited { color: inherit; }
.fish_left_bar a:hover { color: #88aaff; }
.fish_right_bar a { text-decoration: none; }
.fish_right_bar a:hover { text-decoration: underline; }
/* Adjust lists */
.fish_left_bar ul {
padding-left: 2rem;
padding-right: 1rem;
}
.fish_right_bar ul {
list-style-type: circle;
padding-left: 2.4rem;
margin: 1.4rem 0;
}
.fish_right_bar ul li {
margin-bottom: 0.6rem;
}
.fish_right_bar p > code {
display: inline-block;
}
/* Typography */
p { margin: 1rem 0; }
h1, h2, h3, h4, h5, h6 {
color: #1f2d53;
font-family: DejaVuSansCondensed-Bold, DejaVuSans, Roboto, "Lucida Grande", Calibri, Verdana, sans-serif;
}
h1 {
margin: 1.6rem 0 1rem 0;
font-weight: 700;
font-size: 1.7rem;
}
h2 {
margin: 1.6rem 0 1rem 0;
font-weight: 700;
font-size: 1.7rem;
}
h3 {
margin: 1rem 0 0.4rem 0;
font-weight: 500;
font-size: 1.5rem;
}
.interior_title {
font-size: 2rem;
margin: 2rem 0 1.4rem 0;
color: #414141;
padding-bottom: 10px;
border-bottom: 1px solid #AAA;
}
em {
font-style: normal;
}
/* Special Formmating */
/* Keyboard */
.key span {
display:none;
}
.key em {
margin-right: 2px;
}
.key em, .key b {
padding: 1px 4px;
background-color: #fafafa;
background: linear-gradient(to bottom, #eee 0%,#fafafa 100%);
border: 1px solid #bbb;
border-radius: 3px;
font-weight: normal;
white-space: nowrap;
box-shadow: 0 1px 2px #ddd;
}
/* Console display */
tt, code, pre, .fish {
font-family: "DejaVu Sans Mono", "Source Code Pro", Menlo, "Ubuntu Mono", Consolas, Monaco, "Lucida Console", monospace, fixed;
font-weight: 500;
text-shadow: 0 0 0 rgba(0,0,0,0.4); /*Stronger anti-aliasing*/
white-space: -moz-pre-wrap;
white-space: -pre-wrap;
white-space: -o-pre-wrap;
white-space: pre-wrap;
word-wrap: break-word;
}
/*Default 'light' console*/
.fish {
margin: 1rem 0;
padding: 0.6rem 1rem;
font-size: 1.2rem;
line-height: 1.8rem;
color: #111;
background-color: #fafafa;
border: 1px solid #bbb;
border-radius: 0.6rem;
box-shadow: 0 0.2rem 0.2rem #eee;
}
.comment, .suggest { color: #555; }
.command, .function, .binary { color: #223aa4; }
.argument, .path, .file { color: #5961cf; }
.string { color: #6c6d08; }
.operator, .variable, .match, .history { color: #1c8885; }
/* Synopsis variant */
.synopsis {
border: none;
color: #333;
text-shadow: 0 0 0 rgba(0,0,0,0.2);
background: none;
font-size: 1.3rem;
padding: 0;
box-shadow: none;
}
.synopsis .comment, .synopsis .suggest { color: #669; }
.synopsis .command, .synopsis .function, .synopsis .binary { color: #333; }
.synopsis .argument, .synopsis .path, .synopsis .file { color: #666; }
/* Console variants */
.cli-dark {
background-color: #222;
color: #ccc;
text-shadow: none;
padding: 0.6rem 1.2rem;
border-radius: 0.6rem;
}
.cli-dark .key em, .cli-dark .key b {
background-color: #ccc;
box-shadow: 0 0.1rem 0 #666;
border: 1px solid #333;
color: #000;
padding: 0 3px;
}
.cli-dark .comment { color: #c33; }
.cli-dark .command, .cli-dark .function, .cli-dark .binary { color: #6159de; }
.cli-dark .argument, .cli-dark .path, .cli-dark .file { color: #00afff; }
.cli-dark .redirect { color: #fff; }
.cli-dark .operator,.cli-dark .variable, .cli-dark .match, .cli-dark .history { color: #2ff; }
.cli-dark .string { color: #b3b206; }
.cli-dark .suggest, .cli-dark em { color: #777; }
.cli-dark .match { color: #2ff; }
.cli-dark .search_match { background-color: #a100a3; }
.cli-dark .cwd, .cli-dark .prompt .path { color: #2f2; }
.cli-dark .prompt { color: #999; }
.cli-dark .cursor { border-bottom: 2px solid #3F3; }
.cli-dark .underline { color: #00afff; text-decoration: underline; }
.cli-dark .error, .cli-dark .error .path { color: #f33; font-weight: bold; }
/*Menus*/
.menu { margin: 1.4rem 0; line-height: 2.2rem; }
.menu ul { list-style-type: none; }
.menu > ul li { position: relative; }
.menu > ul li:before {
content: "";
color: #88aaff;
font-size: 1.6rem;
position: absolute;
left: -1rem;
top: -1px;
}
/*Page overrides*/
/*Documentation*/
.docs_menu { line-height: 2rem; }
.docs_menu > ul > li { position: static; }
.docs_menu > ul ul { margin: 0.6rem 0; }
.docs_menu > ul ul > li { margin-bottom: 0.2rem; }
/*Tutorial*/
.tutorial_menu { margin-left: 2rem; }
/*Design*/
.design {
max-width: 780px;
margin: 0 auto;
padding: 0 4rem;
}
/*Commands*/
.commands_menu { line-height: 2rem; margin-left: 2rem; }
/*FAQ*/
.faq_menu { line-height: 2rem; margin-top: 4rem; margin-right: 2rem;}
.faq_menu > ul > li { position: static; }
.faq_menu > ul li { margin-bottom: 0.6rem; }
/*Licenses*/
.license {
max-width: 780px;
margin: 0 auto;
padding: 0 4rem;
}
.license li { margin: 1rem 0; }
.license ul li:first-child {
list-style-type: none;
position: relative;
}
.license ul li:first-child:before {
content: "0.";
position: absolute;
left: -2rem;
}

View file

@ -0,0 +1,2 @@
</body>
</html>

View file

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="generator" content="Doxygen $doxygenversion"/>
<title>$projectname: $title</title>
$extrastylesheet
</head>
<body>
<div id="top" class="qindex"><!-- do not close this div here, it is closed by doxygen! -->
<a href="http://fishshell.com/"><code>fish</code> shell</a>
|
<a href="index.html">Documentation</a>
|
<a href="tutorial.html">Tutorial</a>
|
<a href="design.html">Design</a>
|
<a href="commands.html">Commands</a>
|
<a href="faq.html">FAQ</a>
|
<a href="license.html">License</a>

View file

@ -1,14 +1,15 @@
\section vared vared - interactively edit the value of an environment variable
\subsection vared-synopsis Synopsis
<tt>vared VARIABLE_NAME</tt>
\fish{synopsis}
vared VARIABLE_NAME
\endfish
\subsection vared-description Description
\c vared is used to interactively edit the value of an environment
variable. Array variables as a whole can not be edited using \c vared,
but individual array elements can.
`vared` is used to interactively edit the value of an environment variable. Array variables as a whole can not be edited using `vared`, but individual array elements can.
\subsection vared-example Example
<code>vared PATH[3]</code> edits the third element of the PATH array
`vared PATH[3]` edits the third element of the PATH array

View file

@ -1,21 +1,22 @@
\section while while - perform a command multiple times
\subsection while-synopsis Synopsis
<tt>while CONDITION; COMMANDS...; end</tt>
\fish{synopsis}
while CONDITION; COMMANDS...; end
\endfish
\subsection while-description Description
<tt>while</tt> repeatedly executes <tt>CONDITION</tt>, and if the exit status
is 0, then executes <tt>COMMANDS</tt>.
If the exit status of \c CONDITION is non-zero on the first iteration,
\c COMMANDS will not be executed at all.
`while` repeatedly executes `CONDITION`, and if the exit status is 0, then executes `COMMANDS`.
If the exit status of `CONDITION` is non-zero on the first iteration, `COMMANDS` will not be executed at all.
Use <a href="#begin">`begin; ...; end`</a> for complex conditions; more complex control can be achieved with `while true` containing a <a href="#break">break</a>.
Use <a href="#begin"><tt>begin; ...; end</tt></a> for complex conditions; more
complex control can be achieved with <tt>while true</tt> containing a
<a href="#break">break</a>.
\subsection while-example Example
<tt>while test -f foo.txt; echo file exists; sleep 10; end</tt>
outputs 'file exists' at 10 second intervals as long as
the file foo.txt exists.
\fish
while test -f foo.txt; echo file exists; sleep 10; end
# outputs 'file exists' at 10 second intervals as long as the file foo.txt exists.
\endfish

624
lexicon_filter.in Normal file
View file

@ -0,0 +1,624 @@
#! @sed@ -f
#.
# A Doxygen filter for building Fish's lexicon, for documentation bling.
#.
# Written specially for Fish, the shell for the 90's, in sed, the state of the
# art text processor from the 70's. Who's sed? sed's dead, baby, sed's dead.*
# by Mark Griffiths <mark@thebespokepixel.com> *but quite portable
#.
# Finds /fish../endfish blocks in documentation source files and enhances
# markup. Requires that the four character word 'classes' declared here are
# added to Doxyfiles as aliases i.e.:
#.
# Enhance for HTML Help pages (Doxyfile.user)…
# ALIASES = "fish=\htmlonly[block] \n<pre class=\"fish\">"
# ALIASES += "fish{1}=\htmlonly[block] \n<pre class=\"fish \1\">"
# ALIASES += "endfish=</pre>\endhtmlonly \n"
#.
# ALIASES += "blah{1}=<span class=\"comment\">\1</span>"
# ALIASES += "bltn{1}=<span class=\"command\">\1</span>" and so on...
#.
# And simplify for man pages (Doxyfile.help)…
# ALIASES = "fish=<pre>"
# ALIASES += "fish{1}=<pre>"
# ALIASES += "endfish=</pre>"
#.
# ALIASES += "blah{1}=\1"
# ALIASES += "bltn{1}=<em>\1</em>"...
#.
# It's meant to only ever be run once, during make, as Doxygen's 'INPUT
# FILTER', though can be run interactively by passing a file in via stdin. It
# wont respond to arguments.
#.
# It's most easily tested by passing test strings into the compiled script:
#.
# echo "/fish Line to test" | ./fish_lexicon_filter
#.
# The, at times, archiac looking regex is down to ensuring portable sed BREs
#.
# Licensed under whatever terms are most compatible with Fish's GPLv2 license,
# bascially free to use/reuse/redistribute/laugh at/be inspired by. Don't
# pretend it's your code unless you've spent more late nights on it than me but
# if it saves you a late night, do what you can to help rebalance karma. If it
# doesn't work or breaks something, it's your fault for using it: if it seems
# to work it's more likely a hallucination than anything based in reality.
#.
# Pattern flow control for scanning doc.h
/\\fish/,/\\endfish/ {
# Open \fish block, firstly it it's on it's own line
/^\\fish$/b
/^\\fish{[^}]*}$/b
# Then if it's inline. Remove and process immediately...
/^\\fish.*$/ {
# Catch @ symbol
s/@/(at)/
s/^\\fish//
s/\\endfish//
b html
}
# Output blank lines
/^$/b
# Inside \fish block. Process...
/\\endfish/!{
# Catch @ symbol
s/@/((d))/
# Preprocess HTML and HTML-like formatting
/<[^>]*>/ {
b html
}
# Process the rest
b process
}
# End block
/\\endfish/b
}
#.
# This is not the pattern we're looking for
b
#.
# Process any HTML tags.
# Structured to reduce sed's greediness.
:html
# Spans
s|<span style=['"]\([^'"][^'"]*\)">|@span{\1,|
s|<span class=['"]\([^'"][^'"]*\)">|@spcl{\1,|
s|</span>|}|
#.
# Bold
s|<b>|@bold{|
s|<b [^>]*>|@bold{|
s|</b>|}|
#.
# Strong (synonimous with emphasis)
s|<strong>|@bold{|
s|<strong [^>]*>|@bold{|
s|</strong>|}|
#.
# EMPHasis
s|<em>|@emph{|
s|<em [^>]*>|@emph{|
s|</em>|}|
#.
# Italic (synonimous with emphasis)
s|<i>|@emph{|
s|<i [^>]*>|@emph{|
s|</i>|}|
#.
# UNDeRline
s|<u>|@undr{|
s|<u [^>]*>|@undr{|
s|</u>|}|
t html
#.
# Some handy non-standard extensions
# autoSuGgeSTion
s|<s>|@sgst{|
s|<s [^>]*>|@sgst{|
s|</s>|}|
#.
# MaTCH
s|<m>|@mtch{|
s|<m [^>]*>|@mtch{|
s|</m>|}|
#.
# SearchMaTCh
s|<sm>|@smtc{|
s|<sm [^>]*>|@smtc{|
s|</sm>|}|
#.
# ERrOR
s|<error>|@eror{|
s|<error [^>]*>|@eror{|
s|</error>|}|
#.
# AsIs - protect from auto-formatting
s|<asis>|@asis{|
s|</asis>|}|
#.
# OUTPut - protect from auto-formatting
s|<outp>|@outp{|
s|</outp>|}|
t html
#.
# Clean other unhandled html
s|<\([A-Za-z][A-Za-z]*\)[^>]*>\([^<]*\)</\1>|\2|
t html
#.
# Start processing entities
:process
# Output:
# Line marked as output pass through
/@outp/ {
b
}
# Comments:
# Capture full line comments
/^\( *\)#\(.*\)$/ {
# Assume any line starting with a # is complete
s//\1@blah{\2}/
t
}
# Match sub-line comments
/#[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]/ ! {
s/#\(.*$\)/\\\
<@blah{#\1}\
/
}
#.
# Protected entities These shouldn't allow nested structure, so we move them
# to a marked, new line for a future extract/process/insert action.
#.
# AsIs block - resists formatting.
s/@asis{\(.*\)}/\\\
<@asis{\1}\
/g
#.
# Manual <span>
s/@span{\(.*\)}/\\\
<@span{\1}\
/g
#.
# String Literals
s/"\([^"]*\)"/\\\
<@dblq{\1}\
/g
s/'\([^']*\)'/\\\
<@sglq{\1}\
/g
#.
# AutoSuggestions.
s/@sgst{\([^}]*\)}/\\\
<@sgst{\1}\
/
#.
# Command/Function options
# Short options
s/ -\([A-Za-z][A-Za-z]*\)\([^A-Za-z}]\)/ \\\
<@opts{-\1}\
\2/g
#.
# Long options
s/ --\([A-Za-z][A-Za-z0-9=_-]*\)\([^A-Za-z0-9=_-]*\)/ \\\
<@opts{--\1}\
\2/g
#.
# Prompt
s/~>_/\\\
<@prmt{\
<@path{~}\
}/
s/^>_/@prmt/
#.
# Cursor
#.
s/___$/@curs/
s/___\(.\)/\\\
<@curs{\1}\
/
#.
# Trailing Backslash
s/ \\$/ @bksl{ }/
#.
# Paths
/\n<@dblq[^}]*[~/]/b protect
/\n<@sglq[^}]*[~/]/b protect
/\n<@span[^}]*[~/]/b protect
#.
# Normal Directory
s|mkdir |mkdir :|
s|\([~/:][/]*[.A-Za-z_0-9/-]*\)\\ |\1=|g
s| \([~/][/]*[.A-Za-z_0-9/=-]*\)| \\\
<@path{\1}\
|g
s| \(:[/]*[.A-Za-z_0-9/=-]*\)| \\\
<@path{\1}\
|g
t protect
#.
# Dot Relative Directory (no spaces in path)
s| \(./[A-Za-z_0-9/-]*\)| \\\
<@path{\1}\
|g
b protect
#.
# Tidy up. Merge back 'pure' entities from hold space.
:tidy
#.
# Convert loose text to arguments
s/ \([a-zA-Z0-9+%*.-][{},a-zA-Z0-9%*._/?!=-]*\)/ @args{\1}/g
#.
# Or when tight to a newline
s|\n\([a-zA-Z0-9+%*.-][{},a-zA-Z0-9%*._/?!-]*\)|\
@args{\1}|g
#.
# Or when tight to the beginning
s|^\([a-zA-Z][{},a-zA-Z0-9%*._/?!-]*\)|@args{\1}|g
#.
# Pick up loose text after markup.
s/\([})]\)\([a-zA-Z0-9+%*.,][,a-zA-Z0-9%*._/?!-]*\);/\1@args{\2};/g
s/\([})]\)\([a-zA-Z0-9+%*.,][,a-zA-Z0-9%*._/?!-]*\)$/\1@args{\2}/g
#.
# Uncomment the following 2 lines (ss) to log the pattern buffer.
s/^.*$/Pattern : &/w lexicon.log
s/^Pattern : //
#.
# Uncomment the following 4 lines (xssx) to log the hold buffer.
x
s/^.*$/HoldBufr: &/w lexicon.log
s/^HoldBufr: //
x
#.
# Tack the hold space to the end of the pattern buffer.
G
#.
# Uncomment the folowing two lines (ss) to log the buffer join.
s/^.*$/Joined : &/w lexicon.log
s/^Joined : //
#.
# Iterate over alternate lines, matching '<' to '\'
:join
s,\([^\\ ]*\)\\\n\([^<]*\)<\(@[^}]*[}\\]\),\1\3\2,
t join
# Clean up stray new lines
s/\n//g
#.
# Uncomment the folowing two lines (ss) to log the buffer before 'cleaning'.
s/^.*$/PreClean: &/w lexicon.log
s/^PreClean: //
# Clean up special cases
#.
/@blah/{
s/\(blah{[^@]*\)@sglq{\([^}]*\)}/\1'\2'/
s/\(blah{[^@]*\)@dblq{\([^}]*\)}/\1"\2"/
s/\(blah{[^@]*\)@....{\([^}]*\)}/\1\2/
}
/@dblq/{
:cleandblq
s/\(dblq{[^@}<]*\)[<]*@...[^q]{\([^}]*\)}/\1\2/
t cleandblq
}
/@sglq/{
:cleansglq
s/\(sglq{[^@}<]*\)[<]*@...[^q]{\([^}]*\)}/\1\2/
t cleansglq
}
/@vars/{
:cleanvars
s/\(vars{@optr{$}[^@}]*\)@bltn{\([^}]*\)}/\1\2/
s/\(vars{@optr{$}[^@}]*\)@func{\([^}]*\)}/\1\2/
s/\(vars{@optr{$}[^@}]*\)@cmnd{\([^}]*\)}/\1\2/
s/\(vars{@optr{$}[^@}]*\)@args{\([^}]*\)}/\1\2/
t cleanvars
}
/@redr/{
:cleanredr
s/\(redr{[^@}]*\)@bltn{\([^}]*\)}/\1\2/
s/\(redr{[^@}]*\)@func{\([^}]*\)}/\1\2/
s/\(redr{[^@}]*\)@cmnd{\([^}]*\)}/\1\2/
s/\(redr{[^@}]*\)@fsfo{\([^}]*\)}/\1\2/
s/\(redr{[^}]*\)}\( *\)@path{\([^}]*\)/\1\2\3/
t cleanredr
}
/@sgst/{
s/@sgst{<@/@sgst{@/
:cleansgst
s/\(sgst{@curs{.}[^@]*\)@bltn{\([^}]*\)}/\1\2/
s/\(sgst{@curs{.}[^@]*\)@func{\([^}]*\)}/\1\2/
s/\(sgst{@curs{.}[^@]*\)@cmnd{\([^}]*\)}/\1\2/
s/\(sgst{@curs{.}[^@]*\)@opts{\([^}]*\)}/\1\2/
s/\(sgst{@curs{.}[^@]*\)@path{\([^}]*\)}/\1\2/
s/\(sgst{@curs{.}[^@]*\)@args{\([^}]*\)}/\1\2/
s/\(sgst{@curs{.}[^@]*\)@fsfo{\([^}]*\)}/\1\2/
t cleansgst
}
/@fsfo/{
:cleanfsfo
s/\(fsfo{[^@}]*\)@bltn{\([^}]*\)}/\1\2/
s/\(fsfo{[^@}]*\)@func{\([^}]*\)}/\1\2/
s/\(fsfo{[^@}]*\)@cmnd{\([^}]*\)}/\1\2/
t cleanfsfo
}
/@prmt{/{
s/@prmt{<@path/@prmt{@path/
}
#.
# Restore Paths
/@fsfo/ {
s/\(@fsfo{[^=]*\)=/\1 /
}
/@path/ {
:cleanpath
s/\(@path{[^:]*\):/\1/
s/\(@path{[^=]*\)=/\1\\ /
t cleanpath
s/@path{}//
}
#.
# Finally, restructure to follow Fish's command [arguments] semantics.
# Find the initial command, and change any others to arguments, up to a |, ( or ;
# Assumes that a valid line will start with either a builtin, a function or a binary.
#.
# 'if' and 'for' seem to be special cases
#.
# Uncomment the folowing two lines (ss) to log the buffer before semantic conversion.
s/^.*$/PreArgs : &/w lexicon.log
s/^PreArgs : //
#.
# Find initial commands/functions/binaries
#.
# Store prmt, if present
#.
/@prmt/ {
h
s/^\(@prmt *\).*$/\1/
x
s/^@prmt *//
}
#.
# Special case for optional commands
s/@args{\[@bltn/@args{[@xbln/g
# Special case for one-line 'if' statements
/@bltn{if}/ {
s//@xbln{if}/
s/@bltn{set}/@xbln{set}/
s/@bltn{not}/@xbln{not}/
s/@bltn{else}/@xbln{else}/
s/@bltn{contains}/@xbln{contains}/
s/@bltn{test}/@xbln{test}/
s/@bltn{end}/@xbln{end}/
s/@cmnd{grep}/@xcmd{grep}/
}
# one-line 'for' statements
/@bltn{for}/ {
s//@xbln{for}/
s/@args{in}/@xbln{in}/
}
# one-line 'begin' statements
/@bltn{begin}/ {
s//@xbln{begin}/
s/@bltn{end}/@xbln{end}/
}
# one-line 'break' statements
/@bltn{break}/ {
s//@xbln{break}/
s/@bltn{end}/@xbln{end}/
}
# one-line 'continue' statements
/@bltn{continue}/ {
s//@xbln{continue}/
s/@bltn{end}/@xbln{end}/
}
# one-line 'switch' statements
/@bltn{switch}/ {
s//@xbln{switch}/
s/@bltn{case}/@xbln{case}/
s/@bltn{end}/@xbln{end}/
}
# one-line 'function' statements
/@bltn{function}/ {
s//@xbln{function}/
s/@bltn{return}/@xbln{return}/
s/@bltn{end}/@xbln{end}/
}
# one-line 'bind' statements - special input functions
/@bltn{bind}/ {
s//@xbln{bind}/
s/@....{\([a-z]*\)}\(-[a-z-]*\)/@args{\1\2}/
}
# one-line 'builtin' statements
s/@bltn{builtin} @bltn/@xbln{builtin} @xbln/g
s/@bltn{builtin} @cmnd/@xbln{builtin} @xcmd/g
s/@bltn{builtin} @func/@xbln{builtin} @xfnc/g
#.
# one-line 'command' statements
s/@bltn{command} @bltn/@xbln{command} @xbln/g
s/@bltn{command} @cmnd/@xbln{command} @xcmd/g
s/@bltn{command} @func/@xbln{command} @xfnc/g
#.
# one-line 'and/or' statements
s/@bltn{and} @bltn/@xbln{and} @xbln/g
s/@bltn{and} @cmnd/@xbln{and} @xcmd/g
s/@bltn{and} @func/@xbln{and} @xfnc/g
s/@bltn{or} @bltn/@xbln{or} @xbln/g
s/@bltn{or} @cmnd/@xbln{or} @xcmd/g
s/@bltn{or} @func/@xbln{or} @xfnc/g
#.
s/^\( *\)@cmnd/\1@xcmd/
s/\( *[;()] *\)@cmnd/\1@xcmd/g
s/\( *@redr{|} *\)@cmnd/\1@xcmd/g
s/^\( *\)@bltn/\1@xbln/
s/\( *[;()] *\)@bltn/\1@xbln/g
s/\( *@redr{|} *\)@bltn/\1@xbln/g
s/^\( *\)@func/\1@xfnc/
s/\( *[;()] *\)@func/\1@xfnc/g
s/\( *@redr{|} *\)@func/\1@xfnc/g
s/\\@bltn{\([^}]*\)/@args{@bksl{\1}/g
s/@bltn/@args/g
s/@func/@args/g
s/@cmnd/@args/g
#.
s/^.*$/PostArgs: &/w lexicon.log
s/^PostArgs: //
#.
s/xbln/bltn/g
s/xfnc/func/g
s/xcmd/cmnd/g
x
/^@prmt/ {
G
s/^@prmt \n/@prmt /
}
/^@prmt/ ! {
x
}
#.
# Mark up sesitive character entities.
#.
:entities
s/</\&lt;/g
s/>/\&gt;/g
s/((d))/@/g
#.
# Final post processing
s/};\([^]]\)/}@redr{;}\1/g
s/};$/}@redr{;}/
s/ \[\([@(]\)/ @args{[}\1/g
s/ \[\([A-Z]*\) / @args{[\1} /g
s/@args{\([a-zA-Z0-9_.]*\)}\]/@args{\1]}/g
s/@args{\([a-zA-Z0-9_.]*\)}: /@args{\1:} /g
s/@bltn{echo} @fsfo/@bltn{echo} @args/g
s/@bltn{echo}\([a-zA-Z0-9.@{} _-]*\)@fsfo/@bltn{echo}\1@args/g
s/ \] / @args{]} /g
s/ \]$/ @args{]}/g
s/\]}\]$/]]}/
s/\\\([()]\)/@optr{@bksl{\1}}/g
s/\([()]\)/@optr{\1}/g
s/\\n/@bksl{n}/
s/ \\$//
#.
# Uncomment the folowing two lines (ss) to log the final output, sent to Doxygen.
s/^.*$/Output : &\
\
/w lexicon.log
s/^Output : //
s/\n\n$//
#.
# Lines are reassembled, so branch to end
b
# === Main End ===
#.
#.
# === Subroutines ===
# Branched to when content requires.
#.
# Move protected content to hold space and mark up other entities.
:protect
s/^.*$/Input : &/w lexicon.log
s/^Input : //
h
# Clear out any content that has already been marked up, to prevent futher
# markup on words that should be left alone.
#.
:patternflush
s/\n<@[^}]*[}\\]//
s/\\ [^\\]*$/\\/
t patternflush
s/\n$//g
#.
# Swap the pattern and hold buffers and remove unmarked lines and extra
# characters. Basically the inverse of the 'patternflush' action, with
# additional trailing characters stripped.
x
/^\<@[^}]*$/ ! {
s/[^\<]*//
s/^ *\\\n//g
s/\n *\\//g
s/[()] \\//g
s/^[^\<][^@][^\\]*//
s/\n[]|;) ][^\\]*\\//
s/\n[]|;) a-zA-Z0-9-][^\\]*$//
s/\n[]|;)}]\\//
s/\n[]|;)}]\n//
s/\n[]|;)}]$//
s/[()]$//
s/}@curs/}/
s/\n@curs$//
s/\n[^\<@][^\\]*\\//
s/\n[^\<@][^\\]*//
s/^\\//
s/\n$//g
}
s/\\\n/\
/
s/\< \n//
s/^[a-z][a-z]* \n//
#.
# Swap the buffers back.
x
#.
# A special case. Tidy up after commands.
# Redirectors
s/\([^{|] *\)|/\1@redr{|}/g
s/&$/@redr{\&amp;}/
s/\([^{&] *\)&[^a-z]/\1@redr{\&amp;}/g
s/\([^{<>^] *\)\([0-9]* *[<>^][<>^]*[^@][a-zA-Z0-9./_-]*\)/\1@redr{\2}/g
s/\\}/}\\/g
#.
# Now we can add in 'unsafe' entities that would be too greedy.
# Arrays
s/[[][0-9$a-zA-Z_;. -]*]/@args{&}/g
#.
# Declared Variables
s/\($[$]*\)\([A-Za-z_0-9][A-Za-z_0-9]*\)/@vars{@optr{\1}\2}/g
#.
# Files
s/\([^@]\)\([A-Za-z0-9_-][A-Za-z0-9_-]*\.[a-z0-9*][a-z0-9*]*\)/\1@fsfo{\2}/g
#.
:commands
#.
#### This section is built in the Makefile. Just some formatting examples. #####
#.
# Fish builtin (bltn) <- 4 character code that has a Doxygen alias counterpart
# template : s/[[:<:]]function[[:>:]]/@bltn{&}/
#.
# s,[[:<:]]function[[:>:]],@bltn{function},g
# s,[[:<:]]begin[[:>:]],@bltn{begin},g
# ...
#.
# Fish functions (func)
# Populated by 'public' functions' filename.
#.
# s,[[:<:]]fish_pwd[[:>:]],@func{fish_pwd},g
# s,[[:<:]]fish_prompt[[:>:]],@func{fish_prompt},g
# ...
#.
# Shell Command (cmnd)
# Populated from completion filenames
#.
# s,[[:<:]]seq[[:>:]],@cmnd{seq},g
# s,[[:<:]]rm[[:>:]],@cmnd{rm},g
# ...
#.
# Color Variable (clrv)
# Populated from __fish_config_interactive.fish
# Allows fish's 'special' color variables to be identified
#.
# s,[[:<:]]fish_color_normal[[:>:]],@clrv{fish_color_normal},g
# s,[[:<:]]fish_color_command[[:>:]],@clrv{fish_color_command},g
#.
# Once all of the commands/functions/variables/special's have been marked up,
# branch back to tidy up and collapse the pattern/hold buffers back to a
# single line.
#.
# b tidy
#.
#.
# Below is a special section that adds vocabuarly to the lexicon during 'make'.
# As the lexicon is written into the output lexicon_filter, portability is
# automatically handled.
#.
#.!# cmnd whoami
#.!# cmnd mkdir
#.!# cmnd basename
#.!# bltn sleep
#.!# args in

View file

@ -1,166 +0,0 @@
<html>
<head>
<title>fish user documentation</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<style type='text/css'>
/* fish documentation CSS overrides */
/* No scrollbar on the body. Our columns are independently scrollable */
body
{
overflow: hidden;
}
.fish_left_bar, .fish_right_bar, .fish_only_bar
{
position: absolute;
top: 36px;
bottom: 0;
overflow-y: scroll;
-webkit-overflow-scrolling: touch; /* necessary for momentum scrolling */
}
.fish_left_bar
{
width: 250px;
color: white;
}
.fish_left_bar a { color: white; }
.fish_left_bar a:visited { color: inherit; }
.fish_right_bar
{
margin-left: 250px;
margin-right: 0px;
padding: 0 0 0 20px; /* 20 px on left */
background-color: white;
-moz-box-shadow: -5px 0px 5px -2px black;
-webkit-box-shadow: -5px 0px 5px -2px black;
box-shadow: -5px 0px 5px -2px black;
}
.fish_right_bar p
{
margin-right: 8px;
}
.fish_left_big { width: 380px; }
.fish_right_little { margin-left: 380px; }
.fish_left_medium { width: 280; }
.fish_right_medium { margin-left: 280; }
.fish_left_little { width: 200px; }
.fish_right_big { margin-left: 200px; }
.fish_only_bar
{
padding: 0px 20px;
}
h1, h2, h3 { color: #1E335E; }
h1 { font-size: 150%; }
h2 { font-size: 115%; }
h3 { font-size: 105%; }
/* Don't show the header */
div.header { display: none; }
h1.interior_title, h1.interior_title_borderless {
color: #333;
}
h1.interior_title {
padding-bottom: 10px;
border-bottom: 1px solid #AAA;
}
div.contents { margin: 0px; }
div.qindex
{
height: 30px;
line-height: 30px;
text-align: center;
background-image: none;
color: white;
border: none;
}
.fish_left_bar, div.header, div.qindex
{
background-color: #1E335E;
}
div.qindex
{
border: none;
padding: 3px 0px;
/* Ensure the bottom border is visible over the left column */
position: relative;
z-index: 2;
}
div.qindex a
{
color: white;
}
/* Hide the doxygen logo */
.footer { display: none; }
/* Don't let pre elements create a minimum width on the right bar */
.fish_right_bar pre { white-space:pre-wrap; }
/* Adjust list */
.fish_left_bar ul {
padding-left: 27px;
padding-right: 10px;
}
.fish_left_bar ul li { margin-bottom: 5px; }
/* Tighter lists for the little (command) bar */
.fish_left_little ul li { margin-bottom: 0; }
/* Adjust sublists */
.fish_left_bar ul ul { padding-left: 17px; }
.fish_left_bar ul ul li { margin-bottom: 0; }
/* Link hover */
.fish_left_bar a:hover {
text-decoration: none;
background-color: inherit;
color: #99BBFF;
}
/* Horizontal bar */
hr {
height: 1px;
border: 0;
background-color: #AAA;
}
</style>
</head>
<body>
<div class="qindex">
<a class="qindex" href="http://fishshell.com/"><tt>fish</tt> shell</a>
|
<a class="qindex" href="index.html">Documentation</a>
|
<a class="qindex" href="tutorial.html">Tutorial</a>
|
<a class="qindex" href="design.html">Design</a>
|
<a class="qindex" href="commands.html">Commands</a>
|
<a class="qindex" href="faq.html">FAQ</a>
|
<a class="qindex" href="license.html">License</a>
</div>