Thursday, December 29, 2011

screenrc

startup_message off
termcapinfo xterm ti@:te@
defscrollback 5000
#caption always "%{= kw}%-w%{= BW}%n %t%{-}%+w %-= @%H - %LD %d %LM - %c"
caption always "%{= kw}%-w%{= BW}%n %t%{-}%+w"
screen -t alpha bash
screen -t bravo bash
screen -t charlie bash
screen -t delta bash
screen -t echo bash
screen -t foxtrot bash
screen -t glof bash
screen -t hotel bash
screen -t india bash
screen -t juliet bash
select alpha

vimrc

set nu
syntax on
colorscheme evening
set cul
set hlsearch
set ruler
set ai
set nojoinspaces
set formatoptions=qtcor
"set foldmethod=marker
set history=500

"ctags
"use the ctags for tag search
set tags=$CTAGFILE
"search non-cscope tag first
set csto=1
ab tl Tlist
ab tls TlistSync

"cscope
"use cscope to find caller, callee...
set nobackup
set cscopetag
cs add $CSCOPEFILE
map c :cs find c =expand("")
map d :cs find d =expand("")
map e :cs find e =expand("")
map f :cs find f =expand("")
map g :cs find g =expand("")
map i :cs find i =expand("")
map s :cs find s =expand("")
map t :cs find t =expand("")

ab sc set spell
ab nsc set nospell
ab #i #include
ab #d #define
ab #e #endif
ab #p #pragma
ab pn PRINT_NOTICE("start\n");
ab pi PRINT_INFO
ab pe PRINT_ERR
ab pd PRINT_DEBUG
ab #c \////////////////////////////////////////////////////////////////////////////////
\
\
\//////////////////////////////////////////////////////////////////////////////

autocmd BufReadPost *.c set sts=8
autocmd BufReadPost *.c set sw=8
autocmd BufReadPost *.c set expandtab
autocmd BufReadPost *.c set cin
autocmd BufReadPost *.cpp set sts=8
autocmd BufReadPost *.cpp set sw=8
autocmd BufReadPost *.cpp set expandtab
autocmd BufReadPost *.cpp set cin
autocmd BufReadPost *.h set sts=8
autocmd BufReadPost *.h set sw=8
autocmd BufReadPost *.h set expandtab
autocmd BufReadPost *.h set cin
autocmd BufReadPost *.tex set tw=80
autocmd BufReadPost *.tex set ai
autocmd BufReadPost *.sh set sts=8
autocmd BufReadPost *.sh set sw=8
autocmd BufReadPost *.sh set expandtab
autocmd BufReadPost *.sh set cin

bashrc

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

# check terminal
if [ "$TERM" = "rxvt-unicode" ]; then
alias vim='TERM=xterm vim'
fi

# set a fancy prompt (non-color, overwrite the one in /etc/profile)
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\$ '

# User specific aliases and functions

alias ls="ls --color -F"
#alias ls="ls"
export P4CONFIG=.p4config
export SVN_EDITOR=vim
export PATH=/sbin:$PATH

#alias expctgp="export CTAGFILE=$HOME/Perforce/tags; cd ~/Perforce/"
#alias expctgw="export CTAGFILE=$HOME/workshop/tags; cd ~/workshop/"
alias expctgl="export CTAGFILE=$HOME/workshop/source/linux-3.1.1/tags; export CSCOPEFILE=$HOME/workshop/source/linux-3.1.1/cscope.out; cd $HOME/workshop/source/linux-3.1.1"

set_ctag() {
echo "export CTAGFILE=`pwd`/$@"
export CTAGFILE=`pwd`/$@
}

set_cscope() {
echo "export CTAGFILE=`pwd`/$@"
export CSCOPEFILE=`pwd`/$@
}

# convert a number into decimal format
n2d() {
perl -e "printf \"%d\n\", $@"
}

# convert a number into decimal format (floating number)
n2f() {
perl -e "printf \"%f\n\", $@"
}

# convert a number into hex format
n2h() {
perl -e "printf \"%08X\n\", $@"
}
alias n2x="n2h"

# convert a number into binary format
n2b() {
perl -e "printf \"%08b\n\", $@"
}

# convert a number into number of mage (2^20)
n2m() {
perl -e "printf \"%d (M)\n\", $@/1024/1024"
}

# convert binary number into hex format
b2h() {
perl -e "printf \"%02x\n\", 0b$@"
}
alias b2x="b2h"

Thursday, April 21, 2011

converting hex/decimal/bianry with bash

put this functions in the ~/.bashrc

# convert a number into decimal format
n2d() {
perl -e "printf \"%d\n\", $@"
}

# convert a number into hex format
n2h() {
perl -e "printf \"0x%X\n\", $@"
}

# convert a number into binary format
n2b() {
perl -e "printf \"0b%b\n\", $@"
}