Sunday, February 5, 2012

tmux

1) switch panes

ctrl-b + o

2) scroll back

crtl-b + [

to quit scroll mode, press 'q'

tmux.conf

set-option -g prefix C-a

remap control prefix to ctrl+a

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\", $@"
}

Friday, October 29, 2010

set default window size and font in gVim

click on
edit>startup settings to edit the vimrc in windows

"set defautl window size
set lines=24
set columns=90
"set default font:size
set guifont=Courier\ New:h14

Monday, October 4, 2010

google C++ coding style

http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml

Monday, September 27, 2010

gen_ctags

# setting
WORKDIR=`pwd`
# get all file list
echo "get all file list"
rm ctags.Uranus ctags.utopia 2>/dev/null
find $WORKDIR/Uranus/ -name '*.[HhCc]' >> ctags.Uranus
find $WORKDIR/Uranus/ -name '*.cc' >> ctags.Uranus
find $WORKDIR/Uranus/ -name '*.cpp' >> ctags.Uranus
find $WORKDIR/utopia/ -name '*.[HhCc]' >> ctags.utopia
find $WORKDIR/utopia/ -name '*.cc' >> ctags.utopia
find $WORKDIR/utopia/ -name '*.cpp' >> ctags.utopia

# remove unwanted files

echo "remove unwanted files"
# Uranus
sed -i /Cus60/d ctags.Uranus
sed -i /eCospro/d ctags.Uranus
sed -i /Trunk/d ctags.Uranus
sed -i /u3/d ctags.Uranus
# utopis
sed -i /u2/d ctags.utopia
sed -i /u3/d ctags.utopia

sed -i /t2/d ctags.utopia
sed -i /t4/d ctags.utopia
sed -i /t7/d ctags.utopia
sed -i /t8/d ctags.utopia
sed -i /t9/d ctags.utopia
sed -i /t11/d ctags.utopia
sed -i /t12/d ctags.utopia
sed -i /t13/d ctags.utopia
sed -i /titania4/d ctags.utopia
sed -i /titania7/d ctags.utopia
sed -i /titania8/d ctags.utopia
sed -i /titania9/d ctags.utopia

sed -i /Janus/d ctags.utopia
sed -i /janus/d ctags.utopia
sed -i /j2/d ctags.utopia

sed -i /s7/d ctags.utopia
sed -i /s7j/d ctags.utopia
sed -i /s7ml/d ctags.utopia
sed -i /s7ld/d ctags.utopia
sed -i /s8/d ctags.utopia

sed -i /maria10/d ctags.utopia
sed -i /prans2/d ctags.utopia

sed -i /r2/d ctags.utopia

# generate tag file
cat ctags.Uranus ctags.utopia > ctags.files
echo "generate tag file"
ctags -L ctags.files
#cscope -b -q -k

# generate file list for Perforce
echo "generate file list for Perforce"
ESCSTR=$(echo "$WORKDIR" | sed -e 's/\//\\\//g')
echo $ESCSTR
echo "sed -e 's/$ESCSTR//g' ctags.files > ctags.p4"
sed -e "s/$ESCSTR//g" ctags.files > ctags.p4

# export global variable
echo "===== IMPORTANT ====="
echo "please export the following variable"
echo "export CTAGFILE=$WORKDIR/tags"

Saturday, September 25, 2010

linux dump stace functions

1) dump_stack