From f52056a747fc94524dcf15b9bce88c1ea42f74e5 Mon Sep 17 00:00:00 2001 From: Mark Riedesel Date: Wed, 12 Jun 2024 09:27:32 -0500 Subject: [PATCH] add git config and zsh configs (using zim) --- .config/git/config | 127 ++++++++++++++++++++++++++++ .config/zsh/.zimrc | 9 ++ .config/zsh/.zshrc | 37 ++++++++ .config/zsh/config.d/00-zim | 17 ++++ .config/zsh/config.d/add-dots-alias | 1 + .zshenv | 1 + 6 files changed, 192 insertions(+) create mode 100755 .config/git/config create mode 100644 .config/zsh/.zimrc create mode 100644 .config/zsh/.zshrc create mode 100644 .config/zsh/config.d/00-zim create mode 100644 .config/zsh/config.d/add-dots-alias create mode 100644 .zshenv diff --git a/.config/git/config b/.config/git/config new file mode 100755 index 0000000..3984882 --- /dev/null +++ b/.config/git/config @@ -0,0 +1,127 @@ +[user] + name = Mark Riedesel + email = mark@klowner.com + +[core] + editor = nvim + whitespace = trailing-space,space-before-tab,cr-at-eol + pager = less -x4 + +[gist] + private = yes + +[github] + user = klowner + +[color] + diff = auto + status = auto + branch = auto + blame = auto + +[log] + decorate = short + +[status] + relativePaths = false + +[push] + default = simple + +[pack] + windowMemory = 2048m + +[alias] + branchlog = !git log ${1+}${1-master}..HEAD --reverse --date=short --format=\"git:%h %ad %s\" + lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset' --abbrev-commit + lgd = log --color --graph --date=format:%m/%d --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%ad, %cr)%C(bold blue)<%an>%Creset' --abbrev-commit + + # from http://stackoverflow.com/questions/591923/make-git-automatically-remove-trailing-whitespace-before-committing/15398512 + # Logic: + # + # The 'git stash save' fails if the tree is clean (instead of + # creating an empty stash :P). So, we only 'stash' and 'pop' if + # the tree is dirty. + # + # The 'git rebase --whitespace=fix HEAD~' throws away the commit + # if it's empty, and adding '--keep-empty' prevents the whitespace + # from being fixed. So, we first check that the index is dirty. + # + # Also: + # - '(! git diff-index --quiet --cached HEAD)' is true (zero) if + # the index is dirty + # - '(! git diff-files --quiet .)' is true if the tree is dirty + # + # The 'rebase --whitespace=fix' trick is from here: + # http://stackoverflow.com/a/19156679/470844 + fixws = !"\ + if (! git diff-files --quiet .) && \ + (! git diff-index --quiet --cached HEAD) ; then \ + git commit -m FIXWS_SAVE_INDEX && \ + git stash save FIXWS_SAVE_TREE && \ + git rebase --whitespace=fix HEAD~ && \ + git reset --soft HEAD~ && \ + git stash pop ; \ + elif (! git diff-index --quiet --cached HEAD) ; then \ + git commit -m FIXWS_SAVE_INDEX && \ + git rebase --whitespace=fix HEAD~ && \ + git reset --soft HEAD~ ; \ + fi" + + + # The different cases are: + # # - dirty tree and dirty index + # # - dirty tree and clean index + # # - clean tree and dirty index + # # + # # We have to consider separate cases because the 'git rebase + # # --whitespace=fix' is not compatible with empty commits (adding + # # '--keep-empty' makes Git not fix the whitespace :P). + fixws-global-tree-and-index = !"\ + if (! git diff-files --quiet .) && \ + (! git diff-index --quiet --cached HEAD) ; then \ + git commit -m FIXWS_SAVE_INDEX && \ + git add -u :/ && \ + git commit -m FIXWS_SAVE_TREE && \ + git rebase --whitespace=fix HEAD~2 && \ + git reset HEAD~ && \ + git reset --soft HEAD~ ; \ + elif (! git diff-files --quiet .) ; then \ + git add -u :/ && \ + git commit -m FIXWS_SAVE_TREE && \ + git rebase --whitespace=fix HEAD~ && \ + git reset HEAD~ ; \ + elif (! git diff-index --quiet --cached HEAD) ; then \ + git commit -m FIXWS_SAVE_INDEX && \ + git rebase --whitespace=fix HEAD~ && \ + git reset --soft HEAD~ ; \ + fi" + +[merge] + tool = diffconflicts + +[mergetool "diffconflicts"] + cmd = diffconflicts vim $BASE $LOCAL $REMOTE $MERGED + trustExitCode = true + keepBackup = false + +[diff] + tool = meld +[apply] + whitespace = fix + +[filter "spellfile"] + smudge = cat + clean = sort -u + +[rerere] + enabled = true +[pull] + ff = only +[init] + defaultBranch = main +[filter "lfs"] + clean = git-lfs clean -- %f + smudge = git-lfs smudge -- %f + process = git-lfs filter-process + required = true diff --git a/.config/zsh/.zimrc b/.config/zsh/.zimrc new file mode 100644 index 0000000..e9b7b65 --- /dev/null +++ b/.config/zsh/.zimrc @@ -0,0 +1,9 @@ +zmodule prompt-pwd +zmodule git-info +zmodule s1ck94 +zmodule zsh-users/zsh-syntax-highlighting +zmodule completion +zmodule zsh-users/zsh-autosuggestions +zmodule ssh +zmodule utility +zmodule pacman diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc new file mode 100644 index 0000000..0b3ff6d --- /dev/null +++ b/.config/zsh/.zshrc @@ -0,0 +1,37 @@ +# vim:set ft=zsh: + +# Fix for foot terminfo not installed on most servers +alias ssh="TERM=xterm-256color ssh" +source ~/.config/user-dirs.dirs + +## Options +setopt correct # Auto correct mistakes +setopt extendedglob # Extended globbing. Allows using regular expressions with * +setopt nocaseglob # Case insensitive globbing +setopt rcexpandparam # Array expension with parameters +setopt nocheckjobs # Don't warn about running processes when exiting +setopt numericglobsort # Sort filenames numerically when it makes sense +setopt nobeep # No beep +setopt appendhistory # Immediately append history instead of overwriting +setopt histignorealldups # If a new command is a duplicate, remove the older one +setopt autocd # If only directory path is entered, cd there. +setopt inc_append_history # Save commands are added to the history immediately, otherwise only when shell exits. +setopt histignorespace # Don't save commands that start with space +setopt extended_history # Include extra info about executed commands +setopt hist_reduce_blanks # Reduce blanks from commands in history + +zstyle ':completion:*' rehash true # Automatically find new executables in path +zstyle ':completion:*' accept-exact '*(N)' +zstyle ':completion:*' use-cache on +zstyle ':completion:*' cache-path ${XDG_CACHE_DIR:-~/.cache}/zsh +HISTFILE=${XDG_CACHE_DIR:-~/.cache}/.zhistory +HISTSIZE=50000 +SAVEHIST=50000 + + +# Additional configuration files +[ -d ~/.config/zsh/config.d/ ] && source <(cat ~/.config/zsh/config.d/*) + +# Optional local config +[ -f ~/.zshrc.local ] && source ~/.zshrc.local + diff --git a/.config/zsh/config.d/00-zim b/.config/zsh/config.d/00-zim new file mode 100644 index 0000000..46bf7a8 --- /dev/null +++ b/.config/zsh/config.d/00-zim @@ -0,0 +1,17 @@ +#:vim set ft=zsh: +zstyle ':zim:zmodule' use 'degit' +ZIM_HOME=${XDG_CACHE_DIR}/zim + +# Download zimfw plugin manager if missing. +if [[ ! -e ${ZIM_HOME}/zimfw.zsh ]]; then + curl -fsSL --create-dirs -o ${ZIM_HOME}/zimfw.zsh \ + https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh +fi + +# Install missing modules, and update ${ZIM_HOME}/init.zsh if missing or outdated. +if [[ ! ${ZIM_HOME}/init.zsh -nt ${ZDOTDIR:-${HOME}}/.zimrc ]]; then + source ${ZIM_HOME}/zimfw.zsh init -q +fi + +# Initialize modules +source ${ZIM_HOME}/init.zsh diff --git a/.config/zsh/config.d/add-dots-alias b/.config/zsh/config.d/add-dots-alias new file mode 100644 index 0000000..59e9d98 --- /dev/null +++ b/.config/zsh/config.d/add-dots-alias @@ -0,0 +1 @@ +alias dots="$(~/bin/dotfiles alias)" diff --git a/.zshenv b/.zshenv new file mode 100644 index 0000000..aed27b6 --- /dev/null +++ b/.zshenv @@ -0,0 +1 @@ +export ZDOTDIR=~/.config/zsh