init of new dotfiles repository with no secrets

This commit is contained in:
Andrew Davidson 2019-05-01 21:21:48 -04:00
commit 92feacde4b
32 changed files with 4025 additions and 0 deletions

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
.AppleDouble
.netrwhist
vim/.vim/plugged
zsh/.zsh/cache

31
README.md Normal file
View file

@ -0,0 +1,31 @@
# Dotfiles
These are generic dotfiles intended for use across any platform.
## Supported Configurations
* bash
* conky
* emacs
* git
* i3
* mutt
* offlineimap
* khard
* tmux
* vim
* zsh
## Installation
Following the best practices of the local platform install `git` and `stow`.
```
$ git clone ssh://git@gitlab.com/amdavidson/dotfiles.git $HOME/.dotfiles
$ cd $HOME/.dotfiles
$ ./update.sh
$ stow {bash,git,tmux,vim}
```
## Local Configuration
Locally specific `bash` or `zsh` configurations can be put into `$HOME/.$SHELL_local` and they will be applied as a superset of the main `.$SHELLrc` file.

4
bash/.bash_profile Normal file
View file

@ -0,0 +1,4 @@
if [ -f $HOME/.bash_profile_local ]; then
source $HOME/.bash_profile_local
fi
source ~/.bashrc

214
bash/.bashrc Normal file
View file

@ -0,0 +1,214 @@
### @amdavidson's bashrc
# define useful aliases for color codes
sh_norm="\[\033[0m\]"
sh_black="\[\033[0;30m\]"
sh_dark_gray="\[\033[1;30m\]"
sh_blue="\[\033[0;34m\]"
sh_light_blue="\[\033[1;34m\]"
sh_green="\[\033[0;32m\]"
sh_light_green="\[\033[1;32m\]"
sh_cyan="\[\033[0;36m\]"
sh_light_cyan="\[\033[1;36m\]"
sh_red="\[\033[0;31m\]"
sh_light_red="\[\033[1;31m\]"
sh_purple="\[\033[0;35m\]"
sh_light_purple="\[\033[1;35m\]"
sh_brown="\[\033[0;33m\]"
sh_yellow="\[\033[1;33m\]"
sh_light_gray="\[\033[0;37m\]"
sh_white="\[\033[1;37m\]"
# Set some defaults.
export GOPATH="$HOME/go"
export EDITOR="vim"
export PATH=".:$GOPATH/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:~/bin"
export LSCOLORS="ExGxBxDxCxEgEdxbxgxcxd"
export DOTFILES_DIR=$HOME'/.dotfiles'
# Make a pretty prompt.
export PROMPT_COMMAND='history -a; if [ $? -ne 0 ];then ERROR_FLAG=1;else ERROR_FLAG=;fi;$DOTFILES_DIR/check_update.sh'
export PS1=${HOSTCOLOUR}${sh_light_gray}'\t | \h'${sh_green}':\w'${sh_light_gray}' '${sh_light_gray}'${ERROR_FLAG:+'${sh_light_red}'}\$ '${sh_norm}
# New files and folders should not be world readable
umask 0027
# Borrow features from sensible.bash
# Trim long paths in prompt
PROMPT_DIRTRIM=2
# Update window size after every command
shopt -s checkwinsize
# Append history don't overwrite
shopt -s histappend
# Save multi-line commands as one line
shopt -s cmdhist
# Avoid duplicate entries
export HISTCONTROL="erasedups:ignoreboth"
# Use ISO8601 time format for history file.
export HISTTIMEFORMAT='%F %T '
# Big history file
HISTSIZE=500000
HISTFILESIZE=100000
# Aliases!
# jump down the tree.
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
# empty the screen (or use C-l)
alias c="clear"
# why wouldn't you want human readable sizes?
alias df="df -h"
# get outta here!
alias e="exit"
# grep shortie
alias g="grep --color=auto -i "
# get shortcuts.
alias ga="git add"
alias gc="git commit"
alias gd="git diff"
alias gp="git push"
alias gs="git status"
# shorter ls
alias l="ls -G"
# list files with details
alias ll="ls -lh"
# list all files.
alias la="ls -alh"
# List directories.
alias ld="ls -Gd */"
# Find out what connections are happening.
alias lsconn="sudo lsof -i -P"
# add some color to grep.
alias grep="grep --color=auto"
# make the whole directory tree if required and let us know about it.
alias mkdir="mkdir -p -v "
# don't ping forever.
#alias ping="ping -c5"
# refresh the shell customizations without opening a new one.
alias refresh="source ~/.bashrc"
# A python calculator
alias pc='python -ic "from __future__ import division; from math import *"'
# Start nano with line numbering no wrapping and autoindenting
alias nano='nano -ciw '
if [[ $(uname) = 'Darwin' ]]; then
# Open man file in Preview.app.
pman () {
man -t "${1}" | open -f -a /Applications/Preview.app
}
fi
# General purpose extract command.
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.tar.xz) tar xJf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7za e $1 ;;
*.xz) xz -dv $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
# General purpose backup command.
bu () { tar czf ~/.backup/`basename $1`-`date +%Y%m%d%H%M`.tgz $1; }
# History Search
h () { grep "$1" ~/.history/*; }
# Search for a process:
p () {
if [ ! -z $1 ] ; then
ps aux | grep $1 | grep -v grep
else
echo "must provide search string"
fi
}
# Find a file in the current tree.
f () {
if [ ! -z $1 ] ; then
find . | grep $1
#find . -name $1 -print;
fi
}
# Repeat function, do something until you ^C out of it.
# Syntax: r sleep_time_in_seconds command_to_run
r () {
if [ ! -z $1 ]
then
if [ ! -z $2 ]
then
while [ yes ]
do
$2
echo ""
sleep $1
done
else
echo "Must have a command for second argument"
fi
else
echo "Simple function to loop a command."
echo "Example, to print the date every 5 seconds:"
echo "$ r 5 date"
fi
}
# Function to count IP address found in file(s)
count-IPs () {
grep -E -o -h '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)' |\
sed -E 's/([0-9]*\.[0-9]*)\.[0-9]*\.[0-9]*/\1/' | \
uniq -c | \
sort -r
}
# Import local extensions if needed.
if [ -f $HOME/.bashrc_local ]; then
source $HOME/.bashrc_local
fi

