Mercurial > dotfiles
diff dot_bashrc @ 257:d726921aaabe
Clean start of dotfiles repo
author | zegervdv <zegervdv@me.com> |
---|---|
date | Thu, 21 May 2020 11:28:36 +0200 |
parents | |
children | e76bb97c0099 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dot_bashrc Thu May 21 11:28:36 2020 +0200 @@ -0,0 +1,128 @@ +export TERM=xterm-256color +export SHELL=bash + +prompt_env() { + prompt_jobs=$(jobs | wc -l) + prompt_branch=$(hg branch 2> /dev/null | awk -- '{print "on "$1}') + + PS1="\[\e[36m\]\A \[\e[1;34m\]\[\e[35m\]\H\[\e[1;34m\] \w\[\e[0m\] \[\e[32m\]$prompt_branch\[\e[0m\]\n$prompt_jobs > \[\e[0m\]" +} + +PROMPT_COMMAND=prompt_env +PS1="\[\e[36m\]\A \[\e[1;34m\]\[\e[35m\]\H\[\e[1;34m\] \w\[\e[0m\] \[\e[32m\]$prompt_branch\[\e[0m\]\n$prompt_jobs > \[\e[0m\]" + + +alias ll="ls -lAvhtr --color" +alias l=ll +alias fgrep='fgrep -nrI --color --exclude-dir=.hg --exclude=*.log --exclude=*.dup --exclude=*.orig --exclude=transcript --exclude=tags --exclude=Session.vim' +alias xclip='xclip -selection clipboard' +alias mvim=gvim + +export HISTCONTROL=erasedups +export HISTSIZE=10000 +export HISTFILESIZE=20000 +shopt -s histappend +shopt -s cmdhist +export HISTINGORE="pwd:ls:history" + +PATH=$HOME/bin:$PATH + +cd_func () + { + local x2 the_new_dir adir index + local -i cnt + + if [[ $1 == "--" ]]; then + dirs -v + return 0 + fi + + the_new_dir=$1 + [[ -z $1 ]] && the_new_dir=$HOME + + if [[ ${the_new_dir:0:1} == '-' ]]; then + # + # Extract dir N from dirs + index=${the_new_dir:1} + [[ -z $index ]] && index=1 + adir=$(dirs +$index) + [[ -z $adir ]] && return 1 + the_new_dir=$adir + fi + + # + # '~' has to be substituted by ${HOME} + [[ ${the_new_dir:0:1} == '~' ]] && the_new_dir="${HOME}${the_new_dir:1}" + + # + # Now change to the new dir and add to the top of the stack + pushd "${the_new_dir}" > /dev/null + [[ $? -ne 0 ]] && return 1 + the_new_dir=$(pwd) + + # + # Trim down everything beyond 11th entry + popd -n +11 2>/dev/null 1>/dev/null + + # + # Remove any other occurence of this dir, skipping the top of the stack + for ((cnt=1; cnt <= 10; cnt++)); do + x2=$(dirs +${cnt} 2>/dev/null) + [[ $? -ne 0 ]] && return 0 + [[ ${x2:0:1} == '~' ]] && x2="${HOME}${x2:1}" + if [[ "${x2}" == "${the_new_dir}" ]]; then + popd -n +$cnt 2>/dev/null 1>/dev/null + cnt=cnt-1 + fi + done + + return 0 +} + +cd_min () { + cd -$1 +} + +_cd_min() { + local cur opts + cur="${COMP_WORDS[COMP_CWORD]}" + opts=$(dirs -v) + COMPREPLY=($(compgen -W "${opts}" --${cur})) +} +complete -F _cd_min cd_min + +alias cd=cd_func + +alias psm='/bin/ps -u $USER --sort pgid,time,size,time,pcpu -o pid,pgid,state,user,start_time,time,size:9,pcpu,command --forest' + +export EDITOR=nvim +export HGEDITOR=nvim + +stty > /dev/null + +# Options +shopt -s globstar +shopt -s autocd +shopt -s cdspell +shopt -s dirspell +shopt -s histverify +shopt -s nocaseglob + +set -o vi + +# Load mercurial autocompletion +if [ -f /etc/bash_completion ]; then + source /etc/bash_completion +fi + + +[ -f ~/.fzf.bash ] && source ~/.fzf.bash +export FZF_DEFAULT_COMMAND='ag -g ""' +source ~/.config/bash/fzf_aliases + + +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + +[ -f ~/.bashrc.local ] && source ~/.bashrc.local