What is tcsh in linux

Download and Install csh / tcsh shell on Linux

Install csh / tcsh

In case csh is not installed, type the following command at shell prompt as per your Linux distro / version.

Install it on Debian/Ubuntu/Mint Linux

$ sudo apt-get install csh

Install it on CentOS/RHEL

# yum install tcsh

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

Install it on Fedora Linux

$ sudo dnf install tcsh

Set csh as default login shell

To make csh as default login shell, type the following command:
$ which tcsh
OR
$ which csh
Sample output:

Note down the /bin/csh or /bin/tcsh path. To change the shell simply type
$ chsh
OR
$ chsh -s /bin/csh

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Category List of Unix and Linux commands
Documentation help • mandb • man • pinfo
Disk space analyzers df • duf • ncdu • pydf
File Management cat • cp • less • mkdir • more • tree
Firewall Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04
Linux Desktop Apps Skype • Spotify • VLC 3
Modern utilities bat • exa
Network Utilities NetHogs • dig • host • ip • nmap
OpenVPN CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04
Package Manager apk • apt
Processes Management bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop
Searching ag • grep • whereis • which
Shell builtins compgen • echo • printf
Text processing cut • rev
User Information groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w
WireGuard VPN Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04

Comments on this entry are closed.

Sorry, making mistakes again and again.
one more time.
Thnx once again.

thanks for proving this information. It solved my problem while installing xfig in fc8.

Hi, I have a question.
I was trying to install csh via commands
…………………………………………………………………….
kavita@atom:

> which csh
/usr/bin/csh
kavita@atom:

> chsh
Changing login shell for kavita.
Password:
Enter the new value, or press return for the default.
Login Shell [/bin/bash]: kavitac
chsh: Shell must be a full path name.
…………………………………………………………………………….

What I should give the new value & what is the meaning of press return here ?

Type /usr/bin/csh at Login shell and press [Enter] key.

u mean at terminal I should do this.

thanks it works

Hey when I type this /usr/bin/csh on login shell, it says that Shell not changed

What does it mean ?

when i am trying to install csh using
$ sudo apt-get install csh
i get this message

sudo: apt-get: command not found

Sanjeev, I would venture to say you are not running a debian based linux distro. What distro are you running?

hi
how can install csh package on ubuntu

you can write in a terminal as
sudo apt-get instal csh

Hi!
I has innstall sun’s fedora 10. I want innstall tcsh,Ok?
Thanks!’

I am is chinese,So english very not good.

Does anyone know where to download csh? I have been looking on the web with no luck!

@Moon, use yum command to install csh

1. I use Fedora 14, but default of it is .bash cell while I need csh cell. how to get it.?can you help me.?
2. there are 3 files: tcsh-6.19.00.tar, gzm csh-x64.exe.gz, tcsh-x86.exe.gz..which i choose one. then how to install it.

Hi, How do I start Qshell in Linux?Where do I download it?

if I have an upen to linix interfase

is it asame thing

Hi
when i wont to install tcsh in ubuntu
i find this message
E: Impossible de trouver le paquet tcsh
please help me
thanks

Hi i get this error when i give csh at prompt
$ csh
LANG: Undefined variable.
i can run all otehr commands, except this.. pls suggest.. tks

This was a great help to me. For a day I tried converting a c-shell script to bash without any luck, until i discovered this help article. After following steps my app installed like a champ.
Reza

i install fedora 11 but in that i use the command $ SHELL it show only bin/bash
bin/sh but,i do the program in c shell ,so what can i do

Hi, I have Ubuntu 11.10.
when i wrote
csh on command line.. i got following:
The program ‘csh’ can be found in the following packages:
* csh
* tcsh
Ask your administrator to install one of them

when write the following:
sudo apt-get install csh
bharti is not in the sudoers file. This incident will be reported.

i use CentOS 6.2. i have same problem like that, i already install the new package of csh ¨Package tcsh-6.17-19.el6_2.x86_64 already installed and latest version¨ but when i type ¨csh” or ¨tcsh¨ on terminal, still at bash shell.
i have already try with the same way with another PC using Ubuntu 9.04. it work. why it does´t work at CentOS. Do you have any advice…?

thank you for your attention

What are the uses of C Shell and How can i do work with it.

Hi .Thanks for helping me understand what is tsch shell but stil ask whether this enhancement versions are compartible with any given linux .

can u tell me how to install c shell in red hat linux version 5

Thank You very much. Its the first “First-Class-Help”, everybody understand it and:

