-o privileged
the $BASH_ENV and $ENV files are not processed
-t
-o onecmd
-u
-o unset
treat unset variables and parameters other than the special parameters '@' or '*' as an error
-v
verbose.
print shell input lines as they are read
-x
-o xtrace
[debug] print commands and their arguments as they are executed
-B
-o braceexpand
shell will perform brace expansion
-c
-o noclobber
prevent output redirection using '>', '>&', and '<>' from overwriting existing files.
-E
-o errtrace
-H
-o histexpand
-P
do not resolve symbolic links
-T
-o functrace
any trap on DEBUG and RETURN are inherited by shell functions
--
if no arguments follow this option, then the positional parameters are unset
-
signal the end of options, cause all remaining arguments to be assigned to the positional parameters
show current status
show on/off
$ set -o
$ set -o
allexport off
braceexpand on
emacs on
errexit off
errtrace off
functrace off
hashall on
histexpand on
history on
ignoreeof off
interactive-comments on
keyword off
monitor on
noclobber off
noexec off
noglob off
nolog off
notify off
nounset off
onecmd off
physical off
pipefail off
posix off
privileged off
verbose off
vi off
xtrace off
show +o/-o
$ set +o
$ set +o
set +o allexport
set -o braceexpand
set -o emacs
set +o errexit
set +o errtrace
set +o functrace
set -o hashall
set -o histexpand
set -o history
set +o ignoreeof
set -o interactive-comments
set +o keyword
set -o monitor
set +o noclobber
set +o noexec
set +o noglob
set +o nolog
set +o notify
set +o nounset
set +o onecmd
set +o physical
set +o pipefail
set +o posix
set +o privileged
set +o verbose
set +o vi
set +o xtrace
option name
option
expression
allexport
Same as -a.
braceexpand
Same as -B.
emacs
Use an emacs-style line editing interface.
This also affects the editing interface used for read -e.
errexit
Same as -e.
errtrace
Same as -E.
functrace
Same as -T.
hashall
Same as -h.
histexpand
Same as -H.
history
Enable command history, as described in Bash History Facilities. This option is on by default in interactive shells.
ignoreeof
An interactive shell will not exit upon reading EOF.
keyword
Same as -k.
monitor
Same as -m.
noclobber
Same as -C.
noexec
Same as -n.
noglob
Same as -f.
nolog
Currently ignored.
notify
Same as -b.
nounset
Same as -u.
onecmd
Same as -t.
physical
Same as -P.
pipefail
If set, the return value of a pipeline is the value of the last (rightmost) command to exit with a non-zero status, or zero if all commands in the pipeline exit successfully. This option is disabled by default.
posix
Change the behavior of Bash where the default operation differs from the POSIX standard to match the standard (see Bash POSIX Mode). This is intended to make Bash behave as a strict superset of that standard.
privileged
Same as -p.
verbose
Same as -v.
vi
Use a vi-style line editing interface. This also affects the editing interface used for read -e.
set originates from the bourne shell (sh) and is part of the POSIX standard;
shopt is bourne-again shell (bash) specific
$ set | grep -e SHELLOPTS -e BASHOPTS
# for shopt
BASHOPTS=cdspell:checkwinsize:cmdhist:complete_fullquote:expand_aliases:extglob:extquote:force_fignore:globasciiranges:histappend:interactive_comments:login_shell:progcomp:promptvars:sourcepath
# for set
SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
$ set -o | column -t | grep -v off
braceexpand on
emacs on
hashall on
histexpand on
history on
interactive-comments on
monitor on
$ shopt | column -t | grep -v off
cdspell on
checkwinsize on
cmdhist on
complete_fullquote on
expand_aliases on
extglob on
extquote on
force_fignore on
globasciiranges on
histappend on
interactive_comments on
login_shell on
progcomp on
promptvars on
sourcepath on
$ shopt | column -t
autocd off
assoc_expand_once off
cdable_vars off
cdspell on
checkhash off
checkjobs off
checkwinsize on
cmdhist on
compat31 off
compat32 off
compat40 off
compat41 off
compat42 off
compat43 off
compat44 off
complete_fullquote on
direxpand off
dirspell off
dotglob off
execfail off
expand_aliases on
extdebug off
extglob on
extquote on
failglob off
force_fignore on
globasciiranges on
globskipdots on
globstar off
gnu_errfmt off
histappend on
histreedit off
histverify off
hostcomplete off
huponexit off
inherit_errexit off
interactive_comments on
lastpipe off
lithist off
localvar_inherit off
localvar_unset off
login_shell on
mailwarn off
no_empty_cmd_completion off
nocaseglob off
nocasematch off
noexpand_translation off
nullglob off
patsub_replacement on
progcomp on
progcomp_alias off
promptvars on
restricted_shell off
shift_verbose off
sourcepath on
varredir_close off
xpg_echo off
Acceptable keymap names are emacs, emacs-standard, emacs-meta, emacs-ctlx,
vi, vi-move, vi-command, and vi-insert.
vi is equivalent to vi-command; emacs is equivalent to emacs-standard.
$ cat .inputrc
set editing-mode vi
set keymap vi
# or
$ set -o vi
[!NOTE|label🎶] This is a patched version of bash 4.3.48 that adds support for custom prompt mode indicators.
It also adds support for a \m prompt escape to specify where in the prompt the indicator should occur.
set emacs-mode-string \1\e[4 q\e]12;red\a\2
set vi-ins-mode-string \1\e[5 q\e]12;green\a\2
set vi-cmd-mode-string \1\e[4 q\e]12;orange\a\2
# or
set emacs-mode-string "\1\e[3 q\2"
set vi-ins-mode-string "\1\e[5 q\2"
set vi-cmd-mode-string "\1\e[4 q\2"
set show-mode-in-prompt on
# string settings cursor shape
# +------------------------------++--------+
# color begin color end
# +------------+ +---+
set emacs-mode-string "\1\e[38;5;240;1m\2╰╶ ᓆ \1\e[0m\2\1\e[3 q\2"
# string settings cursor shape
# +------------------------------------------++--------+
# color begin color begin color end
# +------------+ +------+ +---+
set vi-ins-mode-string "\1\e[38;5;240;1m\2╰╶ \1\e[33;1m\2ᓎ \1\e[0m\2\1\e[5 q\2"
set vi-cmd-mode-string "\1\e[38;5;240;1m\2╰╶ \1\e[34;1m\2ᓏ \1\e[0m\2\1\e[4 q\2"
set keymap emacs
"\ee": vi-editing-mode
set keymap vi-command
"\ee": emacs-editing-mode
set keymap vi-insert
"\ee": vi-movement-mode
#################### VIM ####################
# FOR MORE INFORMATION CHECK:
# https://wiki.archlinux.org/index.php/Readline
# TURN ON VIM (E.G. FOR READLINE)
set editing-mode vi
# SHOW THE VIM MODE IN THE PROMPT (COMMAND OR INSERT)
set show-mode-in-prompt on
# SET THE MODE STRING AND CURSOR TO INDICATE THE VIM MODE
# FOR THE NUMBER AFTER `\e[`:
# 0: blinking block
# 1: blinking block (default)
# 2: steady block
# 3: blinking underline
# 4: steady underline
# 5: blinking bar (xterm)
# 6: steady bar (xterm)
set vi-ins-mode-string (ins)\1\e[5 q\2
set vi-cmd-mode-string (cmd)\1\e[1 q\2
$ cat ~/.inputrc
set editing-mode vi
set vi-ins-mode-string \1\e[5 q\e]12;green\a\2
set vi-cmd-mode-string \1\e[1 q\e]12;orange\a\2
set show-mode-in-prompt on
# Set the default readline mode as vi
set editing-mode vi
# Show the vi mode indicators
set show-mode-in-prompt on
# The following is a little hard to understand
# a full example omiting the wrapping \1 and \2
#
# \e[ (open sequence: ESC CSI)
# 48;5; (specifies 256 bg)
# 2 (bg color)
# m (end)
# 1; (bold)
# 38;5; (specifies 256 fg)
# 0 (fg color)
# m (end)
# COMMAND (some text to display)
# \e[ (open sequence)
# 0 (reset)
# m (end)
# \e[ (open sequence)
# 0 (cursor type)
# q (end)
# Configures the cmd mode display
set vi-cmd-mode-string "\1\e[48;5;2m\2\1\e[1;38;5;0m\2 N \1\e[0m\2 \1\e[0 q\2"
# Configures the ins mode display
set vi-ins-mode-string "\1\e[48;5;4m\2\1\e[1;38;5;0m\2 I \1\e[0m\2 \1\e[6 q\2"
show options
# display readline variable names and values can be used as input or in a Readline initialization file
$ bind -v
# list current readline variable names and values
$ bind -v
set bind-tty-special-chars on
set blink-matching-paren off
set byte-oriented off
set colored-completion-prefix off
set colored-stats on
set completion-ignore-case on
set completion-map-case off
set convert-meta off
set disable-completion off
set echo-control-characters on
set enable-active-region off
set enable-bracketed-paste off
set enable-keypad off
set enable-meta-key on
set expand-tilde off
set history-preserve-point off
set horizontal-scroll-mode off
set input-meta on
set mark-directories on
set mark-modified-lines off
set mark-symlinked-directories on
set match-hidden-files on
set menu-complete-display-prefix off
set meta-flag on
set output-meta on
set page-completions on
set prefer-visible-bell on
set print-completions-horizontally on
set revert-all-at-newline off
set show-all-if-ambiguous on
set show-all-if-unmodified on
set show-mode-in-prompt on
set skip-completed-text on
set visible-stats on
set bell-style audible
set comment-begin #
set completion-display-width -1
set completion-prefix-display-length 0
set completion-query-items 100
set editing-mode emacs
set emacs-mode-string ╰╶ ᓆ
set history-size 5000
set keymap emacs
set keyseq-timeout 500
set vi-cmd-mode-string ╰╶ ᓏ
set vi-ins-mode-string ╰╶ ᓎ
options
active-region-start-color
active-region-end-color
bell-style
bind-tty-special-chars
blink-matching-paren
colored-completion-prefix
colored-stats
comment-begin
completion-display-width
completion-ignore-case
completion-map-case
completion-prefix-display-length
completion-query-items
convert-meta
disable-completion
echo-control-characters
editing-mode
emacs-mode-string
enable-active-region
enable-bracketed-paste
enable-keypad
enable-meta-key
expand-tilde
history-preserve-point
history-size
horizontal-scroll-mode
input-meta
isearch-terminators
keymap
keyseq-timeout
mark-directories
mark-modified-lines
mark-symlinked-directories
match-hidden-files
menu-complete-display-prefix
output-meta
page-completions
print-completions-horizontally
revert-all-at-newline
show-all-if-ambiguous
show-all-if-unmodified
show-mode-in-prompt
skip-completed-text
vi-cmd-mode-string
vi-ins-mode-string
visible-stats
key bindings
# display readline function names and bindings can be used as input or in a readline initialization file
$ bind -p
# list current readline function names and bindings
$ bind -P
## query
$ bind -p
...
"\e&": tilde-expand
# vi-tilde-expand (not bound)
....
$ bind -q tilde-expand
tilde-expand can be invoked via "\e&".
list all names
$ bind -l
inputrc
# https://www.gnu.org/software/bash/manual/bash.html#index-show_002dmode_002din_002dprompt
set show-mode-in-prompt on
# SET THE MODE STRING AND CURSOR TO INDICATE THE VIM MODE
# FOR THE NUMBER AFTER `\e[`:
# 0: blinking block
# 1: blinking block (default)
# 2: steady block
# 3: blinking underline
# 4: steady underline
# 5: blinking bar (xterm)
# 6: steady bar (xterm)
set emacs-mode-string ╰╶ ᓆ
set vi-ins-mode-string ╰╶ ᓎ
set vi-cmd-mode-string ╰╶ ᓏ
set emacs-mode-string \1\e[38;5;240;1m\2╰╶ ᓆ \1\e[0m\2
set vi-ins-mode-string \1\e[38;5;240;1m\2╰╶ \1\e[33;1m\2ᓎ \1\e[0m\2
set vi-cmd-mode-string \1\e[38;5;240;1m\2╰╶ \1\e[34;1m\2ᓏ \1\e[0m\2
# allow iso-latin1 characters to be inserted
set convert-meta off
# don't strip characters to 7 bits when reading
set input-meta on
set completion-ignore-case on
set show-all-if-ambiguous on
set show-all-if-unmodified on
set mark-symlinked-directories on
set print-completions-horizontally on
# https://github.com/scop/bash-completion
set visible-stats on
# https://groups.google.com/g/iterm2-discuss/c/K6YazwKUvjQ/m/7eqeT-AvBgAJ
set enable-bracketed-paste off
# TAB: menu-complete
# set colored-completion-prefix on
set colored-stats on
set skip-completed-text on
# ask if more than 100 candidates
# set completion-query-items 100
set keymap emacs
"\ee": vi-editing-mode
set keymap vi-command
"\ee": emacs-editing-mode
"dw": kill-word
"dd": kill-whole-line
"db": backward-kill-word
"D":kill-line
"v" : ''
"\C-_": undo
"\C-a": beginning-of-line
"\C-b": backward-char
"\C-d": delete-char
"\C-e": end-of-line
"\C-f": forward-char
"\C-g": abort
"\C-k": kill-line
"\C-l": clear-screen
"\C-p": previous-history
"\C-n": next-history
"\C-w": unix-word-rubout
"\C-q": quoted-insert
"\C-x\C-r": re-read-init-file
"\e#": insert-comment
"\e.": insert-last-argument
"\e.": yank-last-arg
# key bindings to get out of vi-editing-mode
set keymap vi-insert
"\ee": emacs-editing-mode
"\C-_": undo
"\C-a": beginning-of-line
"\C-b": backward-char
"\C-d": delete-char
"\C-e": end-of-line
"\C-f": forward-char
"\C-g": abort
"\C-k": kill-line
"\C-l": clear-screen
"\C-p": previous-history
"\C-n": next-history
"\C-w": unix-word-rubout
"\C-q": quoted-insert
"\C-x\C-r": re-read-init-file
"\e#": insert-comment
"\e.": insert-last-argument
"\e.": yank-last-arg
# https://www.gnu.org/software/bash/manual/bash.html#index-show_002dmode_002din_002dprompt
set show-mode-in-prompt on
# SET THE MODE STRING AND CURSOR TO INDICATE THE VIM MODE
# FOR THE NUMBER AFTER `\e[`:
# 0: blinking block
# 1: blinking block (default)
# 2: steady block
# 3: blinking underline
# 4: steady underline
# 5: blinking bar (xterm)
# 6: steady bar (xterm)
set emacs-mode-string ╰╶ ᓆ
set vi-ins-mode-string ╰╶ ᓎ
set vi-cmd-mode-string ╰╶ ᓏ
set emacs-mode-string \1\e[38;5;240;1m\2╰╶ ᓆ \1\e[0m\2
set vi-ins-mode-string \1\e[38;5;240;1m\2╰╶ \1\e[33;1m\2ᓎ \1\e[0m\2
set vi-cmd-mode-string \1\e[38;5;240;1m\2╰╶ \1\e[34;1m\2ᓏ \1\e[0m\2
####################
# \e : Meta #
# \C : Control #
####################
# allow iso-latin1 characters to be inserted
set convert-meta off
# don't strip characters to 7 bits when reading
set input-meta on
set completion-ignore-case on
set show-all-if-ambiguous on
set show-all-if-unmodified on
set mark-symlinked-directories on
set print-completions-horizontally on
# https://github.com/scop/bash-completion
set visible-stats on
# https://groups.google.com/g/iterm2-discuss/c/K6YazwKUvjQ/m/7eqeT-AvBgAJ
set enable-bracketed-paste off
# TAB: menu-complete
# set colored-completion-prefix on
set colored-stats on
set skip-completed-text on
# ask if more than 100 candidates
# set completion-query-items 100
set keymap emacs
"\ee": vi-editing-mode
set keymap vi-command
"\ee": emacs-editing-mode
# key bindings to get out of vi-editing-mode
set keymap vi-insert
"\ee": vi-movement-mode
##### emacs #####
$if mode=emacs
"\ee": vi-editing-mode # `Esc-e`:vi-insert. https://unix.stackexchange.com/a/409866/29178
# "\e\e": vi-movement-mode
"\e~": complete-username
"\e_": yank-last-arg
"\e?": possible-completions
Meta-Control-h: backward-kill-word
$endif
##### vi #####
$if mode=vi
"\ee": emacs-editing-mode
$endif
##### command mode #####
$if mode=vi-command
"\ee": emacs-editing-mode
v: ""
Control-a: beginning-of-line
Control-b: backward-char
Control-d: delete-char
Control-e: end-of-line
Control-f: forward-char
Control-k: kill-line
Control-n: next-history
Control-p: previous-history
$endif
##### insert mode #####
$if mode=vi-insert
"\ee": emacs-editing-mode
"\C-k": kill-line
"\C-u": unix-line-discard
"\C-p": previous-history
"\C-n": next-history
"\C-a": beginning-of-line
"\C-e": end-of-line
"\C-f": forward-char
"\C-b": backward-char
"\C-l": clear-screen
"\C-d": delete-char
"\C-h": backward-delete-char
"\C-w": unix-word-rubout
"\et": transpose-words
"\ef": forward-word
"\eb": backward-word
"\ed": kill-word
"\e.":yank-last-arg
"\e_": yank-last-arg
"\C-_": undo
$endif
$if Bash
# edit the path
"\C-xp": "PATH=${PATH}\e\C-e\C-a\ef\C-f"
# Quote the current or previous word
"\C-xq": "\eb\"\ef\""
$endif
$ cat ~/.inputrc
set convert-meta off # allow iso-latin1 characters to be inserted
set input-meta on # don't strip characters to 7 bits when reading
set completion-ignore-case on
set show-all-if-ambiguous on
set show-all-if-unmodified on
set mark-symlinked-directories on
set print-completions-horizontally on
set enable-bracketed-paste off # https://groups.google.com/g/iterm2-discuss/c/K6YazwKUvjQ/m/7eqeT-AvBgAJ
# set show-mode-in-prompt on
# TAB: menu-complete
# set colored-completion-prefix on
# set colored-stats on
set skip-completed-text on
# set completion-query-items 100 # ask if more than 100 candidates
# https://unix.stackexchange.com/a/409866/29178
set keymap emacs
$if mode=emacs
"\ee": vi-editing-mode
$endif
set keymap vi-insert
$if mode=vi-insert
"\e": vi-movement-mode
# "jk": vi-movement-mode
# "kj": vi-movement-mode
$endif
# set editing-mode vi
# command mode
set keymap vi-command
$if mode=vi-command
"\ee": emacs-editing-mode
v: ""
Control-a: beginning-of-line
Control-b: backward-char
Control-d: delete-char
Control-e: end-of-line
Control-f: forward-char
Control-k: kill-line
Control-n: next-history
Control-p: previous-history
$endif
# insert mode
set keymap vi-insert
$if mode=vi-insert
"\C-k": kill-line
"\C-u": unix-line-discard
"\C-p": previous-history
"\C-n": next-history
"\C-a": beginning-of-line
"\C-e": end-of-line
"\C-f": forward-char
"\C-b": backward-char
"\C-l": clear-screen
"\C-d": delete-char
"\C-h": backward-delete-char
"\C-w": unix-word-rubout
"\et": transpose-words
"\ef": forward-word
"\eb": backward-word
"\ed": kill-word
"\e.":yank-last-arg
"\e_": yank-last-arg
"\C-_": undo
$endif
$ cat /etc/inputrc
# do not bell on tab-completion
#set bell-style none
set meta-flag on
set input-meta on
set convert-meta off
set output-meta on
# Completed names which are symbolic links to
# directories have a slash appended.
set mark-symlinked-directories on
$if mode=emacs
# for linux console and RH/Debian xterm
"\e[1~": beginning-of-line
"\e[4~": end-of-line
# commented out keymappings for pgup/pgdown to reach begin/end of history
#"\e[5~": beginning-of-history
#"\e[6~": end-of-history
"\e[5~": history-search-backward
"\e[6~": history-search-forward
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word
"\e[1;5C": forward-word
"\e[1;5D": backward-word
# for rxvt
"\e[8~": end-of-line
"\eOc": forward-word
"\eOd": backward-word
# for non RH/Debian xterm, can't hurt for RH/DEbian xterm
"\eOH": beginning-of-line
"\eOF": end-of-line
# for freebsd console
"\e[H": beginning-of-line
"\e[F": end-of-line
$endif
$ bind -q insert-last-argument
insert-last-argument can be invoked via "\e.", "\e_".
upcase-word && downcase-word && capitalize-word
$ bind -q upcase-word
upcase-word can be invoked via "\eu".
$ bind -q downcase-word
downcase-word can be invoked via "\el"
$ bind -q capitalize-word
capitalize-word can be invoked via "\ec".
set editing-mode vi
set show-mode-in-prompt on
set vi-ins-mode-string \1\e[6 q\2
set vi-cmd-mode-string \1\e[2 q\2
# optionally:
# switch to block cursor before executing a command
set keymap vi-insert
RETURN: "\e\n"