view dot_bashrc @ 725:624d8036f5ae

feat: add window number to inactive window and a mapping to select it
author zegervdv <zegervdv@me.com>
date Sun, 11 Dec 2022 16:04:48 +0100
parents 36ba70d17fd6
children
line wrap: on
line source

# vim:ft=bash
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[31m\]\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[31m\]\H\[\e[1;34m\] \w\[\e[0m\] \[\e[32m\]$prompt_branch\[\e[0m\]\n$prompt_jobs > \[\e[0m\]"


alias ls="ls"
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"

export XDG_CONFIG_HOME=$HOME/.config

PATH=$HOME/bin:$PATH
PATH=$HOME/.cargo/bin:$PATH
PATH=$HOME/.local/bin:$PATH
PATH=$HOME/.npm-global/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

export RIPGREP_CONFIG_PATH=$HOME/.config/ripgrep/ripgreprc
export BAT_CONFIG_PATH=$HOME/.config/bat/config

stty > /dev/null

# Options
shopt -s globstar
shopt -s autocd
shopt -s cdspell
shopt -s dirspell
shopt -s histverify
shopt -s nocaseglob
shopt -s direxpand

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

# Must run after local paths are added
export SUDO_EDITOR=$(which nvim)

if [ ! -f ~/.lscolors.parsed.sh ]; then
  echo 'Generating ls colors'
  dircolors --sh ~/.lscolors > ~/.lscolors.parsed.sh
fi
source ~/.lscolors.parsed.sh