Источник

Linux: Tcsh

Chen Weixiang @ Feb 11, 2016

| TAG: Linux

This article introduces the tcsh in detail. And the most of the content is from Tcsh Manual v6.19.00. I try to understand all features and add some examples in this article.

Instruction

The official website of Tcsh is here.

What’s csh?

The C shell (csh) is a Unix shell that was created by Bill Joy while he was a graduate student at University of California, Berkeley in the late 1970s. It has been distributed widely, beginning with the 2BSD release of the BSD Unix system that Joy began distributing in 1978. Other early contributors to the ideas or the code were Michael Ubell, Eric Allman, Mike O’Brien and Jim Kulp.

The C shell is a command processor typically run in a text window, allowing the user to type commands. The C shell can also read commands from a file, called a script. Like all Unix shells, it supports filename wildcarding, piping, here documents, command substitution, variables and control structures for condition-testing and iteration. What differentiated the C shell from others, especially in the 1980s, were its interactive features and overall style. Its new features made it easier and faster to use. The overall style of the language looked more like C and was seen as more readable.

What’s Tcsh?

Tcsh is a Unix shell based on and compatible with the C shell (csh). It is essentially the C shell with programmable command-line completion, command-line editing, and a few other features. Unlike the other common shells, functions cannot be defined in a tcsh script and the user must use aliases instead (as in csh).

The t in tcsh comes from the T in TENEX, an operating system which inspired Ken Greer at Carnegie Mellon University, the author of tcsh, with its command-completion feature. Greer began working on his code to implement Tenex-style file name completion in September 1975, finally merging it into the C shell in December 1981. Mike Ellis at Fairchild A.I. Labs added command completion in September 1983. On October 3, 1983, Greer posted source to the net.sources newsgroup.

Tcsh Releases

Releases Date
6.00.00 1995-09-23
6.01.00 1995-09-23
6.02.00 1995-09-23
6.03.00 1995-09-23
6.04.00 1995-09-23
6.05.00 1995-09-23
6.06.00 1995-09-23
6.07.00 1996-10-27
6.08.00 1998-10-02
6.09.00 1999-08-06
6.10.00 2000-11-19
6.11.00 2001-09-02
6.12.00 2002-07-23
6.13.00 2004-05-19
6.14.00 2005-03-25
6.15.00 2007-03-03
6.16.00 2008-10-09
6.17.00 2009-07-10
6.18.00 2012-01-14
6.19.00 2015-05-21

SYNOPSIS

Formats: tcsh [-bcdefFimnqstvVxX] [-Dname[=value]] [arg . ] tcsh -l

If the first argument (argument 0) to the shell is — then it is a login shell. A login shell can be also specified by invoking the shell with the -l flag as the only argument.

The rest of the flag arguments are interpreted as follows:

Options Description
-b Forces a break from option processing, causing any further shell arguments to be treated as non-option arguments. The remaining arguments will not be interpreted as shell options. This may be used to pass options to a shell script without confusion or possible subterfuge. The shell will not run a set-user ID script without this option.
-c Commands are read from the following argument (which must be present, and must be a single argument), stored in the command shell variable for reference, and executed. Any remaining arguments are placed in the argv shell variable.
-d The shell loads the directory stack from

/.cshdirs as described under Startup and shutdown, whether or not it is a login shell. (+)

-e The shell exits if any invoked command terminates abnormally or yields a non-zero exit status.
-f The shell does not load any resource or startup files, or perform any command hashing, and thus starts faster.
-F The shell uses fork(2) instead of vfork(2) to spawn processes. (+)
-i The shell is interactive and prompts for its top-level input, even if it appears to not be a terminal. Shells are interactive without this option if their inputs and outputs are terminals.
-l The shell is a login shell. Applicable only if -l is the only flag specified.
-m The shell loads

/.tcshrc even if it does not belong to the effective user. Newer versions of su(1) can pass -m to the shell. (+)

-n The shell parses commands but does not execute them. This aids in debugging shell scripts.
-q The shell accepts SIGQUIT and behaves when it is used under a debugger. Job control is disabled. (u)
-s Command input is taken from the standard input.
-t The shell reads and executes a single line of input. A \ may be used to escape the newline at the end of this line and continue onto another line.
-v Sets the verbose shell variable, so that command input is echoed after history substitution.
-V Sets the verbose shell variable even before executing

/.tcshrc.

