Compare commits

..

2 Commits

4 changed files with 168 additions and 173 deletions

View File

@@ -34,7 +34,7 @@ umask 002
#
# Find out system details.
#
os=`uname -o` #GNU/Linux AIX Solaris
os=`uname` #GNU/Linux AIX Solaris
cpu=`uname -p` #x86_64 powerpc sparc
kernel=`uname -s` #Linux AIX SunOS
kversion=`uname -v`
@@ -58,188 +58,26 @@ HISTFILESIZE=5000
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
# Terminal colors if interactive
#
# to see colors use
# for i in {0..255}; do echo $(tput setaf $i)$i; done
#
if [ -n "$PS1" ]; then
#
# If there is no terminal info in the system for current terminal but there is
# one in local terminfo then use it.
#
#tput -T $TERM longname 2>/dev/null >/dev/null
#if [ "$?" -ne "0" ] && [ -f $HOME/.terminfo/$kernel/${TERM:0:1}/$TERM ]; then
# export TERMINFO=$HOME/.terminfo/$kernel;
#fi
#
# Number of colors and standard colors.
#
c_num=$(tput colors)
#
# bold foreground
#cbf_red=$(tput bold; tput setaf 1)
#
# Load better colors for ls.
#
if [ $c_num -ge 256 ] && [ -f ~/.dir_colors ]; then
eval $(dircolors ~/.dir_colors)
fi
function term_colors(){
for i in {0..15}; do
for j in {0..15}; do
c=$((i*16+j));
printf " $(tput setab $c)%04d" $c;
done;
printf "$(tput sgr0)\n";
done
for i in {0..15}; do
for j in {0..15}; do
c=$((i*16+j));
printf " $(tput setaf $c)%04d" $c;
done;
printf "$(tput sgr0)\n";
done
}
fi
set -o vi
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
# Prompt if interactive
#
if [ -n "$PS1" ]; then
#
# Set better colors if available.
#
if [ $c_num -ge 256 ]; then
c_reset="$(tput sgr0)"
c_user="$(tput setaf 203)" #Some bright color
c_host="$(tput setaf 112)" #Green
c_cwd="$(tput setaf 99)"
c_time="$(tput setaf 33)" #Light blue
c_branch="$(tput setaf 138)"
c_error="$(tput setaf 203)" #Red
c_info="$(tput setaf 220)" #Yellow
else
c_reset="$(tput sgr0)"
c_user="$(tput setaf 1)" #
c_host="$(tput setaf 2)" #Green
c_cwd="$(tput setaf 7)" #White
c_time="$(tput setaf 6)" #Cyan
c_branch="$(tput setaf 6)" #Cyan
c_error="$(tput setaf 1)" #Red
c_info="$(tput setaf 3)" #Yellow
fi
[ -n "$(which svn)" ] && prompt_check_svn=true
[ -n "$(which git)" ] && prompt_check_git=true
export PROMPT_COMMAND="__prompt_command"
function __prompt_command()
{
#
# get exit code before any command is run.
# TODO: doesn't work on pi.
#
local exit_code="$?"
prompt_extra=""
if [ "$USER" != "vkhachatrya5" -a "$USER" != "vahagn" ]; then
PS1="\[$c_user\]\u@" # username@
else
PS1=""
fi
PS1+="\[$c_host\]\h:" # hostname
PS1+="\[$c_time\]\t" # time
PS1+=" \[$c_cwd\]\w" # working_dir
#
# git branch if exist
#
if [ -n "$prompt_check_git" ]; then
local git_branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null | tr -d ' ')
if [ -n "$git_branch" ]; then
PS1+="\[$c_branch\]/$git_branch"
fi
fi
#
# svn branch if exist
#
if [ -n "$prompt_check_svn" ]; then
local svn_rev=$(svn info . 2> /dev/null | nawk -F ':' '/Revision:/ { print $2 }')
if [ -n "$svn_rev" ]; then
svn_text="@$svn_rev"
PS1+="\[$c_branch\]\$svn_text" # svn revision
fi
fi
#
# exit code if not zero
#
if [ "$exit_code" -ne "0" ]; then
PS1+=",\[$c_error\]rc=$exit_code"
fi
#
# Python venv.
#
local jobs_bg=$(jobs -r | wc -l | tr -d ' ')
if [ -n "$VIRTUAL_ENV" ]; then
# PS1+=",\[$c_info\]$(realpath --relative-to=$PWD $VIRTUAL_ENV)"
PS1+=",\[$c_info\]$(basename $VIRTUAL_ENV)"
fi
#
# Info about jobs.
#
local jobs_bg=$(jobs -r | wc -l | tr -d ' ')
if [ $jobs_bg -gt 0 ]; then
PS1+=",\[$c_info\]bg=$jobs_bg"
fi
#
# Info about jobs.
#
local jobs_stopped=$(jobs -s | wc -l | tr -d ' ')
if [ $jobs_stopped -gt 0 ]; then
PS1+=",\[$c_info\]stp=$jobs_stopped"
fi
#
# Colors should be set here and surrounded with \[\]otherwise bash fails to
# calculate prompt length. The text is set through PROMPT_COMMAND
PS1+="\[$c_reset\]\$ " # reset colors and print $
}
# Turn on checkwinsize
shopt -s checkwinsize
fi
# Set command prompt
[ -x ~/devel/scripts/config/.profile.prompt ] && source ~/devel/scripts/config/.profile.prompt
# [ -x ${MYDIR}/.profile.dircolor ] && source ${MYDIR}/.profile.dircolor
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
# User specific environment and startup programs
#
#
# Set my paths.
#
if [ -e $HOME/local ]; then
MYLOCAL=$HOME/local
elif [ $kernel == Linux ] && [ -e $HOME/local-lnx ]; then
MYLOCAL=$HOME/local-lnx
elif [ $kernel == SunOS ] && [ -e $HOME/local-sun ]; then
MYLOCAL=$HOME/local-sun
if [ -e $HOME/bin ]; then
export PATH=$HOME/bin:$PATH
fi
if [ -e $MYLOCAL/bin ]; then
export PATH=$MYLOCAL/bin:$PATH
fi
MYSCRIPTS=$HOME/devel/scripts
if [ -e $MYSCRIPTS/bin ]; then
export PATH=$MYSCRIPTS/bin:$PATH
fi
if [ -e $HOME/.local/bin ]; then
export PATH=$HOME/.local/bin:$PATH
fi
#
# VIM
#
@@ -273,7 +111,7 @@ export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quo
#
# Aliases
#
if [ $kernel == AIX ]; then
if [ $kernel == "Darwin" ]; then
alias ls='ls -a'
alias ll='ls -la'
alias pd='pushd >/dev/null'

