`fish` shell | Documentation | Tutorial | Design | Commands | FAQ | License
doc.h
1
1498 \htmlonly </div> \endhtmlonly
1553 color: #005fd7;
1554 font-weight: normal;
1555 }
1556
1557 pre i {
1558 /* Used for arguments */
1559 color: #00afff;
1560 font-style: normal;
1561 }
1562
1563 pre em {
1564 /* Used for path/help word */
1565 color: #0a0;
1566 font-style: normal;
1567 }
1568
1569 .quote {
1570 color: #A50;
1571 }
1572
1573 .error {
1574 /* Used for errors */
1575 color: #F55;
1576 font-weight: bold;
1577 }
1578
1579 .tutorial_nav {
1580 position: relative;
1581 z-index: 2;
1582 margin-left: 10px;
1583 margin-top: 15px;
1584 }
1585
1586 .tutorial_nav ul {
1587 padding: 0 15px;
1588 margin: 0;
1589 }
1590
1591 .tutorial_nav li {
1592 margin: 0;
1593 line-height: normal;
1594 height: auto;
1595 color: #EEE;
1596 font-size: 12pt;
1597 font-family: "Trebuchet MS", Verdana, Arial, sans-serif;
1598 list-style-image: none;
1599 list-style-position: outside;
1600 list-style-type: none;
1601 padding: 3px 15px;
1602 margin: 0 -15px;
1603 }
1604
1605 .tutorial_nav a {
1606 color: inherit;
1607 text-decoration: none;
1608 font-family:
1609 font-size: 12pt;
1610 }
1611
1612 .tutorial_nav .chevron {
1613 font-family: Times, "Times New Roman";
1614 color: #DDF;
1615 font-size: 16pt;
1616 line-height: 10pt;
1617 font-weight: bold;
1618 }
1619
1620 .no_shadow > li > a,
1621 .no_shadow {
1622 text-shadow: none;
1623 }
1624
1625 .nav > li > a:hover {
1626 text-decoration: none;
1627 background-color: inherit;
1628 color: #99BBFF;
1629 }
1630
1631 /* Override some default left bar stuff */
1632 ul.nav li {
1633 margin-bottom: 0;
1634 }
1635
1636
1637 .title_top {
1638 width: 100%;
1639 text-align: left;
1640 color: white;
1641 font-size: 18pt;
1642 height: 72px;
1643 z-index: 1;
1644 text-indent: 260px;
1645 }
1646
1647 .tutorial_content {
1648 -moz-box-shadow: -5px 0px 5px -2px black;
1649 -webkit-box-shadow: -5px 0px 5px -2px black;
1650 box-shadow: -5px 0px 5px -2px black;
1651
1652 margin-left: 280px;
1653 padding: 1px 25px 10px 10px;
1654 position: relative;
1655 z-index: 5;
1656 background-color: white;
1657 }
1658
1659 h3 {
1660 font-size: 25px;
1661 margin-top: 12px;
1662 }
1663
1664 h1, h2, h3 { color: #1E335E; }
1665 h1.interior_title {
1666 color: #333;
1667 padding-bottom: 10px;
1668 border-bottom: 1px solid #AAA;
1669 }
1670
1671 h1 { font-size: 150%; }
1672 h2 { font-size: 135%; }
1673 h3 { font-size: 110%; }
1674
1675
1676
1677 </style>
1678
1679
1680 <div class="fish_left_bar fish_left_medium">
1681 <div class="tutorial_nav">
1682 <ul class="nav no_shadow">
1683 <li><a href="#tut_why_fish"><span class="chevron">&rsaquo;</span> Why fish?</a></li>
1684 <li><a href="#tut_learning_Fish"><span class="chevron">&rsaquo;</span> Learning fish</a></li>
1685 <li><a href="#tut_running_commands"><span class="chevron">&rsaquo;</span> Running Commands</a></li>
1686 <li><a href="#tut_getting_help"><span class="chevron">&rsaquo;</span> Getting Help</a></li>
1687 <li><a href="#tut_syntax_highlighting"><span class="chevron">&rsaquo;</span> Syntax Highlighting</a></li>
1688 <li><a href="#tut_wildcards"><span class="chevron">&rsaquo;</span> Wildcards</a></li>
1689 <li><a href="#tut_pipes_and_redirections"><span class="chevron">&rsaquo;</span> Pipes and Redirections</a></li>
1690 <li><a href="#tut_autosuggestions"><span class="chevron">&rsaquo;</span> Autosuggestions</a></li>
1691 <li><a href="#tut_tab_completions"><span class="chevron">&rsaquo;</span> Tab Completions</a></li>
1692 <li><a href="#tut_variables"><span class="chevron">&rsaquo;</span> Variables</a></li>
1693 <li><a href="#tut_exit_status"><span class="chevron">&rsaquo;</span> Exit Status</a></li>
1694 <li><a href="#tut_exports"><span class="chevron">&rsaquo;</span> Environment Variables</a></li>
1695 <li><a href="#tut_lists"><span class="chevron">&rsaquo;</span> Lists</a></li>
1696 <li><a href="#tut_command_substitutions"><span class="chevron">&rsaquo;</span> Command Substitutions</a></li>
1697 <li><a href="#tut_combiners"><span class="chevron">&rsaquo;</span> Combiners (And, Or, Not)</a></li>
1698 <li><a href="#tut_conditionals"><span class="chevron">&rsaquo;</span> Conditionals (If, Else, Switch)</a></li>
1699 <li><a href="#tut_functions"><span class="chevron">&rsaquo;</span> Functions</a></li>
1700 <li><a href="#tut_loops"><span class="chevron">&rsaquo;</span> Loops</a></li>
1701 <li><a href="#tut_prompt"><span class="chevron">&rsaquo;</span> Prompt</a></li>
1702 <li><a href="#tut_startup"><span class="chevron">&rsaquo;</span> Startup</a></li>
1703 </ul>
1704 </div>
1705 </div>
1706
1707 <div class="fish_right_bar fish_right_medium">
1708
1709 <h1 class="interior_title">fish tutorial</h1>
1710
1711 <h2 id="tut_why_fish">Why fish?</h2>
1712
1713 <p>fish is a fully-equipped command line shell (like bash or zsh) that is smart and user-friendly. fish supports powerful features like syntax highlighting, autosuggestions, and tab completions that just work, with nothing to learn or configure.
1714
1715 <p>If you want to make your command line more productive, more useful, and more fun, without learning a bunch of arcane syntax and configuration options, then fish might be just what you're looking for!
1716
1717 <h2 id="tut_learning_Fish">Learning fish</h2>
1718
1719 <p>This tutorial assumes a basic understanding of command line shells and Unix commands, and that you have a working copy of fish.
1720
1721 <p>If you have a strong understanding of other shells, and want to know what fish does differently, search for the magic phrase <i>unlike other shells</i>, which is used to call out important differences.
1722
1723 <p>When you start fish, you should see this:
1724
1725 <pre>
1726 Welcome to fish, the friendly interactive shell
1727 Type <em>help</em> for instructions on how to use fish
1728 you@hostname <em>~</em>>
1729 </pre>
1730
1731 <p>fish comes with a default prompt that shows your username, hostname, and working directory. You'll see <a href="#tut_prompt">how to change your prompt</a> further down. From now on, we'll pretend your prompt is just a '>' to save space.
1732
1733 <h2 id="tut_running_commands">Running Commands</h2>
1734
1735 <p>fish runs commands like other shells: you type a command, followed by its arguments. Spaces are separators:
1736
1737 <pre>
1738 > <b>echo</b> <i>hello world</i>
1739 hello world
1740 </pre>
1741
1742 You can include a literal space in an argument with a backslash, or by using single or double quotes:
1743
1744 <pre>
1745 > <b>mkdir</b> <i>My\ Files</i>
1746 > <b>cp</b> <i>~/Some\ File</i> <i class=quote>'My Files'</i>
1747 > <b>ls</b> <i class=quote>"My Files"</i>
1748 Some File
1749 </pre>
1750
1751 Commands can be chained with semicolons.
1752
1753 <h2 id="tut_getting_help">Getting Help</h2>
1754
1755 fish has excellent help and man pages. Run <tt>help</tt> to open help in a web browser, and <tt>man</tt> to open it in a man page. You can also ask for help with a specific command, for example, <tt>help set</tt> to open in a web browser, or <tt>man set</tt> to see it in the terminal.
1756
1757 <pre>
1758 > <b>man</b> <i>set</i>
1759 set - handle environment variables
1760 Synopsis...
1761 </pre>
1762
1763 <h2 id="tut_syntax_highlighting">Syntax Highlighting</h2>
1764 You'll quickly notice that fish performs syntax highlighting as you type. Invalid commands are colored red by default:
1765
1766 <pre>
1767 > <b class="error">/bin/mkd</b>
1768 </pre>
1769
1770 A command may be invalid because it does not exist, or refers to a file that you cannot execute. When the command becomes valid, it is shown in a different color:
1771
1772 <pre>
1773 > <b>/bin/mkdir</b>
1774 </pre>
1775
1776 fish will underline valid file paths as you type them:
1777
1778 <pre>
1779 > <b>cat</b> <i><span style="text-decoration: underline">~/somef<u>i</u></span></i>
1780 </pre>
1781
1782 <p>This tells you that there exists a file that starts with '<tt>somefi</tt>', which is useful feedback as you type.
1783
1784 <p>These colors, and many more, can be changed by running <tt>fish_config</tt>, or by modifying variables directly.
1785
1786 <h2 id="tut_wildcards">Wildcards</h2>
1787
1788 fish supports the familiar wildcard *. To list all JPEG files:
1789
1790 <pre>
1791 > <b>ls</b> <i>*.jpg</i>
1792 lena.jpg
1793 meena.jpg
1794 santa maria.jpg
1795 </pre>
1796
1797 <p>You can include multiple wildcards:
1798
1799 <pre>
1800 > <b>ls</b> <i>l*.p*</i>
1801 lena.png
1802 lesson.pdf
1803 </pre>
1804
1805 <p>Especially powerful is the <i>recursive wildcard</i> ** which searches directories recursively:
1806
1807 <pre>
1808 > <b>ls</b> <i>/var
2382
3807
6620