-x Sets the echo shell variable, so that commands are echoed immediately before execution.
-X Is to -x as -V is to -v .
-Dname[=value] Sets the environment variable name to value. (Domain/OS only) (+)
—help Print a help message on the standard output and exit. (+)
—version Print the version/platform/compilation options on the standard output and exit. This information is also contained in the version shell variable. (+)

After processing of flag arguments, if arguments remain but none of the -c , -i , -s , or -t options were given, the first argument is taken as the name of a file of commands, or script, to be executed. The shell opens this file and saves its name for possible resubstitution by $0. Because many systems use either the standard version 6 or version 7 shells whose shell scripts are not compatible with this shell, the shell uses such a standard shell to execute a script whose first character is not a # , i.e., that does not start with a comment.

Remaining arguments are placed in the argv shell variable.

DESCRIPTION

Startup and shutdown

A login shell begins by executing commands from the system files /etc/csh.cshrc and /etc/csh.login. It then executes commands from files in the user’s home directory: first

/.tcshrc (+) or, if

/.tcshrc is not found,

/.cshrc, then

/.history (or the value of the histfile shell variable), then

/.login, and finally

/.cshdirs (or the value of the dirsfile shell variable) (+). The shell may read /etc/csh.login before instead of after /etc/csh.cshrc, and

/.login before instead of after

/.tcshrc or

/.cshrc and

/.history, if so compiled; see the version shell variable. (+)

Non-login shells read only /etc/csh.cshrc and

/.tcshrc or

For examples of startup files, please consult the tcshrc project.

Commands like stty(1) and tset(1), which need be run only once per login, usually go in one’s

/.login file. Users who need to use the same set of files with both csh(1) and tcsh can have only a

/.cshrc which checks for the existence of the tcsh shell variable (q.v.) before using tcsh-specific commands, or can have both a

/.cshrc and a

/.tcshrc which sources (see the builtin command)

/.cshrc. The rest of this manual uses

/.tcshrc to mean

/.tcshrc or, if

/.tcshrc is not found,

In the normal case, the shell begins reading commands from the terminal, prompting with > . (Processing of arguments and the use of the shell to process files containing command scripts are described later.) The shell repeatedly reads a line of command input, breaks it into words, places it on the command history list, parses it and executes each command in the line.

One can log out by typing ^D on an empty line, logout or login or via the shell’s autologout mechanism (see the autologout shell variable). When a login shell terminates it sets the logout shell variable to normal or automatic as appropriate, then executes commands from the files /etc/csh.logout and

/.logout. The shell may drop DTR on logout if so compiled; see the version shell variable.

The names of the system login and logout files vary from system to system for compatibility with different csh(1) variants; see FILES.

When startup, the shell begins by executing commands from the following system files:

Files Login tcsh Non-login tcsh
/etc/csh.cshrc Yes Yes
/etc/csh.login Yes No

/.tcshrc

Yes Yes

/.cshrc

Yes, if

/.tcshrc is not found

Yes, if

/.tcshrc is not found

/.history

Yes No
value of histfile shell variable Yes, if

/.history is not found

No

/.login

Yes No

/.cshdirs

Yes No
value of dirsfile shell variable Yes, if

/.cshdirs is not found

No

Note: The shell may read /etc/csh.login before instead of after /etc/csh.cshrc, and

/.login before instead of after

/.tcshrc or

/.cshrc and

/.history, if so compiled; see the version shell variable. (+)

When a login shell terminates, the shell begins by executing commands from the following system files:

Files Login tcsh
/etc/csh.logout Yes

/.logout

Yes

The command-line editor (+)

Command-line input can be edited using key sequences much like those used in emacs(1) or vi(1). The editor is active only when the edit shell variable is set, which it is by default in interactive shells. The bindkey builtin can display and change key bindings. emacs(1)-style key bindings are used by default (unless the shell was compiled otherwise; see the version shell variable), but bindkey can change the key bindings to vi(1)-style bindings en masse.

The shell always binds the arrow keys (as defined in the TERMCAP environment variable) to

TERMCAP Description
down down-history
up up-history
left backward-char
right forward-char

unless doing so would alter another single-character binding. One can set the arrow key escape sequences to the empty string with settc to prevent these bindings. The ANSI/VT100 sequences for arrow keys are always bound.

Other key bindings are, for the most part, what emacs(1) and vi(1) users would expect and can easily be displayed by bindkey, so there is no need to list them here. Likewise, bindkey can list the editor commands with a short description of each. Certain key bindings have different behavior depending if emacs(1) or vi(1) style bindings are being used; see vimode for more information.

