1
0
Fork 0

add `.bashrc`

urosm 2023-08-12 01:22:07 +02:00
parent 19270d507b
commit 90c1c701ee
1 changed files with 72 additions and 0 deletions

72
.bashrc 100644
View File

@ -0,0 +1,72 @@
# check interactive
case $- in
*i*) ;;
*) return ;;
esac
# history
shopt -s histappend
HISTCONTROL=ignoreboth
HISTSIZE=1000
HISTFILESIZE=2000
# prompt
r="\[\e[00m\]"
b="\[\e[01m\]"
c4="\[\e[34m\]"
c7="\[\e[37m\]"
PS1="${b}\u@\h:$c4\w$c7\$$r "
unset e r b c4 c5 c7
# title
PS1="\[\e]0;\u@\h: \w\a\]$PS1"
# functions
# stat
st() {
find "${1-.}" -maxdepth 1 -printf '%m %u %g %y %P\n' |
sort -V -k 4,5 | column -t -N 'i,u,g,t,n' -R 'i,u' -d
}
# aliases
# exit
alias q="exit"
alias :q="exit"
# grep
alias grep="grep --color"
# ls
alias ls="ls --color"
alias ll="ls -AFv1 --group-directories-first"
# nvim
alias :e="nvim"
# 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
# osc 7
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=${PROMPT_COMMAND:+$PROMPT_COMMAND; }osc7_cwd