From a81d75fe533251968bd42976d6fb8d8ccbd2b5f4 Mon Sep 17 00:00:00 2001 From: Matthias Johnson Date: Sat, 15 Feb 2025 23:58:19 -0700 Subject: [PATCH 1/9] correct file name --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 78f073c..20a8cdf 100644 --- a/README.md +++ b/README.md @@ -41,13 +41,13 @@ Both of these aliases also set git's `status.showUntrackedFiles` to `no`. This p ## installation -1. clone this repository or simply copy the [dotGit.sh](./dotGit.sh) +1. clone this repository or simply copy the [dotgit.sh](./dotgit.sh) 2. add some config sauce to your shell initialization (.i.e. `.zshrc` or `.bashrc`). The `DOT_FILES` and `DOT_HOME` variables **must be set** for the dotGit.sh to load! ```bash export DOT_FILES="${HOME}/.dotfiles" export DOT_HOME="${HOME}" export DOT_ORIGIN="git@github.com:user/your-dotfiles-repo.git" # optional - source ` + source ` ``` 3. restart your shell or `source ~/.zshrc` or `source ~/.bashrc` 4. run `.ginit` or `.gclone` (see the *initial clone setup* below, if cloning) From 7e7f323184969c94f071e6075684965d233b5565 Mon Sep 17 00:00:00 2001 From: Matthias Johnson Date: Sat, 15 Mar 2025 01:29:11 -0600 Subject: [PATCH 2/9] adding .git alias, and .ge now uses fzf exec --- dotgit.sh | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/dotgit.sh b/dotgit.sh index e409b52..0f47533 100644 --- a/dotgit.sh +++ b/dotgit.sh @@ -3,7 +3,10 @@ [[ ! "${DOT_FILES}" ]] && echo "NOT setting dotGit aliases, since DOT_FILES not set." && return [[ ! "${DOT_HOME}" ]] && echo "NOT setting dotGit aliases, since DOT_HOME not set." && return -alias .g='git --git-dir=${DOT_FILES} --work-tree=${DOT_HOME}' +# the master alias +alias .git='git --git-dir=${DOT_FILES} --work-tree=${DOT_HOME}' +# and all the shortcuts +alias .g='.git' alias .ga='.g add' alias .gc='.g commit' alias .gco='.g checkout' @@ -15,26 +18,31 @@ alias .glo='.g log --oneline --decorate' alias .glg='.g log --stat' alias .glgp='.g log --stat --patch' -# shellcheck disable=SC2142,SC215 -alias .ge='_dotgit_ge(){ - cd ${DOT_HOME} - FILE=$( Q="$@"; .g ls-files --full-name | - fzf --preview "bat -n --color=always {}" -q "${Q}") - [[ "$FILE" ]] && $EDITOR "${FILE}" - cd ${OLDPWD} -}; _dotgit_ge' - +# if fzf is installed we can have nice things +# https://github.com/junegunn/fzf if [[ $(command -v fzf) ]]; then + # shellcheck disable=SC2142,SC215 + alias .ge='_dotgit_ge(){ + cd ${DOT_HOME} + .g ls-files --full-name | + fzf -0 --bind "enter:execute($EDITOR {})" \ + --preview "bat -n --color=always {}" \ + --preview-window "right,60%,<60(down,75%),+{2}/2" \ + -q "${@:-}" + cd ${OLDPWD} + }; _dotgit_ge' + # shellcheck disable=SC2142 alias .gg='_dotgit_gg(){ - cd ${DOT_HOME} - .g grep --full-name --color=always -n "$@" | - fzf -0 --ansi -d ":" --bind "enter:execute($EDITOR +{2} {1})" \ - --preview "bat -n -H {2} --color=always {1}" \ - --preview-window "right,60%,<60(down,75%),+{2}/2" - cd ${OLDPWD} - }; _dotgit_gg' + cd ${DOT_HOME} + .g grep --full-name --color=always -n "$@" | + fzf -0 --ansi -d ":" --bind "enter:execute($EDITOR +{2} {1})" \ + --preview "bat -n -H {2} --color=always {1}" \ + --preview-window "right,60%,<60(down,75%),+{2}/2" + cd ${OLDPWD} + }; _dotgit_gg' else + # simplified grep but no "interactive file select" alias .gg='.g grep' fi From ba06a0c356581a167a1685a24e09bf9e2cb8a94a Mon Sep 17 00:00:00 2001 From: Matthias Johnson Date: Sat, 15 Mar 2025 10:34:19 -0600 Subject: [PATCH 3/9] unset -f temp functions --- dotgit.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dotgit.sh b/dotgit.sh index 0f47533..e901248 100644 --- a/dotgit.sh +++ b/dotgit.sh @@ -30,6 +30,7 @@ if [[ $(command -v fzf) ]]; then --preview-window "right,60%,<60(down,75%),+{2}/2" \ -q "${@:-}" cd ${OLDPWD} + unset -f _dotgit_ge; }; _dotgit_ge' # shellcheck disable=SC2142 @@ -40,6 +41,7 @@ if [[ $(command -v fzf) ]]; then --preview "bat -n -H {2} --color=always {1}" \ --preview-window "right,60%,<60(down,75%),+{2}/2" cd ${OLDPWD} + unset -f _dotgit_gg; }; _dotgit_gg' else # simplified grep but no "interactive file select" From 306c72e58a1e2f2c3cdc6f0691b07086ad9c8ec7 Mon Sep 17 00:00:00 2001 From: Matthias Johnson Date: Sun, 23 Mar 2025 11:08:06 -0600 Subject: [PATCH 4/9] now able to suspend from editor process --- dotgit.sh | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/dotgit.sh b/dotgit.sh index e901248..0cb35c9 100644 --- a/dotgit.sh +++ b/dotgit.sh @@ -21,28 +21,30 @@ alias .glgp='.g log --stat --patch' # if fzf is installed we can have nice things # https://github.com/junegunn/fzf if [[ $(command -v fzf) ]]; then - # shellcheck disable=SC2142,SC215 - alias .ge='_dotgit_ge(){ - cd ${DOT_HOME} - .g ls-files --full-name | - fzf -0 --bind "enter:execute($EDITOR {})" \ - --preview "bat -n --color=always {}" \ - --preview-window "right,60%,<60(down,75%),+{2}/2" \ - -q "${@:-}" - cd ${OLDPWD} - unset -f _dotgit_ge; - }; _dotgit_ge' - - # shellcheck disable=SC2142 - alias .gg='_dotgit_gg(){ - cd ${DOT_HOME} - .g grep --full-name --color=always -n "$@" | - fzf -0 --ansi -d ":" --bind "enter:execute($EDITOR +{2} {1})" \ - --preview "bat -n -H {2} --color=always {1}" \ - --preview-window "right,60%,<60(down,75%),+{2}/2" - cd ${OLDPWD} - unset -f _dotgit_gg; - }; _dotgit_gg' + fzf_opts=(--preview "bat -n --color=always {}" + --multi --ansi -0 + --preview-window "right,60%,<60(down,75%),+{2}/2" + --bind 'ctrl-z:ignore' + ) + _dotgit_ge() { + files=$(cd "$DOT_HOME" && .g ls-files --full-name | + fzf "${fzf_opts[@]}" \ + --preview "bat --color=always {1}" \ + --bind "enter:accept-non-empty" \ + -q "${@:-}" | paste -sd' ') + [[ -n "$files" ]] && sh -c "cd $DOT_HOME && $EDITOR $files" + } + alias .ge='_dotgit_ge' + + _dotgit_gg() { + files=$(cd "$DOT_HOME" && .g grep --full-name --color=always -n "$@" | + fzf "${fzf_opts[@]}" -d ":" \ + --preview "bat --color=always -H{2} {1}" \ + --accept-nth "-c 'e {1}|{2}'" | paste -sd' ') + [[ -n "$files" ]] && sh -c "cd $DOT_HOME && $EDITOR $files" + } + # shellcheck disable=SC2154 + alias .gg='_dotgit_gg' # | read -r f; echo $f' else # simplified grep but no "interactive file select" alias .gg='.g grep' From a76ca9737740c500840641e6cea1bcc4cb5e57be Mon Sep 17 00:00:00 2001 From: Matthias Johnson Date: Mon, 24 Mar 2025 01:18:38 -0600 Subject: [PATCH 5/9] first integration of anygit functionality, mutli file support --- dotgit.sh | 198 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 151 insertions(+), 47 deletions(-) diff --git a/dotgit.sh b/dotgit.sh index 0cb35c9..7d44725 100644 --- a/dotgit.sh +++ b/dotgit.sh @@ -1,60 +1,164 @@ #!/usr/bin/env bash -[[ ! "${DOT_FILES}" ]] && echo "NOT setting dotGit aliases, since DOT_FILES not set." && return -[[ ! "${DOT_HOME}" ]] && echo "NOT setting dotGit aliases, since DOT_HOME not set." && return +[[ ! "$DOT_FILES" ]] && echo "NOT setting dotgit aliases, since DOT_FILES not set." && return +[[ ! "$DOT_HOME" ]] && echo "NOT setting dotgit aliases, since DOT_HOME not set." && return + +[[ -n "$DEBUG" ]] && echo loading dotGit aliases + +[[ -z "$DOTGIT_MULTI_LIMIT" ]] && DOTGIT_MULTI_LIMIT=2 +[[ -z "$DOTGIT_MULTI_ACCEPT" ]] && DOTGIT_MULTI_ACCEPT='{1}' +[[ -z "$DOTGIT_PREVIEW" ]] && DOTGIT_PREVIEW='bat -p --color=always' # the master alias alias .git='git --git-dir=${DOT_FILES} --work-tree=${DOT_HOME}' + # and all the shortcuts -alias .g='.git' -alias .ga='.g add' -alias .gc='.g commit' -alias .gco='.g checkout' -alias .gd='.g diff' -alias .gss='.g status --short' -alias .gp='.g push' -alias .gl='.g pull' -alias .glo='.g log --oneline --decorate' -alias .glg='.g log --stat' -alias .glgp='.g log --stat --patch' - -# if fzf is installed we can have nice things -# https://github.com/junegunn/fzf -if [[ $(command -v fzf) ]]; then - fzf_opts=(--preview "bat -n --color=always {}" - --multi --ansi -0 - --preview-window "right,60%,<60(down,75%),+{2}/2" - --bind 'ctrl-z:ignore' - ) - _dotgit_ge() { - files=$(cd "$DOT_HOME" && .g ls-files --full-name | - fzf "${fzf_opts[@]}" \ - --preview "bat --color=always {1}" \ - --bind "enter:accept-non-empty" \ - -q "${@:-}" | paste -sd' ') - [[ -n "$files" ]] && sh -c "cd $DOT_HOME && $EDITOR $files" - } - alias .ge='_dotgit_ge' - - _dotgit_gg() { - files=$(cd "$DOT_HOME" && .g grep --full-name --color=always -n "$@" | - fzf "${fzf_opts[@]}" -d ":" \ - --preview "bat --color=always -H{2} {1}" \ - --accept-nth "-c 'e {1}|{2}'" | paste -sd' ') - [[ -n "$files" ]] && sh -c "cd $DOT_HOME && $EDITOR $files" - } - # shellcheck disable=SC2154 - alias .gg='_dotgit_gg' # | read -r f; echo $f' +alias .ga='.git add' +alias .gc='.git commit' +alias .gco='.git checkout' +alias .gd='.git diff' +alias .gss='.git status --short' +alias .glo='.git log --oneline --decorate' +alias .glg='.git log --stat' +alias .glgp='.git log --stat --patch' +alias .gbl='git blame -w' +alias .gb='git branch' +alias .gba='git branch --all' +alias .gbd='git branch --delete' +alias .gbD='git branch --delete --force' +alias .gm='git merge' +alias .gma='git merge --abort' +alias .gmc='git merge --continue' +alias .gc!='git commit --verbose --amend' +alias .gcm='git commit --message' +alias .gcp='git cherry-pick' +alias .gcpa='git cherry-pick --abort' +alias .gcpc='git cherry-pick --continue' +alias .gclean='git clean --interactive -d' +alias .ginit='git init --bare "${DOT_FILES}"; .git config --local status.showUntrackedFiles no' +# only set up push and pull if DOT_ORIGIN is set +if [[ -n "$DOT_ORIGIN" ]]; then + alias .gp='.git push' + alias .gl='.git pull' + alias .gclone='git clone --bare "${DOT_ORIGIN}" "${DOT_FILES}"; .git config --local status.showUntrackedFiles no' else - # simplified grep but no "interactive file select" - alias .gg='.g grep' + alias .gp='echo "error: must first configure DOT_HOME"' + alias .gl='echo "error: must first configure DOT_HOME"' + alias .gclone='echo "error: must first configure DOT_HOME"' fi - -alias .ginit='git init --bare "${DOT_FILES}"; .g config --local status.showUntrackedFiles no' -[[ -n "$DOT_ORIGIN" ]] && alias .gclone='git clone --bare "${DOT_ORIGIN}" "${DOT_FILES}"; .g config --local status.showUntrackedFiles no' - # if lazygit or gitui are avaiable, we set up a .lazygit and .gitui [[ $(command -v lazygit) ]] && alias .lazygit='lazygit -g ${DOT_FILES}/.dotfiles/ -w ${DOT_HOME}' [[ $(command -v gitui) ]] && alias .gitui='gitui -d ${DOT_FILES}/.dotfiles/ -w ${DOT_HOME}' + +# if fzf is installed we can have nice things +# https://github.com/junegunn/fzf +if [[ $(command -v fzf) ]]; then + fzf_opts=(--multi="$DOTGIT_MULTI_LIMIT" --ansi -0 + --preview-window "right,60%,<60(down,75%),+{2}/2" + --bind 'ctrl-z:ignore' + ) + _dotgit_ge() { + local gitdir + local files + gitdir=$(.git rev-parse --show-toplevel) + files=$(cd "$gitdir" && .git ls-files --full-name | + fzf "${fzf_opts[@]}" \ + --preview "$DOTGIT_PREVIEW {1}" \ + --bind "enter:accept-non-empty" \ + -q "${@:-}" | paste -sd' ') + [[ -n "$files" ]] && sh -c "cd \"$gitdir\" && \"$EDITOR\" $files" + } + alias .ge='_dotgit_ge' + + _dotgit_gg() { + local gitdir + local files + gitdir=$(.git rev-parse --show-toplevel) + files=$(cd "$gitdir" && .git grep --full-name --color=always -n "$@" | + fzf "${fzf_opts[@]}" -d ":" \ + --preview "$DOTGIT_PREVIEW -H{2} {1}" \ + --accept-nth "$DOTGIT_MULTI_ACCEPT" | paste -sd' ') + [[ -n "$files" ]] && sh -c "cd \"$gitdir\" && \"$EDITOR\" $files" + } + alias .gg='_dotgit_gg' +else + # simplified grep but no "interactive file select" + alias .gg='.git grep' +fi + +[[ -n "$DEBUG" ]] && echo dotGit aliases loaded + +if [[ "$DOTGIT_ANYGIT" == 'yes' ]]; then + [[ -n "$DEBUG" ]] && echo loading anyGit aliases + + alias ga='git add' + alias gba='git branch --all' + alias gbd='git branch --delete' + alias gbD='git branch --delete --force' + alias gb='git branch' + alias gbl='git blame -w' + alias gc='git commit' + alias gclean='git clean --interactive -d' + alias gclone='git clone' + alias gcm='git commit --message' + alias gco='git checkout' + alias gcpa='git cherry-pick --abort' + alias gcpc='git cherry-pick --continue' + alias gcp='git cherry-pick' + alias gd='git diff' + alias ge=_dotgit_ge + alias gg=_dotgit_gg + alias ginit='git init' + alias glg='git log --stat' + alias gl='git pull' + alias glgp='git log --stat --patch' + alias glo='git log --oneline --decorate' + alias gma='git merge --abort' + alias gmc='git merge --continue' + alias gm='git merge' + alias gp='git push' + alias grt='git rev-parse --show-toplevel' + alias gss='git status --short' + + # if fzf is installed we can have nice things + # https://github.com/junegunn/fzf + if [[ $(command -v fzf) ]]; then + fzf_opts=(--multi="$DOTGIT_MULTI_LIMIT" --ansi -0 + --preview-window "right,60%,<60(down,75%),+{2}/2" + --header ' to mark more than one file | to open file(s) in editor' + --bind 'ctrl-z:ignore' + --bind 'ctrl-w:toggle-wrap' + ) + _anygit_ge() { + local gitdir + gitdir=$(git rev-parse --show-toplevel) + local files + files=$(cd "$gitdir" && git ls-files --full-name | + fzf "${fzf_opts[@]}" \ + --preview "$DOTGIT_PREVIEW {1}" \ + --bind "enter:accept-non-empty" \ + -q "${@:-}" | paste -sd' ') + [[ -n "$files" ]] && sh -c "cd \"$gitdir\" && \"$EDITOR\" $files" + } + alias ge='_anygit_ge' + + _anygit_gg() { + local gitdir + gitdir=$(git rev-parse --show-toplevel) + local files + files=$(cd "$gitdir" && git grep --full-name --color=always -n "$@" | + fzf "${fzf_opts[@]}" -d ":" \ + --preview "$DOTGIT_PREVIEW -H{2} {1}" \ + --accept-nth "$DOTGIT_MULTI_ACCEPT" | paste -sd' ') + + [[ -n "$files" ]] && sh -c "cd \"$gitdir\" && \"$EDITOR\" $files" + } + alias gg='_anygit_gg' # | read -r f; echo $f' + else + # simplified grep but no "interactive file select" + alias gg='git grep' + fi + [[ -n "$DEBUG" ]] && echo anyGit aliases loaded +fi From 9aef83d1336c8acb7fda2baa9c16a9afca5cba92 Mon Sep 17 00:00:00 2001 From: Matthias Johnson Date: Tue, 25 Mar 2025 13:28:15 -0600 Subject: [PATCH 6/9] adding ANYGIT alias functinality --- dotgit.sh | 94 +++++++++++-------------------------------------------- 1 file changed, 18 insertions(+), 76 deletions(-) diff --git a/dotgit.sh b/dotgit.sh index 7d44725..d8893c9 100644 --- a/dotgit.sh +++ b/dotgit.sh @@ -3,7 +3,7 @@ [[ ! "$DOT_FILES" ]] && echo "NOT setting dotgit aliases, since DOT_FILES not set." && return [[ ! "$DOT_HOME" ]] && echo "NOT setting dotgit aliases, since DOT_HOME not set." && return -[[ -n "$DEBUG" ]] && echo loading dotGit aliases +[[ -n "$DEBUG" ]] && echo loading dotgit aliases [[ -z "$DOTGIT_MULTI_LIMIT" ]] && DOTGIT_MULTI_LIMIT=2 [[ -z "$DOTGIT_MULTI_ACCEPT" ]] && DOTGIT_MULTI_ACCEPT='{1}' @@ -48,16 +48,23 @@ else fi # if lazygit or gitui are avaiable, we set up a .lazygit and .gitui [[ $(command -v lazygit) ]] && - alias .lazygit='lazygit -g ${DOT_FILES}/.dotfiles/ -w ${DOT_HOME}' + alias .lazygit='lazygit -g ${DOT_FILES}/ -w ${DOT_HOME}' [[ $(command -v gitui) ]] && - alias .gitui='gitui -d ${DOT_FILES}/.dotfiles/ -w ${DOT_HOME}' + alias .gitui='gitui -d ${DOT_FILES}/ -w ${DOT_HOME}' # if fzf is installed we can have nice things # https://github.com/junegunn/fzf +read -r -d '' FZF_HEADER< to mark more than one file | to open file(s) in editor' - --bind 'ctrl-z:ignore' - --bind 'ctrl-w:toggle-wrap' - ) - _anygit_ge() { - local gitdir - gitdir=$(git rev-parse --show-toplevel) - local files - files=$(cd "$gitdir" && git ls-files --full-name | - fzf "${fzf_opts[@]}" \ - --preview "$DOTGIT_PREVIEW {1}" \ - --bind "enter:accept-non-empty" \ - -q "${@:-}" | paste -sd' ') - [[ -n "$files" ]] && sh -c "cd \"$gitdir\" && \"$EDITOR\" $files" - } - alias ge='_anygit_ge' - - _anygit_gg() { - local gitdir - gitdir=$(git rev-parse --show-toplevel) - local files - files=$(cd "$gitdir" && git grep --full-name --color=always -n "$@" | - fzf "${fzf_opts[@]}" -d ":" \ - --preview "$DOTGIT_PREVIEW -H{2} {1}" \ - --accept-nth "$DOTGIT_MULTI_ACCEPT" | paste -sd' ') - - [[ -n "$files" ]] && sh -c "cd \"$gitdir\" && \"$EDITOR\" $files" - } - alias gg='_anygit_gg' # | read -r f; echo $f' - else - # simplified grep but no "interactive file select" - alias gg='git grep' - fi - [[ -n "$DEBUG" ]] && echo anyGit aliases loaded -fi +# and to make general aliases availalbe, we source this file again, but set +# the aliases by removing the leading `.` and changing all instances of the +# string 'dotgit' to 'anygit' +# shellcheck source=/dev/null +# the line above makes the source below not complain +[[ "$DOTGIT_ANYGIT" == 'yes' ]] && \ + sed '/alias \.g.*DOT_FILES/d; s/\.g/g/g; s/dotgit/anygit/g' < "$0" | source /dev/stdin From 6a28b0e61fb611a508c2f28ec5a0ecc4a8b08028 Mon Sep 17 00:00:00 2001 From: Matthias Johnson Date: Fri, 4 Apr 2025 00:26:20 -0600 Subject: [PATCH 7/9] adding .g and correcting alias base command --- dotgit.sh | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/dotgit.sh b/dotgit.sh index d8893c9..7b97fbb 100644 --- a/dotgit.sh +++ b/dotgit.sh @@ -11,6 +11,8 @@ # the master alias alias .git='git --git-dir=${DOT_FILES} --work-tree=${DOT_HOME}' +# the short one +alias .g='.git' # and all the shortcuts alias .ga='.git add' @@ -21,20 +23,20 @@ alias .gss='.git status --short' alias .glo='.git log --oneline --decorate' alias .glg='.git log --stat' alias .glgp='.git log --stat --patch' -alias .gbl='git blame -w' -alias .gb='git branch' -alias .gba='git branch --all' -alias .gbd='git branch --delete' -alias .gbD='git branch --delete --force' -alias .gm='git merge' -alias .gma='git merge --abort' -alias .gmc='git merge --continue' -alias .gc!='git commit --verbose --amend' -alias .gcm='git commit --message' -alias .gcp='git cherry-pick' -alias .gcpa='git cherry-pick --abort' -alias .gcpc='git cherry-pick --continue' -alias .gclean='git clean --interactive -d' +alias .gbl='.git blame -w' +alias .gb='.git branch' +alias .gba='.git branch --all' +alias .gbd='.git branch --delete' +alias .gbD='.git branch --delete --force' +alias .gm='.git merge' +alias .gma='.git merge --abort' +alias .gmc='.git merge --continue' +alias .gc!='.git commit --verbose --amend' +alias .gcm='.git commit --message' +alias .gcp='.git cherry-pick' +alias .gcpa='.git cherry-pick --abort' +alias .gcpc='.git cherry-pick --continue' +alias .gclean='.git clean --interactive -d' alias .ginit='git init --bare "${DOT_FILES}"; .git config --local status.showUntrackedFiles no' # only set up push and pull if DOT_ORIGIN is set if [[ -n "$DOT_ORIGIN" ]]; then From a72f8d586219eba09e0f548adf2995d29b336afc Mon Sep 17 00:00:00 2001 From: Matthias Johnson Date: Thu, 16 Oct 2025 22:57:24 -0600 Subject: [PATCH 8/9] changed `DOT_FILES` to `DOT_REPO` --- dotgit.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/dotgit.sh b/dotgit.sh index 7b97fbb..8fe3d11 100644 --- a/dotgit.sh +++ b/dotgit.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -[[ ! "$DOT_FILES" ]] && echo "NOT setting dotgit aliases, since DOT_FILES not set." && return +[[ ! "$DOT_REPO" ]] && echo "NOT setting dotgit aliases, since DOT_REPO not set." && return [[ ! "$DOT_HOME" ]] && echo "NOT setting dotgit aliases, since DOT_HOME not set." && return [[ -n "$DEBUG" ]] && echo loading dotgit aliases @@ -10,7 +10,7 @@ [[ -z "$DOTGIT_PREVIEW" ]] && DOTGIT_PREVIEW='bat -p --color=always' # the master alias -alias .git='git --git-dir=${DOT_FILES} --work-tree=${DOT_HOME}' +alias .git='git --git-dir=${DOT_REPO} --work-tree=${DOT_HOME}' # the short one alias .g='.git' @@ -37,22 +37,22 @@ alias .gcp='.git cherry-pick' alias .gcpa='.git cherry-pick --abort' alias .gcpc='.git cherry-pick --continue' alias .gclean='.git clean --interactive -d' -alias .ginit='git init --bare "${DOT_FILES}"; .git config --local status.showUntrackedFiles no' +alias .ginit='git init --bare "${DOT_REPO}"; .git config --local status.showUntrackedFiles no' # only set up push and pull if DOT_ORIGIN is set if [[ -n "$DOT_ORIGIN" ]]; then alias .gp='.git push' alias .gl='.git pull' - alias .gclone='git clone --bare "${DOT_ORIGIN}" "${DOT_FILES}"; .git config --local status.showUntrackedFiles no' + alias .gclone='git clone --bare "${DOT_ORIGIN}" "${DOT_REPO}"; .git config --local status.showUntrackedFiles no' else - alias .gp='echo "error: must first configure DOT_HOME"' - alias .gl='echo "error: must first configure DOT_HOME"' - alias .gclone='echo "error: must first configure DOT_HOME"' + alias .gp='echo "error: must first configure DOT_ORIGIN"' + alias .gl='echo "error: must first configure DOT_ORIGIN"' + alias .gclone='echo "error: must first configure DOT_ORIGIN"' fi -# if lazygit or gitui are avaiable, we set up a .lazygit and .gitui +# if lazygit or gitui are available, we set up a .lazygit and .gitui [[ $(command -v lazygit) ]] && - alias .lazygit='lazygit -g ${DOT_FILES}/ -w ${DOT_HOME}' + alias .lazygit='lazygit -g ${DOT_REPO}/ -w ${DOT_HOME}' [[ $(command -v gitui) ]] && - alias .gitui='gitui -d ${DOT_FILES}/ -w ${DOT_HOME}' + alias .gitui='gitui -d ${DOT_REPO}/ -w ${DOT_HOME}' # if fzf is installed we can have nice things # https://github.com/junegunn/fzf @@ -99,10 +99,10 @@ fi [[ -n "$DEBUG" ]] && echo dotgit aliases loaded -# and to make general aliases availalbe, we source this file again, but set +# and to make general aliases available, we source this file again, but set # the aliases by removing the leading `.` and changing all instances of the # string 'dotgit' to 'anygit' # shellcheck source=/dev/null # the line above makes the source below not complain [[ "$DOTGIT_ANYGIT" == 'yes' ]] && \ - sed '/alias \.g.*DOT_FILES/d; s/\.g/g/g; s/dotgit/anygit/g' < "$0" | source /dev/stdin + sed '/alias \.g.*DOT_REPO/d; s/\.g/g/g; s/dotgit/anygit/g' < "$0" | source /dev/stdin From 74b5ff628293b2e23e39942fe32e3f9f670afb82 Mon Sep 17 00:00:00 2001 From: Matthias Johnson Date: Thu, 16 Oct 2025 22:57:43 -0600 Subject: [PATCH 9/9] spelling, cleanup, and aliases --- README.md | 99 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 69 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 78f073c..c93a51e 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,69 @@ -# dotGit - 🐚 shell aliases + 🪄 dotfiles + 🧸 bare git repo +# dotGit ::: 🪄 dotfiles + 🧸 bare git repo + 🐚 shell aliases -There are a lot of ways to manage your dotfiles. dotGit implements an idea that has been floating around on the internet for a while: a bare git repo for storing your dotfiles. A quick search finds [this post](https://news.ycombinator.com/item?id=11070797), but there may be older sources. +There are a lot of ways to manage your dotfiles. dotGit implements an idea that has been floating around on the internet for a while: a bare git repo for storing your dotfiles. A quick search finds [this post](https://news.ycombinator.com/item?id=11070797), but there may be older sources. dotGit combines this with some convenient shell aliases, a couple of functions, and FZF's matching magic to track your dotfiles files with ease. dotGit has modest aims: -- 🏡 keep config files where tools expect them in `$HOME` +- 🏡 keep configuration files where tools expect them in `$HOME` - 🐚 stay as light and close to git and the shell as possible -- 🚀 reduce friction and make config changes quick and convenient +- 🚀 reduce friction and make configuration changes quick and convenient -dotGit gives you a handful of shell aliases (tested with `zsh`🐚 and `bash`) to make dotfile management quick and easy. The shortcuts mimic a subset of those found in the [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh) [git](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git) plugin. -- `.g` is the alias for running `git` with correct `--git-dir` and `--work-tree` -- `.ga` runs `git add` -- `.gc` runs `git commmit` -- `.gco` runs `git checkout` -- `.gd` runs `git diff` -- `.gss` shows the `git status --short` -- `.gp` will `git push` the changes to the origin -- `.gl` will `git pull` changes from the origin -- `.glo` runs `git log --oneline --decorate ` -- `.glg` runs `git log --stat` -- `.glgp` runs `git log --stat --patch` -- `.gg` runs `git grep` on your dotfiles. If [FZF](https://github.com/junegunn/fzf) is installed it will be used to present the matches, and make it easy open your `$EDITOR` on the right line (works with vi, emacs, nano, micro, and any editor that accepts the `+` syntax to indicate the line number). -- `.ge` (requires [FZF](https://github.com/junegunn/fzf)) lists all files using FZF and opens the selected file in your `$EDITOR` -- `.lazygit` (requires [lazygit](https://github.com/jesseduffield/lazygit)) will run `lazygit` with the correct `-g` and `-w` -- `.gitui` (requires [gitui](https://github.com/extrawurst/gitui)) will run `gitui` with the correct `-d` and `-w` +## usage -There are two additional aliases used to (re)set up the bare git setup. -- `.ginit` creates the bare git repository in `$DOT_FILES` directory. -- `.gclone` will clone the repository set in `$DOT_ORIGIN` into the `$DOT_FILES` directory -Both of these aliases also set git's `status.showUntrackedFiles` to `no`. This prevents every file in `$DOT_HOME` from showing as "untracked" by git. +Most of dotGit is just some aliases that point to the `--git-dir` and `--work-tree`. + +The real daily winners for me are the "edit" (`.ge`) and "grep" (`.gg`) aliases. They get me to where I need to be fast. + +### a normal workflow for making configuration changes + +1. `.gl` - pull changes from origin +2. make some changes. Try: + - `.ge zshrc` - presents all files with `zshrc` in the name + - `.gg PATH` - runs `git grep` across your dotfiles and presents the results +4. `.gc -m 'commit comment' .zshrc` - will commit the changes +5. `.gp` - pushes the changes to the origin + +### a list of all aliases defined + + +| alias | action | note | +| --- | --- | --- | +| .git | `git --git-dir=${DOT_REPO} --work-tree=${DOT_HOME}` | | +| .g | `.git` | | +| .ga | `.git add` | | +| .gc | `.git commit` | | +| .gco | `.git checkout` | | +| .gd | `.git diff` | | +| .ge | calls the `_dotgit_ge` helper function | the dotGit edit feature [^fzf] | +| .gg | calls the `_dotgit_gg` helper function | grep your dotfiles, and jump to correct line [^line] | +| .gss | `.git status --short` | | +| .glo | `.git log --oneline --decorate` | | +| .glg | `.git log --stat` | | +| .glgp | `.git log --stat --patch` | | +| .gbl | `.git blame -w` | | +| .gb | `.git branch` | | +| .gba | `.git branch --all` | | +| .gbd | `.git branch --delete` | | +| .gbD | `.git branch --delete --force` | | +| .gm | `.git merge` | | +| .gma | `.git merge --abort` | | +| .gmc | `.git merge --continue` | | +| .gc! | `.git commit --verbose --amend` | +| .gcm | `.git commit --message` | | +| .gcp | `.git cherry-pick` | | +| .gcpa | `.git cherry-pick --abort` | | +| .gcpc | `.git cherry-pick --continue` | | +| .gclean | `.git clean --interactive -d` | | +| .ginit | `git init --bare "${DOT_REPO}"; .git config --local status.showUntrackedFiles no` | [^untracked] | +| .gp | `.git push` | requires `DOT_ORIGIN` be set | +| .gl | `.git pull` | requires `DOT_ORIGIN` be set +| .gclone | `git clone --bare "${DOT_ORIGIN}" "${DOT_REPO}"; .git config --local status.showUntrackedFiles no` | | +| .lazygit | `lazygit -g ${DOT_REPO}/ -w ${DOT_HOME}` | requires `lazygit` be installed | +| .gitui | `gitui -d ${DOT_REPO}/ -w ${DOT_HOME}` | requires gitui to be installed | + +[^line]: This works with vi, emacs, nano, micro, and any editor that accepts the line number to open the file to. +[^untracked]: Also set git's `status.showUntrackedFiles` to `no`. This prevents every file in `$DOT_HOME` from showing as "untracked" by git. +[^fzf]: requires [FZF](https://github.com/junegunn/fzf) ## requirements @@ -41,12 +76,12 @@ Both of these aliases also set git's `status.showUntrackedFiles` to `no`. This p ## installation -1. clone this repository or simply copy the [dotGit.sh](./dotGit.sh) -2. add some config sauce to your shell initialization (.i.e. `.zshrc` or `.bashrc`). The `DOT_FILES` and `DOT_HOME` variables **must be set** for the dotGit.sh to load! +1. clone this repository or simply copy the [dotgit.sh](./dotgit.sh) +2. add some configuration sauce to your shell initialization (.i.e. `.zshrc` or `.bashrc`). The `DOT_REPO` and `DOT_HOME` variables **must be set** for the dotgit.sh to load! ```bash - export DOT_FILES="${HOME}/.dotfiles" - export DOT_HOME="${HOME}" - export DOT_ORIGIN="git@github.com:user/your-dotfiles-repo.git" # optional + export DOT_REPO="${HOME}/.dotfiles" # this is where the repo will live + export DOT_HOME="${HOME}" # this is generally the same as `$HOME` + export DOT_ORIGIN="git@github.com:user/your-dotfiles-repo.git" # optional source ` ``` 3. restart your shell or `source ~/.zshrc` or `source ~/.bashrc` @@ -56,7 +91,7 @@ Both of these aliases also set git's `status.showUntrackedFiles` to `no`. This p ## initial clone cleanup -Existing config files will prevent checking out the files. To list the files causing the checkout to fail, run the following. +Existing configuration files will prevent checking out the files. To list the files causing the checkout to fail, run the following. ```bash .g checkout 2>&1|grep -E '^\s'|cut -f2-|xargs -I {} echo "{}" @@ -64,6 +99,10 @@ Existing config files will prevent checking out the files. To list the files cau To remove all the conflicting files, simply change the `echo` in the above command to `rm`. **This will delete files, so be sure you want to remove them.** Once the files are removed the checkout will succeed. +## future features + +- command line completion +- manage system configuration files ## alternatives