Note that editor commands do not have the same notion of a word as does the shell. The editor delimits words with any non-alphanumeric characters not in the shell variable wordchars, while the shell recognizes only whitespace and some of the characters with special meanings to it, listed under Lexical structure.

Examples:

Completion and listing (+)

The shell is often able to complete words when given a unique abbreviation. Type part of a word (for example ls /usr/lost ) and hit the tab key to run the complete-word editor command. The shell completes the filename /usr/lost to /usr/lost+found/ , replacing the incomplete word with the complete word in the input buffer. (Note the terminal / ; completion adds a / to the end of completed directories and a space to the end of other completed words, to speed typing and provide a visual indicator of successful completion. The addsuffix shell variable can be unset to prevent this.) If no match is found (perhaps /usr/lost+found doesn’t exist), the terminal bell rings. If the word is already complete (perhaps there is a /usr/lost on your system, or perhaps you were thinking too far ahead and typed the whole thing) a / or space is added to the end if it isn’t already there.

Completion works anywhere in the line, not at just the end; completed text pushes the rest of the line to the right. Completion in the middle of a word often results in leftover characters to the right of the cursor that need to be deleted.

Commands and variables can be completed in much the same way. For example, typing em[tab] would complete em to emacs if emacs were the only command on your system beginning with em . Completion can find a command in any directory in path or if given a full pathname. Typing echo $ar[tab] would complete $ar to $argv if no other variable began with ar .

The shell parses the input buffer to determine whether the word you want to complete should be completed as a filename, command or variable. The first word in the buffer and the first word following ; , | , |& , && or || is considered to be a command. A word beginning with $ is considered to be a variable. Anything else is a filename. An empty line is completed as a filename.

You can list the possible completions of a word at any time by typing ^D to run the delete-char-or-list-or-eof editor command. The shell lists the possible completions using the ls-F builtin (q.v.) and reprints the prompt and unfinished command line, for example:

If the autolist shell variable is set, the shell lists the remaining choices (if any) whenever completion fails:

If autolist is set to ambiguous , choices are listed only when completion fails and adds no new characters to the word being completed.

A filename to be completed can contain variables, your own or others’ home directories abbreviated with

(see Filename substitution) and directory stack entries abbreviated with = (see Directory stack substitution). For example,

Note that variables can also be expanded explicitly with the expand-variables editor command.

delete-char-or-list-or-eof lists at only the end of the line; in the middle of a line it deletes the character under the cursor and on an empty line it logs one out or, if ignoreeof is set, does nothing. M-^D , bound to the editor command list-choices, lists completion possibilities anywhere on a line, and list-choices (or any one of the related editor commands that do or don’t delete, list and/or log out, listed under delete-char-or-list-or-eof) can be bound to ^D with the bindkey builtin command if so desired.

The complete-word-fwd and complete-word-back editor commands (not bound to any keys by default) can be used to cycle up and down through the list of possible completions, replacing the current word with the next or previous word in the list.

The shell variable fignore can be set to a list of suffixes to be ignored by completion. Consider the following:

and main.o are ignored by completion (but not listing), because they end in suffixes in fignore. Note that a \ was needed in front of

to prevent it from being expanded to home as described under Filename substitution. fignore is ignored if only one completion is possible.

If the complete shell variable is set to enhance , completion 1) ignores case and 2) considers periods, hyphens and underscores ( . , — and _ ) to be word separators and hyphens and underscores to be equivalent. If you had the following files

comp.lang.c comp.lang.perl comp.std.c++ comp.lang.c++ comp.std.c

and typed mail -f c.l.c[tab] , it would be completed to mail -f comp.lang.c , and ^D would list comp.lang.c and comp.lang.c++ . mail -f c..c++[^D] would list comp.lang.c++ and comp.std.c++ . Typing rm a—file[^D] in the following directory

A_silly_file a-hyphenated-file another_silly_file

would list all three files, because case is ignored and hyphens and underscores are equivalent. Periods, however, are not equivalent to hyphens or underscores.

If the complete shell variable is set to Enhance , completion ignores case and differences between a hyphen and an underscore word separator only when the user types a lowercase character or a hyphen. Entering an uppercase character or an underscore will not match the corresponding lowercase character or hyphen word separator. Typing rm a—file[^D] in the directory of the previous example would still list all three files, but typing rm A—file would match only A_silly_file and typing rm a__file[^D] would match just A_silly_file and another_silly_file because the user explicitly used an uppercase or an underscore character.

