From 0f927aa2a0db4a2a4cdbc30ad10cb26311512a16 Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Wed, 3 May 2023 23:02:59 -0700 Subject: [PATCH] Added dotfile commands and completealiases --- init.zsh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/init.zsh b/init.zsh index 564c786..9279935 100644 --- a/init.zsh +++ b/init.zsh @@ -25,7 +25,7 @@ function source_user_file { source_user_file "early-init.zsh" # Some options -setopt autocd extendedglob rm_star_silent +setopt autocd extendedglob rm_star_silent completealiases unsetopt beep notify # Some general, random configuration @@ -121,6 +121,23 @@ alias gu="git pull" alias gf="git fetch" alias gt="git status" +# Dotfile management +function dots { + local args=("--git-dir=${HOME}/src/dotfiles" '--work-tree=/' '--bare') + if (( ${#} == 0 )); then + (cd / + for file in $(git ${args} ls-files); do + printf '%s\t%s\t\e[38;2;255;255;0m%s\e[m\n' \ + "$(git ${args} -c color.status=always status -s "${file}" | sed "s#${file}##")" \ + "/${file}" \ + "$(git ${args} log --max-count=1 --format='%s' "${file}")" + done) | column -t -T2 --separator=" " + else + git ${args} "${@}" + fi +} +compdef -e "words[1]=(git '--git-dir=${HOME}/src/dotfiles' --work-tree=/ --bare); service=git; (( CURRENT+=3 )); _git" dots + # Sudo last line with sudo-command-line() { [[ -z $BUFFER ]] && zle up-history