81
conky/.conkyrc Normal file
View file

@ -0,0 +1,81 @@
background no
font Sans:size=8
#xftfont Sans:size=10
use_xft yes
xftalpha 0.8
update_interval 2.0
total_run_times 0
own_window yes
own_window_type normal
own_window_argb_visual true
own_window_transparent yes
#own_windiw_class conky
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
double_buffer yes
minimum_size 200 5
maximum_width 400
draw_shades yes
draw_outline no
draw_borders no
draw_graph_borders yes
default_color CDE0E7
default_shade_color black
default_outline_color green
alignment top_right
gap_y 35
no_buffers yes
uppercase no
cpu_avg_samples 2
override_utf8_locale no
uppercase yes # set to yes if you want all text to be in uppercase
TEXT
${color CDE0E7}${font OxygenSans:pixelsize=70}${time %l:%M %P}${font}
${hr 1}
${font OxygenSans:pixelsize=20}${time %A} $alignr${color white}${time %Y}-${color white}${time %m}-${color white}${time %d}${font}
${color white}SYSTEM ${hr 3}${color}
Hostname: $alignr$nodename
Uptime: $alignr$uptime
Kernel: $alignr$kernel
Load: $alignr$loadavg
CPU1 ${alignr}${cpu cpu1}%
${cpubar 4 cpu1}
CPU2 ${alignr}${cpu cpu2}%
${cpubar 4 cpu2}
Ram ${alignr}$mem / $memmax ($memperc%)
${membar 4}
Swap ${alignr} $swap / $swapmax ($swapperc%)
${swapbar 4}
Highest CPU $alignr CPU% MEM%
${color aaaaaa}${top name 1}$alignr${top cpu 1}${top mem 1}
${top name 2}$alignr${top cpu 2}${top mem 2}
${top name 3}$alignr${top cpu 3}${top mem 3}${color}
Highest MEM $alignr CPU% MEM%
${color aaaaaa}${top_mem name 1}$alignr${top_mem cpu 1}${top_mem mem 1}
${top_mem name 2}$alignr${top_mem cpu 2}${top_mem mem 2}
${top_mem name 3}$alignr${top_mem cpu 3}${top_mem mem 3}${color}
${color white}Filesystem ${hr 3}${color}
Root (/): ${alignr}${fs_used /} / ${fs_size /}
${fs_bar 4 /}
${color white}NETWORK ${hr 3}${color}
${if_existing /proc/sys/net/ipv4/conf/eth0}
eth0: ${addr eth0}${color aaaaaa}
Down ${downspeed eth0}/s ${alignr}Up ${upspeed eth0}/s
${downspeedgraph eth0 25,107} ${alignr}${upspeedgraph eth0 25,107}
Total ${totaldown eth0} ${alignr}Total ${totalup eth0}${color}
${endif}
${if_existing /proc/sys/net/ipv4/conf/eth1}
eth0: ${addr eth1}${color aaaaaa}
Down ${downspeed eth1} k/s ${alignr}Up ${upspeed eth1} k/s
${downspeedgraph eth1 25,107} ${alignr}${upspeedgraph eth1 25,107}
Total ${totaldown eth1} ${alignr}Total ${totalup eth1}${color}
${endif}

33
git/.gitconfig Normal file
View file

@ -0,0 +1,33 @@
[user]
name = Andrew Davidson
email = andrew@amdavidson.com
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
[color "status"]
added = yellow
changed = green
untracked = cyan
[color]
ui = true
diff = auto
status = auto
branch = auto
[color "diff"]
whitespace = red reverse
[core]
whitespace=fix,-indent-with-non-tab,trailing-space,cr-at-eol
[alias]
lg = "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
[push]
default = simple

134
i3/.i3/config Normal file
View file