Completion and listing are affected by several other shell variables:

recexact can be set to complete on the shortest possible unique match, even if more typing might result in a longer match:

just beeps, because fo could expand to fod or foo , but if we type another o ,

the completion completes on foo , even though food and foonly also match.

autoexpand can be set to run the expand-history editor command before each completion attempt.

autocorrect can be set to spelling-correct the word to be completed (see Spelling correction) before each completion attempt and correct can be set to complete commands automatically after one hits return .

matchbeep can be set to make completion beep or not beep in a variety of situations;

nobeep can be set to never beep at all.

nostat can be set to a list of directories and/or patterns that match directories to prevent the completion mechanism from stat(2)ing those directories.

listmax and listmaxrows can be set to limit the number of items and rows (respectively) that are listed without asking first.

recognize_only_executables can be set to make the shell list only executables when listing commands, but it is quite slow.

Finally, the complete builtin command can be used to tell the shell how to complete words other than filenames, commands and variables. Completion and listing do not work on glob-patterns (see Filename substitution), but the list-glob and expand-glob editor commands perform equivalent functions for glob-patterns.

Spelling correction (+)

The shell can sometimes correct the spelling of filenames, commands and variable names as well as completing and listing them.

Individual words can be spelling-corrected with the spell-word editor command (usually bound to M-s and M-S ) and the entire input buffer with spell-line (usually bound to M-$ ). The correct shell variable can be set to cmd to correct the command name or all to correct the entire line each time return is typed, and autocorrect can be set to correct the word to be completed before each completion attempt.

When spelling correction is invoked in any of these ways and the shell thinks that any part of the command line is misspelled, it prompts with the corrected line:

  • y or space to execute the corrected line,
  • e to leave the uncorrected command in the input buffer,
  • a to abort the command as if ^C had been hit, and
  • anything else to execute the original line unchanged.

Spelling correction recognizes user-defined completions (see the complete builtin command). If an input word in a position for which a completion is defined resembles a word in the completion list, spelling correction registers a misspelling and suggests the latter word as a correction. However, if the input word does not match any of the possible completions for that position, spelling correction does not register a misspelling.

Like completion, spelling correction works anywhere in the line, pushing the rest of the line to the right and possibly leaving extra characters to the right of the cursor.

Editor commands (+)

bindkey lists key bindings and bindkey -l lists and briefly describes editor commands. Only new or especially interesting editor commands are described here. See emacs(1) and vi(1) for descriptions of each editor’s key bindings.

^character means a control character and M-character a meta character, typed as escape-character on terminals without a meta key. Case counts, but commands that are bound to letters by default are bound to both lower- and uppercase letters for convenience.

