From bccad04ea06d38ae45fde2859947966febc3c82a Mon Sep 17 00:00:00 2001 From: Akemi Izuko Date: Sun, 13 Nov 2022 22:47:06 -0700 Subject: [PATCH] Improve git aliases --- bash/.bash_aliases | 2 -- bash/.bash_functions | 16 +++++++++++++++ bin/fitwidth.py | 27 ++++++++++++++++++-------- vim/.vim/init_scripts/key_mappings.vim | 3 +++ 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/bash/.bash_aliases b/bash/.bash_aliases index cc7a35d..639f6f2 100644 --- a/bash/.bash_aliases +++ b/bash/.bash_aliases @@ -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 diff --git a/bash/.bash_functions b/bash/.bash_functions index 3e3edff..4537627 100644 --- a/bash/.bash_functions +++ b/bash/.bash_functions @@ -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 diff --git a/bin/fitwidth.py b/bin/fitwidth.py index 5ff56c4..2c86942 100755 --- a/bin/fitwidth.py +++ b/bin/fitwidth.py @@ -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 diff --git a/vim/.vim/init_scripts/key_mappings.vim b/vim/.vim/init_scripts/key_mappings.vim index 0b94f43..37f940b 100644 --- a/vim/.vim/init_scripts/key_mappings.vim +++ b/vim/.vim/init_scripts/key_mappings.vim @@ -120,6 +120,9 @@ nnoremap . 10- " Set interior window width to 80 columns nnoremap = :vertical resize 84 + " Show full file path +nnoremap 1 + " Editing remaps ======================================== " Uppercase previous word from Insert mode inoremap vbU`>a