@ -0,0 +1,134 @@
# i3 config file (v4)
#font pango:DejaVu Sans Mono 8
font pango:Droid Sans 8
# use these keys for focus, movement, and resize directions when reaching for
# the arrows is not convenient
set $up k
set $down j
set $left h
set $right l
# use Mouse+Mod4 to drag floating windows to their wanted position
floating_modifier Mod4
# start a terminal
bindsym Mod4+Return exec i3-sensible-terminal
# kill focused window
bindsym Mod4+Shift+q kill
# start dmenu (a program launcher)
bindsym Mod4+d exec dmenu_run
# There also is the (new) i3-dmenu-desktop which only displays applications
# shipping a .desktop file. It is a wrapper around dmenu, so you need that
# installed.
# bindsym Mod4+d exec --no-startup-id i3-dmenu-desktop
# change focus
bindsym Mod4+$left focus left
bindsym Mod4+$down focus down
bindsym Mod4+$up focus up
bindsym Mod4+$right focus right
# move focused window
bindsym Mod4+Shift+$left move left
bindsym Mod4+Shift+$down move down
bindsym Mod4+Shift+$up move up
bindsym Mod4+Shift+$right move right
# split in horizontal orientation
bindsym Mod4+Shift+v split h
# split in vertical orientation
bindsym Mod4+v split v
# enter fullscreen mode for the focused container
bindsym Mod4+f fullscreen toggle
# change container layout (stacked, tabbed, toggle split)
bindsym Mod4+s layout stacking
bindsym Mod4+w layout tabbed
bindsym Mod4+e layout toggle split
# toggle tiling / floating
bindsym Mod4+Shift+space floating toggle
# change focus between tiling / floating windows
bindsym Mod4+space focus mode_toggle
# focus the parent container
bindsym Mod4+a focus parent
# move the currently focused window to the scratchpad
bindsym Mod4+Shift+minus move scratchpad
# Show the next scratchpad window or hide the focused scratchpad window.
# If there are multiple scratchpad windows, this command cycles through them.
bindsym Mod4+minus scratchpad show
# switch to workspace
bindsym Mod4+1 workspace 1
bindsym Mod4+2 workspace 2
bindsym Mod4+3 workspace 3
bindsym Mod4+4 workspace 4
bindsym Mod4+5 workspace 5
bindsym Mod4+6 workspace 6
bindsym Mod4+7 workspace 7
bindsym Mod4+8 workspace 8
bindsym Mod4+9 workspace 9
bindsym Mod4+0 workspace 10
# move focused container to workspace
bindsym Mod4+Shift+1 move container to workspace 1
bindsym Mod4+Shift+2 move container to workspace 2
bindsym Mod4+Shift+3 move container to workspace 3
bindsym Mod4+Shift+4 move container to workspace 4
bindsym Mod4+Shift+5 move container to workspace 5
bindsym Mod4+Shift+6 move container to workspace 6
bindsym Mod4+Shift+7 move container to workspace 7
bindsym Mod4+Shift+8 move container to workspace 8
bindsym Mod4+Shift+9 move container to workspace 9
bindsym Mod4+Shift+0 move container to workspace 10
# kill focused window
#bindsym Mod4+Shift+q kill
# reload the configuration file
bindsym Mod4+Shift+c reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym Mod4+Shift+r restart
# exit i3 (logs you out of your X session)
bindsym Mod4+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
bindsym $left resize shrink width 1 px or 1 ppt
bindsym $down resize grow height 1 px or 1 ppt
bindsym $up resize shrink height 1 px or 1 ppt
bindsym $right resize grow width 1 px or 1 ppt
# back to normal: Enter or Escape
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym Mod4+r mode "resize"
# Set window gaps
smart_borders on
smart_gaps on
gaps inner 10
gaps outer 0
focus_follows_mouse no
# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
bar {
position top
status_command i3status
}

40
i3/.i3status.conf Normal file
View file

@ -0,0 +1,40 @@
# i3status configuration file.
# see "man i3status" for documentation.
# It is important that this file is edited as UTF-8.
# The following line should contain a sharp s:
# ß
# If the above line is not correctly displayed, fix your editor first!
general {
colors = false
interval = 5
}
order += "disk /"
order += "ethernet _first_"
order += "battery 0"
order += "load"
order += "tztime local"
ethernet _first_ {
# if you use %speed, i3status requires root privileges
format_up = "Ethernet: %ip (%speed)"
format_down = "Ethernet: down"
}
battery 0 {
format = "%status %percentage %remaining"
}
tztime local {
format = "%Y-%m-%d %H:%M:%S"
}
load {
format = "%1min"
}
disk "/" {
format = "HD: %avail"
}

View file

@ -0,0 +1,32 @@
[addressbooks]
[[Default]]
path = ~/.contacts/Default
[general]
debug = no
default_action = list
editor = vim
merge_editor = vimdiff
[contact table]
# display names by first or last name: first_name / last_name
display = first_name
# group by address book: yes / no
group_by_addressbook = no
# reverse table ordering: yes / no
reverse = no
# append nicknames to name column: yes / no
show_nicknames = no
# show uid table column: yes / no
show_uids = no
# sort by first or last name: first_name / last_name
sort = last_name
# localize dates: yes / no
localize_dates = yes
[vcard]
# Look into source vcf files to speed up search queries: yes / no
search_in_source_files = no
# skip unparsable vcard files: yes / no
skip_unparsable = no

View file

@ -0,0 +1,20 @@
[general]
status_path = "~/.vdirsyncer/status/"
[pair my_contacts]
a = "my_contacts_local"
b = "my_contacts_remote"
collections = ["from a", "from b"]
[storage my_contacts_local]
type = "filesystem"
path = "~/.contacts/"
fileext = ".vcf"
[storage my_contacts_remote]
type = "carddav"
url = "https://carddav.fastmail.com"
username.fetch = ["command", "~/bin/pw.sh", "CARDDAV_USERNAME"]
password.fetch = ["command", "~/bin/pw.sh", "CARDDAV_PASSWORD"]

View file

