dotfiles

config files for my linux setup
git clone git://edryd.org/dotfiles
Log | Files | Refs | README

bashrc (4513B)


      1 # stuff {{{1
      2 # If not running interactively, don't do anything
      3 case $- in
      4 	*i*) ;;
      5 	*) return ;;
      6 esac
      7 
      8 # don't put duplicate lines or lines starting with space in the history.
      9 HISTCONTROL=ignoreboth
     10 
     11 # append to the history file, don't overwrite it
     12 shopt -s histappend
     13 
     14 # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
     15 HISTSIZE=10000
     16 HISTFILESIZE=20000
     17 
     18 # check the window size after each command and, if necessary,
     19 # update the values of LINES and COLUMNS.
     20 shopt -s checkwinsize
     21 
     22 # make less more friendly for non-text input files, see lesspipe(1)
     23 [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
     24 
     25 # enable programmable completion features
     26 if ! shopt -oq posix; then
     27 	if [ -f /usr/share/bash-completion/bash_completion ]; then
     28 		. /usr/share/bash-completion/bash_completion
     29 	elif [ -f /etc/bash_completion ]; then
     30 		. /etc/bash_completion
     31 	fi
     32 fi
     33 
     34 if [ -f "/usr/share/git-core/contrib/completion/git-prompt.sh" ] ; then
     35 	source /usr/share/git-core/contrib/completion/git-prompt.sh
     36 fi
     37 
     38 #}}}
     39 # prompt statement {{{1
     40 # change color of branch name
     41 git_color() {
     42 	if [ -d .git ] || git rev-parse --git-dir >/dev/null 2>&1; then
     43 		local color="${Cyan}"
     44 
     45 		# modified
     46 		git diff --no-ext-diff --quiet --exit-code || color="${Red}"
     47 
     48 		# staged
     49 		if git rev-parse --quiet --verify HEAD >/dev/null; then
     50 			git diff-index --cached --quiet HEAD -- || color="${IRed}"
     51 		fi
     52 
     53 		# stashed
     54 		git rev-parse --verify refs/stash >/dev/null 2>&1 && color="${Yellow}"
     55 
     56 		echo "$color"
     57 	fi
     58 }
     59 
     60 git_ps1_wrap() {
     61 	if type "__git_ps1" &> /dev/null ; then
     62 		__git_ps1 "$@"
     63 	fi
     64 }
     65 
     66 PS1='\[${Blue}\]\u \
     67 \[$(echk_color)\]$(echk_random_face) \
     68 \[$(git_color)\]$(git_ps1_wrap "%s ")\[${Yellow}\]\
     69 $([ \j -gt 0 ] && echo "\j ")\[${White}\]\
     70 \$\[${Color_Off}\] '
     71 
     72 # PS1='\[${White}\]\$\[${Color_Off}\] '
     73 # PS1="${Blue}\u@\h${Color_Off}:${Cyan}\w${White}❯❯${Color_Off} "
     74 # PS1='C:${PWD////\\\\}> '
     75 
     76 PS2='\[${White}\]\$\[${Color_Off}\] '
     77 
     78 command -v sett >/dev/null 2>&1 && PROMPT_COMMAND="[ -d .git -o -f .sett ] && sett"
     79 
     80 # basic {{{1
     81 export EDITOR='nvim'
     82 export MANPAGER='nvim +Man!'
     83 
     84 # allow for color support in terminal
     85 if [ "$TERM" == "xterm" ]; then
     86 	export TERM=xterm-256color
     87 fi
     88 
     89 export GPG_TTY=$(tty)
     90 
     91 # load other files
     92 source ~/bin/ED.sh
     93 source ~/bin/echk
     94 source ~/bin/colors.sh
     95 source ~/bin/z.sh
     96 
     97 # add bins to PATH
     98 if [ -d "$HOME/.local/bin" ] ; then
     99 	PATH="$HOME/.local/bin:$PATH"
    100 fi
    101 if [ -d "/usr/lib/dart/bin" ]; then
    102 	PATH="/usr/lib/dart/bin:$PATH"
    103 fi
    104 if [ -d "$HOME/code/dart/flutter/bin" ]; then
    105 	PATH="$HOME/code/dart/flutter/bin:$PATH"
    106 fi
    107 if [ -d "$HOME/.cargo/bin" ] ; then
    108 	PATH="$HOME/.cargo/bin:$PATH"
    109 fi
    110 if [ -f "$HOME/code/dl/emsdk/emsdk_env.sh" ] ; then
    111 	EMSDK_QUIET=1 source "$HOME/code/dl/emsdk/emsdk_env.sh"
    112 fi
    113 export GOPATH="$HOME/.local/"
    114 
    115 # aliases {{{1
    116 # better tab complete
    117 bind '"\t":menu-complete'
    118 
    119 # enable color support
    120 if [ -x /usr/bin/dircolors ]; then
    121 	test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    122 	alias ls='ls --color=auto -F'
    123 	alias dir='dir --color=auto'
    124 	alias vdir='vdir --color=auto'
    125 
    126 	alias grep='grep --color=auto'
    127 	alias fgrep='fgrep --color=auto'
    128 	alias egrep='egrep --color=auto'
    129 
    130 	alias diff='diff --color=auto'
    131 fi
    132 
    133 # easily change back directories
    134 alias ..='cd ..'
    135 alias ...='cd ../..'
    136 alias ....='cd ../../..'
    137 alias .....='cd ../../../..'
    138 
    139 # better ls-ing
    140 alias ll='ls -alFh'
    141 alias la='ls -A'
    142 
    143 # make these commands safer
    144 alias mv='mv -i'
    145 alias cp='cp -i'
    146 alias ln='ln -i'
    147 alias rm='rm -i'
    148 
    149 # shortcuts
    150 alias sb='source ~/.bashrc'
    151 alias cmon='sudo "$BASH" -c "$(history -p !!)"'
    152 alias emacs='emacs --no-window-system'
    153 alias matlab='matlab -nodesktop'
    154 alias old='tg old'
    155 alias gdb='gdb -q'
    156 alias db='gdb -q -ex run ./$(basename $PWD)' # TODO smart script to allow argument
    157 alias v='valgrind --leak-check=full --show-leak-kinds=all'
    158 alias ytdlp='youtube-dl --extract-audio --audio-format mp3 -o "%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s"'
    159 alias newline='echo >>'
    160 alias term='tabbed -ck st -w'
    161 alias f='feh --force-aliasing --auto-zoom --auto-rotate --scale-down'
    162 alias py='python3 -q'
    163 alias ipy='ipython --no-autoindent'
    164 alias exif='identify -verbose' # TODO only get exif info
    165 alias gg='git grep --untracked'
    166 alias dock-run='docker run -it --rm --detach-keys='ctrl-e,e' -v $PWD:$PWD -w $PWD'
    167 alias fonts-reload='fc-cache -f -v'
    168 alias wifi='sudo nmcli --ask dev wifi connect' # wifi wifi-name
    169 
    170 # If bat is installed, use it as cat
    171 command -v bat >/dev/null 2>&1 && alias cat='bat --style "snip"'
    172 
    173 #}}}