diff --git a/.bash_aliases b/.bash_aliases index 1be69e6..8bbd175 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -1,7 +1,22 @@ PATH=$PATH:~/bin -alias ls='ls --color=auto' -alias ll='ls -la' +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +# some more ls aliases +alias ll='ls -alF' +alias la='ls -A' +alias l='ls -CF' +alias lll='ls --color=always -alF | less -R' # append history instead of overwriting: shopt -s histappend @@ -13,8 +28,15 @@ alias findpy='find . -name "*.py" | xargs grep' alias findfile='find . | grep -v .svn | grep -v .hg | grep -v .git | grep' +# Add an "alert" alias for long running commands. Use like so: +# sleep 10; alert +alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' + alias notes='vim ~/mydocs/notes/notes.txt' +# 20141202 +alias captainslog='vim ~/mydocs/notes/captains_log.md' + # Some hosts alias higgs='ssh higgs' alias medusa='ssh medusa' @@ -36,6 +58,30 @@ alias so=git # so rebase # so diff +alias gd='git diff' +alias gc='git commit' +alias gca='git commit -a' +alias gl='git log' +alias gst='git status' +alias gt='git tag|less' +alias gp='git push --all --follow-tags' +alias gu='git pull --all' +# git activity per week day: +# git log --pretty='%at' | while read d; do date -d "@$d"; done | awk '{print $1}' | sort | uniq -c +alias gad='git log --pretty='"'"'%at'"'"' | while read d; do date -d "@$d"; done | awk '"'"'{print $1}'"'"' | sort | uniq -c' +# git activity per hour of the day: +# git log --pretty='%at' | while read d; do date +%H -d "@$d"; done | sort | uniq -c +alias gah='git log --pretty='"'"'%at'"'"' | while read d; do date +%H -d "@$d"; done | sort | uniq -c' + +# mercurial coloured diff +alias hgd='hg diff | colordiff -y | less -R' +# some more shorthands +alias hgl='hg log | less' +alias hgb='hg branch' +alias hgt='hg tags | less' +alias hgu='hg pull -u' +alias hgp='hg push' + # 20140521 force 256 colours in tmux alias tmux='tmux -2' @@ -43,6 +89,27 @@ alias tmux='tmux -2' # another session that forced down your tmux window size you can simply call alias takeover="tmux detach -a" +# 20140825 as there is no `pip upgrade`, this has to do +alias pip_upgrade="pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs pip install -U" + +# 20140908 reload tmux config +alias tmux_reload="tmux source-file ~/.tmux.conf" + +# project-oriented aliases +alias dcpvag='workon dcp; cd ~/workspace/sanoma/content-library/; vagrant ssh' +alias dcpsrc='cd ~/development/current/content-library/src/content_library/; . ~/development/env/bin/activate' +alias dcpcelery='python manage.py celery worker -Q celery -l info' + +# update/install Calibre ebook manager +alias updatecalibre='sudo -v && wget -nv -O- https://raw.githubusercontent.com/kovidgoyal/calibre/master/setup/linux-installer.py | sudo python -c "import sys; main=lambda:sys.stderr.write('"'"'Download failed\n'"'"'); exec(sys.stdin.read()); main()"' + +# Watch a DNS entry, see when it changes to a new value for example +alias checkdns='watch -n1 dig ' + +#weather(){ curl -s "http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml?query=${@:-}"|perl -ne '/([^<]+)/&&printf "%s: ",$1;/<fcttext>([^<]+)/&&print $1,"\n"';} +weather(){ curl -s "http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml?query=${@:-Amsterdam}"|perl -ne '/<title>([^<]+)/&&printf "%s: ",$1;/<fcttext>([^<]+)/&&print $1,"\n"';} + +# if you're really annoyed with a runaway process function fuck() { if killall -9 "$2"; then echo ; echo " (╯°□°)╯︵$(echo "$2"|toilet -f term -F rotate)"; echo diff --git a/.bashrc b/.bashrc index db53355..649b9e8 100644 --- a/.bashrc +++ b/.bashrc @@ -56,10 +56,91 @@ if [ -n "$force_color_prompt" ]; then fi fi +# http://stackoverflow.com/questions/4023830/bash-how-compare-two-strings-in-version-format +# returns 0 if =, 1 if >, 2 if < +vercomp () { + if [[ $1 == $2 ]] + then + return 0 + fi + local IFS=. + local i ver1=($1) ver2=($2) + # fill empty fields in ver1 with zeros + for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)) + do + ver1[i]=0 + done + for ((i=0; i<${#ver1[@]}; i++)) + do + if [[ -z ${ver2[i]} ]] + then + # fill empty fields in ver2 with zeros + ver2[i]=0 + fi + if ((10#${ver1[i]} > 10#${ver2[i]})) + then + return 1 + fi + if ((10#${ver1[i]} < 10#${ver2[i]})) + then + return 2 + fi + done + return 0 +} + +# check version of git; it supports 'simple' from 1.7.11 up, fall back to 'matching' +vercomp "1.7.11" `git --version|awk '{ print $3 }'` +if [ $? -eq 1 ]; then + git config --global push.default matching + git config --global pull.default matching +fi + hg_ps1() { - #hg prompt "{ on {branch}}{ at {bookmark}}{status}" 2> /dev/null - hg prompt " \[\033[1;37m\]hg\[\033[0m\] {branch}{status}" 2> /dev/null - } + #hg prompt "{ on {branch}}{ at {bookmark}}{status}" 2> /dev/null + hg prompt " \[\033[1;37m\]hg\[\033[0m\] {branch}{status}" 2> /dev/null +} + +set_bash_prompt(){ + # Michiel's colour config + BLACK="\[\033[0m\]" + BLUE="\[\033[0;34m\]" + YELLOW="\[\033[0;33m\]" + GREEN="\[\033[0;32m\]" + RED="\[\033[0;31m\]" + PROMPT_SYMBOL='$' + if [ $USER = 'root' ]; then + #PS1="$YELLOW\t $RED\u$BLACK@\h:\W# " + PS1="${debian_chroot:+$debian_chroot }$(venvinfo)$YELLOW\t $RED\u$BLACK@\h:\W$(jobscount)# " + elif [ -e ~/.dot_is_server ]; then + #PS1="$YELLOW\t $GREEN\u$BLACK@\h:\W$ " + PS1="${debian_chroot:+$debian_chroot }$(venvinfo)$YELLOW\t $GREEN\u$BLACK@\h:\W$(jobscount)$ " + else + #PS1="$YELLOW\t $BLUE\u$BLACK@\h:\W$ " + PS1="${debian_chroot:+$debian_chroot }$(venvinfo)$YELLOW\t $BLUE\u$BLACK@\h:\W$(jobscount)$ " + fi + #PS1="$YELLOW\t $BLUE\u$BLACK@\h:\W$(hg_ps1)$ " + #PS1="$YELLOW\t $BLUE\u$BLACK@\h:\W$(hg_ps1)$(__git_ps1)$ " + # /Michiel's colour config +} + +jobscount() { + # Show amount of running and stopped (backgrounded) jobs + local stopped=$(jobs -sp | wc -l) + local running=$(jobs -rp | wc -l) + ((running+stopped)) && echo -n "[${running}r/${stopped}s]" +} + +venvinfo() { + # Virtualenv information + if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then + # special case for Aspen magic directories + # see http://www.zetadev.com/software/aspen/ + echo "[`basename \`dirname \"$VIRTUAL_ENV\"\``] " + elif [ "$VIRTUAL_ENV" != "" ]; then + echo "(`basename \"$VIRTUAL_ENV\"`) " + fi +} # gitprompt configuration # Set config variables first @@ -70,23 +151,7 @@ hg_ps1() { if [ "$color_prompt" = yes ]; then #PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' - # Michiel's colour config - BLACK="\[\033[0m\]" - BLUE="\[\033[0;34m\]" - YELLOW="\[\033[0;33m\]" - GREEN="\[\033[0;32m\]" - RED="\[\033[0;31m\]" - PROMPT_SYMBOL='$' - if [ $USER = 'root' ]; then - PS1="$RED\t $GREEN\u$BLACK@\h:\W$ " - elif [ -e ~/.dot_is_server ]; then - PS1="$YELLOW\t $GREEN\u$BLACK@\h:\W$ " - else - PS1="$YELLOW\t $BLUE\u$BLACK@\h:\W$ " - fi - #PS1="$YELLOW\t $BLUE\u$BLACK@\h:\W$(hg_ps1)$ " - #PS1="$YELLOW\t $BLUE\u$BLACK@\h:\W$(hg_ps1)$(__git_ps1)$ " - # /Michiel's colour config + PROMPT_COMMAND=set_bash_prompt else PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' fi @@ -101,32 +166,10 @@ xterm*|rxvt*) ;; esac -# enable color support of ls and also add handy aliases -if [ -x /usr/bin/dircolors ]; then - test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" - alias ls='ls --color=auto' - #alias dir='dir --color=auto' - #alias vdir='vdir --color=auto' - - alias grep='grep --color=auto' - alias fgrep='fgrep --color=auto' - alias egrep='egrep --color=auto' -fi - -# some more ls aliases -alias ll='ls -alF' -alias la='ls -A' -alias l='ls -CF' - -# Add an "alert" alias for long running commands. Use like so: -# sleep 10; alert -alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' - # Alias definitions. # You may want to put all your additions into a separate file like # ~/.bash_aliases, instead of adding them here directly. # See /usr/share/doc/bash-doc/examples in the bash-doc package. - if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi @@ -142,8 +185,10 @@ if [ -f /etc/bash_completion ] && ! shopt -oq posix; then . /etc/bash_completion fi -if [ -x ~/.privdotfiles/bin ]; then - PATH=$PATH:~/.privdotfiles/bin +# If the private dotfiles repo is installed, we'd like to use its scripts too +if [ -x ~/.dot/privdotfiles/bin ]; then + PATH=$PATH:~/.dot/privdotfiles/bin fi -PATH=$PATH:/usr/local/bin/android-sdk-linux/platform-tools +# Android-related binaries +PATH=$PATH:/usr/local/bin/android-sdk-linux/platform-tools:/usr/local/bin/android-sdk-linux/tools diff --git a/.gitconfig b/.gitconfig index 723ed7f..e371364 100644 --- a/.gitconfig +++ b/.gitconfig @@ -1,6 +1,6 @@ [user] name = Michiel Scholten - email = michiel@aquariusoft.org + email = michiel@diginaut.net [giggle] main-window-maximized = true diff --git a/.hgrc b/.hgrc index b650afb..6797cb9 100644 --- a/.hgrc +++ b/.hgrc @@ -7,12 +7,13 @@ username = m.scholten hgext.mercurial_keyring = ~/workspace/application_addons/mercurial/mercurial_keyring/mercurial_keyring.py convert = hgext.bookmarks = -graphlog = +graphlog = hgext.purge= hgk= hgflow = ~/workspace/application_addons/mercurial/hgflow/src/hgflow.py #hggit = ~/workspace/application_addons/mercurial/hg-git/hggit prompt = /home/mbscholt/workspace/application_addons/mercurial/hg-prompt/prompt.py +shelve= [git] authors = /home/mbscholt/.hgauthors.txt diff --git a/.tmux.conf b/.tmux.conf index e9cc9ac..9a2f227 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -34,7 +34,9 @@ bind E setw synchronize-panes off # set first window to index 1 (not 0) to map more to the keyboard layout... #set-option -g base-index 1 -set-window-option -g pane-base-index 1 +set-option -g base-index 0 +#set-window-option -g pane-base-index 1 +set-window-option -g pane-base-index 0 # color scheme (styled as vim-powerline) set -g status-left-length 52 @@ -51,10 +53,17 @@ set -g message-attr bold #set -g status-left '#[fg=colour235,bg=colour252,bold] ❐ #S #[fg=colour252,bg=colour238,nobold]#[fg=colour245,bg=colour238,bold] #(whoami) #[fg=colour238,bg=colour234,nobold]' # Status line without username: set -g status-left '#[fg=colour235,bg=colour252,bold] ❐ #S #[fg=colour252,bg=colour234,nobold]' -set -g window-status-format "#[fg=colour235,bg=colour252,bold] #I #W " +#set -g window-status-format "#[fg=colour235,bg=colour252,bold] #I #W " +#set -g window-status-format "#[fg=colour235,bg=colour252]#I #W#[fg=colour235,bg=colour252,bold]" +#set -g window-status-format "#[fg=colour234,bg=colour252,nobold]#I #W#[fg=colour252,bg=colour234,nobold]" +set -g window-status-format "#[fg=colour252,bg=colour234,nobold] #I #W " #set -g window-status-current-format "#[fg=colour234,bg=colour39]⮀#[fg=black,bg=colour39,noreverse,bold] #I: #W #[fg=colour39,bg=colour234,nobold]⮀" -set -g window-status-current-format "#[fg=colour234,bg=colour39]#[fg=black,bg=colour39,noreverse,bold] #I: #W #[fg=colour39,bg=colour234,nobold]" +#set -g window-status-current-format "#[fg=colour234,bg=colour39]#[fg=black,bg=colour39,noreverse,bold] #I: #W #[fg=colour39,bg=colour234,nobold]" +#set -g window-status-current-format "#[fg=colour234,bg=colour39]#[fg=black,bg=colour39,noreverse,bold] #I: #W #[fg=colour39,bg=colour234,nobold]" +set -g window-status-current-format "#[fg=colour234,bg=colour39]#[fg=black,bg=colour39,noreverse,bold] #I #W #[fg=colour39,bg=colour234,nobold]" +set -g window-status-separator "" set -g status-right '#(hostname) #[bg=#bbbbbb]#[fg=#000000] #(cut -d " " -f -3 /proc/loadavg) #[bg=#4e4e4e]#[fg=#ffffff]#(date +" %H:%M ")' +#  # Patch for OS X pbpaste and pbcopy under tmux. #set-option -g default-command "which reattach-to-user-namespace > /dev/null && reattach-to-user-namespace -l $SHELL || $SHELL" @@ -77,5 +86,37 @@ set -g history-limit 10000 # Fix for shift-keys with Fn; needs correct terminfo too setw -g xterm-keys on +# Mouse support for resizing and selecting panes +set -g mode-mouse on +set -g mouse-resize-pane on +set -g mouse-select-pane on +set -g mouse-select-window on + +# toggle mouse mode to allow mouse copy/paste +# set mouse on with prefix m +bind m \ + set -g mode-mouse on \;\ + set -g mouse-resize-pane on \;\ + set -g mouse-select-pane on \;\ + set -g mouse-select-window on \;\ + display 'Mouse: ON' +# set mouse off with prefix M +bind M \ + set -g mode-mouse off \;\ + set -g mouse-resize-pane off \;\ + set -g mouse-select-pane off \;\ + set -g mouse-select-window off \;\ + display 'Mouse: OFF' +# zoom this pane to full screen +bind + \ + new-window -d -n tmux-zoom 'clear && echo TMUX ZOOM && read' \;\ + swap-pane -s tmux-zoom.0 \;\ + select-window -t tmux-zoom +# restore this pane +bind - \ + last-window \;\ + swap-pane -s tmux-zoom.0 \;\ + kill-window -t tmux-zoom + # Local config if-shell "[ -f ~/.tmux.conf.user ]" 'source ~/.tmux.conf.user' diff --git a/.vim/ftdetect/eyaml.vim b/.vim/ftdetect/eyaml.vim new file mode 100644 index 0000000..0419cd5 --- /dev/null +++ b/.vim/ftdetect/eyaml.vim @@ -0,0 +1 @@ +autocmd BufWinEnter *.{eyaml} silent setf yaml diff --git a/.vim/ftdetect/todo.vim b/.vim/ftdetect/todo.vim new file mode 100644 index 0000000..af40649 --- /dev/null +++ b/.vim/ftdetect/todo.vim @@ -0,0 +1 @@ +au BufNewFile,BufRead *.todo set filetype=todo diff --git a/.vim/spell/en.utf-8.add b/.vim/spell/en.utf-8.add new file mode 100644 index 0000000..c517b0e --- /dev/null +++ b/.vim/spell/en.utf-8.add @@ -0,0 +1,7 @@ +Webistrano +smartwatch +Chromebook +Chromebooks +hacktop +Ubuntu +PostgreSQL diff --git a/.vim/spell/en.utf-8.add.spl b/.vim/spell/en.utf-8.add.spl new file mode 100644 index 0000000..7c53db7 Binary files /dev/null and b/.vim/spell/en.utf-8.add.spl differ diff --git a/.vim/spell/nl.utf-8.add b/.vim/spell/nl.utf-8.add new file mode 100644 index 0000000..a0c487b --- /dev/null +++ b/.vim/spell/nl.utf-8.add @@ -0,0 +1,23 @@ +scrumboard +todo +enzo +backups +Nexus +m'n +energielabels +Nuon +BHV +Finke +BTW-aangifte +Scholten +Sen +NLLGG +ALV +Soleus +Wietse +Jelmer +Sloterdijk +ijzerdraadjes +dienstapotheek +vrijdansen +versnellingskabel diff --git a/.vim/spell/nl.utf-8.add.spl b/.vim/spell/nl.utf-8.add.spl new file mode 100644 index 0000000..efa8127 Binary files /dev/null and b/.vim/spell/nl.utf-8.add.spl differ diff --git a/.vim/spell/nl.utf-8.spl b/.vim/spell/nl.utf-8.spl new file mode 100644 index 0000000..14ec811 Binary files /dev/null and b/.vim/spell/nl.utf-8.spl differ diff --git a/.vim/spell/nl.utf-8.sug b/.vim/spell/nl.utf-8.sug new file mode 100644 index 0000000..3191f5e Binary files /dev/null and b/.vim/spell/nl.utf-8.sug differ diff --git a/.vim/syntax/todo.vim b/.vim/syntax/todo.vim new file mode 100644 index 0000000..1154fcd --- /dev/null +++ b/.vim/syntax/todo.vim @@ -0,0 +1,69 @@ +if exists("b:current_syntax") + finish +endif + + +" Keywords that we want to emphasize +syntax keyword todoKeyword todo done +syntax keyword todoKeyword vrij free +highlight link todoKeyword Keyword + + +" Remarks about the day +syntax match todoDayKeyword "thuiswerken" +syntax match todoDayKeyword "papadag" +syntax match todoDayKeyword "vrije dag" +syntax match todoDayKeyword "koningsdag" +highlight todoDayKeyword ctermfg=38 guifg=#00afd7 + + +" Inline commenting +syntax match todoComment "\v#.*$" +highlight link todoComment Comment + + +" Heading (day) delimiters +syn region todoDay matchgroup=todoHeadingDelimiter start="==\@!" end="==*\s*$" keepend oneline + +hi def link todoHeadingDelimiter Delimiter + + +" Generic operators +syntax match todoOperator "\v\*" +syntax match todoOperator "\v/" +syntax match todoOperator "\v\+" +syntax match todoOperator "\v-" + +highlight link todoOperator Operator + + +" Task statuses +syntax match todoStatusDone "\v^v " +syntax match todoStatusDone "\v v " +syntax match todoStatusDone "\v^x " +syntax match todoStatusDone "\v x " +highlight todoStatusDone ctermfg=green guifg=#00ff00 + +syntax match todoStatusDoing "\v^d .*$" +syntax match todoStatusDoing "\v d .*$" +highlight todoStatusDoing ctermfg=DarkYellow guifg=#ffcc00 + +syntax match todoStatusTest "\v^t " +syntax match todoStatusTest "\v t " +highlight todoStatusTest ctermfg=darkcyan guifg=#6666ff + +syntax match todoStatusTodo "\v^- " +syntax match todoStatusTodo "\v - " +highlight todoStatusTodo ctermfg=red guifg=#ff0000 + +syntax match note "\v^n .*$" +syntax match note "\v n .*$" +highlight note ctermfg=Grey guifg=#eeeeee + +highlight link todoStatusDone PreProc +highlight link todoStatusDoing PreProc +highlight link todoStatusTodo PreProc + + +" Syntax highlighting scheme name +let b:current_syntax = "todo" diff --git a/.vimrc b/.vimrc index 05fea1e..97866b7 100644 --- a/.vimrc +++ b/.vimrc @@ -5,8 +5,13 @@ call vundle#begin() " let Vundle manage Vundle, required Plugin 'gmarik/Vundle.vim' +" == UI ====== + " Display tags of the current file ordered by scope +" You need ctags: `sudo apt-get install exuberant-ctags` or +" `brew install ctags` for example Plugin 'majutsushi/tagbar' +nmap <F8> :TagbarToggle<CR> " The unite or unite.vim plug-in can search and display information from " arbitrary sources like files, buffers, recently used files or registers. Plugin 'Shougo/unite.vim' @@ -25,8 +30,79 @@ Plugin 'mhinz/vim-signify' Plugin 'tpope/vim-sensible' " Nice colour scheme Plugin 'jnurmine/Zenburn.git' +" Quick file system tree, mapped to Ctrl+n for quick toggle +Plugin 'scrooloose/nerdtree' +map <C-n> :NERDTreeToggle<CR> +let NERDTreeIgnore = ['\.pyc$'] +" close vim if the only window left open is a NERDTree +autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif + + +" Web Development/Filetype icons +" Needs a font like found at +" https://github.com/ryanoasis/nerd-filetype-glyphs-fonts-patcher +Plugin 'ryanoasis/vim-webdevicons' +" Set guifont when using gvim: +"set guifont=Droid\ Sans\ Mono\ for\ Powerline\ Plus\ Nerd\ File\ Types\ 11 + + +" Full path fuzzy file, buffer, mru, tag, ... finder +Plugin 'kien/ctrlp.vim' +let g:ctrlp_map = '<Leader>t' +let g:ctrlp_match_window_bottom = 0 +let g:ctrlp_match_window_reversed = 0 +let g:ctrlp_custom_ignore = '\v\~$|\.(o|swp|pyc|wav|mp3|ogg|blend)$|(^|[/\\])\.(hg|git|bzr)($|[/\\])|__init__\.py' +let g:ctrlp_working_path_mode = 0 +let g:ctrlp_dotfiles = 0 +let g:ctrlp_switch_buffer = 0 + + +" == Content convenience ====== + +" Spell Check (http://vim.wikia.com/wiki/Toggle_spellcheck_with_function_keys) +let b:myLang=0 +let g:myLangList=["nospell","nl","en_gb","en_us"] +function! ToggleSpell() + let b:myLang=b:myLang+1 + if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif + if b:myLang==0 + setlocal nospell + else + execute "setlocal spell spelllang=".get(g:myLangList, b:myLang) + endif + echo "spell checking language:" g:myLangList[b:myLang] +endfunction + +nmap <silent> <F7> :call ToggleSpell()<CR> + +" In case the spelling language was set by other means than ToggleSpell() (a filetype autocommand say): +if !exists( "b:myLang" ) + if &spell + let b:myLang=index(g:myLangList, &spelllang) + else + let b:myLang=0 + endif +endif + +" Word completion +set complete+=kspell + " Python autocompletion Plugin 'davidhalter/jedi-vim' +" Code checker. For python, install flake8 or pylint, preferably in the +" virtualenv. For Django support, install pylint-django +Plugin 'scrooloose/syntastic' +set statusline+=%#warningmsg# +set statusline+=%{SyntasticStatuslineFlag()} +set statusline+=%* + +let g:syntastic_always_populate_loc_list = 1 +let g:syntastic_auto_loc_list = 1 +let g:syntastic_check_on_open = 1 +let g:syntastic_check_on_wq = 0 + +" No silly 80-char line limit. Sorry pep-8. Also, Django support. +let g:syntastic_python_pylint_post_args="--max-line-length=120 --load-plugins pylint_django" " Handy Markdown stuff Plugin 'tpope/vim-markdown' if v:version >= 704 @@ -45,6 +121,9 @@ let g:undotree_SetFocusWhenToggle=1 " if undotree is opened, it is likely one " many filetypes. Plugin 'scrooloose/nerdcommenter' +" Highlight colours in CSS files +Plugin 'ap/vim-css-color' + " All of your Plugins must be added before the following line call vundle#end() " required filetype plugin indent on " required @@ -59,6 +138,14 @@ set dictionary+=/usr/share/dict/words " use ctrl-n ctrl-n instead of ctrl-x ctrl-k set complete-=k complete+=k +" ctags: check the current folder for tags file and keep going one directory up +" all the way to the homedir +set tags=./tags,./TAGS,tags;~,TAGS;~ + +" ignorecase plus smartcase make searches case-insensitive except when you +" include upper-case characters (so /foo matches FOO and fOo, but /FOO only +" matches the former) +set ignorecase " 2006-04-24 set smartcase @@ -66,7 +153,7 @@ set smartcase set autoread " 2008-04-14 with the if-statement added at 2008-11-19 -if &term == "xterm" || &term == "screen-bce" || &term == "screen-256color" || &term == "screen" +if &term == "xterm" || &term == "xterm-256color" || &term == "screen-bce" || &term == "screen-256color" || &term == "screen" set t_Co=256 colorscheme zenburn @@ -78,8 +165,26 @@ endif " paste and autoindent set pastetoggle=<F10> +" Prettify json and javascript map <Leader>jt <Esc>:%!json_xs -f json -t json-pretty<CR> +" Fly through buffers instead of cycling +nnoremap <leader>l :ls<cr>:b<space> + +" Git and Mercurial 'blame' command. First select lines in visual modes, then +" hit the appropriate leader key sequence (e.g., \g for git blame) +vmap <Leader>g :<C-U>!git blame <C-R>=expand("%:p") <CR> \| sed -n <C-R>=line("'<") <CR>,<C-R>=line("'>") <CR>p <CR> +vmap <Leader>h :<C-U>!hg blame -fu <C-R>=expand("%:p") <CR> \| sed -n <C-R>=line("'<") <CR>,<C-R>=line("'>") <CR>p <CR> + + +" Enables input of special characters by a combination of two characters. +" Example: Type 'a', erase it by typing CTRL-H - and then type ':' - this +" results in the umlaut: ä So Vim remembers the character you have erased and +" combines it with the character you have typed "over" the previous one. +"set digraph +" Disabled as it also works with backspace and gives odd results with some +" normal typing, giving asiatic glyphs and such. Just use CTRL+k a: + " 2014-01-29 some sane Python settings autocmd FileType python set tabstop=4 autocmd FileType python set shiftwidth=4 @@ -88,6 +193,9 @@ autocmd FileType python set expandtab autocmd FileType python set softtabstop=4 autocmd FileType python set autoindent +" Django html template highlighting by default +au BufNewFile,BufRead *.html set filetype=htmldjango + " 2014-01-29 some sane PHP settings autocmd FileType php set tabstop=4 autocmd FileType php set shiftwidth=4 @@ -103,7 +211,7 @@ autocmd FileType tex set smarttab autocmd FileType tex set expandtab autocmd FileType tex set softtabstop=4 autocmd FileType tex set autoindent -" + " 2014-06-24 some sane shell settings autocmd FileType sh set tabstop=4 autocmd FileType sh set shiftwidth=4 @@ -111,3 +219,19 @@ autocmd FileType sh set smarttab autocmd FileType sh set expandtab autocmd FileType sh set softtabstop=4 autocmd FileType sh set autoindent + +" 2014-10-05 some sane Markdown settings +autocmd FileType markdown set tabstop=4 +autocmd FileType markdown set shiftwidth=4 +autocmd FileType markdown set smarttab +autocmd FileType markdown set expandtab +autocmd FileType markdown set softtabstop=4 +autocmd FileType markdown set autoindent + +" 2015-01-13 some sane Yaml settings +autocmd FileType yaml set tabstop=4 +autocmd FileType yaml set shiftwidth=4 +autocmd FileType yaml set smarttab +autocmd FileType yaml set expandtab +autocmd FileType yaml set softtabstop=4 +autocmd FileType yaml set autoindent diff --git a/bin/calibre_update b/bin/calibre_update new file mode 100755 index 0000000..606990f --- /dev/null +++ b/bin/calibre_update @@ -0,0 +1,2 @@ +#!/bin/bash +sudo -v && wget -nv -O- https://raw.githubusercontent.com/kovidgoyal/calibre/master/setup/linux-installer.py | sudo python -c "import sys; main=lambda:sys.stderr.write('Download failed\n'); exec(sys.stdin.read()); main()" diff --git a/bin/cron/load_log b/bin/cron/load_log new file mode 100755 index 0000000..80850c7 --- /dev/null +++ b/bin/cron/load_log @@ -0,0 +1,13 @@ +#!/bin/bash +LOADAVG=$( cat /proc/loadavg | awk '{ print $2 }' ) + +MONTH=`date +%Y-%m` +DATE=`date +%Y-%m-%d` + +LOG="/var/log/custom_logs/cpu/load_$MONTH.log" +TIMESTAMP=`date +%Y%m%d_%H%M` +echo "${TIMESTAMP} $LOADAVG" >> ${LOG} + +LOG="/var/log/custom_logs/temp_daily/cpu/load_$DATE.log" +TIMESTAMP=`date "+%Y%m%d %H%M"` +echo "${TIMESTAMP} $LOADAVG" >> ${LOG} diff --git a/bin/cron/temperature_hdd_log b/bin/cron/temperature_hdd_log new file mode 100755 index 0000000..e1d9cd0 --- /dev/null +++ b/bin/cron/temperature_hdd_log @@ -0,0 +1,37 @@ +#!/bin/bash +#temperature: 23 C + +#TEMPERATURE=`awk '{print $2}' /proc/acpi/thermal_zone/THRM/temperature` +MONTH=`date +%Y-%m` +DATE=`date +%Y-%m-%d` +for HDD in sda sdb sdc sdd sde sdf sdg +do + #TEMPERATURE=`awk '{print $NF}' /root/tmp/hddtemp` + if [ "$HDD" == "sdb" ]; then + TEMPERATURE=`/usr/sbin/smartctl -A /dev/${HDD} | grep \ Temperature_Cel | awk '{print $10}'` + else + TEMPERATURE=`/usr/sbin/smartctl -A /dev/${HDD} | grep Temperature_Cel | awk '{print $10}'` + fi + #if [ "$HDD" == "sde" ]; then + # TEMPERATURE=`/usr/sbin/smartctl -A /dev/sde | grep Temperature_Cel | awk '{print $10}'` + #elif [ "$HDD" == "sdf" ]; then + # TEMPERATURE=`/usr/sbin/smartctl -A /dev/sdf | grep Temperature_Cel | awk '{print $10}'` + #elif [ "$HDD" == "sdc" ]; then + # TEMPERATURE=`/usr/sbin/smartctl -A /dev/sdc | grep Temperature_Cel | awk '{print $10}'` + #elif [ "$HDD" == "sdd" ]; then + # TEMPERATURE=`/usr/sbin/smartctl -A /dev/sdd | grep Temperature_Cel | awk '{print $10}'` + #else + # RAWTEMP=`/usr/sbin/hddtemp /dev/$HDD` + # #echo $RAWTEMP + # TEMPERATURE=`echo $RAWTEMP | awk '{print $NF}' | sed 's/°C//g'` + #fi + LOG="/var/log/custom_logs/hdd/temperature_${HDD}_${MONTH}.log" + TIMESTAMP=`date "+%Y%m%d %H%M"` + echo "${TIMESTAMP} $TEMPERATURE" >> ${LOG} + #echo "${HDD} ${TIMESTAMP} $TEMPERATURE" + #echo "${TIMESTAMP} $TEMPERATURE" + + LOG="/var/log/custom_logs/temp_daily/hdd/temperature_${HDD}_${DATE}.log" + #TIMESTAMP=`date "+%Y%m%d %H%M"` + echo "${TIMESTAMP} $TEMPERATURE" >> ${LOG} +done diff --git a/bin/cron/temperature_log b/bin/cron/temperature_log new file mode 100755 index 0000000..a5aa134 --- /dev/null +++ b/bin/cron/temperature_log @@ -0,0 +1,24 @@ +#!/bin/bash +#temperature: 23 C + +SENSORDATA=$(sensors 2>&1) + +TEMPERATURE="$(grep -i 'Core 0' <<< "${SENSORDATA}" | \ + grep -Eo '[0-9\.]+[[:punct:]]?[ ]?[CF]+' | head -n 1 | \ + sed 's/.\([CF]\)/\1/' | sed 's/C//' )" + +#TEMPERATURE=`awk '{print $2}' /proc/acpi/thermal_zone/THRM/temperature` +MONTH=`date +%Y-%m` +DATE=`date +%Y-%m-%d` +#TOTAL=`awk '{a+=$8}END{print a}' /var/log/custom_logs/temperature.log` +#LINES=`wc -l /var/log/custom_logs/temperature.log | awk '{print $1}'` +#MON=`date +%B` +#m=`wc -l /tmp/temp5_minutes | awk '{print $1}'` + +LOG="/var/log/custom_logs/cpu/temperature_$MONTH.log" +TIMESTAMP=`date +%Y%m%d_%H%M` +echo "${TIMESTAMP} $TEMPERATURE" >> ${LOG} + +LOG="/var/log/custom_logs/temp_daily/cpu/temperature_$DATE.log" +TIMESTAMP=`date "+%Y%m%d %H%M"` +echo "${TIMESTAMP} $TEMPERATURE" >> ${LOG} diff --git a/bin/fixpictimestamps b/bin/fixpictimestamps new file mode 100755 index 0000000..3e1fe65 --- /dev/null +++ b/bin/fixpictimestamps @@ -0,0 +1,14 @@ +#!/bin/bash +find -name '*.jpg' | while read PIC; do +DATE=$(exiftool -p '$DateTimeOriginal' $PIC | sed 's/[: ]//g') +echo "$DATE $PIC" +touch -t $(echo $DATE | sed 's/\(..$\)/\.\1/') $PIC +#mv -i $PIC $(dirname $PIC)/$DATE.jpg +done + +find -name '*.CR2' | while read PIC; do +DATE=$(exiftool -p '$DateTimeOriginal' $PIC | sed 's/[: ]//g') +echo "$DATE $PIC" +touch -t $(echo $DATE | sed 's/\(..$\)/\.\1/') $PIC +#mv -i $PIC $(dirname $PIC)/$DATE.jpg +done diff --git a/bin/git_clean b/bin/git_clean new file mode 100755 index 0000000..5f12da0 --- /dev/null +++ b/bin/git_clean @@ -0,0 +1,15 @@ +#!/bin/bash + +# Dry run, stating what files would be removed +git clean -d -x -n + +read -r -p "Continue the real cleanup of the tree? [y/N] " -n 1 response +response=${response,,} # tolower +if [[ $response =~ ^(yes|y| ) ]]; then + echo + echo "Cleaning up" + git clean -d -x -f +else + echo + echo "Aborted" +fi diff --git a/bin/icons_ozon b/bin/icons_ozon new file mode 100755 index 0000000..3255c74 --- /dev/null +++ b/bin/icons_ozon @@ -0,0 +1,14 @@ +#!/bin/bash +#mydir=$(mktemp -dt "$0") +#mydir=$(mktemp -d "$TMPDIR/$(basename $0).XXXXXXXXXX") +mydir=$(mktemp -d "/tmp/$(basename $0).XXXXXXXXXX") + +cd $mydir +pwd +wget https://github.com/ozonos/ozon-icon-theme/archive/master.zip +unzip -q master.zip +if [ -e /usr/share/icons/Ozon.prev ]; then + sudo rm -rf /usr/share/icons/Ozon.prev +fi +sudo mv /usr/share/icons/Ozon /usr/share/icons/Ozon.prev +sudo mv ozon-icon-theme-master/Ozon /usr/share/icons/ diff --git a/bin/iris_color b/bin/iris_color new file mode 100755 index 0000000..6e52070 --- /dev/null +++ b/bin/iris_color @@ -0,0 +1,24 @@ +#!/bin/bash + +# Make sure only root can run our script +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + +cd /usr/share/themes + +if [ ! -d "Iris Dark" ]; then + echo "Iris theme not found!" + exit 1 +fi + +if [ -d "Iris Dark Green" ]; then + rm -r "Iris Dark Green" +fi + +cp -a "Iris Dark" "Iris Dark Green" +cd "Iris Dark Green" + +# change orange hilight to green (shade from Faba-Mint) +find . -type f -print0 | xargs -0 sed -i 's/df253f/79a142/g' diff --git a/bin/opennotes b/bin/opennotes index 3c0a4b9..a3ceac3 100755 --- a/bin/opennotes +++ b/bin/opennotes @@ -1,3 +1,5 @@ #!/bin/bash -cd ~/mydocs/work/sanoma -vim notes.txt planning_2014.txt notes_2014.md +cd ~/mydocs/notes +git pull +#vim -c ":vsp notes.txt" dammit_blogs.md captains_log.md +vim dammit_blogs.md notes.txt captains_log.md diff --git a/bin/portuser b/bin/portuser new file mode 100755 index 0000000..fb7d6b8 --- /dev/null +++ b/bin/portuser @@ -0,0 +1,6 @@ +#!/bin/bash +if [ -z "$1" ]; then + echo "Provide a TCP port number" +else + sudo fuser -v $1/tcp +fi diff --git a/bin/randomhex b/bin/randomhex new file mode 100755 index 0000000..7d9d38e --- /dev/null +++ b/bin/randomhex @@ -0,0 +1,8 @@ +#!/bin/bash +if [ -e $1 ]; then + NUMBERCHARS=42 +else + NUMBERCHARS=$1 +fi + +cat /dev/urandom | tr -cd 'a-f0-9' | head -c $NUMBERCHARS ; echo diff --git a/bin/sanomanotes b/bin/sanomanotes new file mode 100755 index 0000000..916c988 --- /dev/null +++ b/bin/sanomanotes @@ -0,0 +1,5 @@ +#!/bin/bash +cd ~/mydocs/work/sanoma +git pull +#vim -c ":vsp planning_2015.todo" notes_2015.md notes_2014.md +vim planning_2015.todo notes_2015.md notes_2014.md diff --git a/bin/update_repos b/bin/update_repos index 2603160..8ba6496 100755 --- a/bin/update_repos +++ b/bin/update_repos @@ -1,8 +1,14 @@ #!/bin/bash +REPOSFILE=(~/.git_repos) + +if [ -n "$1" ]; then + REPOSFILE="$1" +fi + saveIFS="$IFS" IFS=$'\n' -LINES=($(<~/.git_repos)) +LINES=($(<"$REPOSFILE")) IFS="$saveIFS" # Set defaults to user's homedir and no group (e.g., subdir) diff --git a/install.sh b/install.sh index ce9e510..fcf4675 100644 --- a/install.sh +++ b/install.sh @@ -24,8 +24,48 @@ install_hg() done } +# Get the directory the dotfiles have been cloned into DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -cd $DIR +echo "Installing from $DIR" +DATETIME=`date +%Y%m%d_%H%M` + +# Go home +cd + +# Symlink all the things +for TARGET + in .bash_aliases .bashrc bin .gitconfig .gitmodules .hgauthors.txt .hgignore .hgrc .screenrc .terminfo .tmux.conf .vim .vimrc install.sh +do + cd + echo $TARGET + if [ "$(readlink $TARGET)" = "$DIR/$TARGET" ]; then + echo " symlink exists and is fine, skipping" + continue + elif [ -e $TARGET ] || [ -L $TARGET ] && [ "$(readlink $TARGET)" != "$DIR/$TARGET" ]; then + echo " exists, moving out of the way" + if [ ! -d "workspace/backup/dotfiles_$DATETIME" ]; then + mkdir -p "workspace/backup/dotfiles_$DATETIME" + fi + DIRNAME=$(dirname ${TARGET}) + if [ $DIRNAME != "." ]; then + mkdir "workspace/backup/dotfiles_$DATETIME/$DIRNAME" + mv $TARGET "workspace/backup/dotfiles_$DATETIME/$DIRNAME" + #echo "workspace/backup/privdotfiles_$DATETIME/$DIRNAME" + else + mv $TARGET "workspace/backup/dotfiles_$DATETIME/" + #echo "workspace/backup/privdotfiles_$DATETIME/${TARGET}" + fi + fi + + # If link is in a subdir, go there + DIRNAME=$(dirname ${TARGET}) + if [ $DIRNAME != "." ]; then + cd $DIRNAME + fi + # Create the symlink + ln -s $DIR/$TARGET + #echo "ln -s $DIR/$TARGET" +done echo "INFO: Init submodules" git submodule init