Skip to content

Commit 164a101

Browse files
committed
board/common: improve default bash settings for better UX
Add HISTCONTROL=ignoreboth to ignore duplicate commands and those starting with space, enable histappend, and improve tab completion behavior. Also add /etc/inputrc for better readline key bindings. Signed-off-by: Joachim Wiberg <[email protected]>
1 parent 805acdf commit 164a101

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

board/common/rootfs/etc/bash.bashrc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,22 @@ export PROMPT_COMMAND=prompt_command
1515
# update the values of LINES and COLUMNS.
1616
shopt -s checkwinsize
1717

18+
# don't put duplicate lines or lines starting with space in the history.
19+
export HISTCONTROL=ignoreboth
20+
21+
# append to the history file, don't overwrite it
22+
shopt -s histappend
23+
24+
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
25+
export HISTSIZE=1000
26+
export HISTFILESIZE=2000
27+
28+
# case-insensitive filename completion
29+
bind "set completion-ignore-case on"
30+
31+
# show all completions immediately instead of ringing bell
32+
bind "set show-all-if-ambiguous on"
33+
1834
log()
1935
{
2036
local fn="/var/log/syslog"

board/common/rootfs/etc/inputrc

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# /etc/inputrc - global inputrc for libreadline
2+
3+
# Be 8 bit clean.
4+
set input-meta on
5+
set output-meta on
6+
7+
# To allow the use of 8bit-characters like the german umlauts, uncomment
8+
# the line below. However this makes the meta key not work as a meta key,
9+
# which is annoying to those which don't need to type in 8-bit characters.
10+
11+
# set convert-meta off
12+
13+
# try to enable the application keypad when it is called. Some systems
14+
# need this to enable the arrow keys.
15+
# set enable-keypad on
16+
17+
# see /usr/share/doc/bash/inputrc.arrows for other codes of arrow keys
18+
19+
# do not bell on tab-completion
20+
# set bell-style none
21+
# set bell-style visible
22+
23+
# some defaults / modifications for the emacs mode
24+
$if mode=emacs
25+
26+
# allow the use of the Home/End keys
27+
"\e[1~": beginning-of-line
28+
"\e[4~": end-of-line
29+
30+
# allow the use of the Delete/Insert keys
31+
"\e[3~": delete-char
32+
"\e[2~": quoted-insert
33+
34+
# mappings for "page up" and "page down" to step to the beginning/end
35+
# of the history
36+
# "\e[5~": beginning-of-history
37+
# "\e[6~": end-of-history
38+
39+
# alternate mappings for "page up" and "page down" to search the history
40+
"\e[5~": history-search-backward
41+
"\e[6~": history-search-forward
42+
43+
# mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving
44+
"\e[1;5C": forward-word
45+
"\e[1;5D": backward-word
46+
"\e[5C": forward-word
47+
"\e[5D": backward-word
48+
"\e\e[C": forward-word
49+
"\e\e[D": backward-word
50+
51+
$if term=rxvt
52+
"\e[7~": beginning-of-line
53+
"\e[8~": end-of-line
54+
"\eOc": forward-word
55+
"\eOd": backward-word
56+
$endif
57+
58+
# for non RH/Debian xterm, can't hurt for RH/Debian xterm
59+
# "\eOH": beginning-of-line
60+
# "\eOF": end-of-line
61+
62+
# for freebsd console
63+
# "\e[H": beginning-of-line
64+
# "\e[F": end-of-line
65+
66+
$endif

0 commit comments

Comments
 (0)