diff --git a/bin/battery_indicator.sh b/bin/battery_indicator.sh new file mode 100755 index 0000000..202cffe --- /dev/null +++ b/bin/battery_indicator.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# modified from http://ficate.com/blog/2012/10/15/battery-life-in-the-land-of-tmux/ + +HEART='♥ ' + +if [[ `uname` == 'Linux' ]]; then + current_charge=$(cat /proc/acpi/battery/BAT1/state | grep 'remaining capacity' | awk '{print $3}') + total_charge=$(cat /proc/acpi/battery/BAT1/info | grep 'last full capacity' | awk '{print $4}') +else + battery_info=`ioreg -rc AppleSmartBattery` + current_charge=$(echo $battery_info | grep -o '"CurrentCapacity" = [0-9]\+' | awk '{print $3}') + total_charge=$(echo $battery_info | grep -o '"MaxCapacity" = [0-9]\+' | awk '{print $3}') +fi + +charged_slots=$(echo "((($current_charge/$total_charge)*10)/3)+1" | bc -l | cut -d '.' -f 1) +if [[ $charged_slots -gt 3 ]]; then + charged_slots=3 +fi + +echo -n '#[fg=colour196]' +for i in `seq 1 $charged_slots`; do echo -n "$HEART"; done + +if [[ $charged_slots -lt 3 ]]; then + echo -n '#[fg=colour254]' + for i in `seq 1 $(echo "3-$charged_slots" | bc)`; do echo -n "$HEART"; done +fi diff --git a/tmux/theme.sh b/tmux/theme.sh index 4eaaee9..707eabc 100644 --- a/tmux/theme.sh +++ b/tmux/theme.sh @@ -51,10 +51,11 @@ set-window-option -g clock-mode-colour $tm_color_active #tm_tunes="#[fg=$tm_color_music]#(osascript ~/.dotfiles/applescripts/tunes.scpt)" #tm_battery="#(~/.dotfiles/bin/battery_indicator.sh)" +tm_battery="#[fg=$tm_color_inactive]#(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep percentage | awk '{print $2}')" tm_date="#[fg=$tm_color_inactive] %R %d %b" tm_host="#[fg=$tm_color_feature,bold]#h" tm_session_name="#[fg=$tm_color_feature,bold]$tm_icon #S" set -g status-left $tm_session_name' ' -set -g status-right $tm_tunes' '$tm_date' '$tm_host +set -g status-right $tm_battery' '$tm_date' '$tm_host diff --git a/vim/ftplugin/go.vim b/vim/ftplugin/go.vim index 4b6d30e..9df729d 100644 --- a/vim/ftplugin/go.vim +++ b/vim/ftplugin/go.vim @@ -8,3 +8,4 @@ au FileType go nmap t (go-test) au FileType go nmap c (go-coverage) au FileType go nmap gd (go-doc) au FileType go nmap ml (go-metalinter) +au FileType go nmap r (go-rename) diff --git a/vim/neosnippets/go.snip b/vim/neosnippets/go.snip new file mode 100644 index 0000000..fe3e96c --- /dev/null +++ b/vim/neosnippets/go.snip @@ -0,0 +1,12 @@ +snippet middleware +options head + func ${1}(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) { + ${2} + next(r, rw) + } + +snippet handler +options head + func ${1}(w http.ResponseWriter, r *http.Request) { + ${2} + } diff --git a/vimrc.symlink b/vimrc.symlink index 8e46584..5b16c05 100644 --- a/vimrc.symlink +++ b/vimrc.symlink @@ -223,3 +223,4 @@ smap neosnippet#expandable_or_jumpable() ? if has('conceal') set conceallevel=2 concealcursor=niv endif +let g:neosnippet#snippets_directory = '~/.dotfiles/vim/neosnippets'