diff --git a/.config/shell/functions b/.config/shell/functions index 8168236..9cd9df4 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -68,10 +68,13 @@ edshell() { ("") file="$CONFIG_SHELL_FUNCTIONS";; (zsh) file="$CONFIG_ZSH/.zshrc";; (prof*) file="$HOME/.zprofile";; - (*) file=$(find $CONFIG_SHELLS -name "$1*" | head -1 | grep . || echo "$CONFIG_SHELLS/$1");; + (-f) grepfile="$(grep --recursive "\(^$2()\|alias $2=\)" $CONFIG_SHELLS -n -m 1)" + file=$(echo "$grepfile" | cut -d':' -f1) + line=$(echo "$grepfile" | cut -d':' -f2);; + (*) file="$(find $CONFIG_SHELLS -name "$1*" | head -1 | grep . || echo "$CONFIG_SHELLS/$1")";; esac checksum="$(md5sum "$file")" - $EDITOR "$file" + $EDITOR $(test "$line" && echo "+$line") "${file%:*}" test "$checksum" != "$(md5sum $file)" && source "$HOME/.zprofile" && exec $SHELL } @@ -174,8 +177,8 @@ alias hx='sudo hexedit --maximize --color' # Paginated hexyl hex() { hexyl "$@" | "${PAGER:-less}" } -alias dic="cat $XDG_DATA_HOME/dictcc/dict.txt | tail -n +16 | - fzf --tiebreak=length --bind='alt-bspace:clear-query'" + +alias dic="cat $XDG_DATA_HOME/dictcc/dict.txt | sed '/#/d;/&/d;/^$/d' | fzf --tiebreak=length --bind='alt-bspace:clear-query'" alias dict="rlwrap rdictcc -d $XDG_DATA_HOME/dictcc" alias dictu="dict -i $XDG_DATA_HOME/dictcc/dict.txt" diff --git a/.config/shell/git b/.config/shell/git index 363210b..835be40 100644 --- a/.config/shell/git +++ b/.config/shell/git @@ -27,13 +27,20 @@ sy() { } gcn() { - if test $# -eq 0 || test -e $1 + root="$(git rev-parse --show-toplevel)" + if test "$root" = "$DATA" then - fulldir="$(realpath ${1:-$PWD})" - dir="${fulldir#$DATA/*/}" + if test $# -eq 0 || test -e $1 + then + fulldir="$(realpath ${1:-$PWD})" + dir="${fulldir#$root/*/}" + else + dir="notes/$1" + fulldir="$root/2-standards/$dir" + fi else - dir="notes/$1" - fulldir="$DATA/2-standards/$dir" + fulldir="$(realpath ${1:-$PWD})" + dir="${fulldir#$root/}" fi echo "$dir:" >/tmp/gcn-msg git commit -v --template /tmp/gcn-msg ${@:2} -- $fulldir