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
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 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='
git ls-files |
while read f

View file

@ -78,6 +78,8 @@ runk() {
override="c"
elif [[ "$1" =~ p ]]; then
override="p"
elif [[ "$1" =~ a ]]; then
override="a"
elif [[ "$1" =~ b ]]; then
override="b"
fi
@ -92,6 +94,12 @@ runk() {
-e 's#\(log([^)]\+)\)#(\1/log(10))#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 \
-e 's#\*\*#^#g' \
-e 's#ln(\([^)]\+\))#l(\1)#g' \
@ -105,6 +113,9 @@ runk() {
elif command -v python3 &>/dev/null && [[ -z "$override" ]] || [[ "$override" == p ]]; then
python3 -c "from math import *; print($py_ver)"
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
echo "$bc_ver" | bc --mathlib
if [[ $is_verbose -eq 1 ]]; then printf 'Using benchcalc: %s\n' "$bc_ver"; fi
@ -123,6 +134,11 @@ function 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 ===================================================
russy () {
if [[ "$1" == "baka" ]]; then

View file

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

View file

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