@ -0,0 +1,94 @@
[Background]
Color=40,42,54
[BackgroundFaint]
Color=40,42,54
[BackgroundIntense]
Color=40,42,54
[Color0]
Color=189,147,249
[Color0Faint]
Color=189,147,249
[Color0Intense]
Color=189,147,249
[Color1]
Color=255,85,85
[Color1Faint]
Color=255,85,85
[Color1Intense]
Color=255,85,85
[Color2]
Color=80,250,123
[Color2Faint]
Color=80,250,123
[Color2Intense]
Color=80,250,123
[Color3]
Color=255,121,198
[Color3Faint]
Color=255,121,198
[Color3Intense]
Color=255,121,198
[Color4]
Color=139,233,253
[Color4Faint]
Color=139,233,253
[Color4Intense]
Color=139,233,253
[Color5]
Color=241,250,140
[Color5Faint]
Color=241,250,140
[Color5Intense]
Color=241,250,140
[Color6]
Color=98,114,164
[Color6Faint]
Color=98,114,164
[Color6Intense]
Color=98,114,164
[Color7]
Color=68,71,90
[Color7Faint]
Color=68,71,90
[Color7Intense]
Color=68,71,90
[Foreground]
Color=248,248,242
[ForegroundFaint]
Color=248,248,242
[ForegroundIntense]
Color=248,248,242
[General]
Description=Dracula
Opacity=1
Wallpaper=

6
mutt/.mailcap Normal file
View file

@ -0,0 +1,6 @@
text/html; firefox %s && sleep 5; test=test -n "$DISPLAY";
text/html; links -html-numbered-links 1 -dump %s; nametemplate=%s.html; copiousoutput
#text/html; w3m -I %{charset} -T text/html; copiousoutput;
text/plain; vim %s;

169
mutt/.muttrc Normal file
View file

@ -0,0 +1,169 @@
# Paths ---------------------
set folder = ~/.maildir
set alias_file = ~/.mutt/alias
set header_cache = ~/.mutt/cache/headers
set message_cachedir = ~/.mutt/cache/bodies
set certificate_file = ~/.mutt/certificates
set mailcap_path = ~/.mailcap
set tmpdir = ~/.mutt/temp
set signature = ~/.sig
# Options -------------------
set wait_key = no
set mbox_type = Maildir
set timeout = 3
set mail_check = 0
unset move
set delete
unset confirmappend
set quit
unset mark_old
set pipe_decode
set thorough_search
# Sidebar -------------------
set sidebar_visible = yes
set sidebar_width = 20
set sidebar_short_path = yes
set sidebar_format = "%B%?F? [%F]?%* %?N?%N/?%S"
color sidebar_new color221 color233
# Header Options ------------
ignore *
unignore from: reply-to: to: cc: bcc: date: subject: x-Spam-score: list-id:
unhdr_order *
hdr_order from: reply-to: to: cc: bcc: date: subject: x-Spam-score: list-id:
# Setup IMAP -------------------
set my_pass=`~/bin/pw.sh IMAP_PASSWORD`
set my_user=`~/bin/pw.sh IMAP_USERNAME`
set folder = "imaps://$my_user:$my_pass@imap.fastmail.com:993"
set spoolfile= "+INBOX"
set record = +Sent
set postponed = +Drafts
set trash = +Trash
set imap_check_subscribed = yes
# Setup SMTP -------------------
set smtp_url=smtp://$my_user:$my_pass@smtp.fastmail.com:587
set ssl_force_tls=yes
#set ssl_starttls=yes
# Mailboxes -----------------
# source ~/.mutt/mailboxes
# Index ---------------------
set date_format = "%m/%d"
set index_format = "[%Z] %D %-20.20F %s"
set sort = threads
set sort_aux = reverse-last-date-received
set uncollapse_jump
set sort_re
set reply_regexp = "^(([Rr][Ee]?(\[[0-9]+\])?: *)?(\[[^]]+\] *)?)*"
bind index R group-reply
bind index <tab> sync-mailbox
bind index <space> collapse-thread
macro index / "<enter-command>unset wait_key<enter><shell-escape>mutt-notmuch-py<enter><change-folder-readonly>~/.cache/mutt_results<enter>" \
"search mail (using notmuch)"
macro index \Cr "T~U<enter><tag-prefix><clear-flag>N<untag-pattern>.<enter>" "mark all messages as read"
macro index,pager o "<shell-escape>$HOME/bin/fastmail.sh<enter>" "run offlineimap to sync fastmail"
macro index,pager C "<copy-message>?<toggle-mailboxes>" "copy a message to a mailbox"
macro index,pager s "<save-message>?<toggle-mailboxes>" "move a message to a mailbox"
bind index D purge-message
bind index,pager <down> sidebar-next
bind index,pager <up> sidebar-prev
bind index,pager <right> sidebar-open
# Pager View -----------------
set pager_index_lines = 10 # number of index lines to show
set pager_context = 3 # number of context lines to show
set pager_stop # don't go to next message automatically
set menu_scroll # scroll in menus
set tilde # show tildes like in vim
unset markers # no ugly plus signs
set quote_regexp = "^( {0,4}[>|:#%]| {0,4}[a-z0-9]+[>|]+)+"
alternative_order text/plain text/enriched text/html
# Pager Bindings -------------
bind pager k previous-line
bind pager j next-line
bind pager R group-reply
# View attachments properly.
bind attach <return> view-mailcap
auto_view text/html
macro pager \Cu "|urlview<enter>" "call urlview to open links"
# Setup Identity
set realname="Andrew Davidson"
set from="andrew@amdavidson.com"
# Setup VIM for editing headers
set edit_headers
set editor="vim +':set textwidth=0' +':set wrapmargin=0' +':set wrap' +':set linebreak' +':set nolist' +/^$ ++1"
# Contacts shortcuts
set query_command = "khard email --parsable --search-in-source-files '%s'"
bind editor <Tab> complete-query
bind editor ^T complete
macro index,pager A "<pipe-message>khard add-email<return>" "add the sender email address to khard"
# Some neat stuff.
set fcc_attach=yes # Forward attachments.
unset reply_self # Don't include myself when replying to all
set smart_wrap # wrap text smartly and don't clip words.
set forward_format='Fwd: %s' # make the forwarding subject line look more like other clients.
set forward_decode
set reply_to
set reverse_name
set include
set forward_quote
# Crypto stuff
set pgp_decode_command="gpg %?p?--passphrase-fd 0? --no-verbose --batch --output - %f"
set pgp_verify_command="gpg --no-verbose --batch --output - --verify %s %f"
set pgp_decrypt_command="gpg --passphrase-fd 0 --no-verbose --batch --output - %f"
set pgp_sign_command="gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --detach-sign --textmode %?a?-u %a? %f"
set pgp_clearsign_command="gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --textmode --clearsign %?a?-u %a? %f"
set pgp_encrypt_only_command="pgpewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --always-trust --encrypt-to 0x49CF25C6 -- -r %r -- %f"
set pgp_encrypt_sign_command="pgpewrap gpg --passphrase-fd 0 --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust --encrypt-to 0x49CF25C6 -- -r %r -- %f"
set pgp_import_command="gpg --no-verbose --import -v %f"
set pgp_export_command="gpg --no-verbose --export --armor %r"
set pgp_verify_key_command="gpg --no-verbose --batch --fingerprint --check-sigs %r"
set pgp_list_pubring_command="gpg --no-verbose --batch --with-colons --list-keys %r"
set pgp_list_secring_command="gpg --no-verbose --batch --with-colons --list-secret-keys %r"
# Sign emails as me.
set pgp_sign_as=0x49CF25C6
# Automatically sign emails.
#set crypt_autosign
# Reply to signed emails with a signed email.
set crypt_replysign
# Encrypt and sign replies to signed emails.
# set crypt_replyencrypt=yes
# Encrypt and sign replies to encrypted emails.
set crypt_replysignencrypted=yes
# Time out of GPG after xx seconds.
set pgp_timeout=28800
# Automatically verify signatures.
set crypt_verify_sig=yes

