Using csh & tcsh

Book description

If you use UNIX, you probably use csh to type commands even if you've never heard of it. It's the standard shell (command line) on most UNIX systems. tcsh is an enhanced version that's freely available and highly recommended.Using csh & tcsh describes from the beginning how to use these shells interactively. More important, it shows how to get your work done faster with less typing. Even if you've used UNIX for years, techniques described in this book can make you more efficient.You'll learn how to:

  • Make your prompt tell you where you are (no more pwd)
  • Use what you've typed before (history)
  • Type long command lines with very few keystrokes (command and filename completion)
  • Remind yourself of filenames when in the middle of typing a command
  • Edit a botched command instead of retyping it
This book does not cover programming or script writing in csh ortcsh because the tasks are better done with a different shell, such as sh (the Bourne shell) or a language like Perl.

Publisher resources

View/Submit Errata

Table of contents

  1. Using csh and tcsh
    1. SPECIAL OFFER: Upgrade this ebook with O’Reilly
    2. Preface
      1. Intended Audience
      2. Scope of This Handbook
        1. Part I, Learning the Basics
        2. Part II, Becoming More Efficient
        3. Part III, Appendixes
      3. How To Read This Handbook
      4. Conventions Used in This Handbook
      5. Comments and Corrections
      6. Acknowledgments
    3. I. Learning the Basics
      1. 1. Introduction
        1. Using the Examples
        2. Selecting a Login Shell
          1. Trying a Shell Temporarily
          2. A Recommendation: Use tcsh, Not csh
        3. Before You Read Further
      2. 2. A Shell Primer
        1. Entering Commands
        2. Command Input and Output
        3. Files and Directories
          1. Filename Patterns
          2. "Invisible" Files
          3. Creating Directories
          4. Changing Your Current Directory
          5. Removing Directories
        4. Combining Commands
        5. Running Commands in the Background
        6. When Do Spaces Matter?
        7. The Shell Startup Files
      3. 3. Using the Shell Effectively
        1. Using Filenames
          1. Letting the Shell Type Filenames for You
          2. Using "Patterns" for Filenames that Don't Exist
          3. Using Shorthand for Home Directory Names
          4. Letting the Shell Correct Your Spelling Mistakes
          5. Dealing with Hard-To-Type Filenames
        2. Reusing and Editing Commands
          1. The Shell's History List
          2. Repeating Commands Using !-Specifiers
          3. Repeating Commands Using the Command Editor
          4. Repeating Part of a Command
          5. Editing Commands
          6. Repeating Commands Using a Loop
        3. Creating Command Shortcuts
        4. Using Command Substitution
        5. Navigating the File System
          1. How To Bounce Easily Between Two Directories
          2. Letting the Shell Find Directories for You
        6. Using Your Prompt
          1. Using tcsh Prompt Formatting Sequences
            1. Put a clock in your prompt
            2. Make your prompt stand out
            3. Put your current location in your prompt
        7. Using Job Control
          1. Why Job Control Is Useful
          2. Basic Job Control
            1. Stopping a job
            2. Moving a job to the background
            3. Bringing a job to the foreground
            4. Killing a job
            5. Stopping a background job
          3. Dealing with Multiple Jobs
            1. Referring to the current job
            2. Referring to jobs by number
            3. Referring to jobs by name
          4. Job Control Shortcuts
          5. What To Do When You See "There are stopped jobs"
    4. II. Becoming More Efficient
      1. 4. The Shell Startup Files
        1. Startup and Shutdown Files
        2. Getting To Know .cshrc and .login
        3. Modifying .cshrc and .login
        4. Using Variables
          1. Shell Variables
          2. Environment Variables
          3. Examining and Using Variable Values
          4. Turning Off Variables
          5. Making tcsh Shell Variables Read-Only
          6. Paired Variables
        5. Organizing Your Startup Files
          1. Login Versus Non-Login Shells
          2. Interactive Versus Non-Interactive Shells
          3. Using the source Command
          4. Protecting tcsh-Only Commands from csh
        6. The .logout File
      2. 5. Setting Up Your Terminal
        1. Identifying Your Terminal Settings
        2. What the Settings Mean
          1. Line Editing Settings
          2. Process Control Settings
        3. Changing Your Terminal Settings
          1. Problems Typing the # and @ Characters
          2. Getting Your Terminal To Backspace
        4. Did Your Terminal Stop Working?
      3. 6. Using Your Command History
        1. The History List
        2. Reviewing Your History
        3. Using Commands from Your History
        4. Event Specifiers
          1. Recalling the Previous Command
          2. Referring to Commands by Number
          3. Referring to Events by Command Name or Substring
          4. Referring to the Current Event
          5. Erroneous History References
          6. Adding Text to Recalled Events
            1. Resolving ambiguous additions
        5. Word Designators
          1. Word Designator Shorthand
          2. Using Word Designators
          3. Repeating a Set of Words
          4. Repeating Words from the Current Command
        6. Event Modifiers
          1. Recalling Commands Without Executing Them
          2. Substitution Modifiers
            1. Repeating a substitution
            2. Repeating the previous substitution
            3. Checking a substitution
          3. Filename Modifiers
        7. Making History Persist Across Login Sessions
      4. 7. The tcsh Command-Line Editor
        1. Editing a Command
        2. Command Key Bindings
          1. Getting Key Binding Information
          2. Comparison of emacs Mode and vi Mode
        3. emacs Editing Mode
          1. emacs Cursor Motion Commands
          2. emacs Modification Commands
          3. Repeating emacs Commands
          4. emacs History-Searching Commands
          5. Using the Arrow Keys in emacs Mode
        4. vi Editing Mode
          1. Using vi Insert Mode
          2. Using vi Command Mode
            1. Cursor motion commands
            2. Repeating commands
            3. Adding text
            4. Deleting text
            5. Replacing text
          3. vi History-Searching Commands
          4. vi Character-Seeking Commands
          5. Using the Arrow Keys in vi Mode
        5. Examining and Modifying Key Bindings
          1. Selecting a Set of Bindings
          2. Getting a List of Editing Commands
          3. Displaying Key Bindings
            1. Displaying all bindings
            2. Displaying individual key bindings
          4. Specifying the key Argument
            1. Options that modify interpretation of the key argument
          5. Changing Key Bindings
            1. Binding an individual key
            2. Binding a key to itself
            3. Removing a binding
            4. Binding a key to a shell command
            5. Binding a key to a literal string
          6. Conflicts Between Terminal Settings and Key Bindings
          7. Conflicts Between Key Bindings
      5. 8. Using Aliases To Create Command Shortcuts
        1. Defining Aliases
          1. Referring to Arguments in Aliases
          2. Referring to the History List in Aliases
          3. Getting Used to Aliases
        2. Uses for Aliases
          1. Aliases Save Typing
          2. Aliases Can Redefine Commands
          3. Aliases Hide Differences Between Systems
        3. Using Sets of Aliases
      6. 9. File-Naming Shortcuts
        1. Using Filename Patterns
          1. Matching Multiple Characters
          2. Matching Single Characters
          3. Combining Pattern Operators
          4. Patterns and Dot Files
          5. Negating Patterns
          6. Be Careful with Patterns
          7. Pretesting Filename Patterns
        2. Using {} To Generate Arguments
        3. Directory Naming Shorthand
          1. Referring to Home Directories Using ˜name
          2. Referring to Directory Stack Entries Using =n
      7. 10. Filename and Programmed Completion
        1. Using Built-In Filename Completion
          1. Displaying Completion Matches
          2. Narrowing the Scope of Completion Matches
          3. Other Types of Completions
          4. Listing Completion Matches Automatically
          5. Completion and the tcsh Command Editor
            1. Stepping through possible completions
            2. Completion in mid-command
            3. Completion and filename patterns
        2. Programmed Completions
        3. Syntax of the complete Command
          1. Selecting the Word To Be Completed
            1. Position-based word selection
            2. Pattern-based word selection
          2. Completing the Selected Word
            1. Restricting the set of completion words
            2. Choosing completions from a given directory
            3. Displaying a message instead of listing matches
            4. Supplying your own completion word list
            5. Adding a suffix to the completed word
          3. Specifying Multiple Completion Rules
        4. Displaying and Removing Programmed Completions
        5. When Programmed Completions Do Not Apply
      8. 11. Quoting and Special Characters
        1. Special Characters
        2. The Shell's Quote Characters
          1. Quoting the Quote Characters
        3. Referring to Files with Problematic Names
          1. Typing Difficult Filenames Using Filename Completion
          2. Typing Difficult Filenames Using Filename Patterns
          3. Quoting Special Characters Yourself
        4. Passing Special Characters to Commands
          1. Referring to a File When the Name Has a Leading Dash
        5. Using Partial Quoting
        6. Quoting Oddities
      9. 12. Using Commands To Generate Arguments
        1. Command Substitution
          1. Finding Files
          2. Taking Arguments from a File
          3. Processing Arguments Individually
        2. Repeating Substituted Commands
        3. Deferred Command Substitution
          1. Verifying the Argument List
            1. Dealing with unexpected output
            2. Dealing with missing output
            3. Verifying arguments using tee
          2. Modifying the Argument List
        4. When To Avoid Command Substitution
          1. Filenames Containing Special Characters
          2. Using xargs Instead of Command Substitution
            1. Limitations of xargs
      10. 13. Navigating the File System
        1. Moving Around
        2. Working in Multiple Locations
          1. Using cd – To Return to the Previous Directory
          2. Using the Directory Stack
          3. Stack Display Formats
          4. Referring to Stack Entries in Command Arguments
          5. An Alternative to the Directory Stack
        3. Letting the Shell Find Directories for You
          1. Limitations of cdpath
        4. Using Aliases and Variables To Move Around
          1. Moving Around Using Aliases
          2. Moving Around Using Variables
          3. Combining Aliases and Variables
      11. 14. Keeping Track of Where You Are
        1. Types of Location Reporting
        2. Displaying Your Location in the Prompt
          1. Using csh To Display Your Location
            1. Using a multiple-line prompt
          2. Using tcsh To Display Your Location
        3. Display Your Location in the Window Title
          1. Communicating with xterm
          2. Setting the Window Title in xterm
          3. Setting the Window Title in Other Terminal Programs
            1. HP-UX hpterm
            2. NCSA Telnet for Macintosh
        4. Putting It All Together
        5. Displaying Other Types of Information
          1. Displaying the Username
          2. Setting the Window Icon in xterm
      12. 15. Job Control
        1. Job States
        2. Obtaining Job Information
          1. Finding Out When Jobs Finish
          2. The Current and Previous Jobs
        3. Changing a Job's State
          1. Stopping a Job
          2. Resuming a Job
            1. Shorthand forms of fg and bg
          3. Killing a Job
            1. Killing stubborn Jobs
          4. Suspending a Non-Login Shell
        4. Other Applications of Job Control
          1. Controlling Background Job Output
          2. Backgrounding Interactive Jobs
          3. Using Job Control To Improve System Response
        5. Job Control and Window Systems
    5. III. Appendixes
      1. A. Obtaining and Installing tcsh
        1. Obtaining the Source Distribution
        2. Build the Distribution—Quick Instructions
        3. Build the Distribution—Detailed Instructions
          1. Overview of the Build Process
          2. Choose an Installation Directory
          3. Configure the Makefile
          4. Configure config.h
          5. Configure config_ f.h
          6. Compile tcsh
          7. Porting tcsh to a New System
        4. Testing and Installing tcsh
        5. Allowing tcsh To Be a Log in Shell
          1. If Your System Does Not Use /etc/shells
      2. B. csh and tcsh Quick Reference
        1. Command Structure
        2. Star tup and Shutdown Files
        3. Variables
          1. Defining, Removing, and Examining Variables
          2. Using Variables
        4. Special Characters
          1. Special Characters in Filenames
          2. Quote Characters
        5. Command History
          1. History Event Specifiers
          2. Word Designators
          3. History Modifiers
        6. Moving Around the File System
        7. Aliases
        8. Filename Completion
        9. Programmed Completion
        10. Job Control
        11. Command Editing in tcsh
          1. emacs Mode Editing Commands
          2. vi Mode Editing Commands
          3. The bindkey Command
      3. C. Other Sources of Information
        1. Documents
        2. Newsgroups
        3. Mailing Lists
    6. Index
    7. About the Author
    8. Colophon
    9. SPECIAL OFFER: Upgrade this ebook with O’Reilly

Product information

  • Title: Using csh & tcsh
  • Author(s): Paul DuBois
  • Release date: July 1995
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781449391065