View File

@@ -1,3 +1,5 @@
[include]
path = ~/.gitconfig.local
[user]
name = Vahagn Khachatryan
email = vahagn.khachatryan@gmail.com
@@ -24,8 +26,6 @@
conflictstyle = diff3
[mergetool]
prompt = false
[include]
path = ~/.gitconfig.local
[core]
excludesfile = ~/.gitignore.global
autocrlf = false
@@ -34,4 +34,7 @@
helper = cache
[pager]
branch = false
[url "git@github.com:"]
insteadOf = github:
[url "git@gitea:"]
insteadOf = gitea:

14
config/.profile.dircolor Executable file
View File

@@ -0,0 +1,14 @@
if [ -n "$PS1" ]; then
#
# Number of colors and standard colors.
#
c_num=$(tput colors)
#
# Load better colors for ls.
#
if [ -x $(which /bin/dircolors) ] && [ $c_num -ge 256 ] && [ -f ~/.dir_colors ]; then
eval $(dircolors ~/.dir_colors)
fi
fi

140
config/.profile.prompt Executable file
View File

@@ -0,0 +1,140 @@
if [ -n "$PS1" ]; then
function term_colors(){
for i in {0..15}; do
for j in {0..15}; do
c=$((i*16+j));
printf " $(tput setab $c)%04d" $c;
done;
printf "$(tput sgr0)\n";
done
for i in {0..15}; do
for j in {0..15}; do
c=$((i*16+j));
printf " $(tput setaf $c)%04d" $c;
done;
printf "$(tput sgr0)\n";
done
}
fi
#
# Prompt if interactive
#
if [ -n "$PS1" ]; then
#
# Number of colors and standard colors.
#
c_num=$(tput colors)
#
# Set better colors if available.
#
if [ $c_num -ge 256 ]; then
c_reset="$(tput sgr0)"
c_user="$(tput setaf 203)" #Some bright color
c_host="$(tput setaf 112)" #Green
c_cwd="$(tput setaf 99)"
c_time="$(tput setaf 33)" #Light blue
c_branch="$(tput setaf 138)"
c_error="$(tput setaf 203)" #Red
c_info="$(tput setaf 220)" #Yellow
else
c_reset="$(tput sgr0)"
c_user="$(tput setaf 1)" #
c_host="$(tput setaf 2)" #Green
c_cwd="$(tput setaf 7)" #White
c_time="$(tput setaf 6)" #Cyan
c_branch="$(tput setaf 6)" #Cyan
c_error="$(tput setaf 1)" #Red
c_info="$(tput setaf 3)" #Yellow
fi
[ -n "$(which svn)" ] && prompt_check_svn=true
[ -n "$(which git)" ] && prompt_check_git=true
[ -n "$(which hg)" ] && prompt_check_hg=true
if [ -n "$ZSH_VERSION" ]; then
s_host="%m"
s_user="%n"
s_cwd="%/"
s_time="%t"
fi
if [ -n "$BASH_VERSION" ]; then
export PROMPT_COMMAND="__prompt_command"
s_host="\h"
s_user="\u"
s_cwd="\w"
s_time="\t"
# Turn on checkwinsize
shopt -s checkwinsize
fi
# zsh
function precmd() {
__prompt_command
}
function __prompt_command() {
#
# get exit code before any command is run. TODO: doesn't work on pi.
#
local exit_code="$?"
prompt_extra=""
PS1=""
if [ "$USER" != "vahagnk" -a "$USER" != "vahagn" ]; then
PS1+="${c_user}${s_user}@" # username@
fi
PS1+="${c_host}${s_host}:" # hostname
PS1+="${c_time}${s_time}" # time
PS1+=" ${c_cwd}${s_cwd}" # working_dir
#
# git branch if exist
#
if [ -n "$prompt_check_git" ]; then
local git_branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null | tr -d ' ')
if [ -n "$git_branch" ]; then
PS1+="${c_branch}@${git_branch}"
fi
fi
#
# svn branch if exist
#
if [ -n "$prompt_check_svn" ]; then
local svn_rev=$(svn info . 2> /dev/null | awk -F ':' '/Revision:/ { print $2 }')
if [ -n "$svn_rev" ]; then
PS1+="${c_branch}@${svn_rev}" # svn revision
fi
fi
#
# Python venv.
#
local jobs_bg=$(jobs -r | wc -l | tr -d ' ')
if [ -n "$VIRTUAL_ENV" ]; then
# PS1+=",\[${c_info}\]$(realpath --relative-to=$PWD $VIRTUAL_ENV)"
PS1+=",${c_info}$(basename $VIRTUAL_ENV)"
fi
#
# Info about jobs.
#
local jobs_bg=$(jobs -r | wc -l | tr -d ' ')
if [ $jobs_bg -gt 0 ]; then
PS1+=",${c_info}bg=${jobs_bg}"
fi
local jobs_stopped=$(jobs -s | wc -l | tr -d ' ')
if [ $jobs_stopped -gt 0 ]; then
PS1+=",${c_info}stp=${jobs_stopped}"
fi
#
# exit code if not zero
#
if [ "$exit_code" -ne "0" ]; then
PS1+=",${c_error}rc=${exit_code}"
fi
#
# Colors should be set here and surrounded with \[\]otherwise bash fails to
# calculate prompt length. The text is set through PROMPT_COMMAND
PS1+="${c_reset}\$ " # reset colors and print $
}
fi