View file

@ -0,0 +1,5 @@
#! /usr/bin/env python2
from subprocess import check_output
def get_pass():
return check_output("~/bin/pw.sh IMAP_PASSWORD", shell=True).strip("\n")

View file

@ -0,0 +1,37 @@
[general]
accounts = Personal
ui = basic
#ui = blinkenlights
maxsynaccounts = 1
pythonfile = ~/.offlineimap.py
[mbnames]
enabled = yes
filename = ~/.mutt/mailboxes
header = "mailboxes "
peritem = "+%(foldername)s"
sep = " "
footer = "\n"
[Account Personal]
localrepository = Local
remoterepository = Remote
postsynchook = notmuch new
# autorefresh = 1
# quick = 10
[Repository Local]
type = Maildir
localfolders = ~/.maildir
sep = .
restoreatime = no
[Repository Remote]
type = IMAP
remotehost = imap.fastmail.com
remoteuser = andrew@amdavidson.com
remotepasseval = get_pass()
maxconnections = 5
keepalive = 60
# holdconnectionopen = yes

9
offlineimap/bin/fastmail.sh Executable file
View file

@ -0,0 +1,9 @@
#!/bin/bash
if [[ "$OSTYPE" == "linux-gnu" ]]; then
/usr/bin/offlineimap -k Repository_Remote:sslcacertfile=/etc/ssl/certs/ca-certificates.crt -c $HOME/.offlineimaprc_fastmail
elif [[ "$OSTYPE" == "darwin"* ]]; then
/usr/local/bin/offlineimap -k Repository_Remote:sslcacertfile=/usr/local/etc/openssl/cert.pem -c $HOME/.offlineimaprc_fastmail
else
echo "Offlineimap not configured to access Fastmail on $OSTYPE"
fi

44
tmux/.tmux.conf Normal file
View file

@ -0,0 +1,44 @@
# Support 256 colors rather than 16.
#set -g default-terminal "screen-256color"
# True color support in tmux
set -g default-terminal "xterm-256color"
set-option -ga terminal-overrides ",xterm-256color:Tc"
# Big history.
set -g history-limit 10000
# Make the status bar pretty.
set -g status-bg colour16
set -g status-fg colour61
set-window-option -g window-status-current-bg colour236
set-window-option -g window-status-current-fg colour141
# Add some info to the status bar
set -g status-right "#H | up #(uptime | awk '{print $3}' | sed 's/,//') days | #(~/bin/tmux-free-memory.sh) free"
# Auto-set window title
setw -g automatic-rename
# Make mouse useful
set -g mouse on
# Add vim keys to navigate
set-window-option -g mode-keys vi
# Add key to reload ~/.tmux.conf
bind r source-file ~/.tmux.conf
# More logical (to me) split keys.
bind - split-window -p 38 -v
bind | split-window -p 38 -h
# Keybindings for resizing panes that don't collide with OSX bindings
bind -r C-h resize-pane -L
bind -r C-j resize-pane -D
bind -r C-k resize-pane -U
bind -r C-l resize-pane -R
# Start a new session if one doesn't exist.
new-session

10
tmux/bin/tmux-free-memory.sh Executable file
View file

@ -0,0 +1,10 @@
#!/bin/bash
if [[ "$OSTYPE" == "linux-gnu" ]]; then
free -m | head -n 2 | tail -n 1 | awk '{print $7}'
elif [[ "$OSTYPE" == "darwin"* ]]; then
vm_stat | awk 'BEGIN{FS="[:]+"}{if(NR<7&&NR>1)sum+=$2; if(NR==2||NR==4||NR==5)free+=$2} END{printf "%3d%%\n",100*((sum - free)/sum)}'
else
echo "?"
fi

