1. 程式人生 > >終端自定義顏色

終端自定義顏色

alias ls='ls -G'
alias ll='ls -l'
alias grep='grep --color'
alias vi='vim'  
alias cd..='cd ..'

export CLICOLOR=1
export LSCOLORS=fxgxaxdxcxegedabagacad

function git_branch {
    ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
    echo "("${ref#refs/heads/}") ";
}

function git_since_last_commit {
    now=`date +%s`;
    last_commit=$(git log --pretty=format:%at -1 2> /dev/null) || return;
    seconds_since_last_commit=$((now-last_commit));
    minutes_since_last_commit=$((seconds_since_last_commit/60));
    hours_since_last_commit=$((minutes_since_last_commit/60));
    minutes_since_last_commit=$((minutes_since_last_commit%60));

    echo "${hours_since_last_commit}h${minutes_since_last_commit}m ";
}

PS1="Alibaba:\W\[\033[1;32m\]\$(git_branch)\[\033[0;37m\]>"

# bash-completion
if [ -f /opt/local/etc/profile.d/bash_completion.sh ]; then
    . /opt/local/etc/profile.d/bash_completion.sh
fi