Learning_the_bash_Shell_Third_Edition 3.1/n(83|65)

#

Table 3-4. Editing mode variables

 

Variable        Meaning
HISTCMD              The history number of the current command.
HISTCONTROL A list of patterns, separated by colons (:), which can have the following values. ignorespace: lines beginning

with a space are not entered into the history list. ignoredups: lines matching the last history line are not entered. erasedups: all previous lines matching the current line are removed from the history list before the line is saved. ignoreboth: enables both ignorespace and ignoredups. a
HISTIGNORE A list of patterns, separated by colons (:), used to decide which command lines to save in the history list. Patterns are considered to start at the beginning of the command line and must fully specify the line, i.e., no wildcard (*) is implicitly appended. The patterns are checked against the line after HISTCONTROL is applied. An ampersand (&) matches the previous line. An explicit & may be generated by escaping it with a backslash. b HISTFILE Name of history file in which the command history is saved. The default is ~/.bash_history.
HISTFILESIZE The maximum number of lines to store in the history file. The default is 500. When this variable is assigned a value, the history file is truncated, if necessary, to the given number of lines.
HISTSIZE The maximum number of commands to remember in the command history. The default is 500.

 

You can also use the variable $_ in the message to print the name of the current mail file. For example:

 

MAILPATH='/usr/mail/you?You have some new mail in $_'

cor@debian:~$ echo $_
-F

  

  

Prompting variables 

Actually, bash uses four prompt strings. They are stored in the variables PS1, PS2,PS3, and PS4. The first of these is called the primary prompt string; it is your usual shell prompt, and its default value is “\s-\v\$ ”. * Many people like to set their primary prompt string to something containing their login name. Here is one way to do this:

 

PS1="\u—> "

  PS2 is called the secondary prompt string; its default value is >.

$ echo "This is a long line, # PS1 for the command
> which is terminated down here" # PS2 for the continuation
$
# PS1 for the next command

  

PS3 and PS4 relate to shell programming and debugging. They will be explained in
Chapter 5, and Chapter 9.

 

As you probably know, every command you use is actually a file that contains code
for your machine to run.

That is where PATH comes in. Its value is a list of directories that the shell searches
every time you enter a command

Hash table

(lqdjango0601) cor@debian:~$ hash
hits	command
   4	/bin/cat
   5	/home/cor/laoqidjango/lqdjango0601/bin/python3
  10	/usr/bin/vi
  15	/bin/ls
   2	/usr/bin/tree
   1	/usr/bin/clea

  

You can also make bash “forget” what is in the hash table by using hash -r to remove everything in the table or hash -d name to remove the specified name. * Another option, -p, allows you to enter a command into the hash table, even if the command doesn’t exist

 

You can find out which variables are environment variables and what their values are by typing export without arguments or by using the -p option to the command.

 

(lqdjango0601) cor@debian:/usr/local/share$ export
declare -x CLUTTER_IM_MODULE="xim"
declare -x COLORTERM="truecolor"
declare -x DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus"
declare -x DESKTOP_SESSION="default"
declare -x DISPLAY=":1"
declare -x GDMSESSION="default"
declare -x GDM_LANG="en_HK.UTF-8"
declare -x GJS_DEBUG_OUTPUT="stderr"
declare -x GJS_DEBUG_TOPICS="JS ERROR;JS LOG"
declare -x GNOME_DESKTOP_SESSION_ID="this-is-deprecated"
declare -x GPG_AGENT_INFO="/run/user/1000/gnupg/S.gpg-agent:0:1"
declare -x GTK_IM_MODULE="fcitx"
declare -x GTK_MODULES="gail:atk-bridge"
declare -x HOME="/home/cor"
declare -x JOURNAL_STREAM="8:13158"
declare -x LANG="en_HK.UTF-8"
declare -x LC_MEASUREMENT="en_HK.UTF-8"
declare -x LC_MONETARY="en_HK.UTF-8"
declare -x LC_NUMERIC="en_HK.UTF-8"
declare -x LC_PAPER="en_HK.UTF-8"
declare -x LC_TIME="en_HK.UTF-8"
declare -x LOGNAME="cor"
declare -x LS_COLORS="rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:"
declare -x OLDPWD="/usr/local"
declare -x PATH="/home/cor/laoqidjango/lqdjango0601/bin:/home/cor/.rbenv/plugins/ruby-build/bin:/home/cor/.rbenv/shims:/home/cor/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/cor/chromiumos/depot_tools"
declare -x PS1="(lqdjango0601) \\[\\e]0;\\u@\\h: \\w\\a\\]\${debian_chroot:+(\$debian_chroot)}\\[\\033[01;32m\\]\\u@\\h\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\\$ "
declare -x PWD="/usr/local/share"
declare -x QT4_IM_MODULE="fcitx"
declare -x QT_ACCESSIBILITY="1"
declare -x QT_IM_MODULE="fcitx"
declare -x QT_LINUX_ACCESSIBILITY_ALWAYS_ON="1"
declare -x QT_QPA_PLATFORMTHEME="qgnomeplatform"
declare -x RBENV_SHELL="bash"
declare -x SESSION_MANAGER="local/debian:@/tmp/.ICE-unix/5347,unix/debian:/tmp/.ICE-unix/5347"
declare -x SHELL="/bin/bash"
declare -x SHLVL="1"
declare -x SSH_AGENT_PID="5431"
declare -x SSH_AUTH_SOCK="/run/user/1000/keyring/ssh"
declare -x TERM="xterm-256color"
declare -x USER="cor"
declare -x USERNAME="cor"
declare -x VIRTUAL_ENV="/home/cor/laoqidjango/lqdjango0601"
declare -x VTE_VERSION="4601"
declare -x WINDOWID="46137350"
declare -x WINDOWPATH="2"
declare -x XAUTHORITY="/run/user/1000/gdm/Xauthority"
declare -x XDG_CURRENT_DESKTOP="GNOME"
declare -x XDG_DATA_DIRS="/usr/share/gnome:/usr/local/share/:/usr/share/"
declare -x XDG_MENU_PREFIX="gnome-"
declare -x XDG_RUNTIME_DIR="/run/user/1000"
declare -x XDG_SEAT="seat0"
declare -x XDG_SESSION_DESKTOP="default"
declare -x XDG_SESSION_ID="5"
declare -x XDG_SESSION_TYPE="x11"
declare -x XDG_VTNR="2"
declare -x XMODIFIERS="@im=fcitx"

  

You may well find that some of these already exist in your own environment, most likely set from the system /etc/profile file (see Chapter 10). You can define them yourself in your .bash_profile and export them, as we did earlier.

 

The value of TERM must be a short character string with lowercase letters that appears as a filename in the terminfo database.

 

posted @ 2021-02-04 10:50  碧水东流至此回  阅读(73)  评论(0编辑  收藏  举报