dotfiles/.bashrc
2019-03-06 16:00:32 +00:00

123 lines
3.7 KiB
Bash

###############################################################################
# File .bashrc
# jul.io
###############################################################################
umask 022
# set PATH so it includes user's private bin if it exists
if [ -d ~/bin ] ; then
PATH="~/bin:${PATH}"
export PATH
fi
# do the same with MANPATH
if [ -d ~/man ]; then
MANPATH=~/man:"${MANPATH}"
export MANPATH
fi
# some programs use a special .dot directory for not
# trashing the home directory with .dotfiles
if [ -d ~/.dot ]; then
DOT=~/.dot
export DOT
fi
export COLORTERM=1
# change darkblue dir-colors to lightgrey because it's unreadable with black background
LS_COLORS="di=01;90"
export LS_COLORS
# prefered editor
export EDITOR=vi
# bash history control
export HISTCONTROL=ignoreboth:erasedups
export HISTFILESIZE=
export HISTSIZE=5000
shopt -s histappend
shopt -s cmdhist
# completion
shopt -s cdspell
shopt -s hostcomplete
# If not running interactively, don't do any more
[ -z "$PS1" ] && return
###############################################################################
# running interactively
###############################################################################
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# only linux, not SunOS etc
if [ `uname` == "Linux" ]; then
# enable color support of ls
if [ "$TERM" != "dumb" ]; then
eval `dircolors -b`
alias ls='ls --color'
fi
fi
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
# set a fancy prompt
if [ $UID == 0 ]; then
# root: red
#PS_COLOR="\[\033[1;31m\]"
export PS1="\t \[$(tput bold)\]\[$(tput sgr0)\]\[\033[38;5;1m\]\u\[$(tput sgr0)\]\[$(tput sgr0)\]\[\033[38;5;7m\]@\h\[$(tput sgr0)\]\[\033[38;5;15m\]:\[$(tput sgr0)\]\[\033[38;5;1m\]\w\[$(tput sgr0)\]\[\033[38;5;15m\]\$(parse_git_branch)\[\033[00m\]\n\\$ \[$(tput sgr0)\]"
else
# user
#PS_COLOR="\[\033[33m\]"
export PS1="\t \[$(tput sgr0)\]\[\033[38;5;3m\]\u\[$(tput sgr0)\]\[\033[38;5;7m\]@\h\[$(tput sgr0)\]\[\033[38;5;15m\]:\[$(tput sgr0)\]\[\033[38;5;87m\]\w\[$(tput sgr0)\]\[\033[38;5;15m\]\$(parse_git_branch)\[\033[00m\]\n\\$ \[$(tput sgr0)\]"
fi
#PS1="\t ${PS_COLOR}${debian_chroot:+($debian_chroot)}\u@\h:\w\$ "
#export PS1="\t \[$(tput sgr0)\]\[\033[38;5;11m\]\u\[$(tput sgr0)\]${PS_COLOR}@\h:\[$(tput sgr0)\]\[\033[38;5;87m\]\w\[$(tput sgr0)\]\[\033[38;5;15m\] \n\\$ \[$(tput sgr0)\]"
# if this is an xterm modify the title
case $TERM in
xterm*)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME} $(date +%H:%M:%S) [${PWD}]\007"'
;;
*)
;;
esac
# define your own aliases in ~/.bash_aliases
[ -f ~/.bash_aliases ] && source ~/.bash_aliases
# local bashrc
[ -f ~/.bashrc_local ] && source ~/.bashrc_local
# enable programmable completion features
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
# host-specific bashrc
[ -f ~/.bashrc_$HOSTNAME ] && source ~/.bashrc_$HOSTNAME
# This allows you to bookmark your favorite places across the file system
# Define a variable containing a path and you will be able to cd into it regardless of the directory you're in
shopt -s cdable_vars
# Examples:
# export dotfiles="$HOME/dotfiles"
# colorful manpages
export LESS_TERMCAP_mb=$'\e[1;32m'
export LESS_TERMCAP_md=$'\e[1;32m'
export LESS_TERMCAP_me=$'\e[0m'
export LESS_TERMCAP_se=$'\e[0m'
export LESS_TERMCAP_so=$'\e[01;33m'
export LESS_TERMCAP_ue=$'\e[0m'
export LESS_TERMCAP_us=$'\e[1;4;31m'