3
vim/.vim/.netrwhist~ Normal file
View file

@ -0,0 +1,3 @@
let g:netrw_dirhistmax =10
let g:netrw_dirhist_cnt =1
let g:netrw_dirhist_1='/home/amdavidson/.dotfiles'

2504
vim/.vim/autoload/plug.vim Normal file

File diff suppressed because it is too large Load diff

164
vim/.vimrc Normal file
View file

@ -0,0 +1,164 @@
" ==================== Plugins ====================
call plug#begin()
" Airline
Plug 'bling/vim-airline'
" Git integration
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
" Dracula theme
Plug 'dracula/vim'
" Sayonara
Plug 'mhinz/vim-sayonara', { 'on': 'Sayonara' }
" Go support for Vim
Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }
call plug#end()
" ==================== Vim Settings ====================
set number " show line numbers
set backspace=indent,eol,start " backspace all the things
set showcmd " show the command while typing it
set noswapfile " no swap files needed
set nobackup " backup files are clutter
set nowritebackup
set splitright " configure default splits
set splitbelow
set encoding=utf-8 " default to utf-8 encoding
set autowrite " save before :next etc.
set autoread " automatically pull in changes
set hidden " allow buffers to be hidden with changes
au FocusLost * :wa " save when focus is lost
set incsearch " show matches while typing search string
set hlsearch " highlight all search matches
set ignorecase " search case insensitively
set smartcase " use case when the search string has uppercase
set ttyfast " assume we can handle faster refreshing
set lazyredraw " do not redraw when running functions
set scrolloff=5 " start scrolling 3 lines before bottom
set showmatch " quickly show the matching bracket
set autoindent " self explanatory
set smarttab " setup tabs to be four spaces
set tabstop=4 " setup tabs to be four spaces
set shiftwidth=4 " setup tabs to be four spaces
set expandtab " setup tabs to be four spaces
set shiftround " use rounding when shifting tabs and spacing is uneven
set clipboard=unnamed " use system clipboard
" Scroll by row rather than line so wrapped lines get included.
nnoremap j gj
nnoremap k gk
" never do this again --> :set paste <ctrl-v> :set no paste
let &t_SI .= "\<Esc>[?2004h"
let &t_EI .= "\<Esc>[?2004l"
inoremap <special> <expr> <Esc>[200~ XTermPasteBegin()
function! XTermPasteBegin()
set pastetoggle=<Esc>[201~
set paste
return ""
endfunction
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
"==================== golang ====================
autocmd FileType go nnoremap <buffer> <F9> :! go run *.go<cr>
else
endif " has("autocmd")
"==================== colorscheme ====================
let g:dracula_colorterm = 0
colorscheme dracula
" ==================== Code Folding ====================
set nofoldenable
set foldlevel=2
set foldmethod=indent
" ==================== Functions ====================
command! CLEAN retab | %s/\s\+$//
" ==================== Keyboard Shortcuts ====================
" set our leader key to space
let mapleader = " "
let g:mapleader = " "
" quit smartly
nnoremap <leader>q :Sayonara<cr>
" Remove search highlight
nnoremap <leader>h :noh<CR>
" Buffer prev/next
nnoremap <leader>n :bnext<CR>
nnoremap <leader>p :bprev<CR>
" Fast saving
nnoremap <leader>w :w!<cr>
" list buffers
nnoremap <leader>v :ls<cr>
" Better split switching
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Just go out in insert mode
imap jk <ESC>l
" Do not show stupid q: window
map q: :q
" Allow saving of files as sudo when I forgot to start vim using sudo.
cmap w!! w !sudo tee > /dev/null %
" Go shortcuts just for .go files
autocmd FileType go nmap <leader>b <Plug>(go-build)
autocmd FileType go nmap <leader>r <Plug>(go-run)
autocmd FileType go nmap <leader>t <Plug>(go-test)
" ==================== Fugitive ====================
nnoremap <leader>ga :Git add %:p<CR><CR>
nnoremap <leader>gs :Gstatus<CR>
nnoremap <leader>gp :Gpush<CR>
vnoremap <leader>gb :Gblame<CR>

14
zsh/.zsh/aliases.zsh Normal file
View file

@ -0,0 +1,14 @@
# Lazy
alias ..='cd ..'
alias lh='ls -d .*' # show hidden files/directories only
alias lsd='ls -aFhlG'
alias l='ls -al'
alias ls='ls -GFh' # Colorize output, add file type indicator, and put sizes in human readable format
alias ll='ls -GFhl' # Same as above, but in long listing format
# List directories sorted by size
alias dus='du -sckx * | sort -nr'
# Refresh when settings have been updated
alias refresh='source ~/.zshrc'

15
zsh/.zsh/bindkeys.zsh Normal file
View file

@ -0,0 +1,15 @@
# To see the key combo you want to use just do:
# cat > /dev/null
# And press it
bindkey "^K" kill-whole-line # ctrl-k
bindkey "^R" history-incremental-search-backward # ctrl-r
bindkey "^A" beginning-of-line # ctrl-a
bindkey "^E" end-of-line # ctrl-e
bindkey "^[[B" history-search-forward # down arrow
bindkey "^[[A" history-search-backward # up arrow
bindkey "^D" delete-char # ctrl-d
bindkey "^F" forward-char # ctrl-f
bindkey "^B" backward-char # ctrl-b
#bindkey -v # Default to standard vi bindings, regardless of editor string

20
zsh/.zsh/checks.zsh Normal file
View file

@ -0,0 +1,20 @@
# checks (stolen from zshuery)
if [[ $(uname) = 'Linux' ]]; then
IS_LINUX=1
fi
if [[ $(uname) = 'Darwin' ]]; then
IS_MAC=1
fi
if [[ -x `which brew` ]]; then
HAS_BREW=1
fi
if [[ -x `which apt-get` ]]; then
HAS_APT=1
fi
if [[ -x `which yum` ]]; then
HAS_YUM=1
fi

22
zsh/.zsh/colors.zsh Normal file
View file

@ -0,0 +1,22 @@
autoload colors; colors
# The variables are wrapped in \%\{\%\}. This should be the case for every
# variable that does not contain space.
for COLOR in RED GREEN YELLOW BLUE MAGENTA CYAN BLACK WHITE; do
eval PR_$COLOR='%{$fg_no_bold[${(L)COLOR}]%}'
eval PR_BOLD_$COLOR='%{$fg_bold[${(L)COLOR}]%}'
done
eval RESET='$reset_color'
export PR_RED PR_GREEN PR_YELLOW PR_BLUE PR_WHITE PR_BLACK
export PR_BOLD_RED PR_BOLD_GREEN PR_BOLD_YELLOW PR_BOLD_BLUE
export PR_BOLD_WHITE PR_BOLD_BLACK
# Clear LSCOLORS
unset LSCOLORS
# Main change, you can see directories on a dark background
#expor tLSCOLORS=gxfxcxdxbxegedabagacad
export CLICOLOR=1
export LS_COLORS=exfxcxdxbxegedabagacad

55
zsh/.zsh/completion.zsh Normal file
View file

@ -0,0 +1,55 @@
autoload -U compinit && compinit
zmodload -i zsh/complist
# man zshcontrib
zstyle ':vcs_info:*' actionformats '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '
zstyle ':vcs_info:*' formats '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{5}]%f '
zstyle ':vcs_info:*' enable git
# Enable completion caching, use rehash to clear
zstyle ':completion::complete:*' use-cache on
zstyle ':completion::complete:*' cache-path ~/.zsh/cache/$HOST
# Fallback to built in ls colors
zstyle ':completion:*' list-colors ''
# Make the list prompt friendly
zstyle ':completion:*' list-prompt '%SAt %p: Hit TAB for more, or the character to insert%s'
# Make the selection prompt friendly when there are a lot of choices
zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s'
# Add simple colors to kill
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
# list of completers to use
#zstyle ':completion:*::::' completer _expand _complete _ignored _approximate
zstyle ':completion:*::::' completer _complete _ignored _approximate
zstyle ':completion:*' menu select=1 _complete _ignored _approximate
# insert all expansions for expand completer
# zstyle ':completion:*:expand:*' tag-order all-expansions
# match uppercase from lowercase
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
# offer indexes before parameters in subscripts
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
# formatting and messages
zstyle ':completion:*' verbose yes
zstyle ':completion:*:descriptions' format '%B%d%b'
zstyle ':completion:*:messages' format '%d'
zstyle ':completion:*:warnings' format 'No matches for: %d'
zstyle ':completion:*:corrections' format '%B%d (errors: %e)%b'
zstyle ':completion:*' group-name ''
# ignore completion functions (until the _ignored completer)
zstyle ':completion:*:functions' ignored-patterns '_*'
zstyle ':completion:*:scp:*' tag-order files users 'hosts:-host hosts:-domain:domain hosts:-ipaddr"IP\ Address *'
zstyle ':completion:*:scp:*' group-order files all-files users hosts-domain hosts-host hosts-ipaddr
zstyle ':completion:*:ssh:*' tag-order users 'hosts:-host hosts:-domain:domain hosts:-ipaddr"IP\ Address *'
zstyle ':completion:*:ssh:*' group-order hosts-domain hosts-host users hosts-ipaddr
zstyle '*' single-ignored show

17
zsh/.zsh/exports.zsh Normal file
View file

@ -0,0 +1,17 @@
# Set PATH
export PATH=~/bin:~/.local/bin:/usr/local/bin:/usr/local/sbin:$PATH
# Setup terminal environment
export TERM=xterm-256color
export CLICOLOR=1
export LSCOLORS=Gxfxcxdxbxegedabagacad
# Enable grep colors
export GREP_COLOR='3;33'
# VIM everything
export EDITOR='vim'
# Fix gnupg
export GPG_TTY=$(tty)

56
zsh/.zsh/functions.zsh Normal file
View file

@ -0,0 +1,56 @@
# Truncate working directory
function truncated_pwd() {
n=$1
path=`collapse_pwd`
dirs=("${(s:/:)path}")
dirs_length=$#dirs
if [[ $dirs_length -ge $n ]]; then
((max=dirs_length - n))
for (( i = 1; i <= $max; i++ )); do
step="$dirs[$i]"
if [[ -z $step ]]; then
continue
fi
if [[ $stem =~ "^\." ]]; then
dirs[$i]=$step[0,2]
else
dirs[$i]=$step[0,1]
fi
done
fi
echo ${(j:/:)dirs}
}
function collapse_pwd {
echo $(pwd | sed -e "s,^$HOME,~,")
}
# Extract anything
extract() {
if [[ -f $1 ]]; then
case $1 in
*.tar.bz2) tar xvjf $1;;
*.tar.gz) tar xvzf $1;;
*.tar.xz) tar xvJf $1;;
*.tar.lzma) tar --lzma xvf $1;;
*.bz2) bunzip $1;;
*.rar) unrar $1;;
*.gz) gunzip $1;;
*.tar) tar xvf $1;;
*.tbz2) tar xvjf $1;;
*.tgz) tar xvzf $1;;
*.zip) unzip $1;;
*.Z) uncompress $1;;
*.7z) 7z x $1;;
*.dmg) hdiutul mount $1;; # mount OS X disk images
*) echo "'$1' cannot be extracted via >ex<";;
esac
else
echo "'$1' is not a valid file"
fi
}

