Improve git aliases

This commit is contained in:
Akemi Izuko 2023-12-23 20:13:58 -07:00
parent 6e3afc33b8
commit 9a851058ba
Signed by: akemi
GPG key ID: 8DE0764E1809E9FC
4 changed files with 38 additions and 10 deletions

View file

@ -90,10 +90,8 @@ fi
# =================================================================== # ===================================================================
if command -v git &> /dev/null; then if command -v git &> /dev/null; then
alias gitst='git status -s' alias gitst='git status -s'
alias gitllog='git log --graph --all --oneline --decorate --color=always | sed -n 1,5p'
alias gitlloga='git log --graph --all --oneline --decorate --color=always | less -R' alias gitlloga='git log --graph --all --oneline --decorate --color=always | less -R'
alias gitllogw='git log --graph --all --date=relative --color=always --pretty="format:%C(auto,yellow)%h%C(auto,magenta) %C(auto,blue)%>(14,trunc)%ad %C(auto,green)%<(13,trunc) %aN%C(auto,red)%gD% D %C(auto,reset)%s" | less -R' alias gitllogw='git log --graph --all --date=relative --color=always --pretty="format:%C(auto,yellow)%h%C(auto,magenta) %C(auto,blue)%>(14,trunc)%ad %C(auto,green)%<(13,trunc) %aN%C(auto,red)%gD% D %C(auto,reset)%s" | less -R'
alias gitdesk='github .'
alias gitcontrib=' alias gitcontrib='
git ls-files | git ls-files |
while read f while read f

View file

@ -78,6 +78,8 @@ runk() {
override="c" override="c"
elif [[ "$1" =~ p ]]; then elif [[ "$1" =~ p ]]; then
override="p" override="p"
elif [[ "$1" =~ a ]]; then
override="a"
elif [[ "$1" =~ b ]]; then elif [[ "$1" =~ b ]]; then
override="b" override="b"
fi fi
@ -92,6 +94,12 @@ runk() {
-e 's#\(log([^)]\+)\)#(\1/log(10))#g' \ -e 's#\(log([^)]\+)\)#(\1/log(10))#g' \
-e 's#ln(\([^)]\+\))#log(\1)#g' \ -e 's#ln(\([^)]\+\))#log(\1)#g' \
)" )"
local awk_ver="$(echo "$@" | sed \
-e 's#\*\*#^#g' \
-e 's#log(\([^)]\+\))#(log(\1)/log(10))#g' \
-e 's#log2(\([^)]\+\))#(log(\1)/log(2))#g' \
-e 's#ln(\([^)]\+\))#log(\1)#g' \
)"
local bc_ver="$(echo "$@" | sed \ local bc_ver="$(echo "$@" | sed \
-e 's#\*\*#^#g' \ -e 's#\*\*#^#g' \
-e 's#ln(\([^)]\+\))#l(\1)#g' \ -e 's#ln(\([^)]\+\))#l(\1)#g' \
@ -105,6 +113,9 @@ runk() {
elif command -v python3 &>/dev/null && [[ -z "$override" ]] || [[ "$override" == p ]]; then elif command -v python3 &>/dev/null && [[ -z "$override" ]] || [[ "$override" == p ]]; then
python3 -c "from math import *; print($py_ver)" python3 -c "from math import *; print($py_ver)"
if [[ $is_verbose -eq 1 ]]; then printf 'Using python: %s\n' "$py_ver"; fi if [[ $is_verbose -eq 1 ]]; then printf 'Using python: %s\n' "$py_ver"; fi
elif command -v gawk &>/dev/null && [[ -z "$override" ]] || [[ "$override" == a ]]; then
gawk --bignum "BEGIN { print $awk_ver }"
if [[ $is_verbose -eq 1 ]]; then printf 'Using gawk: %s\n' "$awk_ver"; fi
else else
echo "$bc_ver" | bc --mathlib echo "$bc_ver" | bc --mathlib
if [[ $is_verbose -eq 1 ]]; then printf 'Using benchcalc: %s\n' "$bc_ver"; fi if [[ $is_verbose -eq 1 ]]; then printf 'Using benchcalc: %s\n' "$bc_ver"; fi
@ -123,6 +134,11 @@ function exit () {
builtin exit builtin exit
} }
# Quick way to glance at recent git history
gitllog() {
git log -n "${1:-6}" --all --oneline --graph --decorate --color=always
}
# Necessary alias =================================================== # Necessary alias ===================================================
russy () { russy () {
if [[ "$1" == "baka" ]]; then if [[ "$1" == "baka" ]]; then

View file

@ -4,14 +4,25 @@ import argparse, sys
# Parse args # Parse args
parser = argparse.ArgumentParser(prog="FitWidth v1.0.0", parser = argparse.ArgumentParser(prog="FitWidth v1.0.0",
description='Fit text (stdin|file) to a given character width'); description='Fit text (stdin|file) to a given character width');
parser.add_argument('-t', '--truncate', action='store_true', parser.add_argument(
help='Truncate longer lines with a "..."'); '-t', '--truncate',
parser.add_argument('-w', '--wrap', action='store_true', action='store_true',
help='Wrap longer lines across two lines with a ">" at the end'); help='Truncate longer lines with a "..."',
parser.add_argument('width', type=int, );
help='Wrap longer lines across two lines with a ">" at the end'); parser.add_argument(
parser.add_argument('file', type=argparse.FileType('r'), nargs='?', '-w', '--wrap',
help="File to read from, instead of stdin"); action='store_true',
help='Wrap longer lines across two lines with a ">" at the end',
);
parser.add_argument(
'width', type=int,
help='Wrap longer lines across two lines with a ">" at the end',
);
parser.add_argument(
'file', nargs='?',
type=argparse.FileType('r'),
help="File to read from, instead of stdin",
);
args = parser.parse_args(); args = parser.parse_args();
# Validate args # Validate args

View file

@ -120,6 +120,9 @@ nnoremap <leader><leader>. 10<C-w>-
" Set interior window width to 80 columns " Set interior window width to 80 columns
nnoremap <leader><leader>= :vertical resize 84<CR> nnoremap <leader><leader>= :vertical resize 84<CR>
" Show full file path
nnoremap <C-g> 1<C-g>
" Editing remaps ======================================== " Editing remaps ========================================
" Uppercase previous word from Insert mode " Uppercase previous word from Insert mode
inoremap <C-y> <ESC>vbU`>a inoremap <C-y> <ESC>vbU`>a