bash
===
Find last command with prefix
Add the following commands in bashrc
```
bind '"\x1b\x5b\x41":history-search-backward'
bind '"\x1b\x5b\x42":history-search-forward'
```
如果鍵盤layout不對,可用以下步驟
首先利用showkey找出鍵盤的代碼
shell>$ showkey -a
Press any keys - Ctrl-D will terminate this program
出現上述提示訊息後,請按下鍵盤的上
^[[A 27 0033 0x1b
91 0133 0x5b
65 0101 0x41
再按鍵盤的下
^[[B 27 0033 0x1b
91 0133 0x5b
66 0102 0x42
最後按下Ctrl+D退開showkey的互動模式,若想要整個系統都支援這個功能時請編輯/etc/bashrc,若只想個人帳號支援請編輯 ~/.bashrc
bashrc
```
# add your local .bashrc customization here
PS1="\[\e[1;36m\][\u@\h \W]\\[\e[0m\]\$ "
#TOOLCHAIN_LINUX=/scratch/zongl/work/glibc/glibc/scripts/build/install/compilers/riscv64-linux-gnu-rv64imafdc-lp64d/bin
TOOLCHAIN_LINUX=/scratch/zongl/work/buildroot/output/host/bin/
TOOLCHAIN_ELF=/scratch/zongl/work/toolchain/riscv64-unknown-elf-gcc-8.2.0-2019.05.3-x86_64-linux-ubuntu14/bin/
export PATH=`echo $PATH | sed 's/:.://'`
export PATH=$TOOLCHAIN_LINUX:$TOOLCHAIN_ELF:$PATH
set +o noclobber
set +o ignoreeof
alias vi=vim
alias grep="grep --color=auto"
alias ls="ls --color=auto"
alias findstr="find . -type f -print | xargs grep --binary-file=without-match"
alias cdw="cd /scratch/zongl/work"
bind '"\x1b\x5b\x41":history-search-backward'
bind '"\x1b\x5b\x42":history-search-forward'
# You want $TERM to be screen-256color when tmux is running, and you want it to be xterm-256color when tmux is not running.
if [ "$TERM" = "screen" ] && [ -n "$TMUX" ]; then
export TERM=screen-256color
else
export TERM=xterm-256color
fi
```