dotfiles

My dotfiles, nothing really interesting to see ...
git clone https://git.onna.be/dotfiles.git
Log | Files | Refs | README

commit b6a88631a52774696bfc8832adfc4d7112fdddd3
Author: Paco Esteban <paco@onna.be>
Date:   Sun,  3 Jun 2018 15:08:12 +0200

first commit of this new version of dotfiles ...

Diffstat:
.gitignore | 3+++
Makefile | 58++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
README.md | 3+++
bin/ssync.sh | 26++++++++++++++++++++++++++
git/.gitconfig | 47+++++++++++++++++++++++++++++++++++++++++++++++
i3/.config/i3/config | 222+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
nvim/.config/nvim/UltiSnips/all.snippets | 134+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
nvim/.config/nvim/UltiSnips/arduino.snippets | 85+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
nvim/.config/nvim/UltiSnips/c.snippets | 145+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
nvim/.config/nvim/UltiSnips/markdown.snippets | 69+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
nvim/.config/nvim/UltiSnips/perl.snippets | 189+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
nvim/.config/nvim/UltiSnips/python.snippets | 714+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
nvim/.config/nvim/UltiSnips/r.snippets | 190+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
nvim/.config/nvim/UltiSnips/rmd.snippets | 11+++++++++++
nvim/.config/nvim/UltiSnips/sh.snippets | 70++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
nvim/.config/nvim/colors/lucius.vim | 799+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
nvim/.config/nvim/init.vim | 150+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
nvim/.config/nvim/pythonx/vimsnippets.py | 98+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
nvim/.config/nvim/templates/template.R | 4++++
nvim/.config/nvim/templates/template.c | 11+++++++++++
nvim/.config/nvim/templates/template.go | 8++++++++
nvim/.config/nvim/templates/template.pl | 8++++++++
nvim/.config/nvim/templates/template.py | 4++++
nvim/.config/nvim/templates/template.sh | 2++
polybar/.config/polybar/config | 230+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
polybar/.config/polybar/launch.sh | 12++++++++++++
tidy/.astylerc | 19+++++++++++++++++++
tidy/.ctags | 23+++++++++++++++++++++++
tidy/.perltidyrc | 3+++
tmux/.tmux.conf | 132+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
x11/.Xresources | 44++++++++++++++++++++++++++++++++++++++++++++
zsh/.zsh/agnoster.zsh-theme | 184+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
zsh/.zsh/aliases.zsh | 183+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
zsh/.zsh/includes.zsh | 29+++++++++++++++++++++++++++++
zsh/.zsh/usb_format.zsh | 218+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
zsh/.zsh_plugins/colored-man-pages.plugin.zsh | 14++++++++++++++
zsh/.zsh_plugins/extract.plugin.zsh | 77+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
zsh/.zshenv | 23+++++++++++++++++++++++
zsh/.zshrc | 37+++++++++++++++++++++++++++++++++++++
39 files changed, 4278 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1,3 @@ +__pycache__ +nvim/.config/nvim/pack/bundle/* +.netrwhist diff --git a/Makefile b/Makefile @@ -0,0 +1,58 @@ +UNAME_S := $(shell uname -s) +ifeq ($(UNAME_S),Linux) + UNAME = Linux +endif +ifeq ($(UNAME_S),Darwin) + UNAME = OSX +endif + +install: + @make $(UNAME) + +OSX: zsh nvim tmux git tidy +Linux: zsh nvim tmux git tidy i3 mutt newsboat + +clean: + @echo "- CLEAN --------------------" + stow -t "$$HOME" -D zsh + stow -t "$$HOME" -D git + stow -t "$$HOME/bin" -D bin + stow -t "$$HOME" -D nvim + stow -t "$$HOME" -D tmux + stow -t "$$HOME" -D i3 + stow -t "$$HOME" -D tidy + +bin: + @echo "- BIN ----------------------" + stow -t "$$HOME/bin" bin + +git: + @echo "- GIT ----------------------" + stow -t "$$HOME" git + +i3: + @echo "- i3 -----------------------" + stow -t "$$HOME" i3 + stow -t "$$HOME" polybar + +nvim: + @echo "- NVIM ---------------------" + stow -t "$$HOME" nvim + +tidy: + @echo "- STYLE and TIDY -----------" + stow -t "$$HOME" tidy + +tmux: + @echo "- TMUX ---------------------" + stow -t "$$HOME" tmux + +x11: + @echo "- X11 ----------------------" + stow -t "$$HOME" x11 + +zsh: + @echo "- ZSH ----------------------" + stow -t "$$HOME" zsh + +.PHONY: insta Linux OSX zsh nvim tmux i3 git tidy bin x11 diff --git a/README.md b/README.md @@ -0,0 +1,3 @@ +# dotfiles + +nothing exciting, just my dotfiles organized somehow ... diff --git a/bin/ssync.sh b/bin/ssync.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +DIRECTION=${1} +if [[ -z "$DIRECTION" ]]; then + echo "Need directio (from | to)" + exit 1 +fi + +if [[ "$DIRECTION" == "to" ]]; then + FROM="$HOME/Sync/" + TO="galadriel:Sync/" +else + FROM="galadriel:Sync/" + TO="$HOME/Sync/" +fi +shift + +rsync \ + -av \ + $* \ + --delete \ + --exclude '*.pyc' \ + --exclude '__pycache__' \ + --exclude 'src/go/bin/*' \ + $FROM \ + $TO diff --git a/git/.gitconfig b/git/.gitconfig @@ -0,0 +1,47 @@ +[user] + name = Paco Esteban + email = paco@onna.be + signingkey = 0x44CA735E +[color] + ui = true +[color "branch"] + current = yellow reverse + local = yellow + remote = green +[color "diff"] + meta = yellow + frag = magenta + old = red + new = green +[color "status"] + added = yellow + changed = green + untracked = cyan +[core] + excludesfile = ~/.gitignore + pager = "/usr/bin/less -M -X -F" +[alias] + st = status + df = diff + ci = commit -v + co = checkout + br = branch + ps = push + glog = log --graph --decorate --branches=* --remotes=* + # commit count by author + who = shortlog -s -n + # ovid++ + stashed = "stash list --pretty=format:'%gd: %Cred%h%Creset %Cgreen[%ar]%Creset %s'" + sl = "stash list --pretty=format:'%gd: %Cred%h%Creset %Cgreen[%ar]%Creset %s'" + ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cgreen\\ [%cn]\\ %Creset%ad" --decorate --numstat + l = log --pretty=format:"%C(yellow)%h\\ %C(cyan)%ad%Cred%d\\ %Creset%s%Cgreen\\ [%an]" --decorate --date=short --graph --branches=* --remotes=* -20 + le = log --oneline --decorate + ds = "diff --staged" + dw = "diff --word-diff=color" + ss = "stash save" + simple = "log --graph --simplify-by-decoration --oneline" + latestbranches = "for-each-ref --sort=-committerdate --format='%(refname:short) %(committerdate:short)'" +[push] + default = simple +[github] + user = pacoesteban diff --git a/i3/.config/i3/config b/i3/.config/i3/config @@ -0,0 +1,222 @@ +# use 'Windows' key +set $mod Mod4 +# Use Mouse+$mod to drag floating windows to their wanted position +floating_modifier $mod +# switch easily between 2 workspaces +workspace_auto_back_and_forth yes + +# terminal setting +set $term --no-startup-id urxvtc +# system restart/shutdown +set $shutdown sudo shutdown -h now +set $reboot sudo reboot +# +##For spotify +set $music spotify +set $pause dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause +set $trupause dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Pause +set $play dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Play +set $next dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next +set $prev dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous +#For PULSEAUDIO/PAMIXER +set $volup --no-startup-id pamixer --allow-boost -i 5 +set $voldown --no-startup-id pamixer --allow-boost -d 5 +set $mute --no-startup-id pamixer --allow-boost -t +set $truemute --no-startup-id pamixer -m + +# my font of choice +font pango:Ubuntu Mono derivative Powerline 12 + +## Startup applications +#Composite manager: +exec --no-startup-id compton --xrender-sync-fence +# backgrounds +exec_always --no-startup-id feh --bg-scale ~/Pictures/1616583.jpg +# polybar +exec_always --no-startup-id ~/.config/polybar/launch.sh +# clipboard manager +exec_always --no-startup-id parcellite +# screensaver +exec_always --no-startup-id xscreensaver -no-splash +# notify daemon +exec_always --no-startup-id dunst +# we don't need the mouse cursor around ... +exec_always --no-startup-id unclutter --timeout 10 --ignore-scrolling --fork + + +## some windows belong to a workspace +assign [class="^Google-chrome$"] 2 +assign [class="^Slack$"] 3 +assign [class="^mpv$"] 9 +assign [class="^Spotify$"] 10 +for_window [class="^Spotify$"] move to workspace 10 +assign [instance="mutt"] 5 +assign [instance="weechat"] 6 +assign [instance="nvim"] 4 + +# don't want bar on chrome and some others +for_window [class="^Google-chrome$"] border none +for_window [class="^qutebrowser$"] border none +for_window [class="^Slack$"] border none +for_window [class="^URxvt$"] border none +# remmina is better floating +for_window [instance="remmina"] floating enable +for_window [instance="remmina"] move position center +for_window [instance="remmina"] resize set 600 400 +# and zbar (barcode reader) too +for_window [class="zbar"] floating enable +for_window [class="zbar"] move position center +# and ranger +for_window [instance="^ranger$"] floating enable +for_window [instance="^ranger$"] resize set 1500 800 +for_window [instance="^ranger$"] border pixel 2 +for_window [instance="^ranger$"] move position center +# and Guvcview +for_window [class="Guvcview"] floating enable +for_window [class="Guvcview"] move position center +for_window [class="Guvcview"] resize set 600 400 +# formula editor for Freecad +for_window [class="Freecad" title="Formula editor"] floating enable +for_window [class="Freecad" title="Formula editor"] move absolute position center +# for_window [class="Freecad" title="Formula editor"] resize set 100 120 +for_window [class="Freecad" title="Formula editor"] border pixel 5 + +# comms workspace decoration +for_window [instance="mutt"] border pixel 2 +for_window [instance="weechat"] border pixel 2 + +# Dropdown/Scratchpad Windows (taken from https://github.com/LukeSmithxyz/voidrice) +# First I have a tmux window used for background scripts. +# I'll later bind this to mod+u. +for_window [instance="dropdown"] floating enable +for_window [instance="dropdown"] resize set 825 500 +for_window [instance="dropdown"] move scratchpad +for_window [instance="dropdown"] border pixel 5 +exec $term -name dropdown + +# fixing steam on tilling wm +# https://github.com/ValveSoftware/steam-for-linux/issues/1040 +for_window [class="^Steam$"] floating enable +for_window [title="^Steam Keyboard$"] floating enable + +## Key bindings +bindsym $mod+u [instance="dropdown"] scratchpad show; [instance="dropdown"] move position center +# ranger file manager +bindsym $mod+r exec $term -name ranger -e zsh -i -c ranger +# start a terminal +bindsym $mod+Return exec $term +# editor +bindsym $mod+v exec $term -name nvim -e zsh -i -c nvim +# kill focused window +bindsym $mod+Shift+q kill +# system things shutdown/reboot +bindsym $mod+Shift+BackSpace exec $reboot +bindsym $mod+Shift+x exec $shutdown +# music +bindsym $mod+m exec $music +bindsym $mod+Shift+m exec $mute +bindsym $mod+p exec $play +bindsym $mod+Shift+p exec $pause +bindsym $mod+n exec $next +bindsym $mod+b exec $prev +# Volume keys +bindsym $mod+plus exec $volup +bindsym $mod+Shift+plus exec $voldown +# email and chat +bindsym $mod+e exec $term -name mutt -e neomutt +bindsym $mod+w exec $term -name weechat -e weechat +# screenshots +bindsym --release Print exec --no-startup-id scrot -z -c -d 1 -s -e 'mv $f ~/tmp/shots/' 'shot_%Y%m%d%H%M%S_$wx$h.png' +bindsym Shift+Print exec --no-startup-id scrot 'shot_%Y%m%d%H%M%S_$wx$h.png' -e 'mv $f ~/tmp/shots/' +# apps launcher +bindsym $mod+d exec --no-startup-id ~/.config/rofi/launch.sh +# change focus +bindsym $mod+h focus left +bindsym $mod+j focus down +bindsym $mod+k focus up +bindsym $mod+l focus right +# alternatively, you can use the cursor keys: +bindsym $mod+Left focus left +bindsym $mod+Down focus down +bindsym $mod+Up focus up +bindsym $mod+Right focus right +# move focused window +bindsym $mod+Shift+h move left +bindsym $mod+Shift+j move down +bindsym $mod+Shift+k move up +bindsym $mod+Shift+l move right +# alternatively, you can use the cursor keys: +bindsym $mod+Shift+Left move left +bindsym $mod+Shift+Down move down +bindsym $mod+Shift+Up move up +bindsym $mod+Shift+Right move right +# split in horizontal orientation +# bindsym $mod+bar split h +bindsym $mod+bar layout splith +# split in vertical orientation +# bindsym $mod+minus split v +bindsym $mod+minus layout splitv +# enter fullscreen mode for the focused container +bindsym $mod+f fullscreen toggle +# change container layout (stacked, tabbed, toggle split) +bindsym $mod+s layout stacking +bindsym $mod+t layout tabbed +bindsym $mod+Shift+t layout toggle split +# toggle tiling / floating +bindsym $mod+Shift+space floating toggle +# change focus between tiling / floating windows +bindsym $mod+space focus mode_toggle +# navigate workspaces +bindsym $mod+1 workspace 1 +bindsym $mod+2 workspace 2 +bindsym $mod+3 workspace 3 +bindsym $mod+4 workspace 4 +bindsym $mod+5 workspace 5 +bindsym $mod+6 workspace 6 +bindsym $mod+7 workspace 7 +bindsym $mod+8 workspace 8 +bindsym $mod+9 workspace 9 +bindsym $mod+0 workspace 10 +# move focused container to workspace +bindsym $mod+Shift+1 move container to workspace 1 +bindsym $mod+Shift+2 move container to workspace 2 +bindsym $mod+Shift+3 move container to workspace 3 +bindsym $mod+Shift+4 move container to workspace 4 +bindsym $mod+Shift+5 move container to workspace 5 +bindsym $mod+Shift+6 move container to workspace 6 +bindsym $mod+Shift+7 move container to workspace 7 +bindsym $mod+Shift+8 move container to workspace 8 +bindsym $mod+Shift+9 move container to workspace 9 +bindsym $mod+Shift+0 move container to workspace 10 +# reload the configuration file +bindsym $mod+Shift+c reload +# restart i3 inplace (preserves your layout/session, can be used to upgrade i3) +bindsym $mod+Shift+period restart +# exit i3 (logs you out of your X session) +bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'" + +# resize window (you can also use the mouse for that) +mode "resize" { + # These bindings trigger as soon as you enter the resize mode + + # Pressing left will shrink the window’s width. + # Pressing right will grow the window’s width. + # Pressing up will shrink the window’s height. + # Pressing down will grow the window’s height. + bindsym h resize shrink width 10 px or 10 ppt + bindsym j resize grow height 10 px or 10 ppt + bindsym k resize shrink height 10 px or 10 ppt + bindsym l resize grow width 10 px or 10 ppt + + # same bindings, but for the arrow keys + bindsym Left resize shrink width 10 px or 10 ppt + bindsym Down resize grow height 10 px or 10 ppt + bindsym Up resize shrink height 10 px or 10 ppt + bindsym Right resize grow width 10 px or 10 ppt + + # back to normal: Enter or Escape + bindsym Return mode "default" + bindsym Escape mode "default" +} + +bindsym $mod+Shift+r mode "resize" diff --git a/nvim/.config/nvim/UltiSnips/all.snippets b/nvim/.config/nvim/UltiSnips/all.snippets @@ -0,0 +1,134 @@ +# This file contains snippets that are always defined. I personally +# have snippets for signatures and often needed texts + +# sligthly lower priority than everything else since specialized versions +# should overwrite. The user needs to adjust her priority in her snippets to +# ~-55 so that other filetypes will still overwrite. +priority -60 + +############## +# NICE BOXES # +############## +global !p +from vimsnippets import foldmarker, make_box, get_comment_format +endglobal + +snippet box "A nice box with the current comment symbol" b +`!p +box = make_box(len(t[1])) +snip.rv = box[0] +snip += box[1] +`${1:${VISUAL:content}}`!p +box = make_box(len(t[1])) +snip.rv = box[2] +snip += box[3]` +$0 +endsnippet + +snippet bbox "A nice box over the full width" b +`!p +if not snip.c: + width = int(vim.eval("&textwidth - (virtcol('.') == 1 ? 0 : virtcol('.'))")) or 71 +box = make_box(len(t[1]), width) +snip.rv = box[0] +snip += box[1] +`${1:${VISUAL:content}}`!p +box = make_box(len(t[1]), width) +snip.rv = box[2] +snip += box[3]` +$0 +endsnippet + +snippet fold "Insert a vim fold marker" b +`!p snip.rv = get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]`${2:1} `!p snip.rv = get_comment_format()[2]` +endsnippet + +snippet foldc "Insert a vim fold close marker" b +`!p snip.rv = get_comment_format()[0]` ${2:1}`!p snip.rv = foldmarker()[1]` `!p snip.rv = get_comment_format()[2]` +endsnippet + +snippet foldp "Insert a vim fold marker pair" b +`!p snip.rv = get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]` `!p snip.rv = get_comment_format()[2]` +${2:${VISUAL:Content}} +`!p snip.rv = get_comment_format()[0]` `!p snip.rv = foldmarker()[1]` $1 `!p snip.rv = get_comment_format()[2]` +endsnippet + +########################## +# LOREM IPSUM GENERATORS # +########################## +snippet lorem "Lorem Ipsum - 50 Words" b +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod +tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At +vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, +no sea takimata sanctus est Lorem ipsum dolor sit amet. +endsnippet + +########################## +# VIM MODELINE GENERATOR # +########################## +# See advice on `:help 'tabstop'` for why these values are set. Uses second +# modeline form ('set') to work in languages with comment terminators +# (/* like C */). +snippet modeline "Vim modeline" +vim`!v ':set '. (&expandtab ? printf('et sw=%i ts=%i', &sw, &ts) : printf('noet sts=%i sw=%i ts=%i', &sts, &sw, &ts)) . (&tw ? ' tw='. &tw : '') . ':'` +endsnippet + +######### +# DATES # +######### +snippet date "YYYY-MM-DD" w +`!v strftime("%F")` +endsnippet + +snippet ddate "Month DD, YYYY" w +`!v strftime("%b %d, %Y")` +endsnippet + +snippet diso "ISO format datetime" w +`!v strftime("%F %H:%M:%S%z")` +endsnippet + +snippet time "hh:mm" w +`!v strftime("%H:%M")` +endsnippet + +snippet datetime "YYYY-MM-DD hh:mm" w +`!v strftime("%Y-%m-%d %H:%M")` +endsnippet + +snippet todo "TODO comment" bw +`!p snip.rv=get_comment_format()[0]` TODO: $1 <`!v strftime('%d-%m-%Y')`, `!v g:snips_author`> `!p snip.rv=get_comment_format()[2]` +$0 +endsnippet + +########################### +# some personal content # +########################### +snippet copy "shot copyright notice" b +`!p snip.rv=get_comment_format()[0]`Copyright © `!v strftime('%Y')` Paco Esteban <paco@onna.be> +`!p snip.rv=get_comment_format()[0]`Distributed under terms of the MIT license. +endsnippet + +snippet license "MIT License" b +Copyright (c) <`!v strftime('%Y')`> Paco Esteban <paco@onna.be> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +endsnippet + +# vim:ft=snippets: diff --git a/nvim/.config/nvim/UltiSnips/arduino.snippets b/nvim/.config/nvim/UltiSnips/arduino.snippets @@ -0,0 +1,85 @@ +priority -5 + +extends c + +snippet setup "Setup func" b +void setup() +{ + Serial.begin(${1:9600}); + ${0} +} +endsnippet + +snippet loop "Main loop func" b +void loop() +{ + ${0} +} +endsnippet + +## IO +# pinMode OUTPUT +snippet pinout "pinMode OUTPUT" b +pinMode(${1}, OUTPUT); +$0 +endsnippet +# pinMode INPUT +snippet pinin "pinMode INPUT" b +pinMode(${1}, INPUT); +$0 +endsnippet +# digitalWrite HIGH +snippet dwHigh "digitalWrite(x, HIGH)" +digitalWrite(${1}, HIGH); +$0 +endsnippet +# digitalWrite LOW +snippet dwLow "digitalWrite(x, HIGH)" +digitalWrite(${1}, LOW); +$0 +endsnippet +# digitalRead +snippet dr "digitalRead()" +digitalRead(${1}); +$0 +endsnippet +# analogRead +snippet ar "analogRead()" +analogRead(${1}); +$0 +endsnippet +# analogWrite +snippet aw "AnalogWrite(x)" +analogWrite(${1}); +$0 +endsnippet +# serialRead +snippet sr "Serial.read()" +Serial.read(); +$0 +endsnippet +# serialWrite +snippet sw "Serial.write(x)" +Serial.write(${1}); +$0 +endsnippet +# serial.print +snippet sp "Serial.print(x)" +Serial.print(${1}); +$0 +endsnippet +# serial.println +snippet sl "Serial.println(x)" +Serial.println(${1}); +$0 +endsnippet +# delay +snippet dl "delay()" +delay(${1}); +$0 +endsnippet +# millis +snippet ml "millis()" +millis(); +$0 +endsnippet diff --git a/nvim/.config/nvim/UltiSnips/c.snippets b/nvim/.config/nvim/UltiSnips/c.snippets @@ -0,0 +1,145 @@ +priority -10 + +snippet def "#define ..." b +#define $1 +endsnippet + +snippet inc "#include <f.h>" b +#include <${1}.h> +endsnippet + +snippet #ifndef "#ifndef ... #define ... #endif" b +#ifndef ${1/([A-Za-z0-9_]+).*/$1/} +#define ${1:SYMBOL} ${2:value} +#endif /* ifndef $1 */ +endsnippet + +snippet #if "#if #endif" b +#if ${1:0} +${VISUAL}$0 +#endif +endsnippet + +snippet mark "#pragma mark (mark)" +#if 0 +${1:#pragma mark - +}#pragma mark $2 +#endif + +$0 +endsnippet + +snippet main "main() (main)" b +int main(int argc, char *argv[]) +{ + ${VISUAL}$0 + return 0; +} +endsnippet + +snippet vmain "main(void)" b +int main(void) +{ + ${VISUAL}$0 + return 0; +} +endsnippet + +snippet for "for int loop (fori)" +for (${4:int} ${2:i} = 0; $2 < ${1:count}; ${3:++$2}) { + ${VISUAL}$0 +} +endsnippet + +snippet switch "Switch case" b +switch (${1:/* variable */}) { + case ${2:/* variable case */}: + ${3} + ${4:break;} + default: + ${0} +} +endsnippet + +snippet case "case statement" +case ${1:/* variable case */}: + ${2} + ${3:break;} +${0} +endsnippet + +snippet wh "while loop" b +while (${1:/* condition */}) { + ${0} +} +endsnippet + +snippet do "do ... while loop" b +do { + ${0} +} while (${1:/* condition */}); +endsnippet + +snippet once "Include header once only guard" +#ifndef ${1:`!p +if not snip.c: + import random, string + name = re.sub(r'[^A-Za-z0-9]+','_', snip.fn).upper() + rand = ''.join(random.sample(string.ascii_letters+string.digits, 8)) + snip.rv = ('%s_%s' % (name,rand)).upper() +else: + snip.rv = snip.c`} +#define $1 + +${VISUAL}$0 + +#endif /* end of include guard: $1 */ +endsnippet + +snippet fprintf "fprintf ..." +fprintf(${1:stderr}, "${2:%s}\n"${2/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$3${2/([^%]|%%)*(%.)?.*/(?2:\);)/} +endsnippet + +# inline if +snippet ifi "Inline if" b +if (${1:/* condition */}) ${2}; +endsnippet + +snippet if "if () ..." b +if (${1:/* condition */}) { + ${VISUAL}$0 +} +endsnippet +snippet else "else {}" +else { + ${0} +} +endsnippet +snippet elif "else if .. (eli)" +else if (${1:/* condition */}) { + ${VISUAL}$0 +} +endsnippet + +snippet printf "printf .. (printf)" +printf("${1:%s}\n"${1/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$2${1/([^%]|%%)*(%.)?.*/(?2:\);)/} +endsnippet + +snippet st "struct" b +struct ${1:`!p snip.rv = (snip.basename or "name") + "_t"`} { + ${0:/* data */} +}; +endsnippet + +snippet func "function" b +${1:void} ${2:function_name}($3) +{ + ${VISUAL}$0 +} +endsnippet + +snippet fund "function declaration" b +${1:void} ${2:function_name}($3); +endsnippet + +# vim:ft=snippets: diff --git a/nvim/.config/nvim/UltiSnips/markdown.snippets b/nvim/.config/nvim/UltiSnips/markdown.snippets @@ -0,0 +1,69 @@ +priority -10 + +########################### +# Sections and Paragraphs # +########################### +snippet sec "Section" b +# ${1:Section Name} +$0 +endsnippet + +snippet ssec "Sub Section" b +## ${1:Section Name} +$0 +endsnippet + +snippet sssec "SubSub Section" b +### ${1:Section Name} +$0 +endsnippet + +snippet par "Paragraph" b +#### ${1:Paragraph Name} +$0 +endsnippet + +snippet spar "Paragraph" b +##### ${1:Paragraph Name} +$0 +endsnippet + +################ +# Common stuff # +################ +snippet link "Link to something" +[${1:${VISUAL:Text}}](${2:https://www.url.com})$0 +endsnippet + +snippet img "Image" +![${1:pic alt}](${2:path}${3/.+/ "/}${3:opt title}${3/.+/"/})$0 +endsnippet + +snippet pre "Inline Code" i +\`$1\`$0 +endsnippet + +snippet code "Codeblock" b +\`\`\` +$1 +\`\`\` +$0 +endsnippet + +snippet refl "Reference Link" +[${1:${VISUAL:Text}}][${2:id}]$0 + +[$2]:${3:http://www.url.com} "${4:$3}" +endsnippet + +snippet fnt "Footnote" +[^${1:${VISUAL:Footnote}}]$0 + +[^$1]:${2:Text} +endsnippet + +pre_expand "create_table(snip)" +snippet "tb(\d+x\d+)" "Customizable table" br +endsnippet + +# vim:ft=snippets: diff --git a/nvim/.config/nvim/UltiSnips/perl.snippets b/nvim/.config/nvim/UltiSnips/perl.snippets @@ -0,0 +1,189 @@ +priority -10 + +########################################################################### +# TextMate Snippets # +########################################################################### +snippet ife "Conditional if..else (ife)" +if ($1) { + ${2:# body...} +} +else { + ${3:# else...} +} + +endsnippet + +snippet ifee "Conditional if..elsif..else (ifee)" +if ($1) { + ${2:# body...} +} +elsif ($3) { + ${4:# elsif...} +} +else { + ${5:# else...} +} + +endsnippet + +snippet xunless "Conditional one-line (unless)" +${1:expression} unless ${2:condition}; + +endsnippet + +snippet xif "Conditional one-line (xif)" +${1:expression} if ${2:condition}; + +endsnippet + +snippet sub "Function (sub)" +sub ${1:function_name} { + ${2:# body...} +} + +endsnippet + +snippet xfore "Loop one-line (xforeach)" +${1:expression} foreach @${2:array}; + +endsnippet + +snippet xwhile "Loop one-line (xwhile)" +${1:expression} while ${2:condition}; + +endsnippet + +snippet test "Test" +#!/usr/bin/env perl -w + +use strict; +use Test::More tests => ${1:1}; +use ${2:ModuleName}; + +ok(${3:assertion}); + +endsnippet + +snippet class "class" +package ${1:ClassName}; + +${2:use parent qw(${3:ParentClass});}${2/.+/\n\n/}sub new { + my $class = shift; + $class = ref $class if ref $class; + my $self = bless {}, $class; + $self; +} + +1; + +endsnippet + +snippet eval "eval" +local $@; +eval { + ${1:# do something risky...} +}; +if (my $${2:exception} = $@) { + ${3:# handle failure...} +} + +endsnippet + +snippet for "for" +for (my $${1:var} = 0; $$1 < ${2:expression}; $$1++) { + ${3:# body...} +} + +endsnippet + +snippet fore "foreach" +foreach ${1:my $${2:x}} (@${3:array}) { + ${4:# body...} +} + +endsnippet + +snippet if "if" +if ($1) { + ${2:# body...} +} + +endsnippet + +snippet slurp "slurp" +my $${1:var} = do { local $/ = undef; open my $fh, '<', ${2:$file}; <$fh> }; + +endsnippet + +snippet unless "unless" +unless ($1) { + ${2:# body...} +} + +endsnippet + +snippet while "while" +while ($1) { + ${2:# body...} +} + +endsnippet + +snippet until "until" +until ($1) { + ${2:# body...} +} + +endsnippet + +snippet openr "Open file for reading" b +open(my $fh, '<:encoding(UTF-8)', $${1:filename}) + or die "Couldnot open file '$$1' $!"; + +while (my $row = <$fh>) { + chomp $row; + ${0} +} + +close $fh; +endsnippet + +snippet openw "Open file for writing" b +open(my $fh, '>:encoding(UTF-8)', $${1:filename}) + or die "Couldnot open file '$$1' $!"; +${0} +close $fh; +endsnippet + +snippet = "" i + => ${0} +endsnippet + +snippet - "" i +-> +endsnippet + +snippet , "" i +->{${0}} +endsnippet + +snippet task "Rex task definition" b +task ${1:task_name} => sub { + ${0} +}; +endsnippet + +snippet subs "Function (sub) with signatures" b +sub ${1:function_name} (${2:params}) { + ${3:# body...} +} + +endsnippet + +snippet sig "Signatures, still experimental ..." b +use feature 'signatures'; +no warnings qw(experimental::signatures); +${0} +endsnippet + +# vim:ft=snippets: diff --git a/nvim/.config/nvim/UltiSnips/python.snippets b/nvim/.config/nvim/UltiSnips/python.snippets @@ -0,0 +1,714 @@ +priority -10 + +########################################################################### +# TEXTMATE SNIPPETS # +########################################################################### + +#! header +snippet #! "Shebang header for python scripts" b +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +$0 +endsnippet + +snippet ifmain "ifmain" b +if __name__ == `!p snip.rv = get_quoting_style(snip)`__main__`!p snip.rv = get_quoting_style(snip)`: + ${1:${VISUAL:main()}} +endsnippet + +snippet with "with" b +with ${1:expr}`!p snip.rv = " as " if t[2] else ""`${2:var}: + ${3:${VISUAL:pass}} +$0 +endsnippet + +snippet for "for loop" b +for ${1:item} in ${2:iterable}: + ${3:${VISUAL:pass}} +endsnippet + +########## +# COMMON # +########## + +# The smart def and smart class snippets use a global option called +# "g:ultisnips_python_style" which, if set to "doxygen" will use doxygen +# style comments in docstrings. + +global !p + +NORMAL = 0x1 +DOXYGEN = 0x2 +SPHINX = 0x3 +GOOGLE = 0x4 +NUMPY = 0x5 +JEDI = 0x6 + +SINGLE_QUOTES = "'" +DOUBLE_QUOTES = '"' + + +class Arg(object): + def __init__(self, arg): + self.arg = arg + self.name = arg.split('=')[0].strip() + + def __str__(self): + return self.name + + def __unicode__(self): + return self.name + + def is_kwarg(self): + return '=' in self.arg + + +def get_args(arglist): + args = [Arg(arg) for arg in arglist.split(',') if arg] + args = [arg for arg in args if arg.name != 'self'] + + return args + + +def get_quoting_style(snip): + style = snip.opt("g:ultisnips_python_quoting_style", "double") + if style == 'single': + return SINGLE_QUOTES + return DOUBLE_QUOTES + +def triple_quotes(snip): + style = snip.opt("g:ultisnips_python_triple_quoting_style") + if not style: + return get_quoting_style(snip) * 3 + return (SINGLE_QUOTES if style == 'single' else DOUBLE_QUOTES) * 3 + +def triple_quotes_handle_trailing(snip, quoting_style): + """ + Generate triple quoted strings and handle any trailing quote char, + which might be there from some autoclose/autopair plugin, + i.e. when expanding ``"|"``. + """ + if not snip.c: + # Do this only once, otherwise the following error would happen: + # RuntimeError: The snippets content did not converge: … + _, col = vim.current.window.cursor + line = vim.current.line + + # Handle already existing quote chars after the trigger. + _ret = quoting_style * 3 + while True: + try: + nextc = line[col] + except IndexError: + break + if nextc == quoting_style and len(_ret): + _ret = _ret[1:] + col = col+1 + else: + break + snip.rv = _ret + else: + snip.rv = snip.c + +def get_style(snip): + style = snip.opt("g:ultisnips_python_style", "normal") + + if style == "doxygen": return DOXYGEN + elif style == "sphinx": return SPHINX + elif style == "google": return GOOGLE + elif style == "numpy": return NUMPY + elif style == "jedi": return JEDI + else: return NORMAL + + +def format_arg(arg, style): + if style == DOXYGEN: + return "@param %s TODO" % arg + elif style == SPHINX: + return ":param %s: TODO" % arg + elif style == NORMAL: + return ":%s: TODO" % arg + elif style == GOOGLE: + return "%s (TODO): TODO" % arg + elif style == JEDI: + return ":type %s: TODO" % arg + elif style == NUMPY: + return "%s : TODO" % arg + + +def format_return(style): + if style == DOXYGEN: + return "@return: TODO" + elif style in (NORMAL, SPHINX, JEDI): + return ":returns: TODO" + elif style == GOOGLE: + return "Returns: TODO" + + +def write_docstring_args(args, snip): + if not args: + snip.rv += ' {0}'.format(triple_quotes(snip)) + return + + snip.rv += '\n' + snip.mkline('', indent='') + + style = get_style(snip) + + if style == GOOGLE: + write_google_docstring_args(args, snip) + elif style == NUMPY: + write_numpy_docstring_args(args, snip) + else: + for arg in args: + snip += format_arg(arg, style) + + +def write_google_docstring_args(args, snip): + kwargs = [arg for arg in args if arg.is_kwarg()] + args = [arg for arg in args if not arg.is_kwarg()] + + if args: + snip += "Args:" + snip.shift() + for arg in args: + snip += format_arg(arg, GOOGLE) + snip.unshift() + snip.rv += '\n' + snip.mkline('', indent='') + + if kwargs: + snip += "Kwargs:" + snip.shift() + for kwarg in kwargs: + snip += format_arg(kwarg, GOOGLE) + snip.unshift() + snip.rv += '\n' + snip.mkline('', indent='') + + +def write_numpy_docstring_args(args, snip): + if args: + snip += "Parameters" + snip += "----------" + + kwargs = [arg for arg in args if arg.is_kwarg()] + args = [arg for arg in args if not arg.is_kwarg()] + + if args: + for arg in args: + snip += format_arg(arg, NUMPY) + if kwargs: + for kwarg in kwargs: + snip += format_arg(kwarg, NUMPY) + ', optional' + snip.rv += '\n' + snip.mkline('', indent='') + + +def write_init_body(args, parents, snip): + parents = [p.strip() for p in parents.split(",")] + parents = [p for p in parents if p != 'object'] + + for p in parents: + snip += p + ".__init__(self)" + + if parents: + snip.rv += '\n' + snip.mkline('', indent='') + + for arg in args: + snip += "self._%s = %s" % (arg, arg) + + +def write_slots_args(args, snip): + quote = get_quoting_style(snip) + arg_format = quote + '_%s' + quote + args = [arg_format % arg for arg in args] + snip += '__slots__ = (%s,)' % ', '.join(args) + + +def write_function_docstring(t, snip): + """ + Writes a function docstring with the current style. + + :param t: The values of the placeholders + :param snip: UltiSnips.TextObjects.SnippetUtil object instance + """ + snip.rv = "" + snip >> 1 + + args = get_args(t[2]) + if args: + write_docstring_args(args, snip) + + style = get_style(snip) + + if style == NUMPY: + snip += 'Returns' + snip += '-------' + snip += 'TODO' + else: + snip += format_return(style) + snip.rv += '\n' + snip.mkline('', indent='') + snip += triple_quotes(snip) + +def get_dir_and_file_name(snip): + return os.getcwd().split(os.sep)[-1] + '.' + snip.basename + +endglobal + +######################################## +# Class & Special Method Name Snippets # +######################################## + +snippet class "class with docstrings" b +class ${1:MyClass}(${2:object}): + + `!p snip.rv = triple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = triple_quotes(snip)` + + def __init__(self$4): + `!p snip.rv = triple_quotes(snip)`${5:TODO: to be defined1.}`!p +snip.rv = "" +snip >> 2 + +args = get_args(t[4]) + +write_docstring_args(args, snip) +if args: + snip.rv += '\n' + snip.mkline('', indent='') + snip += '{0}'.format(triple_quotes(snip)) + +write_init_body(args, t[2], snip) +` + $0 +endsnippet + + +snippet slotclass "class with slots and docstrings" b +class ${1:MyClass}(${2:object}): + + `!p snip.rv = triple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = triple_quotes(snip)` +`!p +snip >> 1 +args = get_args(t[4]) +write_slots_args(args, snip) +` + + def __init__(self$4): + `!p snip.rv = triple_quotes(snip)`${5:TODO: to be defined.}`!p +snip.rv = "" +snip >> 2 + +args = get_args(t[4]) + +write_docstring_args(args, snip) +if args: + snip.rv += '\n' + snip.mkline('', indent='') + snip += triple_quotes(snip) + +write_init_body(args, t[2], snip) +` + $0 +endsnippet + + +snippet contain "methods for emulating a container type" b +def __len__(self): + ${1:pass} + +def __getitem__(self, key): + ${2:pass} + +def __setitem__(self, key, value): + ${3:pass} + +def __delitem__(self, key): + ${4:pass} + +def __iter__(self): + ${5:pass} + +def __reversed__(self): + ${6:pass} + +def __contains__(self, item): + ${7:pass} +endsnippet + + +snippet context "context manager methods" b +def __enter__(self): + ${1:pass} + +def __exit__(self, exc_type, exc_value, traceback): + ${2:pass} +endsnippet + + +snippet attr "methods for customizing attribute access" b +def __getattr__(self, name): + ${1:pass} + +def __setattr__(self, name, value): + ${2:pass} + +def __delattr__(self, name): + ${3:pass} +endsnippet + + +snippet desc "methods implementing descriptors" b +def __get__(self, instance, owner): + ${1:pass} + +def __set__(self, instance, value): + ${2:pass} + +def __delete__(self, instance): + ${3:pass} +endsnippet + + +snippet cmp "methods implementing rich comparison" +def __eq__(self, other): + ${1:pass} + +def __ne__(self, other): + ${2:pass} + +def __lt__(self, other): + ${3:pass} + +def __le__(self, other): + ${4:pass} + +def __gt__(self, other): + ${5:pass} + +def __ge__(self, other): + ${6:pass} + +def __cmp__(self, other): + ${7:pass} +endsnippet + + +snippet repr "methods implementing string representation" +def __repr__(self): + ${1:pass} + +def __str__(self): + ${2:pass} + +def __unicode__(self): + ${3:pass} +endsnippet + + +# note: reflected operands and augmented arithmeitc assignements have been +# intentionally ommited to reduce verbosity. +snippet numeric "methods for emulating a numeric type" b +def __add__(self, other): + ${1:pass} + +def __sub__(self, other): + ${2:pass} + +def __mul__(self, other): + ${3:pass} + +def __div__(self, other): + ${4:pass} + +def __truediv__(self, other): + ${5:pass} + +def __floordiv__(self, other): + ${6:pass} + + +def __mod__(self, other): + ${7:pass} + +def __divmod__(self, other): + ${8:pass} + +def __pow__(self, other): + ${9:pass} + + +def __lshift__(self, other): + ${10:pass} + +def __rshift__(self, other): + ${11:pass} + +def __and__(self, other): + ${12:pass} + +def __xor__(self, other): + ${13:pass} + +def __or__(self, other): + ${14:pass} + + +def __neg__(self): + ${15:pass} + +def __pos__(self): + ${16:pass} + +def __abs__(self): + ${17:pass} + +def __invert__(self): + ${18:pass} + + +def __complex__(self): + ${19:pass} + +def __int__(self): + ${20:pass} + +def __long__(self): + ${21:pass} + +def __float__(self): + ${22:pass} + + +def __oct__(self): + ${22:pass} + +def __hex__(self): + ${23:pass} + + +def __index__(self): + ${24:pass} + +def __coerce__(self, other): + ${25:pass} +endsnippet + +snippet deff +def ${1:fname}(`!p snip.rv = vim.eval('indent(".") ? "self" : ""')`$2): + $0 +endsnippet + +snippet def "function with docstrings" b +def ${1:function}(`!p +if snip.indent: + snip.rv = 'self' + (", " if len(t[2]) else "")`${2:arg1}): + `!p snip.rv = triple_quotes(snip)`${4:TODO: Docstring for $1.}`!p +write_function_docstring(t, snip) ` + ${5:${VISUAL:pass}} +endsnippet + + +snippet defc "class method with docstrings" b +@classmethod +def ${1:function}(`!p +if snip.indent: + snip.rv = 'cls' + (", " if len(t[2]) else "")`${2:arg1}): + `!p snip.rv = triple_quotes(snip)`${4:TODO: Docstring for $1.}`!p +write_function_docstring(t, snip) ` + ${5:${VISUAL:pass}} +endsnippet + + +snippet defs "static method with docstrings" b +@staticmethod +def ${1:function}(${2:arg1}): + `!p snip.rv = triple_quotes(snip)`${4:TODO: Docstring for $1.}`!p +write_function_docstring(t, snip) ` + ${5:${VISUAL:pass}} +endsnippet + + +# doesn't expand when there is a word in front +snippet /(^|(?<=\W))\./ "self." r +self. +endsnippet + +snippet from "from module import name" b +from ${1:module} import ${2:Stuff} +endsnippet + + +############## +# PROPERTIES # +############## +snippet roprop "Read Only Property" b +@property +def ${1:name}(self): + ${2:return self._$1}$0 +endsnippet + +snippet rwprop "Read write property" b +def ${1:name}(): + `!p snip.rv = triple_quotes(snip) if t[2] else '' +`${2:TODO: Docstring for $1.}`!p +if t[2]: + snip >> 1 + + style = get_style(snip) + snip.rv += '\n' + snip.mkline('', indent='') + snip += format_return(style) + snip.rv += '\n' + snip.mkline('', indent='') + snip += triple_quotes(snip) +else: + snip.rv = ""` + def fget(self): + return self._$1$0 + + def fset(self, value): + self._$1 = value + return locals() + +$1 = property(**$1(), doc=$1.__doc__) +endsnippet + + +#################### +# If / Else / Elif # +#################### +snippet if "If" b +if ${1:condition}: + ${2:${VISUAL:pass}} +endsnippet + +snippet ife "If / Else" b +if ${1:condition}: + ${2:${VISUAL:pass}} +else: + ${3:pass} +endsnippet + +snippet ifee "If / Elif / Else" b +if ${1:condition}: + ${2:${VISUAL:pass}} +elif ${3:condition}: + ${4:pass} +else: + ${5:pass} +endsnippet + + +########################## +# Try / Except / Finally # +########################## +snippet try "Try / Except" b +try: + ${1:${VISUAL:pass}} +except ${2:Exception} as ${3:e}: + ${4:raise $3} +endsnippet + +snippet trye "Try / Except / Else" b +try: + ${1:${VISUAL:pass}} +except ${2:Exception} as ${3:e}: + ${4:raise $3} +else: + ${5:pass} +endsnippet + +snippet tryf "Try / Except / Finally" b +try: + ${1:${VISUAL:pass}} +except ${2:Exception} as ${3:e}: + ${4:raise $3} +finally: + ${5:pass} +endsnippet + +snippet tryef "Try / Except / Else / Finally" b +try: + ${1:${VISUAL:pass}} +except${2: ${3:Exception} as ${4:e}}: + ${5:raise} +else: + ${6:pass} +finally: + ${7:pass} +endsnippet + + +###################### +# Assertions & Tests # +###################### + +snippet ae "Assert equal" b +self.assertEqual(${1:${VISUAL:first}},${2:second}) +endsnippet + +snippet at "Assert True" b +self.assertTrue(${1:${VISUAL:expression}}) +endsnippet + +snippet af "Assert False" b +self.assertFalse(${1:${VISUAL:expression}}) +endsnippet + +snippet aae "Assert almost equal" b +self.assertAlmostEqual(${1:${VISUAL:first}},${2:second}) +endsnippet + +snippet ar "Assert raises" b +self.assertRaises(${1:exception}, ${2:${VISUAL:func}}${3/.+/, /}${3:arguments}) +endsnippet + +snippet an "Assert is None" b +self.assertIsNone(${1:${VISUAL:expression}}) +endsnippet + +snippet ann "Assert is not None" b +self.assertIsNotNone(${1:${VISUAL:expression}}) +endsnippet + +snippet testcase "pyunit testcase" b +class Test${1:Class}(${2:unittest.TestCase}): + + `!p snip.rv = triple_quotes(snip)`${3:Test case docstring.}`!p snip.rv = triple_quotes(snip)` + + def setUp(self): + ${4:pass} + + def tearDown(self): + ${5:pass} + + def test_${6:name}(self): + ${7:${VISUAL:pass}} +endsnippet + +snippet " "triple quoted string (double quotes)" b +""" +${1:${VISUAL:doc}} +`!p triple_quotes_handle_trailing(snip, '"')` +endsnippet + +snippet ' "triple quoted string (single quotes)" b +''' +${1:${VISUAL:doc}} +`!p triple_quotes_handle_trailing(snip, "'")` +endsnippet + +snippet doc "doc block (triple quotes)" +`!p snip.rv = triple_quotes(snip)` +${1:${VISUAL:doc}} +`!p snip.rv = triple_quotes(snip)` +endsnippet + +snippet pmdoc "pocoo style module doc string" b +# -*- coding: utf-8 -*- +""" + `!p snip.rv = get_dir_and_file_name(snip)` + `!p snip.rv = '~' * len(get_dir_and_file_name(snip))` + + ${1:DESCRIPTION} + + :copyright: (c) `date +%Y` by ${2:YOUR_NAME}. + :license: ${3:LICENSE_NAME}, see LICENSE for more details. +""" +$0 +endsnippet + +# vim:ft=snippets: diff --git a/nvim/.config/nvim/UltiSnips/r.snippets b/nvim/.config/nvim/UltiSnips/r.snippets @@ -0,0 +1,190 @@ +priority -20 + +global !p +import os +from vimsnippets import complete + +FIELD_TYPES = [ +'character', +'data.frame', +'integer', +'list', +'logical', +'matrix', +'numeric', +'vector'] +endglobal + +snippet #! "Hashbang for Rscript (#!)" b +#!/usr/bin/env Rscript +endsnippet + +snippet setwd "Set workingdir" b +setwd("${1:`!p snip.rv = os.getcwd()`}") +endsnippet + +snippet as "Apply type on variable" w +as.$1`!p snip.rv = complete(t[1], FIELD_TYPES)`($2${VISUAL}) +endsnippet + +snippet is "Test type on variable" w +is.$1`!p snip.rv = complete(t[1], FIELD_TYPES)`($2${VISUAL}) +endsnippet + +snippet dl "Download and install a package" b +download.file("${1:${VISUAL:url to package}}", destfile = "${2:${1/.*\/(\S*)$/(?1:$1)/ga}}") +install.packages("$2", type = "source", repos = NULL) +library("${3:${2/^(\w+)_.*$/(?1:$1)/ga}}") +endsnippet + +snippet lib "Import a library" +library('${0:${VISUAL:package}}') +endsnippet + +snippet req "Require a file" +require('${0:${VISUAL:package}}') +endsnippet + +snippet source "Source a file" +source('${0:${VISUAL:file}}') +endsnippet + +snippet if "If statement" +if ($1) { + ${0:${VISUAL}} +} +endsnippet + +snippet eif "Else-If statement" +else if ($1) { + ${0:${VISUAL}} +} +endsnippet + +snippet el "Else statement" +else { + ${0:${VISUAL}} +} +endsnippet + +snippet ife "if .. else" +if ($1) { + ${2:${VISUAL}} +} else { + $0 +} +endsnippet + +snippet wh "while loop" +while($1) { + ${0:${VISUAL}} +} +endsnippet + +snippet for "for loop" +for (${1:item} in ${2:list}) { + ${0:${VISUAL}} +} +endsnippet + +snippet fun "Function definition" +${1:name} <- function ($2) { + ${0:${VISUAL}} +} +endsnippet + +snippet ret "Return call" +return(${0:${VISUAL}}) +endsnippet + +snippet df "Data frame" +${1:name}[${2:rows}, ${0:cols}] +endsnippet + +snippet c "c function" +c(${0:${VISUAL:items}}) +endsnippet + +snippet li "list function" +list(${0:${VISUAL:items}}) +endsnippet + +snippet mat "matrix function" +matrix(${1:${VISUAL:data}}, nrow = ${2:rows}, ncol = ${0:cols}) +endsnippet + +snippet apply "apply function" +apply(${1:${VISUAL:array}}, ${2:margin}, ${0:function}) +endsnippet + +snippet lapply "lapply function" +lapply(${1:${VISUAL:list}}, ${0:function}) +endsnippet + +snippet sapply "sapply function" +sapply(${1:${VISUAL:list}}, ${0:function}) +endsnippet + +snippet vapply "vapply function" +vapply(${1:${VISUAL:list}}, ${2:function}, ${0:type}) +endsnippet + +snippet mapply "mapply function" +mapply(${1:${VISUAL:function}}, ${0:...}) +endsnippet + +snippet tapply "tapply function" +tapply(${1:${VISUAL:vector}}, ${2:index}, ${0:function}) +endsnippet + +snippet rapply "rapply function" +rapply(${1:${VISUAL:list}}, ${0:function}) +endsnippet + +snippet pl "Plot function" +plot(${1:${VISUAL:x}}, ${0:y}) +endsnippet + +snippet ggp "ggplot2 plot" +ggplot(${1:${VISUAL:data}}, aes(${0:aesthetics})) +endsnippet + +snippet fis "Fisher test" +fisher.test(${1:x}, ${0:y}) +endsnippet + +snippet chi "Chi Squared test" +chisq.test(${1:x}, ${0:y}) +endsnippet + +snippet tt "t-test" +t.test(${1:x}, ${0:y}) +endsnippet + +snippet wil "Wilcox test" +wilcox.test(${1:x}, ${0:y}) +endsnippet + +snippet cor "Correlation test" +cor.test(${1:x}, ${0:y}) +endsnippet + +snippet fte "FTE test" +var.test(${1:x}, ${0:y}) +endsnippet + +snippet kvt "KV test" +kv.test(${1:x}, ${0:y}) +endsnippet + +################################# +# easily create string vector # +################################# +# Given individual words separated by spaces +# Select words (e.g. shift-v for whole line (such as the line above) +# then press <Tab> then type "vec", press <Tab> again to get this: +# var <- c("#","Given","individual","words","separated","by","spaces") +# var <- c("#","type","out","individual","words","separated","by","spaces") +snippet vec +${1:var} <- c("${0:${VISUAL:/ /","/g}}") +endsnippet diff --git a/nvim/.config/nvim/UltiSnips/rmd.snippets b/nvim/.config/nvim/UltiSnips/rmd.snippets @@ -0,0 +1,11 @@ +extends markdown + +## diferent codeblocks I usually use. +snippet "(bash|perl|python|go|c)" "Language code block" br +\`\`\`{r, engine = '${1:`!p +snip.rv = match.group(1) + `}', eval = ${2:FALSE}} +${3:${VISUAL}} +\`\`\` +$0 +endsnippet diff --git a/nvim/.config/nvim/UltiSnips/sh.snippets b/nvim/.config/nvim/UltiSnips/sh.snippets @@ -0,0 +1,70 @@ +priority -10 + +snippet #! +#!/usr/bin/env bash +endsnippet + +snippet sbash "safe bash options" +#!/usr/bin/env bash +set -euo pipefail +IFS=$'\n\t' +`!p snip.rv ='\n\n' ` +endsnippet + +snippet temp "Tempfile" +${1:TMPFILE}="$(mktemp -t ${3:--suffix=${4:.SUFFIX}} ${2:`!p +snip.rv = re.sub(r'[^a-zA-Z]', '_', snip.fn) or "untitled" +`}.XXXXXX)" +${5:${6/(.+)/trap "/}${6:rm -f '$${1/.*\s//}'}${6/(.+)/" 0 # EXIT\n/}${7/(.+)/trap "/}${7:rm -f '$${1/.*\s//}'; exit 1}${7/(.+)/" 2 # INT\n/}${8/(.+)/trap "/}${8:rm -f '$${1/.*\s//}'; exit 1}${8/(.+)/" 1 15 # HUP TERM\n/}} + +endsnippet + +snippet case "case .. esac (case)" +case ${1:word} in + ${2:pattern} ) + $0;; +esac +endsnippet + +snippet elif "elif .. (elif)" +elif ${2:[[ ${1:condition} ]]}; then + ${0:#statements} +endsnippet + +snippet for "for ... done (for)" +for (( i = 0; i < ${1:10}; i++ )); do + ${0:#statements} +done +endsnippet + +snippet fori "for ... in ... done (fori)" +for ${1:i}${2/.+/ in /}${2:words}; do + ${0:#statements} +done +endsnippet + +snippet here "here document (here)" +<<-${2:'${1:TOKEN}'} + $0 +${1/['"`](.+)['"`]/$1/} +endsnippet + +snippet if "if ... then (if)" +if ${2:[[ ${1:condition} ]]}; then + ${0:#statements} +fi +endsnippet + +snippet until "until ... (done)" +until ${2:[[ ${1:condition} ]]}; do + ${0:#statements} +done +endsnippet + +snippet while "while ... (done)" +while ${2:[[ ${1:condition} ]]}; do + ${0:#statements} +done +endsnippet + +# vim:ft=snippets: diff --git a/nvim/.config/nvim/colors/lucius.vim b/nvim/.config/nvim/colors/lucius.vim @@ -0,0 +1,799 @@ +" ============================================================================ +" Name: Lucius vim color scheme +" Author: Jonathan Filip <jfilip1024@gmail.com> +" Version: 8.1.7 +" ---------------------------------------------------------------------------- +" +" Light and dark color scheme for GUI and 256 color terminal. +" +" There are several options available to customize the color scheme to your +" own tastes. This is particularly useful when you have to work in different +" environments at different times (home, work, day, night, etc). +" +" The GUI and 256 color terminal versions of this color scheme are identical. +" +" You can set up the color scheme by manually setting the options you want or +" by choosing one of the presets defined. These presets are loaded after you +" first source the color scheme file and are all commands that start with +" 'Lucius'. +" +" I have also started to create color schemes for different applications. I +" have been using them for PuTTY, iTerm2, and Visual Studio, but will keep +" adding more as I go along. You can find the files for these on Github: +" +" https://github.com/jonathanfilip/lucius +" +" You can also clone the following repository if you use Pathogen or something +" similar. It holds the vim color scheme in a 'colors' directory: +" +" https://github.com/jonathanfilip/vim-lucius +" +" +" +" Presets: +" +" There are several presets available that will set all the options for you. +" There are screenshots of each preset below: +" +" * LuciusDark (dark default): http://i.imgur.com/LsZbF.png +" * LuciusDarkHighContrast: http://i.imgur.com/e70i9.png +" * LuciusDarkLowContrast: http://i.imgur.com/Hmw8s.png +" * LuciusBlack: http://i.imgur.com/iD4ri.png +" * LuciusBlackHighContrast: http://i.imgur.com/lHvTJ.png +" * LuciusBlackLowContrast: http://i.imgur.com/oZLkg.png +" +" * LuciusLight (light default): http://i.imgur.com/soYD8.png +" * LuciusLightLowContrast: http://i.imgur.com/95I86.png +" * LuciusWhite: http://i.imgur.com/wDzkz.png +" * LuciusWhiteLowContrast: http://i.imgur.com/jlUf4.png +" +" To use the presets, you just need to set the color scheme first. In your +" vimrc, you can just do this: +" +" colorscheme lucius +" LuciusBlack +" +" You can still just set the background variable and then set the color +" scheme. This will default to LuciusDark for 'dark' and LuciusLight for +" 'light'. +" +" +" Options: +" +" The presets available cover most of the options. You can, however, customize +" things by setting the following variables yourself: +" +" g:lucius_style (default: 'dark') +" +" Set this option to either 'light' or 'dark' for your desired color scheme. +" It has the same effect as setting the background. +" +" g:lucius_contrast (default: 'normal') +" +" This option determines the contrast to use for text/ui elements. It can be +" set to 'low', 'normal', or 'high'. At this time there is no 'high' for the +" light scheme. +" +" g:lucius_contrast_bg (default: 'normal') +" +" Setting this option makes the background a higher contrast. Current settings +" are 'normal' and 'high'. +" +" g:lucius_use_bold (default: 1) +" +" Setting this will cause the color scheme to use bold fonts for some items. +" +" g:lucius_use_underline (default: 1) +" +" Setting this will cause the color scheme to use underlined fonts for some +" items. +" +" g:lucius_no_term_bg (default: 0) +" +" Setting this will cause the color scheme to not set a background color in +" the terminal (useful for transparency or terminals with different background +" colors). +" +" License: +" +" Copyright (c) 2015 Jonathan Filip +" +" Permission is hereby granted, free of charge, to any person obtaining a copy +" of this software and associated documentation files (the "Software"), to deal +" in the Software without restriction, including without limitation the rights +" to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +" copies of the Software, and to permit persons to whom the Software is +" furnished to do so, subject to the following conditions: +" +" The above copyright notice and this permission notice shall be included in +" all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +" OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +" THE SOFTWARE. +" +" ============================================================================ + + + +" ============================================================================ +" Options: +" ============================================================================ + +unlet! g:colors_name +hi clear +if exists("syntax_on") + syntax reset +endif + +if exists("g:lucius_style") + let s:style = g:lucius_style +else + let s:style = &background +endif + +if exists("g:lucius_contrast") + let s:contrast = g:lucius_contrast +else + let s:contrast = "normal" +endif + +if exists("g:lucius_contrast_bg") + let s:contrast_bg = g:lucius_contrast_bg +else + let s:contrast_bg = "normal" +endif + +if exists("g:lucius_use_bold") + let s:use_bold = g:lucius_use_bold +else + let s:use_bold = 1 +endif + +if exists("g:lucius_use_underline") + let s:use_underline = g:lucius_use_underline +else + let s:use_underline = 1 +endif + +if exists("g:lucius_no_term_bg") + let s:no_term_bg = g:lucius_no_term_bg +else + let s:no_term_bg = 0 +endif + + +" ============================================================================ +" Color Map: +" ============================================================================ + +let s:color_map = { + \ 'bg': 'bg', 'fg': 'fg', 'NONE': 'NONE', + \ '#000000': '16', '#00005f': '17', '#000087': '18', '#0000af': '19', + \ '#0000d7': '20', '#0000ff': '21', '#005f00': '22', '#005f5f': '23', + \ '#005f87': '24', '#005faf': '25', '#005fd7': '26', '#005fff': '27', + \ '#008700': '28', '#00875f': '29', '#008787': '30', '#0087af': '31', + \ '#0087d7': '32', '#0087ff': '33', '#00af00': '34', '#00af5f': '35', + \ '#00af87': '36', '#00afaf': '37', '#00afd7': '38', '#00afff': '39', + \ '#00d700': '40', '#00d75f': '41', '#00d787': '42', '#00d7af': '43', + \ '#00d7d7': '44', '#00d7ff': '45', '#00ff00': '46', '#00ff5f': '47', + \ '#00ff87': '48', '#00ffaf': '49', '#00ffd7': '50', '#00ffff': '51', + \ '#5f0000': '52', '#5f005f': '53', '#5f0087': '54', '#5f00af': '55', + \ '#5f00d7': '56', '#5f00ff': '57', '#5f5f00': '58', '#5f5f5f': '59', + \ '#5f5f87': '60', '#5f5faf': '61', '#5f5fd7': '62', '#5f5fff': '63', + \ '#5f8700': '64', '#5f875f': '65', '#5f8787': '66', '#5f87af': '67', + \ '#5f87d7': '68', '#5f87ff': '69', '#5faf00': '70', '#5faf5f': '71', + \ '#5faf87': '72', '#5fafaf': '73', '#5fafd7': '74', '#5fafff': '75', + \ '#5fd700': '76', '#5fd75f': '77', '#5fd787': '78', '#5fd7af': '79', + \ '#5fd7d7': '80', '#5fd7ff': '81', '#5fff00': '82', '#5fff5f': '83', + \ '#5fff87': '84', '#5fffaf': '85', '#5fffd7': '86', '#5fffff': '87', + \ '#870000': '88', '#87005f': '89', '#870087': '90', '#8700af': '91', + \ '#8700d7': '92', '#8700ff': '93', '#875f00': '94', '#875f5f': '95', + \ '#875f87': '96', '#875faf': '97', '#875fd7': '98', '#875fff': '99', + \ '#878700': '100', '#87875f': '101', '#878787': '102', '#8787af': '103', + \ '#8787d7': '104', '#8787ff': '105', '#87af00': '106', '#87af5f': '107', + \ '#87af87': '108', '#87afaf': '109', '#87afd7': '110', '#87afff': '111', + \ '#87d700': '112', '#87d75f': '113', '#87d787': '114', '#87d7af': '115', + \ '#87d7d7': '116', '#87d7ff': '117', '#87ff00': '118', '#87ff5f': '119', + \ '#87ff87': '120', '#87ffaf': '121', '#87ffd7': '122', '#87ffff': '123', + \ '#af0000': '124', '#af005f': '125', '#af0087': '126', '#af00af': '127', + \ '#af00d7': '128', '#af00ff': '129', '#af5f00': '130', '#af5f5f': '131', + \ '#af5f87': '132', '#af5faf': '133', '#af5fd7': '134', '#af5fff': '135', + \ '#af8700': '136', '#af875f': '137', '#af8787': '138', '#af87af': '139', + \ '#af87d7': '140', '#af87ff': '141', '#afaf00': '142', '#afaf5f': '143', + \ '#afaf87': '144', '#afafaf': '145', '#afafd7': '146', '#afafff': '147', + \ '#afd700': '148', '#afd75f': '149', '#afd787': '150', '#afd7af': '151', + \ '#afd7d7': '152', '#afd7ff': '153', '#afff00': '154', '#afff5f': '155', + \ '#afff87': '156', '#afffaf': '157', '#afffd7': '158', '#afffff': '159', + \ '#d70000': '160', '#d7005f': '161', '#d70087': '162', '#d700af': '163', + \ '#d700d7': '164', '#d700ff': '165', '#d75f00': '166', '#d75f5f': '167', + \ '#d75f87': '168', '#d75faf': '169', '#d75fd7': '170', '#d75fff': '171', + \ '#d78700': '172', '#d7875f': '173', '#d78787': '174', '#d787af': '175', + \ '#d787d7': '176', '#d787ff': '177', '#d7af00': '178', '#d7af5f': '179', + \ '#d7af87': '180', '#d7afaf': '181', '#d7afd7': '182', '#d7afff': '183', + \ '#d7d700': '184', '#d7d75f': '185', '#d7d787': '186', '#d7d7af': '187', + \ '#d7d7d7': '188', '#d7d7ff': '189', '#d7ff00': '190', '#d7ff5f': '191', + \ '#d7ff87': '192', '#d7ffaf': '193', '#d7ffd7': '194', '#d7ffff': '195', + \ '#ff0000': '196', '#ff005f': '197', '#ff0087': '198', '#ff00af': '199', + \ '#ff00d7': '200', '#ff00ff': '201', '#ff5f00': '202', '#ff5f5f': '203', + \ '#ff5f87': '204', '#ff5faf': '205', '#ff5fd7': '206', '#ff5fff': '207', + \ '#ff8700': '208', '#ff875f': '209', '#ff8787': '210', '#ff87af': '211', + \ '#ff87d7': '212', '#ff87ff': '213', '#ffaf00': '214', '#ffaf5f': '215', + \ '#ffaf87': '216', '#ffafaf': '217', '#ffafd7': '218', '#ffafff': '219', + \ '#ffd700': '220', '#ffd75f': '221', '#ffd787': '222', '#ffd7af': '223', + \ '#ffd7d7': '224', '#ffd7ff': '225', '#ffff00': '226', '#ffff5f': '227', + \ '#ffff87': '228', '#ffffaf': '229', '#ffffd7': '230', '#ffffff': '231', + \ '#080808': '232', '#121212': '233', '#1c1c1c': '234', '#262626': '235', + \ '#303030': '236', '#3a3a3a': '237', '#444444': '238', '#4e4e4e': '239', + \ '#585858': '240', '#626262': '241', '#6c6c6c': '242', '#767676': '243', + \ '#808080': '244', '#8a8a8a': '245', '#949494': '246', '#9e9e9e': '247', + \ '#a8a8a8': '248', '#b2b2b2': '249', '#bcbcbc': '250', '#c6c6c6': '251', + \ '#d0d0d0': '252', '#dadada': '253', '#e4e4e4': '254', '#eeeeee': '255', + \ } + + +" ============================================================================ +" Functions: +" ============================================================================ + +function! s:AddCterm(name) + exec "let l:gfg = synIDattr(synIDtrans(hlID('" . a:name . + \ "')), 'fg', 'gui')" + exec "let l:gbg = synIDattr(synIDtrans(hlID('" . a:name . + \ "')), 'bg', 'gui')" + let l:gfg = l:gfg == "" ? "NONE" : l:gfg + let l:gbg = l:gbg == "" ? "NONE" : l:gbg + exec "hi " . a:name . " ctermfg=" . s:color_map[l:gfg] . + \ " ctermbg=" . s:color_map[l:gbg] +endfunction + +function! s:AddSpCterm(name) + exec "let l:gsp = synIDattr(synIDtrans(hlID('" . a:name . + \ "')), 'sp', 'gui')" + let l:gsp = l:gsp == "" ? "NONE" : l:gsp + exec "hi " . a:name . " ctermfg=" . s:color_map[l:gsp] +endfunction + + +" ============================================================================ +" Text Groups: +" ============================================================================ + +let s:normal_items = [ + \ "ColorColumn", "Comment", "Conceal", "Constant", "Cursor", "CursorColumn", + \ "CursorIM", "CursorLine", "CursorLineNr", "DiffAdd", "DiffChange", + \ "DiffDelete", "Directory", "Error", "ErrorMsg", "Identifier", + \ "IncSearch", "LineNr", "MatchParen", "ModeMsg", "MoreMsg", + \ "NonText", "Pmenu", "PmenuSbar", "PmenuSel", + \ "PmenuThumb", "PreProc", "Question", "Search", "SignColumn", + \ "Special", "SpecialKey", "Statement", "StatusLineNC", "TabLine", + \ "TabLineFill", "Todo", "Type", "VertSplit", "Visual", + \ "WarningMsg", "WildMenu", + \ ] + +let s:bold_items = [ + \ "DiffText", "FoldColumn", "Folded", "StatusLine", "TabLineSel", + \ "Title", "CursorLineNr", + \ ] + +let s:underline_items = [ + \ "Underlined", "VisualNOS" + \ ] + +let s:undercurl_items = [ + \ "SpellBad", "SpellCap", "SpellLocal", "SpellRare" + \ ] + + +" ============================================================================ +" Color Definitions: +" ============================================================================ + +" ---------------------------------------------------------------------------- +" 'Normal' Colors: +" ---------------------------------------------------------------------------- + +hi clear Normal +hi Normal gui=none cterm=none term=none + +if s:style == "light" + if s:contrast == "high" + hi Normal guifg=#000000 + elseif s:contrast == "low" + hi Normal guifg=#626262 + else + hi Normal guifg=#444444 + endif +else + if s:contrast == "high" + hi Normal guifg=#eeeeee + elseif s:contrast == "low" + hi Normal guifg=#bcbcbc + else + hi Normal guifg=#d7d7d7 + endif +endif + +if s:style == "light" + if s:contrast_bg == "high" + hi Normal guibg=#ffffff + else + hi Normal guibg=#eeeeee + endif +else + if s:contrast_bg == "high" + hi Normal guibg=#121212 + else + hi Normal guibg=#303030 + endif +endif + +call s:AddCterm("Normal") + + +" ---------------------------------------------------------------------------- +" Extra setup +" ---------------------------------------------------------------------------- + +exec "set background=" . s:style + +" Clear default settings +for s:item in s:normal_items + s:bold_items + s:underline_items + s:undercurl_items + exec "hi " . s:item . " guifg=NONE guibg=NONE gui=none" + \ . " ctermfg=NONE ctermbg=NONE cterm=none term=none" +endfor + +let g:colors_name="lucius" + + +" ---------------------------------------------------------------------------- +" Text Markup: +" ---------------------------------------------------------------------------- + +if s:style == "light" + hi NonText guifg=#afafd7 + hi SpecialKey guifg=#afd7af + if s:contrast == "low" + hi Comment guifg=#9e9e9e + hi Conceal guifg=#9e9e9e + hi Constant guifg=#d78700 + hi Directory guifg=#00af87 + hi Identifier guifg=#00af00 + hi PreProc guifg=#00afaf + hi Special guifg=#af00af + hi Statement guifg=#0087d7 + hi Title guifg=#0087d7 + hi Type guifg=#0087af + else + hi Comment guifg=#808080 + hi Conceal guifg=#808080 + hi Constant guifg=#af5f00 + hi Directory guifg=#00875f + hi Identifier guifg=#008700 + hi PreProc guifg=#008787 + hi Special guifg=#870087 + hi Statement guifg=#005faf + hi Title guifg=#005faf + hi Type guifg=#005f87 + endif +else + hi NonText guifg=#5f5f87 + hi SpecialKey guifg=#5f875f + if s:contrast == "low" + hi Comment guifg=#6c6c6c + hi Conceal guifg=#6c6c6c + hi Constant guifg=#afaf87 + " hi Constant guifg=#afd787 + hi Directory guifg=#87af87 + hi Identifier guifg=#87af5f + hi PreProc guifg=#5faf87 + hi Special guifg=#af87af + hi Statement guifg=#5fafd7 + hi Title guifg=#00afd7 + hi Type guifg=#5fafaf + " hi Number guifg=#8787d7 + " hi String guifg=#5f8700 + elseif s:contrast == "high" + hi Comment guifg=#8a8a8a + hi Conceal guifg=#8a8a8a + hi Constant guifg=#ffffd7 + hi Directory guifg=#d7ffd7 + hi Identifier guifg=#d7ffaf + hi PreProc guifg=#afffd7 + hi Special guifg=#ffd7ff + hi Statement guifg=#afffff + hi Title guifg=#87d7ff + hi Type guifg=#afffff + else + hi Comment guifg=#808080 + hi Conceal guifg=#808080 + hi Constant guifg=#d7d7af + hi Directory guifg=#afd7af + hi Identifier guifg=#afd787 + hi PreProc guifg=#87d7af + hi Special guifg=#d7afd7 + hi Statement guifg=#87d7ff + hi Title guifg=#5fafd7 + hi Type guifg=#87d7d7 + endif +endif + + +" ---------------------------------------------------------------------------- +" Highlighting: +" ---------------------------------------------------------------------------- + +hi Cursor guifg=bg +hi CursorColumn guifg=NONE +hi CursorIM guifg=bg +hi CursorLine guifg=NONE +hi Visual guifg=NONE +hi VisualNOS guifg=fg guibg=NONE +if s:style == "light" + hi CursorColumn guibg=#dadada + hi CursorLine guibg=#dadada + hi IncSearch guifg=fg guibg=#5fd7d7 + hi MatchParen guifg=NONE guibg=#5fd7d7 + hi Search guifg=fg guibg=#ffaf00 + hi Visual guibg=#afd7ff + if s:contrast == "low" + hi Cursor guibg=#87afd7 + hi CursorIM guibg=#87afd7 + hi Error guifg=#d70000 guibg=#ffd7d7 + hi Todo guifg=#af8700 guibg=#ffffaf + else + hi Cursor guibg=#5f87af + hi CursorIM guibg=#5f87af + hi Error guifg=#af0000 guibg=#d7afaf + hi Todo guifg=#875f00 guibg=#ffffaf + endif +else + hi CursorColumn guibg=#444444 + hi CursorLine guibg=#444444 + hi IncSearch guifg=bg + hi MatchParen guifg=fg guibg=#87af00 + hi Search guifg=bg + hi Visual guibg=#005f87 + if s:contrast == "low" + hi Cursor guibg=#5f87af + hi CursorIM guibg=#5f87af + hi Error guifg=#d75f5f guibg=#870000 + hi IncSearch guibg=#00afaf + hi Search guibg=#d78700 + hi Todo guifg=#afaf00 guibg=#5f5f00 + elseif s:contrast == "high" + hi Cursor guibg=#afd7ff + hi CursorIM guibg=#afd7ff + hi Error guifg=#ffafaf guibg=#af0000 + hi IncSearch guibg=#87ffff + hi Search guibg=#ffaf5f + hi Todo guifg=#ffff87 guibg=#87875f + else + hi Cursor guibg=#87afd7 + hi CursorIM guibg=#87afd7 + hi Error guifg=#ff8787 guibg=#870000 + hi IncSearch guibg=#5fd7d7 + hi Search guibg=#d78700 + hi Todo guifg=#d7d75f guibg=#5f5f00 + endif +endif + + +" ---------------------------------------------------------------------------- +" Messages: +" ---------------------------------------------------------------------------- + +hi Question guifg=fg +if s:style == "light" + if s:contrast == "low" + hi ErrorMsg guifg=#d70000 + hi ModeMsg guifg=#0087ff + hi MoreMsg guifg=#0087ff + hi WarningMsg guifg=#d78700 + else + hi ErrorMsg guifg=#af0000 + hi ModeMsg guifg=#005faf + hi MoreMsg guifg=#005faf + hi WarningMsg guifg=#af5f00 + endif +else + if s:contrast == "low" + hi ErrorMsg guifg=#d75f5f + hi ModeMsg guifg=#87afaf + hi MoreMsg guifg=#87afaf + hi WarningMsg guifg=#af875f + elseif s:contrast == "high" + hi ErrorMsg guifg=#ff8787 + hi ModeMsg guifg=#afffff + hi MoreMsg guifg=#afffff + hi WarningMsg guifg=#ffaf87 + else + hi ErrorMsg guifg=#ff5f5f + hi ModeMsg guifg=#afd7d7 + hi MoreMsg guifg=#afd7d7 + hi WarningMsg guifg=#d7875f + endif +endif + + +" ---------------------------------------------------------------------------- +" UI: +" ---------------------------------------------------------------------------- + +hi ColorColumn guifg=NONE +hi Pmenu guifg=bg +hi PmenuSel guifg=fg +hi PmenuThumb guifg=fg +hi StatusLine guifg=bg +hi TabLine guifg=bg +hi TabLineSel guifg=fg +hi WildMenu guifg=fg +if s:style == "light" + hi ColorColumn guibg=#e4e4e4 + hi CursorLineNr guifg=#626262 guibg=#dadada + hi FoldColumn guibg=#bcbcbc + hi Folded guibg=#bcbcbc + hi LineNr guifg=#9e9e9e guibg=#dadada + hi PmenuSel guibg=#afd7ff + hi SignColumn guibg=#d0d0d0 + hi StatusLineNC guifg=#dadada + hi TabLineFill guifg=#dadada + hi VertSplit guifg=#e4e4e4 + hi WildMenu guibg=#afd7ff + if s:contrast == "low" + hi FoldColumn guifg=#808080 + hi Folded guifg=#808080 + hi Pmenu guibg=#9e9e9e + hi PmenuSbar guifg=#9e9e9e guibg=#626262 + hi PmenuThumb guibg=#9e9e9e + hi SignColumn guifg=#808080 + hi StatusLine guibg=#9e9e9e + hi StatusLineNC guibg=#9e9e9e + hi TabLine guibg=#9e9e9e + hi TabLineFill guibg=#9e9e9e + hi TabLineSel guibg=#afd7ff + hi VertSplit guibg=#9e9e9e + else + hi FoldColumn guifg=#626262 + hi Folded guifg=#626262 + hi Pmenu guibg=#808080 + hi PmenuSbar guifg=#808080 guibg=#444444 + hi PmenuThumb guibg=#9e9e9e + hi SignColumn guifg=#626262 + hi StatusLine guibg=#808080 + hi StatusLineNC guibg=#808080 + hi TabLine guibg=#808080 + hi TabLineFill guibg=#808080 + hi TabLineSel guibg=#afd7ff + hi VertSplit guibg=#808080 + endif +else + hi ColorColumn guibg=#3a3a3a + hi CursorLineNr guifg=#9e9e9e guibg=#444444 + hi FoldColumn guibg=#4e4e4e + hi Folded guibg=#4e4e4e + hi LineNr guifg=#626262 guibg=#444444 + hi PmenuSel guibg=#005f87 + hi SignColumn guibg=#4e4e4e + hi StatusLineNC guifg=#4e4e4e + hi TabLineFill guifg=#4e4e4e + hi VertSplit guifg=#626262 + hi WildMenu guibg=#005f87 + if s:contrast == "low" + hi FoldColumn guifg=#a8a8a8 + hi Folded guifg=#a8a8a8 + hi Pmenu guibg=#8a8a8a + hi PmenuSbar guifg=#8a8a8a guibg=#bcbcbc + hi PmenuThumb guibg=#585858 + hi SignColumn guifg=#8a8a8a + hi StatusLine guibg=#8a8a8a + hi StatusLineNC guibg=#8a8a8a + hi TabLine guibg=#8a8a8a + hi TabLineFill guibg=#8a8a8a + hi TabLineSel guibg=#005f87 + hi VertSplit guibg=#8a8a8a + elseif s:contrast == "high" + hi FoldColumn guifg=#c6c6c6 + hi Folded guifg=#c6c6c6 + hi Pmenu guibg=#bcbcbc + hi PmenuSbar guifg=#bcbcbc guibg=#dadada + hi PmenuThumb guibg=#8a8a8a + hi SignColumn guifg=#bcbcbc + hi StatusLine guibg=#bcbcbc + hi StatusLineNC guibg=#bcbcbc + hi TabLine guibg=#bcbcbc + hi TabLineFill guibg=#bcbcbc + hi TabLineSel guibg=#0087af + hi VertSplit guibg=#bcbcbc + else + hi FoldColumn guifg=#bcbcbc + hi Folded guifg=#bcbcbc + hi Pmenu guibg=#b2b2b2 + hi PmenuSbar guifg=#b2b2b2 guibg=#d0d0d0 + hi PmenuThumb guibg=#808080 + hi SignColumn guifg=#b2b2b2 + hi StatusLine guibg=#b2b2b2 + hi StatusLineNC guibg=#b2b2b2 + hi TabLine guibg=#b2b2b2 + hi TabLineFill guibg=#b2b2b2 + hi TabLineSel guibg=#005f87 + hi VertSplit guibg=#b2b2b2 + endif +endif + + +" ---------------------------------------------------------------------------- +" Diff: +" ---------------------------------------------------------------------------- + +hi DiffAdd guifg=fg +hi DiffChange guifg=fg +hi DiffDelete guifg=fg + +if s:style == "light" + hi DiffAdd guibg=#afd7af + hi DiffChange guibg=#d7d7af + hi DiffDelete guibg=#d7afaf + hi DiffText guibg=#d7d7af + if s:contrast == "low" + hi DiffText guifg=#ff8700 + else + hi DiffText guifg=#d75f00 + endif +else + hi DiffAdd guibg=#5f875f + hi DiffChange guibg=#87875f + hi DiffDelete guibg=#875f5f + hi DiffText guibg=#87875f + if s:contrast == "low" + hi DiffText guifg=#d7d75f + else + hi DiffText guifg=#ffff87 + endif +endif + + +" ---------------------------------------------------------------------------- +" Spelling: +" ---------------------------------------------------------------------------- + +if s:style == "light" + hi SpellBad guisp=#d70000 + hi SpellCap guisp=#00afd7 + hi SpellLocal guisp=#d7af00 + hi SpellRare guisp=#5faf00 +else + hi SpellBad guisp=#ff5f5f + hi SpellCap guisp=#5fafd7 + hi SpellLocal guisp=#d7af5f + hi SpellRare guisp=#5faf5f +endif + + +" ---------------------------------------------------------------------------- +" Miscellaneous: +" ---------------------------------------------------------------------------- + +hi Ignore guifg=bg +hi Underlined guifg=fg + + +" ============================================================================ +" Text Emphasis: +" ============================================================================ + +if s:use_bold == 1 + for s:item in s:bold_items + exec "hi " . s:item . " gui=bold cterm=bold term=none" + endfor +endif + +if s:use_underline == 1 + for s:item in s:underline_items + exec "hi " . s:item . " gui=underline cterm=underline term=none" + endfor + for s:item in s:undercurl_items + exec "hi " . s:item . " cterm=underline" + endfor +endif + +for s:item in s:undercurl_items + exec "hi " . s:item . " gui=undercurl term=none" +endfor + + +" ============================================================================ +" Cterm Colors: +" ============================================================================ + +for s:item in s:normal_items + s:bold_items + s:underline_items + call s:AddCterm(s:item) +endfor + +for s:item in s:undercurl_items + call s:AddSpCterm(s:item) +endfor + +if s:no_term_bg == 1 + hi Normal ctermbg=NONE +endif + + +" ============================================================================ +" Alternative Bold Definitions: +" ============================================================================ + +let s:alternative_bold_items = ["Identifier", "PreProc", "Statement", + \ "Special", "Constant", "Type"] + +for s:item in s:alternative_bold_items + exec "let s:temp_gui_fg = synIDattr(synIDtrans(hlID('" . s:item . + \ "')), 'fg', 'gui')" + exec "let s:temp_cterm_fg = synIDattr(synIDtrans(hlID('" . s:item . + \ "')), 'fg', 'cterm')" + exec "hi B" . s:item . " guifg=" . s:temp_gui_fg . " ctermfg=" . + \ s:temp_cterm_fg . " gui=bold cterm=bold term=none" +endfor + + +" ============================================================================ +" Plugin Specific Colors: +" ============================================================================ + +" Tagbar: +hi link TagbarAccessPublic Constant +hi link TagbarAccessProtected Type +hi link TagbarAccessPrivate PreProc + +" Vimwiki: +hi link VimwikiHeader1 BIdentifier +hi link VimwikiHeader2 BPreProc +hi link VimwikiHeader3 BStatement +hi link VimwikiHeader4 BSpecial +hi link VimwikiHeader5 BConstant +hi link VimwikiHeader6 BType + + +" ============================================================================ +" Preset Commands: +" ============================================================================ + +function! SetLucius(style, contrast, contrast_bg) + let g:lucius_style = a:style + let g:lucius_contrast = a:contrast + let g:lucius_contrast_bg = a:contrast_bg +endfunction + +command! LuciusLight call SetLucius("light", "normal", "normal") + \ | colorscheme lucius +command! LuciusLightLowContrast call SetLucius("light", "low", "normal") + \ | colorscheme lucius +command! LuciusLightHighContrast call SetLucius("light", "high", "normal") + \ | colorscheme lucius + +command! LuciusWhite call SetLucius("light", "normal", "high") + \ | colorscheme lucius +command! LuciusWhiteLowContrast call SetLucius("light", "low", "high") + \ | colorscheme lucius +command! LuciusWhiteHighContrast call SetLucius("light", "high", "high") + \ | colorscheme lucius + +command! LuciusDark call SetLucius("dark", "normal", "normal") + \ | colorscheme lucius +command! LuciusDarkLowContrast call SetLucius("dark", "low", "normal") + \ | colorscheme lucius +command! LuciusDarkHighContrast call SetLucius("dark", "high", "normal") + \ | colorscheme lucius + +command! LuciusBlack call SetLucius("dark", "normal", "high") + \ | colorscheme lucius +command! LuciusBlackLowContrast call SetLucius("dark", "low", "high") + \ | colorscheme lucius +command! LuciusBlackHighContrast call SetLucius("dark", "high", "high") + \ | colorscheme lucius + +" vim: tw=78 diff --git a/nvim/.config/nvim/init.vim b/nvim/.config/nvim/init.vim @@ -0,0 +1,150 @@ +" Basic config +set shiftwidth=4 " Number of spaces to use for each step of (auto)indent +set tabstop=4 " Number of spaces that a <Tab> in the file counts for +set softtabstop=4 " Number of spaces that a <Tab> counts for while performing editing +set expandtab " use spaces instead of tabs +set scrolloff=2 " show 2 lines before/after cursor always +set number +set relativenumber +set cursorline +set cursorcolumn +set ignorecase +set smartcase " don't use ignorecase when we search for a cased pattern +set noshowcmd " we have airline, more info than needed +set noshowmode " showmode disabled because of lightline plugin +set hidden " avoiding annoying messages (no write since last change) +set splitright " split windows on the right ! +set list " mark non-printable chars as per above instructions +set listchars=tab:▸\ ,trail:·,precedes:«,extends:»,nbsp:+ +set wildmode=longest,list:longest " command completion works as I want +set foldmethod=syntax +set updatetime=1000 + +" appearance +color lucius +LuciusBlackLowContrast + +" per buffer/filetype configs +autocmd BufNewFile,BufRead Rexfile setfiletype perl +autocmd FileType make setlocal ts=8 sts=8 sw=8 noexpandtab +autocmd FileType yaml setlocal ts=2 sts=2 sw=2 +autocmd FileType openscad setlocal ts=2 sts=2 sw=2 +autocmd BufNewFile,BufRead *.txt set tw=79 wrap lbr formatprg=par\ -w79req +autocmd BufReadPost *mutt-* set syntax=mail tw=72 wrap lbr formatprg=par\ -w72req +autocmd BufNewFile *.sh 0r $HOME/.config/nvim/templates/template.sh +" perltidy and template +autocmd Filetype perl nnoremap <silent> <Leader>t :mark t <bar> execute'%!perltidy' <bar> execute 'normal! `t' <bar> delmarks t<CR> +autocmd Filetype perl vnoremap <silent> <Leader>t :!perltidy<CR> +autocmd BufNewFile *.pl 0r $HOME/.config/nvim/templates/template.pl +" same for c +autocmd Filetype c,cpp,arduino nnoremap <silent> <Leader>t :mark t <bar> execute'%!astyle' <bar> execute 'normal! `t' <bar> delmarks t<CR> +autocmd Filetype c,cpp,arduino vnoremap <buffer> <Leader>t :!astyle<CR> +autocmd BufNewFile *.c 0r $HOME/.config/nvim/templates/template.c +" and for go ... +autocmd Filetype go nnoremap <buffer> <Leader>t :GoFmt<CR> +autocmd Filetype go vnoremap <buffer> <Leader>t :GoFmt<CR> +autocmd FileType go nmap <leader>b <Plug>(go-build) +autocmd FileType go nmap <leader>r <Plug>(go-run) +autocmd FileType go nmap <leader>i <Plug>(go-info) +autocmd BufNewFile *.go 0r $HOME/.config/nvim/templates/template.go +" and for python +autocmd FileType python nnoremap <silent> <Leader>i :!isort %<CR><CR> +autocmd FileType python nnoremap <silent> <Leader>t :mark t <bar> execute'%!yapf' <bar> execute 'normal! `t' <bar> delmarks t<CR> +autocmd Filetype python vnoremap <silent> <Leader>t :!yapf<CR> +autocmd FileType python setlocal textwidth=79 shiftround +autocmd BufNewFile *.py 0r $HOME/.config/nvim/templates/template.py + +" some useful mappings +" space bar un-highlights search +noremap <silent> <Space> :silent noh<Bar>echo<CR> +" better behaviour of > in visual mode +vnoremap > >gv +vnoremap < <gv +" search with true regexp, not vim's ... +nnoremap / /\v +vnoremap / /\v +" go fast to home end of line +inoremap <C-e> <C-o>$ +inoremap <C-a> <C-o>0 +" char forward back in insert mode (useful for auto-close) +inoremap <C-f> <C-o>a +inoremap <C-b> <C-o>h +" copy and paste from system easily +if has("mac") + nnoremap cp "*p + vnoremap cy "*y +else + nnoremap cp "+p + vnoremap cy "+y +endif +" \b calls make +nnoremap <leader>b :make<CR> +" sanity in terminal mode +tnoremap <Esc> <C-\><C-n> +tnoremap <C-v><Esc> <Esc> + +" plugins config +" FZF +nnoremap <C-p> :Files<CR> +nnoremap <C-b> :Buffers<CR> +" ALE +let g:ale_linters = { +\ 'perl': ['perl'], +\} +let g:ale_sign_column_always = 1 +let g:airline#extensions#ale#enabled = 1 +nmap <silent> [W <Plug>(ale_first) +nmap <silent> [w <Plug>(ale_previous) +nmap <silent> ]w <Plug>(ale_next) +nmap <silent> ]W <Plug>(ale_last) +" airline +let g:airline#extensions#tabline#enabled = 1 +let g:airline#extensions#tabline#tab_nr_type = 2 +let g:airline#extensions#tabline#buffer_idx_mode = 1 +let g:airline#extensions#tabline#formatter = 'unique_tail_improved' +let g:airline#extensions#tabline#show_close_button = 0 +let g:airline#extensions#branch#enabled = 1 +let g:airline#extensions#virtualenv#enabled = 1 +let g:airline_powerline_fonts = 1 +nmap <leader>1 <Plug>AirlineSelectTab1 +nmap <leader>2 <Plug>AirlineSelectTab2 +nmap <leader>3 <Plug>AirlineSelectTab3 +nmap <leader>4 <Plug>AirlineSelectTab4 +nmap <leader>5 <Plug>AirlineSelectTab5 +nmap <leader>6 <Plug>AirlineSelectTab6 +nmap <leader>7 <Plug>AirlineSelectTab7 +nmap <leader>8 <Plug>AirlineSelectTab8 +nmap <leader>9 <Plug>AirlineSelectTab9 +nmap <leader>[ <Plug>AirlineSelectPrevTab +nmap <leader>] <Plug>AirlineSelectNextTab +" Nerdcommenter +let g:NERDSpaceDelims = 1 +let g:NERDDefaultAlign = 'left' +let g:NERDCommentEmptyLines = 1 +let g:NERDTrimTrailingWhitespace = 1 +let g:NERDCompactSexyComs = 1 +" vim-go +let g:go_highlight_functions = 1 +let g:go_highlight_methods = 1 +let g:go_highlight_fields = 1 +let g:go_highlight_types = 1 +let g:go_highlight_operators = 1 +let g:go_highlight_build_constraints = 1 +let g:go_highlight_extra_types = 1 +let g:go_fmt_command = "goimports" +let g:go_template_autocreate = 0 +let g:go_info_mode = 'guru' +" gitgutter +nmap ]h <Plug>GitGutterNextHunk +nmap [h <Plug>GitGutterPrevHunk +" vim -grepper +let g:grepper = {} +let g:grepper.tools = ['rg', 'git', 'grep'] +nnoremap <Leader>* :Grepper -cword -noprompt +nmap gs <plug>(GrepperOperator) +xmap gs <plug>(GrepperOperator) +" UltiSnips +" Disabling snipmate +let g:UltiSnipsEnableSnipMate = 0 +" vim-virtualenv +let g:virtualenv_directory = "~/Sync/src/virtualenvs" diff --git a/nvim/.config/nvim/pythonx/vimsnippets.py b/nvim/.config/nvim/pythonx/vimsnippets.py @@ -0,0 +1,98 @@ +"""Helper methods used in UltiSnips snippets.""" + +import string +import vim + + +def complete(tab, opts): + """ + get options that start with tab + + :param tab: query string + :param opts: list that needs to be completed + + :return: a string that start with tab + """ + msg = "({0})" + if tab: + opts = [m[len(tab):] for m in opts if m.startswith(tab)] + if len(opts) == 1: + return opts[0] + + if not len(opts): + msg = "{0}" + return msg.format("|".join(opts)) + + +def _parse_comments(s): + """ Parses vim's comments option to extract comment format """ + i = iter(s.split(",")) + + rv = [] + try: + while True: + # get the flags and text of a comment part + flags, text = next(i).split(':', 1) + + if len(flags) == 0: + rv.append(('OTHER', text, text, text, "")) + # parse 3-part comment, but ignore those with O flag + elif 's' in flags and 'O' not in flags: + ctriple = ["TRIPLE"] + indent = "" + + if flags[-1] in string.digits: + indent = " " * int(flags[-1]) + ctriple.append(text) + + flags, text = next(i).split(':', 1) + assert flags[0] == 'm' + ctriple.append(text) + + flags, text = next(i).split(':', 1) + assert flags[0] == 'e' + ctriple.append(text) + ctriple.append(indent) + + rv.append(ctriple) + elif 'b' in flags: + if len(text) == 1: + rv.insert(0, ("SINGLE_CHAR", text, text, text, "")) + except StopIteration: + return rv + + +def get_comment_format(): + """ Returns a 4-element tuple (first_line, middle_lines, end_line, indent) + representing the comment format for the current file. + + It first looks at the 'commentstring', if that ends with %s, it uses that. + Otherwise it parses '&comments' and prefers single character comment + markers if there are any. + """ + commentstring = vim.eval("&commentstring") + if commentstring.endswith("%s"): + c = commentstring[:-2] + return (c, c, c, "") + comments = _parse_comments(vim.eval("&comments")) + for c in comments: + if c[0] == "SINGLE_CHAR": + return c[1:] + return comments[0][1:] + + +def make_box(twidth, bwidth=None): + b, m, e, i = (s.strip() for s in get_comment_format()) + bwidth_inner = bwidth - 3 - max(len(b), + len(i + e)) if bwidth else twidth + 2 + sline = b + m + bwidth_inner * m[0] + 2 * m[0] + nspaces = (bwidth_inner - twidth) // 2 + mlines = i + m + " " + " " * nspaces + mlinee = " " + " " * (bwidth_inner - twidth - nspaces) + m + eline = i + m + bwidth_inner * m[0] + 2 * m[0] + e + return sline, mlines, mlinee, eline + + +def foldmarker(): + "Return a tuple of (open fold marker, close fold marker)" + return vim.eval("&foldmarker").split(",") diff --git a/nvim/.config/nvim/templates/template.R b/nvim/.config/nvim/templates/template.R @@ -0,0 +1,4 @@ +#!/usr/bin/env Rscript +# Description + + diff --git a/nvim/.config/nvim/templates/template.c b/nvim/.config/nvim/templates/template.c @@ -0,0 +1,11 @@ +/* + * ... + */ + +#include <stdio.h> + +int main(void) +{ + + return 0; +} diff --git a/nvim/.config/nvim/templates/template.go b/nvim/.config/nvim/templates/template.go @@ -0,0 +1,8 @@ +// ... +package main + +import "fmt" + +func main() { + fmt.Println("foo") +} diff --git a/nvim/.config/nvim/templates/template.pl b/nvim/.config/nvim/templates/template.pl @@ -0,0 +1,8 @@ +#!/usr/bin/env perl +# +# ... + +use v5.26; +use strict; +use warnings; + diff --git a/nvim/.config/nvim/templates/template.py b/nvim/.config/nvim/templates/template.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# vim:fenc=utf-8 + diff --git a/nvim/.config/nvim/templates/template.sh b/nvim/.config/nvim/templates/template.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash + diff --git a/polybar/.config/polybar/config b/polybar/.config/polybar/config @@ -0,0 +1,230 @@ +; vim:ft=dosini + +[colors] +background = #000000 +background-alt = #444 +foreground = #dfdfdf +foreground-alt = #555 +primary = #afafaf +secondary = #e60053 +alert = #bd2c40 +col = #00f + +[bar/example] +monitor = ${env:MONITOR:HDMI-0} +width = 100% +height = 24 +fixed-center = false + +background = ${colors.background} +foreground = ${colors.foreground} + +line-size = 3 +line-color = #000000 + +border-size = 0 +border-color = #00000000 + +padding-left = 0 +padding-right = 0 + +module-margin-left = 1 +module-margin-right = 0 + +font-0 = "Ubuntu Mono derivative Powerline:pixelsize=13;1" +font-1 = "Noto Sans:size=12;1" +font-2 = "Font Awesome 5 Free:style=Regular:pixelsize=11;1" +font-3 = "Font Awesome 5 Free:style=Solid:pixelsize=11;1" +font-4 = "Font Awesome 5 Brands:style=Regular:pixelsize=11;1" + +; modules-left = i3 xwindow +modules-left = i3 +modules-right = temperature cpu ram eth home filesystem volume date + +tray-position = right +tray-padding = 5 + +scroll-up = i3wm-wsnext +scroll-down = i3wm-wsprev + +[module/xwindow] +type = internal/xwindow +label = %title:0:30:...% + +[module/filesystem] +type = internal/fs +interval = 25 + +mount-0 = / + +label-mounted = %{F#0a81f5}%mountpoint%%{F-}: %percentage_used%% +label-unmounted = %mountpoint% not mounted +label-unmounted-foreground = ${colors.foreground-alt} + +[module/home] +type = internal/fs +interval = 25 + +mount-0 = /home + +format-mounted-prefix = "| " +format-mounted-prefix-foreground = ${colors.foreground-alt} + +label-mounted = %{F#0a81f5}~%{F-}: %percentage_used%% +label-unmounted = %mountpoint% not mounted +label-unmounted-foreground = ${colors.foreground-alt} + +[module/bspwm] +type = internal/bspwm + +label-focused = %index% +label-focused-background = ${colors.background-alt} +label-focused-underline= ${colors.primary} +label-focused-padding = 2 + +label-occupied = %index% +label-occupied-padding = 2 + +label-urgent = %index%! +label-urgent-background = ${colors.alert} +label-urgent-padding = 2 + +label-empty = %index% +label-empty-foreground = ${colors.foreground-alt} +label-empty-padding = 2 + +[module/i3] +type = internal/i3 +format = <label-state> <label-mode> +index-sort = true +wrapping-scroll = false + +ws-icon-0 = 1; +ws-icon-1 = 2; +ws-icon-2 = 3; +ws-icon-3 = 4; +ws-icon-4 = 5; +ws-icon-5 = 6; +ws-icon-6 = 7; +ws-icon-7 = 8; +ws-icon-8 = 9; +ws-icon-9 = 10; + +label-mode-padding = 2 +label-mode-foreground = #000 +label-mode-background = ${colors.primary} + +label-focused = %index% %icon% +label-focused-background = ${xrdb:color0} +label-focused-underline = ${module/bspwm.label-focused-underline} +label-focused-padding = ${module/bspwm.label-focused-padding} + +; unfocused = Inactive workspace on any monitor +label-unfocused = %index% %icon% +label-unfocused-padding = ${module/bspwm.label-occupied-padding} + +; visible = Active workspace on unfocused monitor +label-visible = %index% %icon% +label-visible-background = ${self.label-focused-background} +label-visible-underline = ${self.label-focused-underline} +label-visible-padding = ${self.label-focused-padding} + +; urgent = Workspace with urgency hint set +label-urgent = %index% %icon% +label-urgent-background = ${module/bspwm.label-urgent-background} +label-urgent-padding = ${module/bspwm.label-urgent-padding} + +[module/cpu] +type = internal/cpu +interval = 2 +format-underline = ${xrdb:color1} +label = %percentage:3%% + +[module/ram] +type = internal/memory +interval = 3 +label = mem %gb_used%/%gb_free% +format-prefix = "| " +format-prefix-foreground = ${colors.foreground-alt} + +[module/eth] +type = internal/network +interface = bond0 +interval = 3.0 + +format-connected-underline = ${xrdb:color2} +format-connected-prefix = "| " +format-connected-prefix-foreground = ${colors.foreground-alt} +label-connected = Up%upspeed:9% Dwn%downspeed:9% + +format-disconnected-prefix = "| " +format-disconnected = <label-disconnected> +format-disconnected-underline = ${self.format-connected-underline} +label-disconnected = no eth +label-disconnected-foreground = ${colors.foreground-alt} + +[module/date] +type = internal/date +interval = 5 + +date = " %a, %b %d, %Y" +time = "- %H:%M" + +format-prefix = "| " +format-prefix-foreground = ${colors.foreground-alt} +format-underline = ${xrdb:color12} + +label = %date% %time% + +[module/volume] +type = internal/volume + +format-volume = <label-volume> <bar-volume> +label-volume = VOL +label-volume-foreground = ${root.foreground} + +format-volume-prefix = "| " +format-volume-foreground = ${colors.foreground-alt} +format-muted-prefix = "| " +format-muted-foreground = ${colors.foreground-alt} +label-muted = sound muted + +bar-volume-width = 10 +bar-volume-foreground-0 = ${xrdb:color10} +bar-volume-foreground-1 = ${xrdb:color10} +bar-volume-foreground-2 = ${xrdb:color10} +bar-volume-foreground-3 = ${xrdb:color10} +bar-volume-foreground-4 = ${xrdb:color10} +bar-volume-foreground-5 = ${xrdb:color11} +bar-volume-foreground-6 = ${xrdb:color1} +bar-volume-gradient = false +bar-volume-indicator = | +bar-volume-indicator-font = 1 +bar-volume-fill = = +bar-volume-fill-font = 1 +bar-volume-empty = = +bar-volume-empty-font = 1 +bar-volume-empty-foreground = ${colors.foreground-alt} + +[module/temperature] +type = internal/temperature +thermal-zone = 0 +warn-temperature = 60 + +format-prefix = "| " +format-prefix-foreground = ${colors.foreground-alt} +format = <label> +format-underline = ${xrdb:color1} +format-warn = <label-warn> +format-warn-underline = ${self.format-underline} + +label = cpu %temperature% +label-warn = cpu %temperature% +label-warn-foreground = ${colors.secondary} + +[settings] +screenchange-reload = true + +[global/wm] +margin-top = 5 +margin-bottom = 5 diff --git a/polybar/.config/polybar/launch.sh b/polybar/.config/polybar/launch.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# Terminate already running bar instances +killall -q polybar + +# Wait until the processes have been shut down +while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done + +# Launch bar1 and bar2 +polybar example & + +echo "Bars launched..." diff --git a/tidy/.astylerc b/tidy/.astylerc @@ -0,0 +1,19 @@ +--style=kr +--indent=spaces=4 +--indent-preproc-cond +--indent-switches +--indent-cases +--indent-namespaces +--indent-col1-comments +--indent-preprocessor +--break-blocks +--pad-oper +--pad-header +--pad-paren-in +--align-pointer=name +--align-reference=name +--keep-one-line-statements +--convert-tabs +--max-code-length=79 +--pad-method-colon=none +--delete-empty-lines diff --git a/tidy/.ctags b/tidy/.ctags @@ -0,0 +1,23 @@ +--recurse=yes +--tag-relative=yes +--exclude=.git + +--langmap=perl:+.pod +--regex-perl=/package[ \t]+['"]*([A-Za-z][A-Za-z0-9:]+)['" \t]*;/\1/p,package,packages/ +--regex-perl=/with[ \t]+['"]*([A-Za-z][A-Za-z0-9:]+)['" \t]*;/\1/w,role,roles/ +--regex-perl=/extends[ \t]+['"]*([A-Za-z][A-Za-z0-9:]+)['" \t]*;/\1/e,extends/ +--regex-perl=/use[ \t]+base[ \t]+['"]*([A-Za-z][A-Za-z0-9:]+)['" \t]*;/\1/e,extends/ +--regex-perl=/use[ \t]+parent[ \t]+['"]*([A-Za-z][A-Za-z0-9:]+)['" \t]*;/\1/e,extends/ +--regex-perl=/^[ \t]*use[ \t]+['"]*([A-Za-z][A-Za-z0-9:]+)['" \t]*;/\1/u,use,uses/ +--regex-perl=/^[ \t]*require[ \t]+['"]*([A-Za-z][A-Za-z0-9:]+)['" \t]*;/\1/r,require,requires/ +--regex-perl=/^[ \t]*has[ \t]+['"]*([A-Za-z_+][A-Za-z0-9_]+)['"]*[ \t]+/\1/a,attribute,attributes/ +--regex-perl=/^[ \t]*around[ \t]+['"]*([A-Za-z_][A-Za-z0-9_]+)['"]*[ \t]+/\1/x,around/ +--regex-perl=/^[ \t]*\*([A-Za-z_][A-Za-z0-9:_]+)[ \t]+=/\1/l,alias,aliases/ +--regex-perl=/^[ \t]*our[ \t]+([\$@%][A-Za-z_][A-Za-z0-9_]+)/\1/o,our,ours/ +--regex-perl=/use[ \t]+constante[ \t]+['"]*([A-Za-z_][A-Za-z0-9_]+)['" \t]*/\1/c,constants/ +--regex-perl=/task\s+['"]?([$A-Za-z_]+)['"]?(,| =>)\s+sub/\1/t,tasks,Tasks/ +--regex-perl=/^\=head1\s+(.+)/\1/d,pod,Plain Old Documentation/ +--regex-perl=/^\=head2\s+(.+)/-- \1/d,pod,Plain Old Documentation/ +--regex-perl=/^\=head[3-5]\s+(.+)/--- \1/d,pod,Plain Old Documentation/ +--regex-perl=/^__(DATA|END)__$/__\1__/g,labels/ +-R diff --git a/tidy/.perltidyrc b/tidy/.perltidyrc @@ -0,0 +1,3 @@ +-q +-pbp +-ci=2 diff --git a/tmux/.tmux.conf b/tmux/.tmux.conf @@ -0,0 +1,132 @@ +run-shell "tmux setenv -g MYOS $(uname)" +if-shell '[ "$MYOS" == "Darwin" ]' 'set-option -g default-command "reattach-to-user-namespace -l zsh"' +if-shell '[ "$MYOS" == "Linux" ]' 'set -g default-command zsh' +set -g default-terminal "screen-256color" +set -g status-interval 5 +set -g status-justify left +set-option -g renumber-windows on +set-option -g status-keys vi +# no automatic rename +set-option -g allow-rename off + +# canviem a Ctrl-a +set -g prefix C-a +unbind C-b + +# use send-prefix to pass C-a through to application +bind C-a send-prefix + +# shorten command delay +set -sg escape-time 10 +set -sg display-panes-time 2000 +set -sg display-time 2000 + +# set window and pane index to 1 (0 by default) +set-option -g base-index 1 +setw -g pane-base-index 1 + +# Show pane status on the border +set -g pane-border-status top +set -g pane-border-format "#P: #{pane_current_command}" + +set -g history-limit 5000 + +# reload ~/.tmux.conf using PREFIX r +bind r source-file ~/.tmux.conf \; display "Reloaded!" + +# Smart pane switching with awareness of vim splits +# See: https://github.com/christoomey/vim-tmux-navigator +is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ + | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" +bind-key -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L" +bind-key -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D" +bind-key -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U" +bind-key -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R" +bind-key -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l" + +# use PREFIX | to split window horizontally and PREFIX - to split vertically +bind | split-window -h +bind - split-window -v + +# map Vi movement keys as pane movement keys +# bind -r h select-pane -L +# bind -r j select-pane -D +# bind -r k select-pane -U +# bind -r l select-pane -R + +# we broke last window binding l to movement +bind / last-window + +bind-key @ select-layout tiled + +# resize panes using PREFIX H, J, K, L +bind -r H resize-pane -L 5 +bind -r J resize-pane -D 5 +bind -r K resize-pane -U 5 +bind -r L resize-pane -R 5 + +# move panes using PREFIX C-h, C-j, C-k, C-l +#bind-key C-j swap-pane -D +#bind-key C-k swap-pane -U +#bind-key C-h swap-pane -U +#bind-key C-l swap-pane -D + +# Vi copypaste mode +set-window-option -g mode-keys vi +bind-key -T copy-mode-vi v send-keys -X begin-selection +if-shell '[ "$MYOS" == "Darwin" ]' 'bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"' +if-shell '[ "$MYOS" == "Linux" ]' 'bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -selection clipboard"' + +## ---------- +## Status Bar +## ---------- +# set pane colors - hilight the active pane +set-option -g pane-border-fg colour235 +set-option -g pane-active-border-fg colour27 + +# colorize messages in the command line +set-option -g message-bg colour0 +set-option -g message-fg colour27 + +# visual notification of activity in other windows +setw -g monitor-activity off +set -g visual-activity off + +# set color for status bar +set-option -g status-bg colour250 +set-option -g status-fg black +set-option -g status-attr dim + +# set window list colors - red for active and cyan for inactive +set-window-option -g window-status-fg black +set-window-option -g window-status-bg colour250 +set-window-option -g window-status-attr dim + +set-window-option -g window-status-current-fg colour255 +set-window-option -g window-status-current-bg colour27 +set-window-option -g window-status-current-attr bold + +setw -g window-status-separator ' ' +setw -g window-status-format '#I  #W#F' +setw -g window-status-current-format '#[fg=colour250,bg=colour27,nobold,nounderscore,noitalics]#[fg=white,bg=colour27,bold]#I  #W #[fg=colour27,bg=colour250,nobold,nounderscore,noitalics]' + +# status bar +#set -g status-right "#{?pane_synchronized,#[fg=colour160]#[bg=colour250]#[fg=colour255]#[bg=colour160]**SYNC**#[fg=colour234]#[bg=colour160],#[fg=colour234,bg=white,nobold,nounderscore,noitalics]}#[fg=colour250,bg=colour234] %a #[fg=colour247,bg=colour234]#[fg=colour247,bg=colour234] %b %d  %R #[fg=colour250,bg=colour234,nobold,nounderscore,noitalics]#[fg=black,bg=colour250] #H " +set -g status-right "#{?window_zoomed_flag,#[fg=colour160]#[bg=colour250]#[fg=colour255]#[bg=colour160]**ZOOM**#[fg=colour234]#[bg=colour160],#{?pane_synchronized,#[fg=colour160]#[bg=colour250]#[fg=colour255]#[bg=colour160]**SYNC**#[fg=colour234]#[bg=colour160],#[fg=colour234,bg=white,nobold,nounderscore,noitalics]}}#[fg=colour250,bg=colour234] %a #[fg=colour247,bg=colour234]#[fg=colour247,bg=colour234] %b %d  %R #[fg=colour250,bg=colour234,nobold,nounderscore,noitalics]#[fg=black,bg=colour250] #H " + + +## ------------------ +## personal bind keys +## ------------------ +#bind-key -c "S" neww -n sam "ssh sam" +bind-key -c "G" neww -n galadriel "ssh galadriel" + +bind-key -c "S" setw synchronize-panes on +bind-key -c "O" setw synchronize-panes off + +bind C-p pipe-pane -o "cat >>~/tmp/#h-#I-#W.log" \; display "Toggled logging to ~/tmp/#h-#I-#W.log" + +# moving panes around +bind-key C-g command-prompt -p "get pane from:" "join-pane -s ':%%'" +bind-key C-s command-prompt -p "send pane to:" "join-pane -t ':%%'" +bind-key C-b break-pane diff --git a/x11/.Xresources b/x11/.Xresources @@ -0,0 +1,44 @@ +!Xft.dpi: 96 +Xft.dpi: 100 +Xft.antialias: true +Xft.rgba: rgb +Xft.hinting: true +Xft.hintstyle: hintslight + +!URxvt.background: black +!URxvt.foreground: grey +URxvt.buffered: true +URxvt.cursorColor: #395573 +URxvt.cursorUnderline: false +URxvt.cursorBlink: false +URxvt.geometry: 80x22 +URxvt.transparent: false +URxvt*urgentOnBell: true +URxvt.lineSpace: 0 +URxvt.letterSpace: -1 +URxvt*scrollBar_right: false +URxvt*scrollBar: false +URxvt*borderLess: false + +URxvt.font: xft:Ubuntu Mono derivative Powerline:pixelsize=18:antialias=true:hinting=true, \ + xft:PowerlineSymbols:pixelsize=18:antialias=true:hinting=true, \ + xft:Symbola:pixelsize=18:antialias=true:hinting=true +URxvt.boldFont: xft:Ubuntu Mono derivative Powerline:bold:pixelsize=18:antialias=true:hinting=true, \ + xft:PowerlineSymbols:bold:pixelsize=18:antialias=true:hinting=true, \ + xft:Symbola:bold:pixelsize=18:antialias=true:hinting=true +URxvt.italicFont: xft:Ubuntu Mono derivative Powerline:italic:pixelsize=18:antialias=true:hinting=true, \ + xft:PowerlineSymbols:italic:pixelsize=18:antialias=true:hinting=true, \ + xft:Symbola:italic:pixelsize=18:antialias=true:hinting=true +URxvt.boldItalicFont: xft:Ubuntu Mono derivative Powerline:bold:italic:pixelsize=18:antialias=true:hinting=true, \ + xft:PowerlineSymbols:bold:italic:pixelsize=18:antialias=true:hinting=true, \ + xft:Symbola:bold:italic:pixelsize=18:antialias=true:hinting=true + +URxvt.perl-ext-common: default,clipboard,url-select +URxvt.iso14755: False +URxvt.keysym.M-u: perl:url-select:select_next +URxvt.url-select.underline: true +URxvt.url-select.launcher: /usr/bin/google-chrome-stable +URxvt.keysym.M-v: perl:clipboard:paste +URxvt.keysym.M-C-v: perl:clipboard:paste_escaped + +#include "/home/paco/.colours/buhman" diff --git a/zsh/.zsh/agnoster.zsh-theme b/zsh/.zsh/agnoster.zsh-theme @@ -0,0 +1,184 @@ +# vim:ft=zsh ts=2 sw=2 sts=2 +# +# agnoster's Theme - https://gist.github.com/3712874 +# A Powerline-inspired theme for ZSH +# +# # README +# +# In order for this theme to render correctly, you will need a +# [Powerline-patched font](https://gist.github.com/1595572). +# +# In addition, I recommend the +# [Solarized theme](https://github.com/altercation/solarized/) and, if you're +# using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app - +# it has significantly better color fidelity. +# +# # Goals +# +# The aim of this theme is to only show you *relevant* information. Like most +# prompts, it will only show git information when in a git working directory. +# However, it goes a step further: everything from the current user and +# hostname to whether the last call exited with an error to whether background +# jobs are running in this shell will all be displayed automatically when +# appropriate. + +### Segment drawing +# A few utility functions to make it easy and re-usable to draw segmented prompts + +# This is needed ! +setopt promptsubst + + +CURRENT_BG='NONE' +if [[ -z "$PRIMARY_FG" ]]; then + PRIMARY_FG=black +fi + +# Characters +SEGMENT_SEPARATOR="\ue0b0" +PLUSMINUS="\u00b1" +BRANCH="\ue0a0" +DETACHED="\u27b2" +#DETACHED="\u27a6" +#DETACHED="->" +CROSS="\u2718" +#CROSS="x" +LIGHTNING="\u26a1" +#GEAR="\u2699" +GEAR="\u26ed" + +# Begin a segment +# Takes two arguments, background and foreground. Both can be omitted, +# rendering default background/foreground. +prompt_segment() { + local bg fg + [[ -n $1 ]] && bg="%K{$1}" || bg="%k" + [[ -n $2 ]] && fg="%F{$2}" || fg="%f" + if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then + print -n "%{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%}" + else + print -n "%{$bg%}%{$fg%}" + fi + CURRENT_BG=$1 + [[ -n $3 ]] && print -n $3 +} + +# End the prompt, closing any open segments +prompt_end() { + if [[ -n $CURRENT_BG ]]; then + print -n "%{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" + else + print -n "%{%k%}" + fi + print -n "%{%f%}" + CURRENT_BG='' +} + +### Prompt components +# Each component will draw itself, and hide itself if no information needs to be shown + +# Context: user@hostname (who am I and where am I) +prompt_context() { + local user=`whoami` + + if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CONNECTION" ]]; then + prompt_segment $PRIMARY_FG default " %(!.%{%F{yellow}%}.)$user@%m " + fi +} + +# Git: branch/detached head, dirty status +prompt_git() { + local color ref + is_dirty() { + test -n "$(git status --porcelain --ignore-submodules)" + } + ref="$vcs_info_msg_0_" + if [[ -n "$ref" ]]; then + if is_dirty; then + color=yellow + ref="${ref} $PLUSMINUS" + else + color=green + ref="${ref} " + fi + if [[ "${ref/.../}" == "$ref" ]]; then + ref="$BRANCH $ref" + else + ref="$DETACHED ${ref/.../}" + fi + prompt_segment $color $PRIMARY_FG + print -Pn " $ref" + fi +} + +# Dir: current working directory +prompt_dir() { + #prompt_segment blue $PRIMARY_FG ' %~ ' + prompt_segment 27 white ' %~ ' +} + +# Status: +# - was there an error +# - am I root +# - are there background jobs? +prompt_status() { + local symbols + symbols=() + # [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}$CROSS" + [[ $RETVAL -ne 0 ]] && symbols+="[%{%F{red}%}$RETVAL%{%f%}]" + [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}$LIGHTNING" + [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}$GEAR" + + [[ -n "$symbols" ]] && prompt_segment $PRIMARY_FG default " $symbols " +} + +# Display current virtual environment +prompt_virtualenv() { + if [[ -n $VIRTUAL_ENV ]]; then + color=cyan + prompt_segment $color $PRIMARY_FG + print -Pn " $(basename $VIRTUAL_ENV) " + fi +} + +# Display k8s cluster info if flag is on +prompt_k8s() { + if [[ -n $K8S_PROMPT ]]; then + prompt_segment 39 $PRIMARY_FG + print -n "$(kube_ps1)" + fi +} + +## Main prompt +prompt_agnoster_main() { + RETVAL=$? + CURRENT_BG='NONE' + prompt_status + prompt_context + prompt_virtualenv + prompt_k8s + prompt_dir + prompt_git + prompt_end +} + +prompt_agnoster_precmd() { + vcs_info + PROMPT='%{%f%b%k%}$(prompt_agnoster_main) ' +} + +prompt_agnoster_setup() { + autoload -Uz add-zsh-hook + autoload -Uz vcs_info + + prompt_opts=(cr subst percent) + + add-zsh-hook precmd prompt_agnoster_precmd + + zstyle ':vcs_info:*' enable git + zstyle ':vcs_info:*' check-for-changes false + zstyle ':vcs_info:git*' formats '%b' + zstyle ':vcs_info:git*' actionformats '%b (%a)' +} + +prompt_agnoster_setup "$@" diff --git a/zsh/.zsh/aliases.zsh b/zsh/.zsh/aliases.zsh @@ -0,0 +1,183 @@ +MYOS=$(uname) +if [[ "$MYOS" == "Linux" ]]; then + alias ls='ls -F --color' + alias open="xdg-open" + CLIP_COMMAND="xclip -selection clipboard" +fi +if [[ "$MYOS" == "FreeBSD" ]]; then + alias ls='ls -F -G' + CLIP_COMMAND="" +fi +if [[ "$MYOS" == "Darwin" ]]; then + alias ls='ls -F' + CLIP_COMMAND="pbcopy" +fi + +alias cp='cp -v' +alias tree='tree -C' +alias tm='tmux attach' +alias g='git' +alias k='kubectl' +alias kg='kubectl get' +alias kgp='kubectl get pod' +alias kgpw='kubectl get pod -o wide' +alias kgdep='kubectl get deployment' +alias kgsvc='kubectl get service' +alias kging='kubectl get ingress' +alias kgcm='kubectl get configmap' +alias kgsec='kubectl get secret' +alias kd='kubectl describe' +alias ka='kubectl apply -f' +alias krm='kubectl delete' +alias kex='kubectl exec -i -t' +alias kedep='kubectl edit deployment' +alias kecm='kubectl edit configmap' +alias ktopn='kubectl top node' +alias ktopp='kubectl top pod' +alias kctx='kubectx' +alias kns='kubens' +alias gcil='gcloud compute instances list' +alias gcssh='gcloud compute ssh' +alias gcscp='gcloud compute scp' +alias vim='nvim' +alias cal='cal -m' +alias d='docker' +alias dps='docker ps -a' +alias dim='docker images' +alias dex='docker exec -ti' +alias drun='docker run --rm' +alias dpull='docker pull' +alias dpush='docker push' +alias dclean='docker system prune -af' +alias ddf='docker system df' +alias cal='cal -3m' +alias info='info --vi-keys' # GNU info act like man command +alias figletfonts='ls -1 `figlet -I2` | grep "\.flf$" | cut -f 1 -d "." | sort -u' # list figlet fonts +alias r1='ssh r1' +alias diff='diff -u' + +# most used config files fast access +cfg-i3() { $EDITOR $HOME/.config/i3/config } +cfg-nvim() { $EDITOR $HOME/.config/nvim/init.vim } +cfg-polybar() { $EDITOR $HOME/.config/polybar/config } +cfg-ranger() { $EDITOR $HOME/.config/ranger/rc.conf } +cfg-ranger-rifle() { $EDITOR $HOME/.config/ranger/rifle.conf } +cfg-ranger-commands() { $EDITOR ~/.config/ranger/commands.py } +cfg-zsh() { $EDITOR $HOME/.zshrc } +cfg-zsh-alias() { $EDITOR $HOME/.zsh/aliases.zsh } +cfg-mutt() { $EDITOR $HOME/.muttrc } +cfg-newsboat() { $EDITOR $HOME/.newsboat/config } +cfg-newsboat-urls() { $EDITOR $HOME/.newsboat/urls } +cfg-tmux() { $EDITOR $HOME/.tmux.conf } + +# directory definitions +e=$HOME/Sync/src/electronica +s=$HOME/Sync/src +p=$HOME/Sync/src/powerspace +d=$HOME/Documents +D=$HOME/Downloads +f=/mnt/fotos +m=/mnt/media +M=/mnt/mirror +h=/mnt/home +cad=/mnt/home/src/CAD + +# transmission stuff +alias trls='transmission-remote 10.42.10.55 --authenv -l' +function trrm () { + transmission-remote 10.42.10.55 --authenv -t $1 --remove-and-delete +} +function tradd () { + transmission-remote 10.42.10.55 --authenv -a $1 +} +function trclean() { + for i in $(transmission-remote 10.42.10.55 --authenv -l | awk '$2=="100%" {print $1}') + do + transmission-remote 10.42.10.55 --authenv -t $i --remove-and-delete + done +} + +## useful base conversion functions +function h2d(){ printf "%'d\n" 0x$@; } +function b2d(){ printf "%'d\n" 0b$@; } +function o2d(){ printf "%'d\n" "[8]$@"; } +# the other permitations are a python script in ~/bin + +# What is my External IP +function myip() { printf "External IP: %s\n" $(curl -s http://ifconfig.co/) ;} + +# Utils + +# Retry a function +# @param $1 number Retry Times +# @param $2 number Retry Wait +# @param $@ mixed Function and arguments +function retry() { + times=$1; shift; + wait=$1; shift; + until "$@"; do + (( --times <= 0 )) && return 1 + sleep $wait + done +} +# quick and dirty file backup +function bak() { + \cp -v ${1}{,.bak} +} +# replace all spaces by underscore +function mvsp() { + autoload -U zmv + zmv '* *' '$f:gs/ /_' +} +# Grep the history with 'h' +function h () { history 0 | grep $1 } +# Curl alias to calculate response time. +function curl_time() { + curl -o /dev/null -Ls -w " \ + time_namelookup: %{time_namelookup}\n \ + time_connect: %{time_connect}\n \ + time_appconnect: %{time_appconnect}\n \ + time_pretransfer: %{time_pretransfer}\n \ + time_redirect: %{time_redirect}\n \ +time_starttransfer: %{time_starttransfer}\n \ + ----------\n \ + time_total: %{time_total}\n" "$1" +} +# weather forecast on the terminal +function wf () { + CITY=$1 + if [[ -z "$CITY" ]]; then + CITY="Mataró" + fi + curl wttr.in/${CITY} +} +# transfer.sh upload helper +function transfer() { + if [ $# -eq 0 ]; then + echo -e "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md" + return 1 + fi + tmpfile=$( mktemp -t transferXXX ) + if tty -s; then + basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g') + curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile + else + curl --progress-bar --upload-file "-" "https://transfer.sh/$1" >> $tmpfile + fi + # send output to stderr AND to clipboard + cat $tmpfile >&2 | $CLIP_COMMAND + echo " " + rm -f $tmpfile +} +# function to copy main ssh keys to clipboard when needed +function pubkey () { + KEY="id_rsa.pub" + if [[ "$1" == "pws" ]]; then + KEY="id_rsa-ps_festeban.pub" + fi + cat ${HOME}/.ssh/${KEY} |\ + tee |\ + $CLIP_COMMAND + echo "=> Public key ($KEY) copied to clipboard." +} + diff --git a/zsh/.zsh/includes.zsh b/zsh/.zsh/includes.zsh @@ -0,0 +1,29 @@ +# plenv +if which plenv > /dev/null; then eval "$(plenv init - zsh)"; fi + +# gcloud completion +[ -f /opt/google-cloud-sdk/completion.zsh.inc ] && source /opt/google-cloud-sdk/completion.zsh.inc + +# nice 'x' command for all kinds of compressed file extraction +[ -f $HOME/.zsh_plugins/extract.plugin.zsh ] && source $HOME/.zsh_plugins/extract.plugin.zsh + +# color sin man pages ... +[ -f $HOME/.zsh_plugins/colored-man-pages.plugin.zsh ] && source $HOME/.zsh_plugins/colored-man-pages.plugin.zsh + +# fzf stuff +if [ -f /usr/share/fzf/key-bindings.zsh ]; then + source /usr/share/fzf/key-bindings.zsh +elif [ -f $HOME/etc/fzf/key-bindings.zsh ]; then + source $HOME/etc/fzf/key-bindings.zsh +fi +if [ -f /usr/share/fzf/completion.zsh ]; then + source /usr/share/fzf/completion.zsh +elif [ -f $HOME/etc/fzf/completion.zsh ]; then + source $HOME/etc/fzf/completion.zsh +fi + +# kubectl completion and nice kube info on prompt +if [ $commands[kubectl] ]; then + source <(kubectl completion zsh) + [ -f $HOME/Sync/src/kube-ps1/kube-ps1.sh ] && source $HOME/Sync/src/kube-ps1/kube-ps1.sh +fi diff --git a/zsh/.zsh/usb_format.zsh b/zsh/.zsh/usb_format.zsh @@ -0,0 +1,218 @@ +#-------- Format USB v4 [last updated October 23, 2016] {{{ +#------------------------------------------------------ +# DEMO: https://www.youtube.com/watch?v=7txO1cdNJsQ +# DESC: format USB and create a single partition + +format2usb-ext() { + if [ $# -lt 3 ]; then + echo -e "format and create a partition that fills up the whole device" + echo -e "\nUsage: $0 <filesystem:ext2|ext3|ext4> <device_label> <device_name>" + echo -e "Example: $0 ext2 MY_USB sdx" + echo -e " $0 ext3 MY_USB sdx" + echo -e " $0 ext4 MY_USB sdx" + return 1 + fi + FSTYPE="$1" + DEVICE_LABEL="$2" + DEVICE_NAME="$3" + echo ">>>Checking if device is mounted " + MOUNT_STATUS=$(mount | grep /dev/"$DEVICE_NAME" | wc -l) + if [ "$MOUNT_STATUS" -ne 0 ] + then + lsblk -o "NAME,SIZE,FSTYPE,TYPE,LABEL,MOUNTPOINT,UUID" | grep "$DEVICE_NAME" + echo ">>>/dev/$DEVICE_NAME is mounted. You have to unmount the device and all of its partitions then try again " + return 1 + fi + echo ">>>Please double check the device you are about to FORMAT " + lsblk -o "NAME,SIZE,FSTYPE,TYPE,LABEL,MOUNTPOINT,UUID" | grep --color -E "$DEVICE_NAME|$" + echo -n ">>>WARNING: You are about to FORMAT a device at /dev/$DEVICE_NAME. Do you want to continue? [y/n] " + read REPLY + if [[ $REPLY =~ ^[Yy]$ ]] + then + echo ">>>You chose to continue " + else + return 1 + fi + echo ">>>Delete any existing partition then create a new single partition " + echo -e "d\n\nd\n\nd\n\nd\n\nd\n\nd\n\nd\n\nd\n\no\nn\np\n1\n\n\nw" | sudo fdisk /dev/"$DEVICE_NAME" + # delete partiton x8 using d\n\n + # d delete a partition + # default, partition + # o create a new empty DOS partition table + # n add a new partition + # p print the partition table + # 1 partition number 1 + # default, start immediately after preceding partition + # default, extend partition to end of disk + # w write table to disk and exit + echo ">>>Formatting the device " + echo -e "y\n" | sudo mkfs."$FSTYPE" -L "$DEVICE_LABEL" /dev/"$DEVICE_NAME"1 + echo ">>>Changing permission of the filesystem " + mkdir -p -v /tmp/testmount + sudo mount /dev/"$DEVICE_NAME"1 /tmp/testmount + sudo chmod -R 777 /tmp/testmount + echo ">>>Change EXT filesystem 5% reserved space to 0% (increase storage space) " + MOUNTED_TESTMOUNT=$(df | awk '/testmount/ {print $1}') + sudo tune2fs -m 0 "$MOUNTED_TESTMOUNT" + sudo tune2fs -l "$MOUNTED_TESTMOUNT" | grep --color=auto 'Reserved block count' + echo ">>>Unmounting and cleanup " + sudo umount /tmp/testmount + rmdir -v /tmp/testmount +} + +format2usb-exfat() { + if [ $# -lt 2 ]; then + echo -e "format and create a partition that fills up the whole device" + echo -e "exFAT label max is 15 character and is all uppercase" + echo -e "\nUsage: $0 <label> <device>" + echo -e "Example: $0 MY_USB sdx" + return 1 + fi + # exFat likes the labels to be in uppercase + DEVICE_LABEL=$(echo "$1" | tr '[:lower:]' '[:upper:]') + DEVICE_NAME="$2" + echo ">>>Checking if device is mounted " + MOUNT_STATUS=$(mount | grep /dev/"$DEVICE_NAME" | wc -l) + if [ "$MOUNT_STATUS" -ne 0 ] + then + lsblk -o "NAME,SIZE,FSTYPE,TYPE,LABEL,MOUNTPOINT,UUID" | grep "$DEVICE_NAME" + echo ">>>/dev/$DEVICE_NAME is mounted. You have to unmount the device and all of its partitions then try again " + return 1 + fi + echo ">>>Please double check the device you are about to FORMAT " + lsblk -o "NAME,SIZE,FSTYPE,TYPE,LABEL,MOUNTPOINT,UUID" | grep --color -E "$2|$" + echo -n ">>>WARNING: You are about to FORMAT a device at /dev/$DEVICE_NAME. Do you want to continue? [y/n] " + read REPLY + if [[ $REPLY =~ ^[Yy]$ ]] + then + echo ">>>You chose to continue " + else + return 1 + fi + echo ">>>Delete any existing partition then create a new single partition " + echo -e "d\n\nd\n\nd\n\nd\n\nd\n\nd\n\nd\n\nd\n\no\nn\np\n1\n\n\nt\n7\nw" | sudo fdisk /dev/"$DEVICE_NAME" + # delete partiton x8 using d\n\n + # d delete a partition + # default, partition + # o create a new empty DOS partition table + # n add a new partition + # p print the partition table + # 1 partition number 1 + # default, start immediately after preceding partition + # default, extend partition to end of disk + # t change a partition type (L to list all types) + # 7 HPFS/NTFS/exFAT + # w write table to disk and exit + echo ">>>Formatting the device " + sudo mkfs.exfat -n "$DEVICE_LABEL" /dev/"$DEVICE_NAME"1 + echo ">>>Changing permission of the filesystem " + mkdir -p -v /tmp/testmount + sudo mount /dev/"$DEVICE_NAME"1 /tmp/testmount + sudo chmod -R 777 /tmp/testmount + sudo umount /tmp/testmount + rmdir -v /tmp/testmount +} + +format2usb-fat32() { + if [ $# -lt 2 ]; then + echo -e "format and create a partition that fills up the whole device" + echo -e "FAT32 label max is 11 character and is all uppercase" + echo -e "\nUsage: $0 <label> <device>" + echo -e "Example: $0 MY_USB sdx" + return 1 + fi + # fat32 likes the labels to be in uppercase + DEVICE_LABEL=$(echo "$1" | tr '[:lower:]' '[:upper:]') + DEVICE_NAME="$2" + echo ">>>Checking if device is mounted " + MOUNT_STATUS=$(mount | grep /dev/"$DEVICE_NAME" | wc -l) + if [ "$MOUNT_STATUS" -ne 0 ] + then + lsblk -o "NAME,SIZE,FSTYPE,TYPE,LABEL,MOUNTPOINT,UUID" | grep "$DEVICE_NAME" + echo ">>>/dev/$DEVICE_NAME is mounted. You have to unmount the device and all of its partitions then try again " + return 1 + fi + echo ">>>Please double check the device you are about to FORMAT " + lsblk -o "NAME,SIZE,FSTYPE,TYPE,LABEL,MOUNTPOINT,UUID" | grep --color -E "$2|$" + echo -n ">>>WARNING: You are about to FORMAT a device at /dev/$DEVICE_NAME. Do you want to continue? [y/n] " + read REPLY + if [[ $REPLY =~ ^[Yy]$ ]] + then + echo ">>>You chose to continue " + else + return 1 + fi + echo ">>>Delete any existing partition then create a new single partition " + echo -e "d\n\nd\n\nd\n\nd\n\nd\n\nd\n\nd\n\nd\n\no\nn\np\n1\n\n\nt\nb\nw" | sudo fdisk /dev/"$DEVICE_NAME" + # delete partiton x8 using d\n\n + # d delete a partition + # default, partition + # o create a new empty DOS partition table + # n add a new partition + # p print the partition table + # 1 partition number 1 + # default, start immediately after preceding partition + # default, extend partition to end of disk + # t change a partition type (L to list all types) + # b W95 FAT32 + # w write table to disk and exit + echo ">>>Formatting the device " + sudo mkfs.fat -F 32 -n "$DEVICE_LABEL" -I /dev/"$DEVICE_NAME"1 + echo ">>>Changing permission of the filesystem " + mkdir -p -v /tmp/testmount + sudo mount /dev/"$DEVICE_NAME"1 /tmp/testmount + sudo chmod -R 777 /tmp/testmount + sudo umount /tmp/testmount + rmdir -v /tmp/testmount +} + +format2usb-ntfs() { + if [ $# -lt 2 ]; then + echo -e "format and create a partition that fills up the whole device" + echo -e "\nUsage: $0 <label> <device>" + echo -e "Example: $0 MY_USB sdx" + return 1 + fi + DEVICE_LABEL="$1" + DEVICE_NAME="$2" + echo ">>>Checking if device is mounted " + MOUNT_STATUS=$(mount | grep /dev/"$DEVICE_NAME" | wc -l) + if [ "$MOUNT_STATUS" -ne 0 ] + then + lsblk -o "NAME,SIZE,FSTYPE,TYPE,LABEL,MOUNTPOINT,UUID" | grep "$DEVICE_NAME" + echo ">>>/dev/$DEVICE_NAME is mounted. You have to unmount the device and all of its partitions then try again " + return 1 + fi + echo ">>>Please double check the device you are about to FORMAT " + lsblk -o "NAME,SIZE,FSTYPE,TYPE,LABEL,MOUNTPOINT,UUID" | grep --color -E "$DEVICE_NAME|$" + echo -n ">>>WARNING: You are about to FORMAT a device at /dev/$DEVICE_NAME. Do you want to continue? [y/n] " + read REPLY + if [[ $REPLY =~ ^[Yy]$ ]] + then + echo ">>>You chose to continue " + else + return 1 + fi + echo ">>>Delete any existing partition then create a new single partition " + echo -e "d\n\nd\n\nd\n\nd\n\nd\n\nd\n\nd\n\nd\n\no\nn\np\n1\n\n\nt\n7\nw" | sudo fdisk /dev/"$DEVICE_NAME" + # delete partiton x8 using d\n\n + # d delete a partition + # default, partition + # o create a new empty DOS partition table + # n add a new partition + # p print the partition table + # 1 partition number 1 + # default, start immediately after preceding partition + # default, extend partition to end of disk + # t change a partition type (L to list all types) + # 7 HPFS/NTFS/exFAT + # w write table to disk and exit + echo ">>>Formatting the device " + sudo mkfs.ntfs -f -L "$DEVICE_LABEL" /dev/"$DEVICE_NAME"1 + echo ">>>Changing permission of the filesystem " + mkdir -p -v /tmp/testmount + sudo mount /dev/"$DEVICE_NAME"1 /tmp/testmount + sudo chmod -R 777 /tmp/testmount + sudo umount /tmp/testmount + rmdir -v /tmp/testmount +} diff --git a/zsh/.zsh_plugins/colored-man-pages.plugin.zsh b/zsh/.zsh_plugins/colored-man-pages.plugin.zsh @@ -0,0 +1,14 @@ +man() { + env \ + LESS_TERMCAP_mb=$(printf "\e[1;34m") \ + LESS_TERMCAP_md=$(printf "\e[1;34m") \ + 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") \ + PAGER="${commands[less]:-$PAGER}" \ + _NROFF_U=1 \ + PATH="$HOME/bin:$PATH" \ + man "$@" +} diff --git a/zsh/.zsh_plugins/extract.plugin.zsh b/zsh/.zsh_plugins/extract.plugin.zsh @@ -0,0 +1,77 @@ +alias x=extract + +extract() { + local remove_archive + local success + local extract_dir + + if (( $# == 0 )); then + cat <<-'EOF' >&2 + Usage: extract [-option] [file ...] + + Options: + -r, --remove Remove archive. + EOF + fi + + remove_archive=1 + if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then + remove_archive=0 + shift + fi + + while (( $# > 0 )); do + if [[ ! -f "$1" ]]; then + echo "extract: '$1' is not a valid file" >&2 + shift + continue + fi + + success=0 + extract_dir="${1:t:r}" + case "$1" in + (*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$1" | tar xv } || tar zxvf "$1" ;; + (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;; + (*.tar.xz|*.txz) + tar --xz --help &> /dev/null \ + && tar --xz -xvf "$1" \ + || xzcat "$1" | tar xvf - ;; + (*.tar.zma|*.tlz) + tar --lzma --help &> /dev/null \ + && tar --lzma -xvf "$1" \ + || lzcat "$1" | tar xvf - ;; + (*.tar) tar xvf "$1" ;; + (*.gz) (( $+commands[pigz] )) && pigz -d "$1" || gunzip "$1" ;; + (*.bz2) bunzip2 "$1" ;; + (*.xz) unxz "$1" ;; + (*.lzma) unlzma "$1" ;; + (*.Z) uncompress "$1" ;; + (*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk) unzip "$1" -d $extract_dir ;; + (*.rar) unrar x -ad "$1" ;; + (*.7z) 7za x "$1" ;; + (*.deb) + mkdir -p "$extract_dir/control" + mkdir -p "$extract_dir/data" + cd "$extract_dir"; ar vx "../${1}" > /dev/null + cd control; tar xzvf ../control.tar.gz + cd ../data; extract ../data.tar.* + cd ..; rm *.tar.* debian-binary + cd .. + ;; + (*) + echo "extract: '$1' cannot be extracted" >&2 + success=1 + ;; + esac + + (( success = $success > 0 ? $success : $? )) + (( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1" + shift + done +} + +## pack functions +function mktar() { tar cvf "${1%%/}.tar" "${1%%/}/"; } +function mktgz() { tar cvzf "${1%%/}.tar.gz" "${1%%/}/"; } +function mktbz() { tar cvjf "${1%%/}.tar.bz2" "${1%%/}/"; } +function mkzip() { zip -r "${1%%/}.zip" "${1%%/}/"; } diff --git a/zsh/.zshenv b/zsh/.zshenv @@ -0,0 +1,23 @@ +export FZF_DEFAULT_COMMAND="rg --files" +export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" +export RSYNC_RSH=ssh +export EDITOR=nvim +export VISUAL=nvim +export PAGER=less +export LESS="-R" +export HISTSIZE=5000 +export HISTFILE=~/.history_zsh +export SAVEHIST=4000 +export GOPATH=~/Sync/src/go +export PASSWORD_STORE_DIR=$HOME/Sync/password-store +export PASSWORD_STORE_CLIP_TIME=60 +export PASSWORD_STORE_GENERATED_LENGTH=32 +export PASSWORD_STORE_ENABLE_EXTENSIONS=true +# agnoster theme needs this to hide redundant user info +export DEFAULT_USER=$USER + +typeset -U path +path=(~/.plenv/bin $GOPATH/bin $path) + +# for completion colored ... +export LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:' diff --git a/zsh/.zshrc b/zsh/.zshrc @@ -0,0 +1,37 @@ +# vi key bindings +setopt VI +# do not kill background processes on exit +setopt NO_HUP +# try to correct my mistakes +setopt CORRECT +# dir stack things +setopt AUTO_PUSHD PUSHD_SILENT PUSHD_TO_HOME +## Remove duplicate entries +setopt PUSHD_IGNORE_DUPS +## This reverts the +/- operators. +setopt PUSHD_MINUS +# shared hist between shells +setopt SHARE_HISTORY +setopt HIST_IGNORE_DUPS +setopt HIST_IGNORE_ALL_DUPS +setopt HIST_REDUCE_BLANKS +setopt HIST_IGNORE_SPACE +# It turns out I do use autocd ... +setopt AUTO_CD + +# completion +autoload -U compinit zcalc +compinit +zstyle ':completion:*' menu select +zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} +# use the vi navigation keys in menu completion +zmodload zsh/complist +bindkey -M menuselect 'h' vi-backward-char +bindkey -M menuselect 'k' vi-up-line-or-history +bindkey -M menuselect 'l' vi-forward-char +bindkey -M menuselect 'j' vi-down-line-or-history + +source $HOME/.zsh/includes.zsh +source $HOME/.zsh/aliases.zsh +source $HOME/.zsh/agnoster.zsh-theme +[ -f $HOME/.zshenv.local ] && source $HOME/.zshenv.local