From fed8c201dc4ba27627bfb66c9bc1c3d7e05b96ee Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Wed, 19 Aug 2015 20:03:18 +0200 Subject: Updated vimrc for nvim compatiblity --- vim/.vimrc | 69 ++++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 27 deletions(-) diff --git a/vim/.vimrc b/vim/.vimrc index 20d49fb..cde36c1 100644 --- a/vim/.vimrc +++ b/vim/.vimrc @@ -1,11 +1,11 @@ -execute pathogen#infect() +silent! execute pathogen#infect() """ DEFAULT VIM SETTINGS " Reload vimrc on save augroup reload_vimrc " { - autocmd! - autocmd BufWritePost $MYVIMRC source $MYVIMRC + autocmd! + autocmd BufWritePost $MYVIMRC source $MYVIMRC augroup END " } let mapleader=" " @@ -14,9 +14,15 @@ syntax on filetype plugin indent on " Set colorscheme when the terminal has 256 color support -if &t_Co == 256 - colorscheme Benokai -endif +try + if (&t_Co == 256) && match($TERM, "256color") >= 0 + colorscheme Benokai + else + throw "nocolor" + endif +catch + colorscheme desert +endtry " Some vim settings set number @@ -30,7 +36,6 @@ set listchars=trail:·,tab:▸\ ,eol:¬ set scrolloff=1 set backspace=indent,eol,start set cursorline -set cursorcolumn " Disable ex mode nnoremap Q @@ -56,30 +61,40 @@ noremap! " Append modeline when pressing ml function! AppendModeline() - let l:modeline = printf(" vim: set ts=%d sw=%d tw=%d %set :", - \ &tabstop, &shiftwidth, &textwidth, &expandtab ? '' : 'no') - let l:modeline = substitute(&commentstring, "%s", l:modeline, "") - call append(line("$"), l:modeline) + let l:modeline = printf(" vim: set ts=%d sw=%d tw=%d %set :", + \ &tabstop, &shiftwidth, &textwidth, &expandtab ? '' : 'no') + let l:modeline = substitute(&commentstring, "%s", l:modeline, "") + call append(line("$"), l:modeline) endfunction nnoremap ml :call AppendModeline() +" NeoVIM specifics +if has('nvim') + nmap h + tnoremap +endif + """ PLUGIN SPECIFIC SETTINGS -" NERDTree: -" Open NERDTree when no file is specified -autocmd StdinReadPre * let s:std_in=1 -autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif -autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif - -" Airline: -" On arch linux install the following: -" otf-powerline-symbols-git -" powerline-fonts-git -let g:airline_powerline_fonts = 1 -if !exists('g:airline_symbols') - let g:airline_symbols = {} +if exists("g:loaded_pathogen") + + " NERDTree: + " Open NERDTree when no file is specified + autocmd StdinReadPre * let s:std_in=1 + autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif + autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif + + " Airline: + " On arch linux install the following: + " otf-powerline-symbols-git + " powerline-fonts-git + let g:airline_powerline_fonts = 1 + if !exists('g:airline_symbols') + let g:airline_symbols = {} + endif + let g:airline_symbols.space = "\ua0" + set laststatus=2 + endif -let g:airline_symbols.space = "\ua0" -set laststatus=2 -" vim: set ts=8 sw=8 tw=78 noet : +" vim: set ts=4 sw=4 tw=4 et : -- cgit v1.2.3 From 14fd7d4326579569f27cf3ff415f626c0be3ad8b Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Tue, 25 Aug 2015 13:07:31 +0200 Subject: Added nvim as default editor if exists --- bash/.bashrc | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/bash/.bashrc b/bash/.bashrc index e8a61fc..7e460bb 100755 --- a/bash/.bashrc +++ b/bash/.bashrc @@ -98,20 +98,25 @@ elif exists vlc; then alias jblive='vlc rtmp://videocdn-us.geocdn.scaleengine.net/jblive/live/jblive.stream' fi -if exists vim; then +if exists nvim; then + export EDITOR="nvim" +elif exists vim; then export EDITOR="vim" - vim() { - if [[ -z $@ ]]; then - $usr/bin/vim - elif [[ -d $@ ]]; then - dir=$(pwd) - cd $@ && $usr/bin/vim && cd $dir - else - $usr/bin/vim $@ - fi - } +elif exists vi; then + export EDITOR="vi" fi +vim() { + if [[ -z $@ ]]; then + $EDITOR + elif [[ -d $@ ]]; then + dir=$(pwd) + cd $@ && $EDITOR && cd $dir + else + $EDITOR $@ + fi +} + if exists go; then export GOPATH="$HOME/programming/go" export PATH="$PATH:$GOPATH/bin" -- cgit v1.2.3 From 8b225133c9d7da23ce32e222858ed0fa6051d98d Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Tue, 25 Aug 2015 13:18:05 +0200 Subject: Added comments to bashrc --- bash/.bashrc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/bash/.bashrc b/bash/.bashrc index 7e460bb..c71c184 100755 --- a/bash/.bashrc +++ b/bash/.bashrc @@ -5,14 +5,18 @@ # If not running interactively, don't do anything [[ $- != *i* ]] && return +# Default PS1 export PS1='[\d][\t]\u on \h\n\w $ ' +# Additional local paths export PATH="$PATH:$HOME/.local/bin" export PATH="$PATH:$HOME/.local/usr/bin" export PATH="$PATH:$HOME/.local/usr/local/bin" +# Quit the shell like in vim alias :q="exit" +# Keep OS compatibility case "$(uname)" in Linux) alias ls="ls --color=auto" @@ -28,6 +32,7 @@ case "$(uname)" in ;; esac +# Colorfull manpages man() { env LESS_TERMCAP_mb=$'\E[01;31m' \ LESS_TERMCAP_md=$'\E[01;38;5;74m' \ @@ -39,6 +44,7 @@ man() { man "$@" } +# Helpfull functions exists() { hash $@ 2> /dev/null } @@ -61,6 +67,7 @@ is_alias() { fi } +# Execute functions and aliasses with sudo if exists sudo; then sudo() { # Allow functions and aliasses to be executed with sudo @@ -88,16 +95,19 @@ if exists sudo; then } fi +# Set autocomplete for sudo if exists complete && exists sudo; then complete -cf sudo fi +# Jupiterbroadcasting live stream if exists mpv; then alias jblive='mpv rtmp://videocdn-us.geocdn.scaleengine.net/jblive/live/jblive.stream' elif exists vlc; then alias jblive='vlc rtmp://videocdn-us.geocdn.scaleengine.net/jblive/live/jblive.stream' fi +# Set the default editor if exists nvim; then export EDITOR="nvim" elif exists vim; then @@ -117,6 +127,7 @@ vim() { fi } +# Programming language specifics if exists go; then export GOPATH="$HOME/programming/go" export PATH="$PATH:$GOPATH/bin" @@ -127,12 +138,14 @@ if exists gem; then export PATH="$PATH:$GEM_HOME" fi +# Ezjail shortcuts if exists ezjail-admin && exists sudo; then jl() { sudo ezjail-admin $1 $2\.tomvanderlee.com } fi +# Showbanned ipadresses if exists pfctl && exists sudo; then showbanned () { @@ -150,14 +163,17 @@ if exists pfctl && exists sudo; then } fi +# Always use pacaur even if it is not installed if (exists pacman && ! exists pacaur) && exists sudo; then alias pacaur="sudo pacman" fi +# Set the default pager if exists less; then export PAGER="less" fi +# Pip upgrade script if exists pip; then pip() { if [[ "$1" == "upgrade" ]] || [[ "$1" == "update" ]]; then @@ -175,10 +191,12 @@ if exists pip; then } fi +# Fancy bash prompt if exists liquidprompt; then source liquidprompt fi +# Fancy system info if exists archey3; then archey3 elif exists screenfetch; then -- cgit v1.2.3 From ef52a18605b17a67eeed0a5772fb60d6d0106899 Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Tue, 25 Aug 2015 13:43:50 +0200 Subject: Removed sudo function --- bash/.bashrc | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/bash/.bashrc b/bash/.bashrc index c71c184..247955a 100755 --- a/bash/.bashrc +++ b/bash/.bashrc @@ -67,34 +67,6 @@ is_alias() { fi } -# Execute functions and aliasses with sudo -if exists sudo; then - sudo() { - # Allow functions and aliasses to be executed with sudo - if is_function $1 2> /dev/null; then - tmpfile="/tmp/$(date +%s).sh" - - echo "#!$usr/bin/bash" > "$tmpfile" - echo "usr=$usr" >> "$tmpfile" - type $1 | grep -v "is a function" >> "$tmpfile" - echo "$@" >> "$tmpfile" - - chmod +x "$tmpfile" - - $usr/bin/sudo "$tmpfile" - - rm "$tmpfile" - elif is_alias $1 2> /dev/null; then - alias=$(type $1 2> /dev/null | - sed -n "s/^$1\ is\ aliased\ to\ \`\(.*\)'$/\1/p") - - $usr/bin/sudo "$alias" - else - $usr/bin/sudo "$@" - fi - } -fi - # Set autocomplete for sudo if exists complete && exists sudo; then complete -cf sudo -- cgit v1.2.3