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