00001
01540 \htmlonly </div> \endhtmlonly
01595 color: #005fd7;
01596 font-weight: normal;
01597 }
01598
01599 pre i {
01600
01601 color: #00afff;
01602 font-style: normal;
01603 }
01604
01605 pre em {
01606
01607 color: #0a0;
01608 font-style: normal;
01609 }
01610
01611 .quote {
01612 color: #A50;
01613 }
01614
01615 .error {
01616
01617 color: #F55;
01618 font-weight: bold;
01619 }
01620
01621 .tutorial_nav {
01622 position: relative;
01623 z-index: 2;
01624 margin-left: 10px;
01625 margin-top: 15px;
01626 }
01627
01628 .tutorial_nav ul {
01629 padding: 0 15px;
01630 margin: 0;
01631 }
01632
01633 .tutorial_nav li {
01634 margin: 0;
01635 line-height: normal;
01636 height: auto;
01637 color: #EEE;
01638 font-size: 12pt;
01639 font-family: "Trebuchet MS", Verdana, Arial, sans-serif;
01640 list-style-image: none;
01641 list-style-position: outside;
01642 list-style-type: none;
01643 padding: 3px 15px;
01644 margin: 0 -15px;
01645 }
01646
01647 .tutorial_nav a {
01648 color: inherit;
01649 text-decoration: none;
01650 font-family:
01651 font-size: 12pt;
01652 }
01653
01654 .tutorial_nav .chevron {
01655 font-family: Times, "Times New Roman";
01656 color: #DDF;
01657 font-size: 16pt;
01658 line-height: 10pt;
01659 font-weight: bold;
01660 }
01661
01662 .no_shadow > li > a,
01663 .no_shadow {
01664 text-shadow: none;
01665 }
01666
01667 .nav > li > a:hover {
01668 text-decoration: none;
01669 background-color: inherit;
01670 color: #99BBFF;
01671 }
01672
01673
01674 ul.nav li {
01675 margin-bottom: 0;
01676 }
01677
01678
01679 .title_top {
01680 width: 100%;
01681 text-align: left;
01682 color: white;
01683 font-size: 18pt;
01684 height: 72px;
01685 z-index: 1;
01686 text-indent: 260px;
01687 }
01688
01689 .tutorial_content {
01690 -moz-box-shadow: -5px 0px 5px -2px black;
01691 -webkit-box-shadow: -5px 0px 5px -2px black;
01692 box-shadow: -5px 0px 5px -2px black;
01693
01694 margin-left: 280px;
01695 padding: 1px 25px 10px 10px;
01696 position: relative;
01697 z-index: 5;
01698 background-color: white;
01699 }
01700
01701 h3 {
01702 font-size: 25px;
01703 margin-top: 12px;
01704 }
01705
01706 h1, h2, h3 { color: #1E335E; }
01707 h1.interior_title {
01708 color: #333;
01709 padding-bottom: 10px;
01710 border-bottom: 1px solid #AAA;
01711 }
01712
01713 h1 { font-size: 150%; }
01714 h2 { font-size: 135%; }
01715 h3 { font-size: 110%; }
01716
01717
01718
01719 </style>
01720
01721
01722 <div class="fish_left_bar fish_left_medium">
01723 <div class="tutorial_nav">
01724 <ul class="nav no_shadow">
01725 <li><a href="#tut_why_fish"><span class="chevron">›</span> Why fish?</a></li>
01726 <li><a href="#tut_learning_Fish"><span class="chevron">›</span> Learning fish</a></li>
01727 <li><a href="#tut_running_commands"><span class="chevron">›</span> Running Commands</a></li>
01728 <li><a href="#tut_getting_help"><span class="chevron">›</span> Getting Help</a></li>
01729 <li><a href="#tut_syntax_highlighting"><span class="chevron">›</span> Syntax Highlighting</a></li>
01730 <li><a href="#tut_wildcards"><span class="chevron">›</span> Wildcards</a></li>
01731 <li><a href="#tut_pipes_and_redirections"><span class="chevron">›</span> Pipes and Redirections</a></li>
01732 <li><a href="#tut_autosuggestions"><span class="chevron">›</span> Autosuggestions</a></li>
01733 <li><a href="#tut_tab_completions"><span class="chevron">›</span> Tab Completions</a></li>
01734 <li><a href="#tut_variables"><span class="chevron">›</span> Variables</a></li>
01735 <li><a href="#tut_exit_status"><span class="chevron">›</span> Exit Status</a></li>
01736 <li><a href="#tut_exports"><span class="chevron">›</span> Shell Variables</a></li>
01737 <li><a href="#tut_lists"><span class="chevron">›</span> Lists</a></li>
01738 <li><a href="#tut_command_substitutions"><span class="chevron">›</span> Command Substitutions</a></li>
01739 <li><a href="#tut_combiners"><span class="chevron">›</span> Combiners (And, Or, Not)</a></li>
01740 <li><a href="#tut_conditionals"><span class="chevron">›</span> Conditionals (If, Else, Switch)</a></li>
01741 <li><a href="#tut_functions"><span class="chevron">›</span> Functions</a></li>
01742 <li><a href="#tut_loops"><span class="chevron">›</span> Loops</a></li>
01743 <li><a href="#tut_prompt"><span class="chevron">›</span> Prompt</a></li>
01744 <li><a href="#tut_startup"><span class="chevron">›</span> Startup</a></li>
01745 </ul>
01746 </div>
01747 </div>
01748
01749 <div class="fish_right_bar fish_right_medium">
01750
01751 <h1 class="interior_title">fish tutorial</h1>
01752
01753 <h2 id="tut_why_fish">Why fish?</h2>
01754
01755 <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.
01756
01757 <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!
01758
01759 <h2 id="tut_learning_Fish">Learning fish</h2>
01760
01761 <p>This tutorial assumes a basic understanding of command line shells and Unix commands, and that you have a working copy of fish.
01762
01763 <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.
01764
01765 <p>When you start fish, you should see this:
01766
01767 <pre>
01768 Welcome to fish, the friendly interactive shell
01769 Type <em>help</em> for instructions on how to use fish
01770 you@hostname <em>~</em>>
01771 </pre>
01772
01773 <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.
01774
01775 <h2 id="tut_running_commands">Running Commands</h2>
01776
01777 <p>fish runs commands like other shells: you type a command, followed by its arguments. Spaces are separators:
01778
01779 <pre>
01780 > <b>echo</b> <i>hello world</i>
01781 hello world
01782 </pre>
01783
01784 You can include a literal space in an argument with a backslash, or by using single or double quotes:
01785
01786 <pre>
01787 > <b>mkdir</b> <i>My\ Files</i>
01788 > <b>cp</b> <i>~/Some\ File</i> <i class=quote>'My Files'</i>
01789 > <b>ls</b> <i class=quote>"My Files"</i>
01790 Some File
01791 </pre>
01792
01793 Commands can be chained with semicolons.
01794
01795 <h2 id="tut_getting_help">Getting Help</h2>
01796
01797 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.
01798
01799 <pre>
01800 > <b>man</b> <i>set</i>
01801 set - handle shell variables
01802 Synopsis...
01803 </pre>
01804
01805 <h2 id="tut_syntax_highlighting">Syntax Highlighting</h2>
01806 You'll quickly notice that fish performs syntax highlighting as you type. Invalid commands are colored red by default:
01807
01808 <pre>
01809 > <b class="error">/bin/mkd</b>
01810 </pre>
01811
01812 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:
01813
01814 <pre>
01815 > <b>/bin/mkdir</b>
01816 </pre>
01817
01818 fish will underline valid file paths as you type them:
01819
01820 <pre>
01821 > <b>cat</b> <i><span style="text-decoration: underline">~/somef<u>i</u></span></i>
01822 </pre>
01823
01824 <p>This tells you that there exists a file that starts with '<tt>somefi</tt>', which is useful feedback as you type.
01825
01826 <p>These colors, and many more, can be changed by running <tt>fish_config</tt>, or by modifying variables directly.
01827
01828 <h2 id="tut_wildcards">Wildcards</h2>
01829
01830 fish supports the familiar wildcard *. To list all JPEG files:
01831
01832 <pre>
01833 > <b>ls</b> <i>*.jpg</i>
01834 lena.jpg
01835 meena.jpg
01836 santa maria.jpg
01837 </pre>
01838
01839 <p>You can include multiple wildcards:
01840
01841 <pre>
01842 > <b>ls</b> <i>l*.p*</i>
01843 lena.png
01844 lesson.pdf
01845 </pre>
01846
01847 <p>Especially powerful is the <i>recursive wildcard</i> ** which searches directories recursively:
01848
01849 <pre>
01850 > <b>ls</b> <i>/var
02424
06682