From e278f4c62c2d677580dda72252bffd1848056302 Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Mon, 22 Feb 2021 23:13:21 -0500 Subject: [PATCH] git/sh: Move git aliases from shell to git-config There's several benefits to doing this. Most notably, the aliases become available to other programs (i.e. in mutt(1) or vim(1)). As a side benefit, completions also work for aliases out of the box, so we can scrap our hacky __git_complete code in the bashrc. This commit also cleans up a couple unused aliases and removes the core.editor=$EDITOR line from the git config... like... that's the default? :) Must have been an oversight when I went through the effort to distinguish between vi vs vim --- .aliases | 25 ------------------------- .bashrc | 13 ------------- .config/git/config | 17 ++++++++++++++--- 3 files changed, 14 insertions(+), 41 deletions(-) diff --git a/.aliases b/.aliases index f497487..e7cd988 100644 --- a/.aliases +++ b/.aliases @@ -13,31 +13,6 @@ alias ls='ls ${colorflag}' alias l='ls -lAh ${colorflag}' alias ll='ls -lh ${colorflag}' -# Git aliases -alias ga='git add' -alias gc='git commit --verbose' -alias gd='git diff' -alias gp='git push' -alias gs='git status' -alias gst='git status' -alias gl='git pull' -alias gco='git checkout' -alias gf='git fetch' -alias glg='git log --stat --decorate' -alias glgr='git log --oneline | head -n 10' -alias g_='git stash' -alias g_p='git stash pop' -alias gb='git branch' -alias grb='git rebase' -alias grs='git reset' -alias gm='git merge' -alias gg='git grep' -alias vlg='vim -c "GV"' # 'vim log' of a file - -# Quick Actions -alias curljson='curl -H "Content-Type: application/json"' -alias sysmail='mutt -f /var/mail/$USER' - # Lightweight funcs aw() { w3m "https://wiki.archlinux.org/index.php?search=$1"; } ddg() { w3m "https://duckduckgo.com/lite?q=$1"; } diff --git a/.bashrc b/.bashrc index 20e975d..61530c4 100644 --- a/.bashrc +++ b/.bashrc @@ -18,7 +18,6 @@ PROMPT_COMMAND="history -a" # Record history after each command # Includes include() { [ -r "$1" ] && source "$1"; } include "$HOME/.shrc" # Common shell configuration -include "$HOME/.bash/git-completion.bash" # Git Completion include "$HOME/etc/console_theme.sh" # Virtual Console colors (if TERM == "linux") include "$HOME/.bashrc.local" # System specific settings @@ -50,15 +49,3 @@ if [ -n "$USE_FANCY_PROMPT" ]; then PS2="$YELLOW> $RESET" fi fi - -# Git completion for ~/.aliases -if [ -n "$(type -t __git_complete)" ] && - [ "$(type -t __git_complete)" == "function" ]; then - __git_complete ga _git_add - __git_complete gco _git_checkout - __git_complete gd _git_diff - __git_complete gr _git_rebase - __git_complete gb _git_branch -fi - -alias rb='source ~/.bashrc' diff --git a/.config/git/config b/.config/git/config index 65e48e9..f33bc75 100644 --- a/.config/git/config +++ b/.config/git/config @@ -1,6 +1,3 @@ -[core] - editor = $EDITOR - [user] email = alex@alexkarle.com name = Alex Karle @@ -13,3 +10,17 @@ annotate = yes [pull] ff = only +[alias] + s = status -s + ss = status + l = log --stat + d = diff + c = commit + a = add + f = fetch + rb = rebase + co = checkout + g = grep + rs = reset + p = push + b = branch -- libgit2 0.28.4