92 lines
		
	
	
	
		
			2.5 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			92 lines
		
	
	
	
		
			2.5 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
vscripts="${HOME}/vscripts"
 | 
						|
[[ -d ${vscripts} && ${PATH} != *${vscripts}* ]] && export PATH=${PATH}:${vscripts}
 | 
						|
 | 
						|
completion_path='/usr/share/bash-completion/bash_completion'
 | 
						|
[[ -r "${completion_path}" ]] && . "${completion_path}"
 | 
						|
 | 
						|
# grc
 | 
						|
colorize() {
 | 
						|
        local cmds cmd
 | 
						|
        cmds=(\
 | 
						|
            cc configure cvs df diff dig gcc gmake id ip last lsof make mount \
 | 
						|
            mtr netstat ping ping6 ps tcpdump traceroute traceroute6 \
 | 
						|
        )
 | 
						|
        for cmd in ${cmds[@]}; do
 | 
						|
            alias ${cmd}="command grc -es --colour=auto ${cmd}"
 | 
						|
        done
 | 
						|
}
 | 
						|
if is_exec grc; then
 | 
						|
    colorize
 | 
						|
fi
 | 
						|
 | 
						|
# because fuck you thats' why
 | 
						|
fuck() { echo 'no, fuck you'; }
 | 
						|
 | 
						|
# some cool git stuff
 | 
						|
gdiff() { /usr/bin/git diff --color "$@"; }
 | 
						|
 | 
						|
gdf()
 | 
						|
{
 | 
						|
    local fancydiff='/usr/bin/diff-so-fancy'
 | 
						|
    local githighlight='/usr/share/git/diff-highlight/diff-highlight'
 | 
						|
    if [[ -x ${fancydiff} ]]; then
 | 
						|
        gdiff "$@" | ${fancydiff} | less --tabs=4 -RSFX
 | 
						|
    elif [[ -x ${githighlight} ]]; then
 | 
						|
        gdiff "$@" | ${githighlight} | less --tabs=4 -RSFX
 | 
						|
    else
 | 
						|
        gdiff "$@"
 | 
						|
    fi
 | 
						|
}
 | 
						|
 | 
						|
git_prompt()
 | 
						|
{
 | 
						|
    local staged_count unstaged_count untracked_count unmerged_count
 | 
						|
    local git_status branch_info full_status IFS=
 | 
						|
 | 
						|
    prompt_command
 | 
						|
 | 
						|
    if ! raw_status="$(git status --porcelain -bu 2>/dev/null)"; then
 | 
						|
        return
 | 
						|
    fi
 | 
						|
 | 
						|
    git_status=''
 | 
						|
    staged_count=0
 | 
						|
    unstaged_count=0
 | 
						|
    untracked_count=0
 | 
						|
    unmerged_count=0
 | 
						|
 | 
						|
    while read line; do
 | 
						|
        [[ "${line:0:2}" == '##' ]] && branch_info="${line:3}"
 | 
						|
        [[ "${line:0:2}" =~ .[MD] ]] && (( unstaged_count++ ))
 | 
						|
        [[ "${line:0:2}" =~ [MDARC]. ]] && (( staged_count++ ))
 | 
						|
        [[ "${line:0:2}" == '??' ]] && (( untracked_count++ ))
 | 
						|
        [[ "${line:0:2}" =~ (U[ADU]|A[AU]|D[DU]) ]] && (( unmerged_count++ ))
 | 
						|
    done <<< "${raw_status}"
 | 
						|
 | 
						|
    (( $unstaged_count > 0 )) && git_status+="${ppurple}~${unstaged_count}"
 | 
						|
    (( $staged_count > 0 )) && git_status+="${pblue}+${staged_count}"
 | 
						|
    (( $untracked_count > 0 )) && git_status+="${pred}-${untracked_count}"
 | 
						|
    (( $unmerged_count > 0 )) && git_status+="${porange}*${unmerged_count}"
 | 
						|
    [[ -z "${git_status}" ]] && git_status="${pgreen}ok"
 | 
						|
 | 
						|
    full_status="{ ${pgray3}${branch_info}${preset} | ${git_status}${preset} }"
 | 
						|
 | 
						|
    if [[ -n "${OLD_PROMPT}" ]]; then
 | 
						|
        PS1="${ps_line1} ${full_status}\n${ps_line2}"
 | 
						|
    else
 | 
						|
        echo ${full_status}
 | 
						|
    fi
 | 
						|
}
 | 
						|
 | 
						|
gitmode()
 | 
						|
{
 | 
						|
    if [[ -n "${OLD_PROMPT}" ]]; then
 | 
						|
        PROMPT_COMMAND=${OLD_PROMPT}
 | 
						|
        unset OLD_PROMPT
 | 
						|
    else
 | 
						|
        OLD_PROMPT=${PROMPT_COMMAND}
 | 
						|
        PROMPT_COMMAND=git_prompt
 | 
						|
    fi
 | 
						|
}
 | 
						|
 | 
						|
gitmode
 |