Commands Default Bindings Description
backward-char ^B
left
Move back a character. Cursor behavior modified by vimode.
forward-char ^F
right
Move forward one character. Cursor behavior modified by vimode.
backward-delete-word M-^H
M-^?
Cut from beginning of current word to cursor — saved in cut buffer. Word boundary behavior modified by vimode.
backward-word M-b
M-B
Move to beginning of current word. Word boundary and cursor behavior modified by vimode.
forward-word M-f
M-F
Move forward to end of current word. Word boundary and cursor behavior modified by vimode.
beginning-of-line ^A
home
Move to beginning of line. Cursor behavior modified by vimode.
end-of-line ^E
end
Move cursor to end of line. Cursor behavior modified by vimode.
capitalize-word M-c
M-C
Capitalize the characters from cursor to end of current word. Word boundary behavior modified by vimode.
downcase-word M-l
M-L
Lowercase the characters from cursor to end of current word. Word boundary behavior modified by vimode.
complete-word tab Completes a word as described under Completion and listing.
complete-word-raw ^X-tab Like complete-word, but ignores user-defined completions.
complete-word-fwd not bound Replaces the current word with the first word in the list of possible completions. May be repeated to step down through the list. At the end of the list, beeps and reverts to the incomplete word.
complete-word-back not bound Like complete-word-fwd, but steps up from the end of the list.
copy-prev-word M-^_ Copies the previous word in the current line into the input buffer. See also insert-last-word. Word boundary behavior modified by vimode.
dabbrev-expand M-/ Expands the current word to the most recent preceding one for which the current is a leading substring, wrapping around the history list (once) if necessary. Repeating dabbrev-expand without any intervening typing changes to the next previous word etc., skipping identical matches much like history-search-backward does.
delete-char not bound Deletes the character under the cursor. See also delete-char-or-list-or-eof. Cursor behavior modified by vimode.
delete-char-or-list not bound Does delete-char if there is a character under the cursor or list-choices at the end of the line. See also delete-char-or-list-or-eof.
delete-char-or-list-or-eof ^D Does delete-char if there is a character under the cursor, list-choices at the end of the line or end-of-file on an empty line. See also those three commands, each of which does only a single action, and delete-char-or-eof, delete-char-or-list and list-or-eof, each of which does a different two out of the three.
delete-char-or-eof not bound Does delete-char if there is a character under the cursor or end-of-file on an empty line. See also delete-char-or-list-or-eof. Cursor behavior modified by vimode.
delete-word M-d
M-D
Cut from cursor to end of current word — save in cut buffer. Word boundary behavior modified by vimode.
up-history up-arrow
^P
Copies the previous entry in the history list into the input buffer. If histlit is set, uses the literal form of the entry. May be repeated to step up through the history list, stopping at the top.
down-history down-arrow
^N
Like up-history, but steps down, stopping at the original input line.
history-search-backward M-p
M-P
Searches backwards through the history list for a command beginning with the current contents of the input buffer up to the cursor and copies it into the input buffer. The search string may be a glob-pattern (see Filename substitution) containing * , ? , [] or <> . up-history and down-history will proceed from the appropriate point in the history list. Emacs mode only. See also history-search-forward and i-search-back.
history-search-forward M-n
M-N
Like history-search-backward, but searches forward.
i-search-back not bound Searches backward like history-search-backward, copies the first match into the input buffer with the cursor positioned at the end of the pattern, and prompts with bck: and the first match. Additional characters may be typed to extend the search, i-search-back may be typed to continue searching with the same pattern, wrapping around the history list if necessary.
i-search-fwd not bound Like i-search-back, but searches forward. Word boundary behavior modified by vimode.
end-of-file not bound Signals an end of file, causing the shell to exit unless the ignoreeof shell variable (q.v.) is set to prevent this. See also delete-char-or-list-or-eof.
expand-history M-space Expands history substitutions in the current word. See History substitution. See also magic-space, toggle-literal-history and the autoexpand shell variable.
expand-glob ^X-* Expands the glob-pattern to the left of the cursor. See Filename substitution.
expand-line not bound Like expand-history, but expands history substitutions in each word in the input buffer.
expand-variables ^X-$ Expands the variable to the left of the cursor. See Variable substitution.
insert-last-word M-_ Inserts the last word of the previous input line ( !$ ) into the input buffer. See also copy-prev-word.
list-choices M-^D Lists completion possibilities as described under Completion and listing. See also delete-char-or-list-or-eof and list-choices-raw.
list-choices-raw ^X-^D Like list-choices, but ignores user-defined completions.
list-glob ^X-g
^X-G
Lists (via the ls-F builtin) matches to the glob-pattern (see Filename substitution) to the left of the cursor.
list-or-eof not bound Does list-choices or end-of-file on an empty line. See also *delete-char-or-list-or-eof.
magic-space not bound Expands history substitutions in the current line, like expand-history, and inserts a space. magic-space is designed to be bound to the space bar, but is not bound by default.
normalize-command ^X-? Searches for the current word in PATH and, if it is found, replaces it with the full path to the executable. Special characters are quoted. Aliases are expanded and quoted but commands within aliases are not. This command is useful with commands that take commands as arguments, e.g., dbx and sh -x .
normalize-path ^X-n
^X-N
Expands the current word as described under the expand setting of the symlinks shell variable.
overwrite-mode not bound Toggles between input and overwrite modes.
run-fg-editor M-^Z Saves the current input line and looks for a stopped job where the file name portion of its first word is found in the editors shell variable. If editors is not set, then the file name portion of the EDITOR environment variable ( ed if unset) and the VISUAL environment variable ( vi if unset) will be used. If such a job is found, it is restarted as if fg %job had been typed. This is used to toggle back and forth between an editor and the shell easily. Some people bind this command to ^Z so they can do this even more easily.
run-help M-h
M-H
Searches for documentation on the current command, using the same notion of current command as the completion routines, and prints it. There is no way to use a pager; run-help is designed for short help files. If the special alias helpcommand is defined, it is run with the command name as a sole argument. Else, documentation should be in a file named command.help, command.1, command.6, command.8 or command, which should be in one of the directories listed in the HPATH environment variable. If there is more than one help file only the first is printed.
self-insert-command text characters In insert mode (the default), inserts the typed character into the input line after the character under the cursor. In overwrite mode, replaces the character under the cursor with the typed character. The input mode is normally preserved between lines, but the inputmode shell variable can be set to insert or overwrite to put the editor in that mode at the beginning of each line. See also overwrite-mode.
sequence-lead-in arrow prefix