20
zsh/.zsh/hooks.zsh Normal file
View file

@ -0,0 +1,20 @@
function precmd {
# vcs_info
# Put the string "hostname::/full/directory/path" in the title bar:
echo -ne "\e]2;$PWD\a"
# Put the parentdir/currentdir in the tab
echo -ne "\e]1;$PWD:h:t/$PWD:t\a"
}
function set_running_app {
printf "\e]1; $PWD:t:$(history $HISTCMD | cut -b7- ) \a"
}
function preexec {
set_running_app
}
function postexec {
set_running_app
}

114
zsh/.zsh/options.zsh Normal file
View file

@ -0,0 +1,114 @@
### Basics
# Do not beep on errors
setopt no_beep
# allow comments in interactive shells
setopt interactive_comments
### History
HISTSIZE=10000
SAVEHIST=9000
HISTFILE=~/.zsh_history
### Directories
# auto change directories if you type a directory with no cd
setopt auto_cd
# do not push multiple copies of the same directory onto the directory stack
setopt pushd_ignore_dups
### Expansion and Globbing
# treat #, ~, and ^ as part of patterns for file name generation
setopt extended_glob
### History
# allow multiple terminal sessions but append to a unified history
# setopt append_history
# save timestamp and duration to history
setopt extended_history
# save commands as they are typed, don't wait for shell exit
# setopt inc_append_history
# Delete oldest dupes first
setopt hist_expire_dups_first
# Do not add dupes to history
# setopt hist_ignore_dups
# Ignore commands that begin with a space
setopt hist_ignore_space
# Do not show dupes twice in history search
setopt hist_find_no_dups
# Remove extra blanks from commands being added to history
setopt hist_reduce_blanks
# Dont execute just expand history
setopt hist_verify
# imports new commands and appends typed commands to history
setopt share_history
### Completion
# When completing from the middle of the word, move cursor to end of word
setopt always_to_end
# Show cmopletion menu on multiple tab presses
setopt auto_menu
# any parameter that is set to the absolute name of a directory immediately
# becomes a name for that directory
# setopt auto_name_dirs
# Allow completion from within a word/phrase
setopt complete_in_word
# Do not autoselect the first completion entry
unsetopt menu_complete
### Correction
# Enable spelling correction for commands
setopt correct
# Enable spelling correciton for arguments
setopt correctall
### Prompt
# Enable parameter expansion, command substitution, and arithmetic expansion
setopt prompt_subst
# Only show rprompt on current prompt
setopt transient_rprompt
### Scripts and Functions
# Perform implicit tees or cats when multiple redirections are attempted
setopt multios

