reboot: chezmoi

This commit is contained in:
Matthew Ryan Dillon 2023-01-25 22:13:24 -07:00
parent 1dfcb6068f
commit e8846ec72b
36 changed files with 5 additions and 1387 deletions

View file

@ -0,0 +1,8 @@
#!/usr/bin/env zsh
# If reattach-to-user-namespace is not available, just run the command.
if [ -n "$(command -v reattach-to-user-namespace)" ]; then
reattach-to-user-namespace $@
else
exec "$@"
fi

66
home/dot_gitconfig Normal file
View file

@ -0,0 +1,66 @@
[user]
name = Matthew Dillon
email = matthewrdillon@gmail.com
[core]
editor = nvim
[color]
diff = auto
status = auto
branch = auto
interactive = auto
ui = auto
[gc]
auto = 1
[merge]
summary = true
tool = vimdiff
conflictstyle = diff3
prompt = false
[alias]
unstage = reset HEAD
uncommit = reset --soft HEAD^
# http://stackoverflow.com/a/9074343
lg1 = log \
--graph \
--abbrev-commit \
--decorate \
--format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' \
--all
lg2 = log \
--graph \
--abbrev-commit \
--decorate \
--format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' \
--all
lg = !"git lg1"
# https://gist.github.com/mwhite/6887990
a = add
c = commit --verbose
ca = commit -a --verbose
m = commit --amend --verbose
d = diff
dc = diff --cached
s = status -s
# TODO: drop when ready
# co = checkout
# cob = checkout -b
sw = switch
swc = switch -c
# list branches sorted by last modified
b = "!git for-each-ref --sort='-authordate' --format='%(authordate)%09%(objectname:short)%09%(refname)' refs/heads | sed -e 's-refs/heads/--'"
# list aliases
la = "!git config -l | grep alias | cut -c 7-"
# [credential]
# helper = osxkeychain
[pull]
rebase = true
[init]
defaultBranch = main
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[safe]
directory = %(prefix)///wsl.localhost/Ubuntu/home/matthew/projects/personal/notes
directory = //wsl.localhost/Ubuntu/home/matthew/projects/personal/notes

1
home/dot_npmrc Normal file
View file

@ -0,0 +1 @@
prefix=~/.npm-packages

4
home/dot_psqlrc Normal file
View file

@ -0,0 +1,4 @@
\echo `date +"%Y-%m-%d %H:%M:%S"`
\set PROMPT1 '%M:%[%033[1;31m%]%>%[%033[0m%] %n@%/%R%#%x '
\pset null '[NULL]'
\pset border 2

1
home/dot_ripgreprc Normal file
View file

