71 lines
1.7 KiB
Bash
71 lines
1.7 KiB
Bash
# ~/.bashrc
|
|
|
|
# if not running interactively, don't do anything
|
|
[ -z "$PS1" ] && return
|
|
|
|
# history
|
|
HISTFILESIZE=-1
|
|
HISTCONTROL=ignoredups:erasedups
|
|
trap "history -n; history -w; history -c; history -r;" EXIT
|
|
PROMPT_COMMAND="history -n; history -w; history -c; history -r; $PROMPT_COMMAND"
|
|
|
|
# readline
|
|
set -o vi
|
|
bind 'set show-mode-in-prompt on'
|
|
bind 'set vi-ins-mode-string \1\e[01;35m\2+\1\e[0m\2'
|
|
bind 'set vi-cmd-mode-string :'
|
|
bind 'set keyseq-timeout 0'
|
|
|
|
bind 'set keymap vi-command'
|
|
bind 'j:history-search-forward'
|
|
bind 'k:history-search-backward'
|
|
bind 'set keymap vi-insert'
|
|
bind '"\e[A":history-search-backward'
|
|
bind '"\e[B":history-search-forward'
|
|
|
|
bind 'set show-all-if-ambiguous on'
|
|
bind 'set completion-display-width 0'
|
|
bind 'set colored-stats on'
|
|
bind 'set visible-stats on'
|
|
|
|
# prompt
|
|
PS1="\[\033[01m\]\u@\h:\[\e[01;34m\]\w\[\e[37m\]\$\[\e[00m\] "
|
|
|
|
# title
|
|
PS1="\[\e]0;\u@\h:\w\a\]$PS1"
|
|
|
|
# alias
|
|
alias q="exit"
|
|
alias diff="diff --color=auto"
|
|
alias grep="grep --color=auto"
|
|
alias ls="ls --color=auto"
|
|
alias ll="ls -AF1"
|
|
alias lll="ls -AFlh"
|
|
alias ff="find 2>/dev/null"
|
|
|
|
# bash completion
|
|
if ! shopt -oq posix; then
|
|
if [ -f /usr/share/bash-completion/bash_completion ]; then
|
|
. /usr/share/bash-completion/bash_completion
|
|
elif [ -f /etc/bash_completion ]; then
|
|
. /etc/bash_completion
|
|
fi
|
|
fi
|
|
|
|
# osc7
|
|
osc7_cwd() {
|
|
local strlen=${#PWD}
|
|
local encoded=""
|
|
local pos c o
|
|
for (( pos=0; pos<strlen; pos++ )); do
|
|
c=${PWD:$pos:1}
|
|
case "$c" in
|
|
[-/:_.!\'\(\)~[:alnum:]] ) o="${c}" ;;
|
|
* ) printf -v o '%%%02X' "'${c}" ;;
|
|
esac
|
|
encoded+="${o}"
|
|
done
|
|
printf '\e]7;file://%s%s\e\\' "${HOSTNAME}" "${encoded}"
|
|
}
|
|
PROMPT_COMMAND="osc7_cwd; $PROMPT_COMMAND"
|