1
0
Fork 0

update `.bashrc`

urosm 2023-12-20 20:49:40 +01:00
parent 1c3c2ca149
commit 596932ca27
1 changed files with 13 additions and 51 deletions

64
bashrc
View File

@ -1,39 +1,18 @@
# check interactive
case $- in
*i*) ;;
*) return ;;
esac
# ~/.bashrc
# if not running interactively, don't do anything
[ -z "$PS1" ] && return
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# history
shopt -s histappend
HISTCONTROL=ignoreboth
HISTSIZE=1000
HISTFILESIZE=2000
PROMPT_COMMAND="history -a"
# 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' -l 5 -R 'i,u' -d
}
# color
case "$TERM" in
foot) export TERMCOLOR=truecolor;;
esac
# set the title to user@host:dir
PS1="\[\e]0;\u@\h:\w\a\]$PS1"
# aliases
# exit
@ -48,9 +27,9 @@ alias ls="ls --color"
alias ll="ls -AFv1 --group-directories-first"
# nvim
alias :e="$EDITOR"
alias :e="nvim"
# bash completion
# enable bash completion in interactive shells
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
@ -58,20 +37,3 @@ if ! shopt -oq posix; 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