36
zsh/.zsh/prompt.zsh Normal file
View file

@ -0,0 +1,36 @@
#setopt promptsubst
autoload -U colors && colors # Enable colors in prompt
# Show Git branch/tag, or name-rev if on detached head
function git_branch {
local FULL_BRANCH="$(git symbolic-ref -q HEAD 2>/dev/null || git name-rev --name-only --no-undefined --always HEAD 2>/dev/null)"
local SHORT_BRANCH="$(echo $FULL_BRANCH | sed 's/refs\/heads\///')"
echo " %F{blue}$SHORT_BRANCH%f"
}
function git_is_ahead {
local NUM_AHEAD="$(git log --oneline @{u}.. 2>/dev/null | wc -l | tr -d ' ')"
if [ "$NUM_AHEAD" -gt 0 ]; then
echo " %F{red}↑%f"
fi
}
function git_is_behind {
local NUM_BEHIND="$(git log --oneline ..@{u} 2>/dev/null | wc -l | tr -d ' ' )"
if [ "$NUM_BEHIND" -gt 0 ]; then
echo " %F{blue}↓%f"
fi
}
function git_unstaged {
local CHANGED=$(git status --porcelain --ignore-submodule -unormal 2>/dev/null | wc -l)
if [ $CHANGED -gt 0 ]; then
echo -e "%F{yellow}~%f\c"
fi
}
function current_pwd {
echo $(pwd | sed -e "s,^$HOME,~,")
}
PROMPT='${PR_BOLD_YELLOW}$(truncated_pwd 3)$(git_branch)%{$reset_color%}$(git_unstaged)$(git_is_ahead)$(git_is_behind) %(?.%F{magenta}.%F{red})%f '

18
zsh/.zshrc Normal file
View file

@ -0,0 +1,18 @@
if [[ $TERM = 'dumb' ]]; then
export PS1='dumbterm> '
else
source ~/.zsh/checks.zsh
source ~/.zsh/colors.zsh
source ~/.zsh/options.zsh
source ~/.zsh/exports.zsh
source ~/.zsh/prompt.zsh
source ~/.zsh/completion.zsh
source ~/.zsh/aliases.zsh
source ~/.zsh/bindkeys.zsh
source ~/.zsh/functions.zsh
source ~/.zsh/hooks.zsh
fi
if [ -e ~/.zshrc_local ]; then
source ~/.zshrc_local
fi