add git config and zsh configs (using zim)

This commit is contained in:
Mark Riedesel 2024-06-12 09:27:32 -05:00
parent 87f414ba2c
commit f52056a747
6 changed files with 192 additions and 0 deletions

127
.config/git/config Executable file
View file

@ -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

9
.config/zsh/.zimrc Normal file
View file

@ -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

37
.config/zsh/.zshrc Normal file
View file

@ -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

View file

@ -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

View file

@ -0,0 +1 @@
alias dots="$(~/bin/dotfiles alias)"