diff --git a/.bashrc b/.bashrc new file mode 100644 index 0000000..876afb6 --- /dev/null +++ b/.bashrc @@ -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' -l 5 -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