The guy who is familiar with DOS is trying to make UNIX like DOS,
One of them is to set the Unix prompt as $ p $ G. The following describes the method.
The GNU bash (Bourne again shell) is more convenient for different shell settings)
And KSh (Korn shell) and tcsh (enhanced version of CSH, CSH in Linux is
Symbol connection ). The General Sh (Bourne shell) and CSH settings are cool. One by one
Various shell setting methods:
Ksh:
Because KSh treats the prompt variable PS1 as a special variable, KSh automatically changes
The new PS1 value, so you just need to simply add the environment variable $ PWD corresponding to the current path to PS1:
PS1 = '$ PWD $'
SH:
Because the Bourne shell only uses PS1 as a common variable and does not support aliases, no
To perfectly implement the same functions in DOS, the solution is to redefine a command (such as XCD)
Implement it as a function:
XCD () {CD $ *; PS1 = "'pwd' $ ";}
Switch the directory with XCD each time.
CSH:
CSH does not perform special processing on the prompt variable $ prompt, But it supports aliases. You can modify them.
CD syntax to make it automatically modify the prompt:
Alias setprompt 'set prompt = "$ {CWD} % "'
Setprompt # To set the initial prompt
Alias CD 'chdir \! * & Setprompt'
Bash:
Bash provides some special variables to support prompt settings. \ W indicates the current path and sets
Equivalent to replacing $ home ~, To shorten the length of the prompt.
PS1 = '\ W $'
In Linux, the hostname is also added:
PS1 = '\ H: \ W $' # \ h indicates the hostname
In order to be more like DOS, we can clearly distinguish different commands. I usually add a line break:
PS1 ='
\ H: \ W $'
Tcsh:
The tcsh method is similar to bash, except that the variable names are different:
Set prompt = '% ~ '# % ~ Indicates the current path
Sample:
Different practices in Solaris: how to display a directory in the command line?
The guy who is familiar with DOS is trying to make UNIX like DOS,
One of them is to set the Unix prompt as $ p $ G. The following describes the method.
The GNU bash (Bourne again shell) is more convenient for different shell settings)
And KSh (Korn shell) and tcsh (enhanced version of CSH, CSH in Linux is
Symbol connection ). The General Sh (Bourne shell) and CSH settings are cool. One by one
Various shell setting methods:
Ksh:
Because KSh treats the prompt variable PS1 as a special variable, KSh automatically changes
The new PS1 value, so you just need to simply add the environment variable $ PWD corresponding to the current path to PS1:
PS1 = '$ PWD $'
SH:
Because the Bourne shell only uses PS1 as a common variable and does not support aliases, no
To perfectly implement the same functions in DOS, the solution is to redefine a command (such as XCD)
Implement it as a function:
XCD () {CD $ *; PS1 = "'pwd' $ ";}
Switch the directory with XCD each time.
CSH:
CSH does not perform special processing on the prompt variable $ prompt, But it supports aliases. You can modify them.
CD syntax to make it automatically modify the prompt:
Alias setprompt 'set prompt = "$ {CWD} % "'
Setprompt # To set the initial prompt
Alias CD 'chdir \! * & Setprompt'
Bash:
Bash provides some special variables to support prompt settings. \ W indicates the current path and sets
Equivalent to replacing $ home ~, To shorten the length of the prompt.
PS1 = '\ W $'
In Linux, the hostname is also added:
PS1 = '\ H: \ W $' # \ h indicates the hostname
In order to be more like DOS, we can clearly distinguish different commands. I usually add a line break:
PS1 ='
\ H: \ W $'
Tcsh:
The tcsh method is similar to bash, except that the variable names are different:
Set prompt = '% ~ '# % ~ Indicates the current path