[[ -d $HOME/.bin ]] && export PATH=$HOME/.bin:$PATH # essentials alias ls="ls --color=auto" alias l="ls -l" alias la="ls -la" alias df="df -h" alias du="du -h" # net alias pingheise="ping www.heise.de" alias pinggoogle="ping www.google.com" # apps alias g="git" complete -o bashdefault -o default -o nospace -F __git_wrap__git_main g # anti-stupidity (I don't use ghostscript and can still call it with \gs) alias gs="git s" export EDITOR=nvim alias vim="$EDITOR -p" # open files in tabs alias vi=$EDITOR alias v=$EDITOR export HISTTIMEFORMAT='%F__%H-%M-%S $ ' export HISTCONTROL=ignoreboth # if a line has ~100 chars (each 1 byte usually, because utf-8) then 10 lines = 1k # max 10 MB --> 10 * 10.000 = 100.000 lines export HISTSIZE=100000 # two lines per hist (timestamp, command) --> 2.000.000 lines export HISTFILESIZE=200000 export HISTIGNORE="ls:la:l:cd:pwd:clear:history:jobs:fg:bg:pushd*:popd*:g s:g d:g l" # some color definitions CLEAR="\[\e[0m\]" BLACK="\[\e[0;30m\]" BLUE="\[\e[0;34m\]" BROWN="\[\e[0;33m\]" CYAN="\[\e[0;36m\]" DARK_GRAY="\[\e[1;30m\]" GOLD="\[\e[38;5;136m\]" GREEN="\[\e[0;32m\]" LIGHT_BLUE="\[\e[1;34m\]" LIGHT_CYAN="\[\e[1;36m\]" LIGHT_GRAY="\[\e[0;37m\]" LIGHT_GREEN="\[\e[1;32m\]" LIGHT_PURPLE="\[\e[1;35m\]" LIGHT_RED="\[\e[1;31m\]" PURPLE="\[\e[0;35m\]" RED="\[\e[0;31m\]" WHITE="\[\e[1;37m\]" YELLOW="\[\e[1;33m\]" __fh_prompt_git_stuff() { local branch local branch_color local git_status # ignore $HOME [[ $PWD == $HOME ]] && return # check if we're in a git repo # 4 ms on my box, recurses automatically git_status=$(git status -s 2>/dev/null) if [[ $? != 0 ]]; then return else branch=$(git branch | grep '^*' | sed s/\*\ //) [[ -z $branch ]] && branch='[NOBRANCH]' if [[ -z $git_status ]]; then branch_color="${GREEN}" else branch_color="${RED}" fi echo " ${branch_color}${branch}" fi } __fh_prompt_jobs() { local job_count=$(jobs -p | wc -l) if [[ $job_count > 1 ]]; then echo jobs -l fi } __fh_prompt() { local retcode=$? # this must be first # user@host local host_name="${FH_PROMPT_HOST:-\h}" local host_color=$GOLD local host_prefix="\u@${host_color}${host_name}" # working directory local dir=" ${GREEN}\w" # non-zero exit local uid_color="${GOLD}" if [[ $retcode != 0 ]]; then uid_color="${RED}" fi local uid=" ${uid_color}\\\$" # putting it all together PS1="${host_prefix}$(__fh_prompt_git_stuff)${dir}${uid} ${CLEAR}" local job_prompt="$(__fh_prompt_jobs)" [[ -n "$job_prompt" ]] && PS1="${job_prompt}\n$PS1" # always append history history -a } PROMPT_COMMAND=__fh_prompt # debug # http://stackoverflow.com/questions/5014823/how-to-profile-a-bash-shell-script-slow-startup # export PS4='⬠$(date "+.%N")\011 ' # source prompt # vim: set ft=sh :