^X

Indicates that the following characters are part of a multi-key sequence. Binding a command to a multi-key sequence really creates two bindings: the first character to sequence-lead-in and the whole sequence to the command. All sequences beginning with a character bound to sequence-lead-in are effectively bound to undefined-key unless bound to another command.
spell-line M-$ Attempts to correct the spelling of each word in the input buffer, like spell-word, but ignores words whose first character is one of — , ! , ^ or % , or which contain \ , * or ? , to avoid problems with switches, substitutions and the like. See Spelling correction.
spell-word M-s
M-S
Attempts to correct the spelling of the current word as described under Spelling correction. Checks each component of a word which appears to be a pathname.
toggle-literal-history M-r
M-R
Expands or unexpands history substitutions in the input buffer. See also expand-history and the autoexpand shell variable.
undefined-key any unbound key Beeps.
vi-beginning-of-next-word not bound Vi goto the beginning of next word. Word boundary and cursor behavior modified by vimode.
vi-eword not bound Vi move to the end of the current word. Word boundary behavior modified by vimode.
vi-search-back ? Prompts with ? for a search string (which may be a glob-pattern, as with history-search-backward), searches for it and copies it into the input buffer. The bell rings if no match is found. Hitting return ends the search and leaves the last match in the input buffer. Hitting escape ends the search and executes the match. vi mode only.
vi-search-fwd / Like vi-search-back, but searches forward.
which-command M-? Does a which (see the description of the builtin command) on the first word of the input buffer.
yank-pop M-y When executed immediately after a yank or another yank-pop, replaces the yanked string with the next previous string from the killring. This also has the effect of rotating the killring, such that this string will be considered the most recently killed by a later yank command. Repeating yank-pop will cycle through the killring any number of times.

Lexical structure

The shell splits input lines into words at blanks and tabs. The special characters & | ; > ( ) and the doubled characters && || >> are always separate words, whether or not they are surrounded by whitespace.

When the shell’s input is not a terminal, the character # is taken to begin a comment. Each # and the rest of the input line on which it appears is discarded before further parsing.