@ -0,0 +1 @@
--glob=!.git/*

52
home/dot_tmux.conf Normal file
View file

@ -0,0 +1,52 @@
# need to set escape-time first, for wsl deploys
set -sg escape-time 50
setw -g automatic-rename
set-option -g default-shell $SHELL
# set -g default-command "~/bin/safe-reattach-to-user-namespace -l ${SHELL}"
set -g default-terminal "screen-256color"
set -ga terminal-overrides ",xterm-256color*:Tc"
set -g prefix C-a
unbind C-b
bind C-a last-window
unbind r
bind r source-file ~/.tmux.conf
set -g base-index 1
bind c new-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
bind '"' split-window -c "#{pane_current_path}"
set-window-option -g mode-keys vi
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
set-option -g status-bg colour18
set-option -g status-fg colour136
set -g status-justify centre
set -g status-left-length 50
set -g status-right-length 140
set -g status-left '#[fg=green]#H#[default] session:#S'
set -g status-right '\
#[fg=black,bg=colour119]#(cd ~/.password-store/.bin && ./check_status.sh)#[default] \
#[fg=black,bg=colour207]#(cd ~/.dotfiles && ./check_status.sh)#[default] \
#[fg=black,bg=colour226]#(cd ~/.ssh/.bin && ./check_status.sh)#[default] \
#[fg=black,bg=colour215]#(cd ~/projects/personal/notes/.bin && ./check_status.sh)#[default] \
#[fg=white,bg=default]%a %l:%M:%S %p#[default] #[fg=blue]%Y-%m-%d'
set-option -g renumber-windows on
set-option -g destroy-unattached 'off'
# Enable mouse control (clickable windows, panes, resizable panes)
set -g mouse on
bind-key -T copy-mode-vi 'v' send -X begin-selection
bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel
# NOTE: the following line is for macos, but its presence doesnt seem to be a prob. on linux
bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'reattach-to-user-namespace pbcopy'
bind-key p paste-buffer

14
home/dot_zlogin Normal file
View file

@ -0,0 +1,14 @@
#
# Executes commands at login post-zshrc.
#
# Execute code that does not affect the current session in the background.
{
# Compile the completion dump to increase startup speed.
zcompdump="${ZDOTDIR:-$HOME}/.zcompdump"
if [[ -s "$zcompdump" && (! -s "${zcompdump}.zwc" || "$zcompdump" -nt "${zcompdump}.zwc") ]]; then
zcompile "$zcompdump"
fi
} &!
# this seems like the easiest way to get a wsl startup script to work
2>/dev/null 1>/dev/null mpd

3
home/dot_zlogout Normal file
View file

@ -0,0 +1,3 @@
#
# Executes commands at logout.

144
home/dot_zpreztorc Normal file
View file

@ -0,0 +1,144 @@
#
# Sets Prezto options.
#
# General
#
# Set case-sensitivity for completion, history lookup, etc.
# zstyle ':prezto:*:*' case-sensitive 'yes'
# Color output (auto set to 'no' on dumb terminals).
zstyle ':prezto:*:*' color 'yes'
# Set the Zsh modules to load (man zshmodules).
# zstyle ':prezto:load' zmodule 'attr' 'stat'
# Set the Zsh functions to load (man zshcontrib).
# zstyle ':prezto:load' zfunction 'zargs' 'zmv'
# Set the Prezto modules to load (browse modules).
# The order matters.
zstyle ':prezto:load' pmodule \
'environment' \
'terminal' \
'editor' \
'history' \
'directory' \
'spectrum' \
'utility' \
'completion' \
'git' \
'prompt' \
'tmux' \
'gpg'
#
# Editor
#
# Set the key mapping style to 'emacs' or 'vi'.
zstyle ':prezto:module:editor' key-bindings 'vi'
# Auto convert .... to ../..
# zstyle ':prezto:module:editor' dot-expansion 'yes'
#
# Git
#
# Ignore submodules when they are 'dirty', 'untracked', 'all', or 'none'.
# zstyle ':prezto:module:git:status:ignore' submodules 'all'
# Disable aliases
zstyle ':prezto:module:git:alias' skip 'yes'
#
# GNU Utility
#
# Set the command prefix on non-GNU systems.
# zstyle ':prezto:module:gnu-utility' prefix 'g'
#
# History Substring Search
#
# Set the query found color.
# zstyle ':prezto:module:history-substring-search:color' found ''
# Set the query not found color.
# zstyle ':prezto:module:history-substring-search:color' not-found ''
# Set the search globbing flags.
# zstyle ':prezto:module:history-substring-search' globbing-flags ''
#
# Pacman
#
# Set the Pacman frontend.
# zstyle ':prezto:module:pacman' frontend 'yaourt'
#
# Prompt
#
# Set the prompt theme to load.
# Setting it to 'random' loads a random theme.
# Auto set to 'off' on dumb terminals.
zstyle ':prezto:module:prompt' theme 'peepcode'
#
# Screen
#
# Auto start a session when Zsh is launched in a local terminal.
# zstyle ':prezto:module:screen:auto-start' local 'yes'
# Auto start a session when Zsh is launched in a SSH connection.
# zstyle ':prezto:module:screen:auto-start' remote 'yes'
#
# SSH
#
# Set the SSH identities to load into the agent.
# zstyle ':prezto:module:ssh:load' identities 'id_rsa' 'id_rsa2' 'id_github'
#
# Syntax Highlighting
#
# Set syntax highlighters.
# By default, only the main highlighter is enabled.
# zstyle ':prezto:module:syntax-highlighting' highlighters \
# 'main' \
# 'brackets' \
# 'pattern' \
# 'cursor' \
# 'root'
#
# Set syntax highlighting styles.
# zstyle ':prezto:module:syntax-highlighting' styles \
# 'builtin' 'bg=blue' \
# 'command' 'bg=blue' \
# 'function' 'bg=blue'
#
#
# Terminal
#
# Auto set the tab and window titles.
zstyle ':prezto:module:terminal' auto-title 'yes'
#
# Tmux
#
# Auto start a session when Zsh is launched in a local terminal.
# zstyle ':prezto:module:tmux:auto-start' local 'yes'
# Auto start a session when Zsh is launched in a SSH connection.
# zstyle ':prezto:module:tmux:auto-start' remote 'yes'

2
home/dot_zprofile Normal file
View file

@ -0,0 +1,2 @@
# Matthew Dillon
# matthewrdillon@gmail.com

83
home/dot_zshenv Normal file
View file

@ -0,0 +1,83 @@
# Browser
if [[ "$OSTYPE" == darwin* ]]; then
export BROWSER='open'
fi
# Editors
export EDITOR='nvim'
export VISUAL='nvim'
export PAGER='less'
# Language
if [[ -z "$LANG" ]]; then
export LANG='en_US.UTF-8'
fi
# Less
# Set the default Less options.
# Mouse-wheel scrolling has been disabled by -X (disable screen clearing).
# Remove -X and -F (exit if the content fits on one screen) to enable it.
export LESS='-F -g -i -M -R -S -w -X -z-4'
# Set the Less input preprocessor.
if (( $+commands[lesspipe.sh] )); then
export LESSOPEN='| /usr/bin/env lesspipe.sh %s 2>&-'
fi
# Temporary Files
if [[ ! -d "$TMPDIR" ]]; then
export TMPDIR="/tmp/$USER"
mkdir -p -m 700 "$TMPDIR"
fi
TMPPREFIX="${TMPDIR%/}/zsh"
if [[ ! -d "$TMPPREFIX" ]]; then
mkdir -p "$TMPPREFIX"
fi
# Necessary for tmux on WSL, shouldn't impact macos
export TMUX_TMPDIR='/tmp'
# Paths
typeset -gU cdpath fpath mailpath path
check_paths=(
# miniconda
/opt/miniconda3/bin
# macports
/opt/local/bin
/opt/local/sbin
# npm
$HOME/.npm-packages/bin
# yarn
$HOME/.yarn/bin
$HOME/.config/yarn/global/node_modules/.bin
# rust
$HOME/.cargo/bin
# WSL
# /mnt/c/windows
# /mnt/c/windows/system32
# home
$HOME/bin
# go
/usr/local/go/bin
)
for fp in $check_paths; do
if [[ -s "$fp" ]]; then
path+=("$fp")
fi
done
export -U PATH
export CONDA_ENVS_PATH=$HOME/.conda/envs:/opt/miniconda3/envs
export CONDA_PKGS_DIRS=$HOME/.conda/pkgs
export RIPGREP_CONFIG_PATH=$HOME/.ripgreprc
if [ -e /home/matthew/.nix-profile/etc/profile.d/nix.sh ]; then . /home/matthew/.nix-profile/etc/profile.d/nix.sh; fi # added by Nix installer

79
home/dot_zshrc Normal file
View file

@ -0,0 +1,79 @@
# Matthew Dillon
# matthewrdillon@gmail.com
srcs=(
"${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
"/opt/miniconda3/etc/profile.d/conda.sh"
"$HOME/.cargo/env"
)
for fp in $srcs; do
if [[ -s "$fp" ]]; then
source "$fp"
fi
done
BASE16_SHELL=$HOME/.config/base16-shell/
[ -n "$PS1" ] && [ -s $BASE16_SHELL/profile_helper.sh ] && eval "$($BASE16_SHELL/profile_helper.sh)"
alias q="conda activate q2dev"
alias i="ipython3"
alias vim="nvim"
# Backup shortcuts (borrowed parts from https://github.com/laurent22/rsync-time-backup
function prune_backups() {
dest_root="/Volumes/field_on_fire/$HOST"
epoch=$(date "+%s")
previous='0000-00-00-000000'
for filename in $(find "$dest_root" -type d -name "????-??-??-??????" -prune | sort -r); do
backup_date=$(basename "$filename")
timestamp=$(date -j -f "%Y-%m-%d-%H%M%S" "$backup_date" "+%s")
if [ -z "$timestamp" ]; then
echo "Error parsing date date: $filename"
continue
fi
if [ $timestamp -ge $((epoch - 86400)) ]; then
true
elif [ $timestamp -ge $((epoch - 2678400)) ]; then
if [ "${backup_date:0:10}" '==' "${previous:0:10}" ]; then
rm -rf "$filename"
fi
else
if [ "${backup_date:0:7}" '==' "${previous:0:7}" ]; then
rm -rf "$filename"
fi
fi
previous=$backup_date
done
}
function back_things_up() {
date=$(date +"%Y-%m-%d-%H%M%S")
# TODO: update this...
dest_root="/Volumes/field_on_fire/$HOST"
rsync -azP \
--stats \
--human-readable \
--itemize-changes \
--size-only \
--link-dest=$dest_root/latest \
--exclude-from $HOME/.dotfiles/rsync_excludes.txt \
$HOME/ \
$dest_root/$date && \
rm -f $dest_root/latest && \
ln -s $dest_root/$date $dest_root/latest
# TODO: once confident pruning is working well, add that in here
}
function devlog() {
vim -c 'Goyo' '+normal Go' +startinsert ~/projects/personal/devlog/logs/$(date '+%Y-%m-%d').gmi
}
# NOTE: this might need a mapped network drive to work (e.g. Z:\)
function cmd() {
CMD=$1
shift;
ARGS=$@
WIN_PWD=$(wslpath -w ${PWD})
cmd.exe /c "pushd ${WIN_PWD} && ${CMD} ${ARGS}"
}

View file

@ -0,0 +1,4 @@
*~
.DS_Store
.idea
.vscode

View file

@ -0,0 +1,4 @@
theme = "base16_terminal"
[editor]
true-color = true

View file

@ -0,0 +1,15 @@
pid_file "~/.config/mpd/mpd.pid"
playlist_directory "~/.config/mpd/playlists"
music_directory "http://anonymous@wren.local:5005/music"
database {
plugin "proxy"
host "wren.local"
}
audio_output {
type "pulse"
name "spleen"
server "/mnt/wslg/PulseServer"
}