From ed7ef55a987237aa064e2a83c4bf647a33b4c141 Mon Sep 17 00:00:00 2001 From: nojhan Date: Sat, 5 Feb 2011 13:24:47 +0100 Subject: [PATCH] first commit --- .Xresources | 7 +++ .bashrc | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++++ .vimrc | 152 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 328 insertions(+) create mode 100644 .Xresources create mode 100644 .bashrc create mode 100644 .vimrc diff --git a/.Xresources b/.Xresources new file mode 100644 index 0000000..3be618f --- /dev/null +++ b/.Xresources @@ -0,0 +1,7 @@ + +*VT100*color4: DodgerBlue1 +*VT100*color12: SteelBlue1 + +XTerm*background: #1e1e27 +XTerm*foreground: #cfbfad + diff --git a/.bashrc b/.bashrc new file mode 100644 index 0000000..6eda6fb --- /dev/null +++ b/.bashrc @@ -0,0 +1,169 @@ +if [ -f /etc/bashrc ]; then + . /etc/bashrc # --> Read /etc/bashrc, if present. +fi + +function proxy() +{ + export http_proxy="http://localhost:8888" + export ftp_proxy="ftp://localhost:8888" + echo "localhost:8888" +} + +function noproxy() +{ + export http_proxy="" + export ftp_proxy="" +} + +# Set up prompts. Color code them for logins. Red for root, +# white for user logins, green for ssh sessions, cyan for telnet, +# magenta with red "(ssh)" for ssh + su, magenta for telnet. +THIS_TTY=tty`ps aux | grep $$ | grep bash | awk '{ print $7 }'` +SESS_SRC=`who | grep $THIS_TTY | awk '{ print $6 }'` + +SSH_FLAG=0 +SSH_IP=`echo $SSH_CLIENT | awk '{ print $1 }'` +if [ $SSH_IP ] ; then + SSH_FLAG=1 +fi +SSH2_IP=`echo $SSH2_CLIENT | awk '{ print $1 }'` +if [ $SSH2_IP ] ; then + SSH_FLAG=1 +fi +if [ $SSH_FLAG -eq 1 ] ; then + CONN=ssh +elif [ -z $SESS_SRC ] ; then + CONN=lcl +elif [ $SESS_SRC = "(:0.0)" -o $SESS_SRC = "" ] ; then + CONN=lcl +else + CONN=tel +fi + +# Okay...Now who we be? +if [ `/usr/bin/whoami` = "root" ] ; then + USR=u_root +else + USR=nou_root +fi + +BLUE="\[\033[0;34m\]" +LIGHT_GRAY="\[\033[0;37m\]" +LIGHT_GREEN="\[\033[1;32m\]" +LIGHT_BLUE="\[\033[1;34m\]" +LIGHT_CYAN="\[\033[1;36m\]" +YELLOW="\[\033[1;33m\]" +WHITE="\[\033[1;37m\]" +RED="\[\033[0;31m\]" +NO_COL="\[\033[00m\]" + +#Set some prompts... +if [ $CONN = lcl -a $USR = nou_root ] ; then + PS1="${WHITE}[\u \w]\\$ ${NO_COL}" +elif [ $CONN = lcl -a $USR = u_root ] ; then + PS1="${YELLOW}[\w]\\$ ${NO_COL}" +elif [ $CONN = tel -a $USR = nou_root ] ; then + PS1="[\u${LIGHT_GREEN}@\h${NO_COL} \w]\\$ " +elif [ $CONN = tel -a $USR = u_root ] ; then + PS1="${RED}[\u @${YELLOW}\h${RED} \w]\\$ ${NO_COL}" +elif [ $CONN = ssh -a $USR = nou_root ] ; then + PS1="[\u @${LIGHT_BLUE}\h${NO_COL} \w]\\$ " +elif [ $CONN = ssh -a $USR = u_root ] ; then + PS1="${RED}[\u @${LIGHT_BLUE}\h${RED} \w]\\$ ${NO_COL}" +fi + +# Prevents accidentally clobbering files. +alias mv='mv -i' +alias mkdir='mkdir -p' + +# The 'ls' family (this assumes you use the GNU ls)) +# Mispelling on azerty keyboards +alias lks='ls' +alias ks='ls' +alias ms='ls' + +alias ls='ls -hF --color' # add colors for filetype recognition +alias l='ls' +alias la='ls -Al' # show hidden files +alias lx='ls -lXB' # sort by extension +alias lk='ls -lSr' # sort by size +alias lc='ls -lcr' # sort by change time +alias lu='ls -lur' # sort by access time +alias lr='ls -lR' # recursive ls +alias lt='ls -ltr' # sort by date +alias lm='ls -al --color=none|less' # pipe through 'less' +alias ll='ls -l' +alias tree='tree -Csu' # nice alternative to 'ls' + +alias psg='ps aux|grep ' # grep a process + +# Find a file with a pattern in name from the current directory +# ff name +function ff() +{ find . -type f -iname '*'$*'*' -ls ; } + +# get the current IP adresses on eth0 +function myip() +{ + MY_IP=$(/sbin/ifconfig eth0 | awk '/inet/ { print $2 } ' | sed -e s/adr:// | sed -e s/inet6://) + echo $MY_IP +} + +# repeat n times command +# repeat 10 echo "ok" +function repeat() +{ + local i max + max=$1; shift; + for ((i=1; i <= max ; i++)); do # --> C-like syntax + eval "$@"; + done +} + +# move to ~/.Trash instead of rm a file +function del() +{ + for i in $* ; do + mv $i ~/.Trash + done +} + +# alias I want to learn +function h() +{ +echo "la : show hidden files" +echo "lx : sort by extension" +echo "lk : sort by size" +echo "lc : sort by change time" +echo "lu : sort by access time" +echo "lr : recursive ls" +echo "lt : sort by date" +echo "lm : pipe through 'less'" +echo "tree : nice alternative to 'ls'" +echo "ff [pattern] : find a file with a pattern in name" +echo "myip : show the IP address of eth0" +echo "repeat [n] [command] : repeat n times command" +echo "clean : remove backip files (*~)" +echo "psg : ps aux | grep " +echo "rcp : copy with rsync/ssh" +} + +# default editor +export EDITOR='gvim' + +# move backup files to trash +alias clean='mv *~ ~/.Trash/' + +# do not permits to recall dangerous commands in bash history +export HISTIGNORE='&:[bf]g:exit:*>|*:history*::*rm*-rf*:*rm*-f*' + +# baskcup shortcuts +alias rcp='rsync -avz --rsh "ssh -l nojhan" ' +alias rcp_443='rsync -avz --rsh "ssh -p 443 -l nojhan" ' + +# ipython shell with correct default apps +alias ipy='ipython -pylab -p scipy --editor="gvim"' + +# nautilus file manager in browser mode without ddestkop management +alias nautile='nautilus --no-desktop --browser' + diff --git a/.vimrc b/.vimrc new file mode 100644 index 0000000..c27626e --- /dev/null +++ b/.vimrc @@ -0,0 +1,152 @@ +syntax on " Coloration syntaxique +color inkpot + +set hlsearch " Surligne les resultats recherche +set wrap " retour a la ligne auto (affichage) +set showmatch " Affiche parenthese correspondante +set autoindent " Indentation automatique +set smartindent +filetype indent on " activates indenting for files +set softtabstop=4 " Largeur d'une tabulation +set shiftwidth=4 " Largeur de l'indentation +set nu " numérotation des lignes +set autochdir " utilise le répertoire courant comme base +set ai " auto indenting +set ic " case insensitive search +set scs " smartcase: Ignore case only if search string has no Uppercase chars. +set hlsearch " highlight what you search for +set incsearch " type-ahead-find +set shiftwidth=4 +set tabstop=4 +set expandtab +set wildmenu " command-line completion shows a list of matches +set wildmode=longest,list:longest,full " Bash-vim completion behavior + + +set laststatus=2 " Affiche la barre de status quoi qu'il en soit (0 pour la masquer, 1 pour ne l'afficher que si l'ecran est divise) +if has("statusline") + set statusline=\ %f%m%r\ [%{strlen(&ft)?&ft:'aucun'},%{strlen(&fenc)?&fenc:&enc},%{&fileformat},ts:%{&tabstop}]%=%l,%c%V\ %P +elseif has("cmdline_info") + set ruler " Affiche la position du curseur en bas a gauche de l'ecran +endif + + +if has("fname_case") + au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,*.L,.emacs,.sawfishrc,*.pddl setf lisp +else + au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,.emacs,.sawfishrc,*.pddl setf lisp +endif + + +" move the current line up or down +nmap :m+== +nmap :m-2== +imap :m+== +imap :m-2== + +"autocmd FileType python set omnifunc=pythoncomplete#Complete +"autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS +"autocmd FileType html set omnifunc=htmlcomplete#CompleteTags +"autocmd FileType css set omnifunc=csscomplete#CompleteCSS +"autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags +"autocmd FileType php set omnifunc=phpcomplete#CompletePHP +"autocmd FileType c set omnifunc=ccomplete#Complete + +filetype plugin on +set ofu=syntaxcomplete#Complete + +au BufRead,BufNewFile *.mwiki setf Wikipedia +au BufRead,BufNewFile *.wikipedia.org.* setf Wikipedia + +" autocomplétion avec plutôt que , en fonction du contexte +function! Smart_TabComplete() + let line = getline('.') " curline + let substr = strpart(line, -1, col('.')+1) " from start to cursor + let substr = matchstr(substr, "[^ \t]*$") " word till cursor + if (strlen(substr)==0) " nothing to match on empty string + return "\" + endif + let has_period = match(substr, '\.') != -1 " position of period, if any + let has_slash = match(substr, '\/') != -1 " position of slash, if any + if (!has_period && !has_slash) + return "\\" " existing text matching + elseif ( has_slash ) + return "\\" " file matching + else + return "\\" " plugin matching + endif +endfunction + +inoremap =Smart_TabComplete() + +" Idem, contexte moins précis +"function InsertTabWrapper() +" let col = col('.') - 1 +" if !col || getline('.')[col - 1] !~ '\k' +" return "\" +" else +" return "\\" +" endif +"endfunction +" +"inoremap =InsertTabWrapper() + + +"switch spellcheck languages +let g:myLang = 0 +let g:myLangList = [ "nospell", "fr_fr", "en_gb" ] +function! MySpellLang() + "loop through languages + let g:myLang = g:myLang + 1 + if g:myLang >= len(g:myLangList) | let g:myLang = 0 | endif + if g:myLang == 0 | set nospell | endif + if g:myLang == 1 | setlocal spell spelllang=fr_fr | endif + if g:myLang == 2 | setlocal spell spelllang=en_us | endif + echo "language:" g:myLangList[g:myLang] +endf +map :call MySpellLang() +imap :call MySpellLang() + +" REQUIRED. This makes vim invoke Latex-Suite when you open a tex file. +filetype plugin on + +" IMPORTANT: grep will sometimes skip displaying the file name if you +" search in a singe file. This will confuse Latex-Suite. Set your grep +" program to always generate a file-name. +set grepprg=grep\ -nH\ $* + +" OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to +" 'plaintex' instead of 'tex', which results in vim-latex not being loaded. +" The following changes the default filetype back to 'tex': +let g:tex_flavor='latex' + +" search the file for FIXME, TODO and put them in a handy list +map TaskList + +" F11 - taglist window +map :TlistToggle + +" open buffers as tabs along the top or bottom of your screen +map :MiniBufExplorer + +" configure tags - add additional tags here or comment out not-used ones +set tags+=~/.vim/tags/cpp +"set tags+=~/.vim/tags/gl +"set tags+=~/.vim/tags/sdl +"set tags+=~/.vim/tags/qt4 +" build tags of your own project with CTRL+F12 +map :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q . + +" OmniCppComplete +let OmniCpp_NamespaceSearch = 1 +let OmniCpp_GlobalScopeSearch = 1 +let OmniCpp_ShowAccess = 1 +let OmniCpp_ShowPrototypeInAbbr = 1 " show function parameters +let OmniCpp_MayCompleteDot = 1 " autocomplete after . +let OmniCpp_MayCompleteArrow = 1 " autocomplete after -> +let OmniCpp_MayCompleteScope = 1 " autocomplete after :: +let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"] +" automatically open and close the popup menu / preview window +au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif +set completeopt=menuone,menu,longest,preview +