A special character (including a blank or tab) may be prevented from having its special meaning, and possibly made part of another word, by preceding it with a backslash ( \ ) or enclosing it in single ( ‘ ), double ( » ) or backward ( \` ) quotes. When not otherwise quoted a newline preceded by a \’ is equivalent to a blank, but inside quotes this sequence results in a newline.

Furthermore, all Substitutions except History substitution can be prevented by enclosing the strings (or parts of strings) in which they appear with single quotes or by quoting the crucial character(s) (e.g., $ or \` for Variable substitution or Command substitution respectively) with \ . (Alias substitution is no exception: quoting in any way any character of a word for which an alias has been defined prevents substitution of the alias. The usual way of quoting an alias is to precede it with a backslash.) History substitution is prevented by backslashes but not by single quotes. Strings quoted with double or backward quotes undergo Variable substitution and Command substitution, but other substitutions are prevented.

Text inside single or double quotes becomes a single word (or part of one). Metacharacters in these strings, including blank and tabs, do not form separate words. Only in one special case (see Command substitution) can a double-quoted string yield parts of more than one word; single-quoted strings never do. Backward quotes are special: they signal Command substitution (q.v.), which may result in more than one word.

Quoting complex strings, particularly strings which themselves contain quoting characters, can be confusing. Remember that quotes need not be used as they are in human writing! It may be easier to quote not an entire string, but only those parts of the string which need quoting, using different types of quoting to do so if appropriate.

The backslash_quote shell variable (q.v.) can be set to make backslashes always quote \ , ‘ , and » . (+) This may make complex quoting tasks easier, but it can cause syntax errors in csh(1) scripts.

Substitutions

We now describe the various transformations the shell performs on the input in the order in which they occur. We note in passing the data structures involved and the commands and variables which affect them. Remember that substitutions can be prevented by quoting as described under Lexical structure.

History substitution

Each command, or event, input from the terminal is saved in the history list. The previous command is always saved, and the history shell variable can be set to a number to save that many commands. The histdup shell variable can be set to not save duplicate events or consecutive duplicate events.

Saved commands are numbered sequentially from 1 and stamped with the time. It is not usually necessary to use event numbers, but the current event number can be made part of the prompt by placing an ! in the prompt shell variable.

The shell actually saves history in expanded and literal (unexpanded) forms. If the histlit shell variable is set, commands that display and store history use the literal form.

The history builtin command can print, store in a file, restore and clear the history list at any time, and the savehist and histfile shell variables can be set to store the history list automatically on logout and restore it on login.

History substitutions introduce words from the history list into the input stream, making it easy to repeat commands, repeat arguments of a previous command in the current command, or fix spelling mistakes in the previous command with little typing and a high degree of confidence.

History substitutions begin with the character ! . They may begin anywhere in the input stream, but they do not nest. The ! may be preceded by a \ to prevent its special meaning; for convenience, a ! is passed unchanged when it is followed by a blank, tab, newline, = or ( . History substitutions also occur when an input line begins with ^ . This special abbreviation will be described later. The characters used to signal history substitution ( ! and ^ ) can be changed by setting the histchars shell variable. Any input line which contains a history substitution is printed before it is executed.

A history substitution may have an event specification, which indicates the event from which words are to be taken, a word designator, which selects particular words from the chosen event, and/or a modifier, which manipulates the selected words.

An event specification can be

event Description
n A number, referring to a particular event
-n An offset, referring to the event n before the current event
# The current event. This should be used carefully in csh(1), where there is no check for recursion. tcsh allows 10 levels of recursion. (+)
! The previous event (equivalent to -1 )
s The most recent event whose first word begins with the string s
?s? The most recent event which contains the string s. The second ? can be omitted if it is immediately followed by a newline.

For example, consider this bit of someone’s history list:

The commands are shown with their event numbers and time stamps. The current event, which we haven’t typed in yet, is event 13. !11 and !-2 refer to event 11. !! refers to the previous event, 12. !! can be abbreviated ! if it is followed by : . !n refers to event 9, which begins with n . !?old? also refers to event 12, which contains old . Without word designators or modifiers history references simply expand to the entire event, so we might type !cp to redo the copy command or !!|more if the diff output scrolled off the top of the screen.

History references may be insulated from the surrounding text with braces if necessary. For example, !vdoc would look for a command beginning with vdoc , and, in this example, not find one, but !doc would expand unambiguously to vi wumpus.mandoc . Even in braces, history substitutions do not nest.

(+) While csh(1) expands, for example, !3d to event 3 with the letter d appended to it, tcsh expands it to the last event beginning with 3d ; only completely numeric arguments are treated as event numbers. This makes it possible to recall events beginning with numbers. To expand !3d as in csh(1) say !<3>d .

To select words from an event we can follow the event specification by a : and a designator for the desired words. The words of an input line are numbered from 0, the first (usually command) word being 0, the second word (first argument) being 1, etc. The basic word designators are:

Designators Description
0 The first (command) word
n The nth argument
^ The first argument, equivalent to 1
$ The last argument
% The word matched by an ?s? search
x-y A range of words
-y Equivalent to 0-y
* Equivalent to ^-$ , but returns nothing if the event contains only 1 word
x* Equivalent to x-$
x- Equivalent to x* , but omitting the last word ( $ )

Selected words are inserted into the command line separated by single blanks. For example, the diff command in the previous example might have been typed as diff . 1.old . 1 (using :1 to select the first argument from the previous event) or diff !-2:2 !-2:1 to select and swap the arguments from the cp command. If we didn’t care about the order of the diff we might have said diff !-2:1-2 or simply diff !-2:* . The cp command might have been written cp wumpus.man !#:1.old , using # to refer to the current event. !n:- hurkle.man would reuse the first two words from the nroff command to say nroff -man hurkle.man .

The : separating the event specification from the word designator can be omitted if the argument selector begins with a ^ , $ , * , % or — . For example, our diff command might have been diff !!^.old !!^ or, equivalently, diff !!$.old !!$ . However, if !! is abbreviated ! , an argument selector beginning with — will be interpreted as an event specification.

A history reference may have a word designator but no event specification. It then references the previous command. Continuing our diff example, we could have said simply diff !^.old !^ or, to get the arguments in the opposite order, just diff !* .

Источник

Читайте также:  Как увеличить tx power kali linux
Оцените статью