From 8d1984cc69a4e4b2f6ebab6bc4d15dab03b65c4d Mon Sep 17 00:00:00 2001 From: Thomas FORGIONE Date: Mon, 22 Aug 2016 12:04:24 +0200 Subject: [PATCH] Initial commit --- init.vim | 208 ++++++++++++++++++++++++++ make-links.sh | 11 ++ zsh/aliases.zsh | 38 +++++ zsh/config.zsh | 79 ++++++++++ zsh/exports.zsh | 22 +++ zsh/functions.zsh | 90 +++++++++++ zsh/oh-my-zsh/themes/laptop.zsh-theme | 68 +++++++++ zshrc | 17 +++ 8 files changed, 533 insertions(+) create mode 100644 init.vim create mode 100755 make-links.sh create mode 100644 zsh/aliases.zsh create mode 100644 zsh/config.zsh create mode 100644 zsh/exports.zsh create mode 100644 zsh/functions.zsh create mode 100644 zsh/oh-my-zsh/themes/laptop.zsh-theme create mode 100644 zshrc diff --git a/init.vim b/init.vim new file mode 100644 index 0000000..7431d84 --- /dev/null +++ b/init.vim @@ -0,0 +1,208 @@ +" VIM-PLUG MANAGER ##################################################{{{ +" First install vim-plug with the following command: +" curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim +" Then copy this file in: ~/.config/nvim/ +" Install all requirements (neovim, python3, python3 neovim package, +" nerd-fonts, rust, cargo, ... (see below for details)) +" Finally launch nvim and run: :PlugInstall + +call plug#begin('~/.config/nvim/plugged') + +" Nerdtree file explorer +Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } | Plug 'Xuyuanp/nerdtree-git-plugin' +" Great collection of color themes +Plug 'flazz/vim-colorschemes' +" correct terminal palette colors +Plug 'KevinGoodsell/vim-csexact' +" rst syntax +Plug 'mitsuhiko/vim-rst' +" Display thin vertical line at each indentation level for code indented with spaces +" Plug 'Yggdroot/indentLine' +" Personalized status bar +Plug 'bling/vim-airline' +" Some icons (need to install nerd-fonts to work) +" Plug 'ryanoasis/vim-devicons' +" Comment any type of code (gcc, gcip) +Plug 'tomtom/tcomment_vim' +" Auto completion tools (deoplete is still alpha) +Plug 'Shougo/deoplete.nvim' +" Snippets made easy () +Plug 'Shougo/neosnippet.vim' | Plug 'Shougo/neosnippet-snippets' +" Search files +" Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } | Plug 'junegunn/fzf.vim' +" Real-time collaborative editing +" Plug 'Floobits/floobits-neovim' +" An asynchronous markdown preview plugin for Neovim (requires Rust and Cargo) +" function! BuildComposer(info) +" if a:info.status != 'unchanged' || a:info.force +" !cargo build --release +" UpdateRemotePlugins +" endif +" endfunction +" Plug 'euclio/vim-markdown-composer', {'do': function('BuildComposer')} +" Git stuff +Plug 'tpope/vim-fugitive' +" Add plugins to &runtimepath +call plug#end() +" }}} + +"NeoBundle Scripts----------------------------- +if has('vim_starting') + if &compatible + set nocompatible " Be iMproved + endif + + " Required: + set runtimepath+=/home/thomas/.nvim/bundle/neobundle.vim/ +endif + +" Required: +call neobundle#begin(expand('/home/thomas/.nvim/bundle')) + +" Let NeoBundle manage NeoBundle +" Required: +NeoBundleFetch 'Shougo/neobundle.vim' + +" NeoBundle 'Shougo/vimproc.vim', { +" \ 'build' : { +" \ 'windows' : 'tools\\update-dll-mingw', +" \ 'cygwin' : 'make -f make_cygwin.mak', +" \ 'mac' : 'make -f make_mac.mak', +" \ 'linux' : 'make', +" \ 'unix' : 'gmake', +" \ }, +" \ } +" NeoBundle 'Quramy/tsuquyomi' + +" Required: +call neobundle#end() + +" Required: +filetype plugin indent on + +" If there are uninstalled bundles found on startup, +" this will conveniently prompt you to install them. +NeoBundleCheck +"End NeoBundle Scripts------------------------- + +" Vundle +" filetype off +" set rtp+=~/.config/nvim/bundle/Vundle.vim +" +" call vundle#begin("~/.config/nvim/bundle") +" Plugin 'VundleVim/Vundle.vim' +" Plugin 'suan/vim-instant-markdown' +" call vundle#end() +" +" filetype plugin indent on +" End vundle + +" COLOR #############################################################{{{ +set background=dark " use dark background +syntax enable " enable syntax processing +colorscheme mypeachpuff " awesome colorscheme +" }}} + +" INDENTATION #######################################################{{{ +set expandtab " tabs are spaces +set tabstop=4 " number of visual spaces per TAB +set shiftwidth=4 " number of spaces for 1 indentation level +" set list listchars=tab:▸\ ,trail:·,extends:>,precedes:<,nbsp:¬ +filetype plugin indent on " load filetype-specific indent files +set autoindent +" }}} + +" UI CONFIG #########################################################{{{ +set number " show line numbers +set showcmd " show command in bottom bar +set wildmenu " visual autocomplete for command menu +set lazyredraw " redraw only when we need to. +set showmatch " highlight matching [{()}] +set encoding=utf8 +let g:airline_powerline_fonts = 1 +set guifont=Droid\ Sans\ Mono\ for\ Powerline\ Plus\ Nerd\ File\ Types\ 11 +set clipboard=unnamedplus +set updatecount=50 + +" Remove trailing spaces +autocmd BufWritePre * :%s/\s\+$//e +" }}} + +" SEARCHING #########################################################{{{ +set title +set showmatch +set hlsearch +set noincsearch +" }}} + +" NERDTREE ##########################################################{{{ +let NERDTreeIgnore = ['\.pyc$','__pycache__'] +set shell=sh +let g:NERDTreeIndicatorMapCustom = { + \ "Modified" : "✹", + \ "Staged" : "✚", + \ "Untracked" : "✭", + \ "Renamed" : "➜", + \ "Unmerged" : "═", + \ "Deleted" : "✖", + \ "Dirty" : "✗", + \ "Clean" : "✔︎", + \ "Unknown" : "?" + \ } +let g:WebDevIconsNerdTreeGitPluginForceVAlign = 1 +" }}} + +" AUTO COMPLETION ###################################################{{{ +" Use deoplete. +let g:deoplete#enable_at_startup = 1 +" neosnippet plugin key-mappings. +imap (neosnippet_expand_or_jump) +smap (neosnippet_expand_or_jump) +xmap (neosnippet_expand_target) +" Complete on tab +""Window users can copy the file to their machine. +function! Tab_Or_Complete() + if col('.')>1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^\w' + return "\" + else + return "\" + endif +endfunction +:inoremap =Tab_Or_Complete() + +" Compile on F12 +nnoremap :wa \| !make-client.sh +inoremap :wa \|!make-client.sh +vnoremap :wa \|!make-client.sh + +" Escape on F1 +map +imap +" }}} + +" MARKDOWN PREVIEW ##################################################{{{ +let g:markdown_composer_browser = 'chromium' +" }}} +" +" BACKUPS ###########################################################{{{ +set directory=$HOME/.vim/swp// +set backupdir=$HOME/.vim/backups/ +set nobackup + +" Persistent undo +if exists('+undofile') + set undofile + set undolevels=1000 + set undoreload=10000 + if exists('+undodir') + set undodir=$HOME/.vim/undo + endif +endif + +" Markdown : do not open browser if i'm not telling you +let g:instant_markdown_autostart = 0 + +autocmd BufWritePost * :silent execute ':w! ' ."$HOME/.vim/backups/" . escape(substitute(expand('%:p'), "/", "%", "g"), "%") + +autocmd BufEnter,BufNew *.pgsql set filetype=pgsql. + diff --git a/make-links.sh b/make-links.sh new file mode 100755 index 0000000..f925dc5 --- /dev/null +++ b/make-links.sh @@ -0,0 +1,11 @@ +#/bin/bash + +DIRNAME=`dirname $0` + +# make-link source target +function make_link { + rm -rf $HOME/$2 && ln -s $PWD/$DIRNAME/$1 $HOME/$2 +} + +make_link zshrc .zshrc +make_link init.vim .config/nvim/init.vim diff --git a/zsh/aliases.zsh b/zsh/aliases.zsh new file mode 100644 index 0000000..04658df --- /dev/null +++ b/zsh/aliases.zsh @@ -0,0 +1,38 @@ +# Some aliases + +# v is shorter +alias v="$EDITOR" + +# htop is better +alias top="htop" + +# Vim like alias +alias :q="exit" + +# Avoid typos +alias ake="make" + +# My pdf reader +alias pdf="evince" + +# Auto color on pacman +alias pacman='pacman --color=auto' + +# clean for cmake files +alias cclean='\rm -r `find . -name "CMakeCache.txt"` `find . -name "cmake_install.cmake"` `find . -name "CMakeFiles"` `find . -name "Makefile"`' + +# Some games +alias war3="optirun wine /home/thomas/.wine/drive_c/Program\ Files/Warcraft/War3.exe -opengl" +alias nox="cd /home/thomas/.wine/drive_c/Westwood/Nox/; optirun wine Game.exe; cd -1" + +# Start jekyll server easily +alias jekyll="bundle exec jekyll serve" + +# Some cd aliases +alias cd..="cd .." +alias cd...="cd ../.." +alias cd....="cd ../../.." +alias lsd="ls" + +# Make wd command work +alias wd=". wd" diff --git a/zsh/config.zsh b/zsh/config.zsh new file mode 100644 index 0000000..b703731 --- /dev/null +++ b/zsh/config.zsh @@ -0,0 +1,79 @@ +# Path to your oh-my-zsh configuration. +ZSH=$HOME/.oh-my-zsh +ZSH_CUSTOM=$DOTFILES/zsh/oh-my-zsh + +ZSH_THEME="laptop" + +# Set to this to use case-sensitive completion +# CASE_SENSITIVE="true" + +# Uncomment following line if you want to disable autosetting terminal title. +DISABLE_AUTO_TITLE="true" + +# Uncomment following line if you want red dots to be displayed while waiting for completion +# COMPLETION_WAITING_DOTS="true" + +# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) +# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/me +# Example format: plugins=(rails git textmate ruby lighthouse) +plugins=(git zsh-syntax-highlighting) + +source $ZSH/oh-my-zsh.sh + +# Source gulp completion +# source ~/.config/zsh/extensions/gulp.plugin.zsh/gulp.plugin.zsh + +# Config of stderred +# if [ -f "/usr/lib/libstderred.so" ]; then +# export LD_PRELOAD="/usr/lib/libstderred.so" +# fi + +unsetopt correctall +unsetopt autocd +unsetopt cdablevars +setopt inc_append_history +unsetopt share_history +setopt HIST_IGNORE_SPACE + +export HISTSIZE=100000 +export SAVEHIST=$HISTSIZE + +autoload -Uz up-line-or-beginning-search +autoload -Uz down-line-or-beginning-search +zle -N up-line-or-beginning-search +zle -N down-line-or-beginning-search +zle -N gnome_function +bindkey '\eOA' up-line-or-beginning-search +bindkey '\e[A' up-line-or-beginning-search +bindkey '\eOB' down-line-or-beginning-search +bindkey '\e[B' down-line-or-beginning-search +bindkey "\e[H" beginning-of-line # Début +bindkey "\e[F" end-of-line # Fin +zstyle ':completion:*:processes' command 'ps -ax' +zstyle ':completion:*:processes-names' command 'ps -aeo comm=' +zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' +zstyle ':completion:*:*:kill:*' menu yes select +zstyle ':completion:*:*:killall:*:processes-names' list-colors '=(#b) #([0-9]#)*=0=01;31' +zstyle ':completion:*:*:killall:*' menu yes select + +# Fancy ctrl-z +fancy-ctrl-z () { + if [[ $#BUFFER -eq 0 ]]; then + bg + zle redisplay + else + zle push-input + fi +} +zle -N fancy-ctrl-z +bindkey '^Z' fancy-ctrl-z + + +zstyle ':completion:*:*:vim:*:*files' ignored-patterns '*.o|*.class|*.pdf|*.tar|*.tar.gz|main' +zstyle ':completion:*:*:vimcat:*:*files' ignored-patterns '*.o|*.class|*.pdf|*.tar|*.tar.gz|main' +zstyle ':completion:*:sudo:*' command-path /usr/local/sbin /usr/local/bin \ + /usr/sbin /usr/bin /sbin /bin /usr/X11R6/bin +zstyle ':completion:*:back:*' command-path /usr/local/sbin /usr/local/bin \ + /usr/sbin /usr/bin /sbin /bin /usr/X11R6/bin +zstyle ':completion:*:optirun:*' command-path /usr/local/sbin /usr/local/bin \ + /usr/sbin /usr/bin /sbin /bin /usr/X11R6/bin diff --git a/zsh/exports.zsh b/zsh/exports.zsh new file mode 100644 index 0000000..ed2017d --- /dev/null +++ b/zsh/exports.zsh @@ -0,0 +1,22 @@ +# The path +export PATH=$PATH/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin/core_perl:/opt/android-ndk:/usr/lib/emscripten:/home/thomas/.script/check:/home/thomas/.gem/ruby/2.3.0/bin:/home/thomas/.script/blog:/home/thomas/.script/mail:/home/thomas/.script/ + +# My editor +export EDITOR="nvim" + +# Some config +export LD_LIBRARY_PATH=/usr/lib +export LD_PRELOAD='/usr/$LIB/libstdc++.so.6 /usr/$LIB/libgcc_s.so.1 /usr/$LIB/libxcb.so.1' +export MAKEFLAGS="-j`nproc`" + +# Paths needed for soft +export CLASSPATH="$CLASSPATH:/home/thomas/.java/packages/*:/home/thomas/.java/packages/lib/*:/usr/share/java/*:/usr/share/scala/lib/*" +export MATLABPATH=$HOME/.matlab2 +export GOPATH="$HOME/.config/go" +export LATEX_HOME=. +export LATEX_INCLUDES=/home/thomas/Prog/People/David/latexEditor/includes + +# I want clang as default compiler +export CC="clang" +export CXX="clang++" +export WINEDEBUG=-all diff --git a/zsh/functions.zsh b/zsh/functions.zsh new file mode 100644 index 0000000..221c277 --- /dev/null +++ b/zsh/functions.zsh @@ -0,0 +1,90 @@ +# Some helping functions + +### File manipulation ### +# Copy to clipboard +copy() { + if [ $# -eq 0 ]; then + xclip -selection c + else + cat $1 | xclip -selection c + fi +} + +# Swap files +swap() { + local tmp=`mktemp` + mv "$1" "$tmp" + mv "$2" "$1" + mv "$tmp" "$2" +} + +# mkdir && cd +mkcd() { + mkdir $1 && cd $1 +} + +### Vim helpers ### +vclass() { + v src/"$1".cpp -c ":vs include/$1.hpp" +} +vide() { + v $1 -c ":NERDTree" +} +v2() { + v $1 -c ":vs $2" +} +vfind() { + v `find . -name "$1"` +} + +### Awesome functions ### +# Wallpaper change +wallpaper() { + case $1 in + 'vixen' ) echo "change_wallpaper('vixen.jpg');" | awesome-client;; + 'vixen2' ) echo "change_wallpaper('vixen2.jpg');" | awesome-client;; + 'arch' ) echo "change_wallpaper('arch4.png');" | awesome-client;; + 'harley' ) echo "change_wallpaper('1200custom.png');" | awesome-client;; + *) return -1 + esac +} + +# Notify to awesome +notify() { + if [ $# -lt 2 ]; then + echo "naughty.notify({text = \"$1\", timeout = 10})" | awesome-client + elif [ $# -lt 3 ]; then + echo "naughty.notify({title=\"$1\", text = \"$2\", timeout = 10})" | awesome-client + fi +} + +### Others ### +# colors for the man pages +man() { + env LESS_TERMCAP_mb=$(printf "\e[1;31m") \ + LESS_TERMCAP_md=$(printf "\e[1;31m") \ + LESS_TERMCAP_me=$(printf "\e[0m") \ + LESS_TERMCAP_se=$(printf "\e[0m") \ + LESS_TERMCAP_so=$(printf "\e[1;44;33m") \ + LESS_TERMCAP_ue=$(printf "\e[0m") \ + LESS_TERMCAP_us=$(printf "\e[1;32m") \ + man "$@" +} + +# Better svn log +svn() { + case $* in + log ) shift 1; command svn log "$@" | less ;; + * ) command svn "$@" ;; + esac +} + +# Clears resolv.conf with google's dns +resolv() { + echo 'nameserver 8.8.8.8' | sudo tee /etc/resolv.conf > /dev/null +} + +# Generate a standard LaTeX maefile +makelatex() { + cp /home/thomas/.script/classgen/Makefile.latex ./Makefile +} diff --git a/zsh/oh-my-zsh/themes/laptop.zsh-theme b/zsh/oh-my-zsh/themes/laptop.zsh-theme new file mode 100644 index 0000000..4e4db7d --- /dev/null +++ b/zsh/oh-my-zsh/themes/laptop.zsh-theme @@ -0,0 +1,68 @@ +# ZSH Theme - Preview: http://dl.dropbox.com/u/4109351/pics/gnzh-zsh-theme.png +# Based on bira theme + +# load some modules +autoload -U colors zsh/terminfo # Used in the colour alias below +colors +setopt prompt_subst + +# make some aliases for the colours: (coud use normal escap.seq's too) +for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do + eval PR_$color='%{$fg[${(L)color}]%}' +done +eval PR_NO_COLOR="%{$terminfo[sgr0]%}" +eval PR_BOLD="%{$terminfo[bold]%}" + +# Check the UID +if [[ $UID -ge 1000 ]]; then # normal user + eval PR_USER='${PR_MAGENTA}%n${PR_NO_COLOR}' + eval PR_USER_OP='${PR_BLUE}%#${PR_NO_COLOR}' + local PR_PROMPT='$PR_NO_COLOR▶$PR_NO_COLOR' + local PR_ARROW_UP='╭── ' + local PR_ARROW_DOWN='╰' +elif [[ $UID -eq 0 ]]; then # root + eval PR_USER='${PR_RED}%n${PR_NO_COLOR}' + eval PR_USER_OP='${PR_RED}%#${PR_NO_COLOR}' + local PR_ARROW_UP='${PR_RED}╭── ${PR_NO_COLOR}' + local PR_ARROW_DOWN='${PR_RED}╰${PR_NO_COLOR}' + local PR_PROMPT='$PR_RED▶$PR_NO_COLOR' +fi + +# Check if we are on SSH or not +if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then + eval PR_HOST='${PR_GREEN}%M${PR_NO_COLOR}' #SSH +else + eval PR_HOST='${PR_BLUE}%M${PR_NO_COLOR}' # no SSH +fi + +# local return_code="%(?..%{$PR_RED%}%? ↵%{$PR_NO_COLOR%})" + +local user_host='$PR_BOLD${PR_USER}$PR_BOLD' +local current_dir='$PR_BOLD%{$PR_BLUE%}%~%{$PR_NO_COLOR%}' +local rvm_ruby='' +if which rvm-prompt &> /dev/null; then + rvm_ruby='%{$PR_RED%}‹$(rvm-prompt i v g s)›%{$PR_NO_COLOR%}' +else + if which rbenv &> /dev/null; then + rvm_ruby='%{$PR_RED%}‹$(rbenv version | sed -e "s/ (set.*$//")›%{$PR_NO_COLOR%}' + fi +fi + +local return_code="" +local git_branch='$(git_prompt_info)' + +#PROMPT="${user_host} ${current_dir} ${rvm_ruby}${git_branch}$PR_PROMPT " +separator='${PR_YELLOW}::${PR_NO_COLOR}' +tty | read tty_value +if [[ $tty_value == *pts* ]]; then # if in a tty + PROMPT="$PR_ARROW_UP${user_host}${separator}${PR_NO_COLOR}${current_dir} ${rvm_ruby} ${git_branch} +$PR_ARROW_DOWN$PR_PROMPT ${PR_NO_COLOR}" + return_code="%(?.%{$PR_GREEN%}%? ↵%{$PR_NO_COLOR%}.%{$PR_RED%}%? ↵%{$PR_NO_COLOR%})" +else + eval PR_NO_COLOR="$PR_WHITE" + PROMPT="${user_host} ${current_dir} ${rvm_ruby} ${git_branch}> ${PR_NO_COLOR}" + return_code="%(?.%{$PR_GREEN%}%? <%{$PR_NO_COLOR%}.%{$PR_RED%}%? <%{$PR_NO_COLOR%})" +fi +RPS1=" ${return_code}" +ZSH_THEME_GIT_PROMPT_PREFIX="%{$PR_YELLOW%}‹" +ZSH_THEME_GIT_PROMPT_SUFFIX="›%{$PR_NO_COLOR%}" diff --git a/zshrc b/zshrc new file mode 100644 index 0000000..a3e2ff1 --- /dev/null +++ b/zshrc @@ -0,0 +1,17 @@ +# ~/.zshrc + +# Path to the dotfiles +DOTFILES=$HOME/.config/dotfiles + +# Path to your oh-my-zsh configuration +ZSH=$HOME/.oh-my-zsh +ZSH_CUSTOM=$HOME/.config/dotfiles/zsh/oh-my-zsh + +ZSH_THEME="laptop" + +source $DOTFILES/zsh/exports.zsh +source $DOTFILES/zsh/config.zsh +source $DOTFILES/zsh/aliases.zsh + +clear && screenfetch +echo -ne "\033[F\033[F\033[F\033[F\033[F\t\t\t\t\t\b\033[1;36mA:\033[0m `/home/thomas/.script/motorcyle.py`\n\n\n\n\n"