1
0
Fork 0

Shortmap additions and improvements

master
Mike Gerwitz 2014-08-21 23:34:48 -04:00
commit d73811b536
No known key found for this signature in database
GPG Key ID: F22BB8158EE30EAB
3 changed files with 69 additions and 5 deletions

View File

@ -21,6 +21,8 @@ By default, the following mappings are available, each with tab completion:
* `a` - git add
* `A` - git add -A
* `b` - git branch
* `bv` - git branch -v
* `B` - git bisect
* `Bs` - git bisect start
* `Bg` - git bisect good
@ -34,7 +36,13 @@ By default, the following mappings are available, each with tab completion:
* `d` - git diff
* `ds` - git diff --stat
* `f` - git fetch
* `lh` - git log --oneline --decorate --color | head
* `L` - git log --show-signature
* `Ld` - git log --show-signature --decorate
* `Lf` - git log --show-signature --first-parent
* `Lg` - git log --show-signature --graph
* `Lgd` - git log --show-signature --graph --decorate
* `Lm` - git log --show-signature --merges
* `Ln` - git log --show-signature --no-merges
* `m` - git merge
* `ma` - git merge --abort
* `p` - git push
@ -47,6 +55,10 @@ By default, the following mappings are available, each with tab completion:
* `Rc` - git rebase --continue
* `s` - git status --short
* `S` - git stash
* `Sa` - git stash apply
* `Sl` - git stash list
* `Sp` - git stash pop
* `Ss` - git stash show
* `t` - execute tig
* `T` - git tag
* `-` - git checkout -

View File

@ -2,6 +2,8 @@
#
# Provides short mappings for common Git commands
#
# Copyright (C) 2011, 2012, 2013, 2014 Mike Gerwitz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
@ -13,9 +15,11 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# #
declare -r __git_short_path="${1:-$(pwd)/shortmaps}"
__git-short_cmdok()
{
@ -70,6 +74,11 @@ __git-short_shortalias()
local -r shortcmd="$1"
shift
if [ "$shortcmd" == --help ]; then
__git-short_help
return
fi
# if we're not within a git dir, fall back to an actual command of this
# name
__gitdir >/dev/null || {
@ -91,10 +100,41 @@ __git-short_shortalias()
}
__git-short_help()
{
cat <<EOH
Git Shortmaps loaded from:
- $HOME/.git-shortmaps
- $__git_short_path
Defined shortmaps:
$( __git-short_map_out | sed 's/^/ /' )
git-shortmaps Copyright (C) 2011, 2012, 2013, 2014 Mike Gerwitz
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions; see the GNU GPLv3+ for details at
<https://www.gnu.org/licenses/>.
EOH
}
__git-short_map_out()
{
local shortcmd
for shortcmd in "${!__git_short_maps[@]}"; do
echo -e "$shortcmd\t${__git_short_maps[$shortcmd]}"
done \
| sort \
| { type column &>/dev/null && column -t -s$'\t' || cat; }
}
# load shortmaps from cwd (or provided path) and home dir (if available)
__git-short_load_maps()
{
local -r path="${1:-./shortmaps}"
local -r path="$1"
cat "$path" ~/.git-shortmaps 2>/dev/null
}
@ -120,5 +160,5 @@ while read shortcmd comp cmd; do
__git-short_docomplete "$shortcmd" __git-short_shortmap
__git-short_register_alias "$shortcmd"
done < <( __git-short_load_maps "$1" )
done < <( __git-short_load_maps "$__git_short_path" )

View File

@ -1,5 +1,7 @@
a _git_add :add
A _git_add :add -A
b _git_branch :branch
bv _git_branch :branch -v
B _git_bisect :bisect
Bs _git_bisect :bisect start
Bg _git_bisect :bisect good
@ -13,7 +15,13 @@ CS _git_commit :commit -S -am
d _git_diff :diff
ds _git_diff :diff --stat
f _git_fetch :fetch
lh _git_log |git log --oneline --decorate --color | head
L _git_log :log --show-signature
Ld _git_log :log --show-signature --decorate
Lf _git_log :log --show-signature --first-parent
Lg _git_log :log --show-signature --graph
Lgd _git_log :log --show-signature --graph --decorate
Lm _git_log :log --show-signature --merges
Ln _git_log :log --show-signature --no-merges
m _git_merge :merge
ma : :merge --abort
p _git_push :push
@ -26,6 +34,10 @@ Ra _git_rebase :rebase --abort
Rc _git_rebase :rebase --continue
s : :status --short
S _git_stash :stash
Sa _git_stash :stash apply
Sl _git_stash :stash list
Sp _git_stash :stash pop
Ss _git_stash :stash show
t : tig
T _git_tag :tag
- : :checkout -