config/shell: improve directory interaction
This commit is contained in:
parent
8f429a45ea
commit
1fa210b99b
|
@ -68,10 +68,13 @@ edshell() {
|
||||||
("") file="$CONFIG_SHELL_FUNCTIONS";;
|
("") file="$CONFIG_SHELL_FUNCTIONS";;
|
||||||
(zsh) file="$CONFIG_ZSH/.zshrc";;
|
(zsh) file="$CONFIG_ZSH/.zshrc";;
|
||||||
(prof*) file="$HOME/.zprofile";;
|
(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
|
esac
|
||||||
checksum="$(md5sum "$file")"
|
checksum="$(md5sum "$file")"
|
||||||
$EDITOR "$file"
|
$EDITOR $(test "$line" && echo "+$line") "${file%:*}"
|
||||||
test "$checksum" != "$(md5sum $file)" && source "$HOME/.zprofile" && exec $SHELL
|
test "$checksum" != "$(md5sum $file)" && source "$HOME/.zprofile" && exec $SHELL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,8 +177,8 @@ alias hx='sudo hexedit --maximize --color'
|
||||||
# Paginated hexyl
|
# Paginated hexyl
|
||||||
hex() { hexyl "$@" | "${PAGER:-less}" }
|
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 dict="rlwrap rdictcc -d $XDG_DATA_HOME/dictcc"
|
||||||
alias dictu="dict -i $XDG_DATA_HOME/dictcc/dict.txt"
|
alias dictu="dict -i $XDG_DATA_HOME/dictcc/dict.txt"
|
||||||
|
|
||||||
|
|
|
@ -27,13 +27,20 @@ sy() {
|
||||||
}
|
}
|
||||||
|
|
||||||
gcn() {
|
gcn() {
|
||||||
|
root="$(git rev-parse --show-toplevel)"
|
||||||
|
if test "$root" = "$DATA"
|
||||||
|
then
|
||||||
if test $# -eq 0 || test -e $1
|
if test $# -eq 0 || test -e $1
|
||||||
then
|
then
|
||||||
fulldir="$(realpath ${1:-$PWD})"
|
fulldir="$(realpath ${1:-$PWD})"
|
||||||
dir="${fulldir#$DATA/*/}"
|
dir="${fulldir#$root/*/}"
|
||||||
else
|
else
|
||||||
dir="notes/$1"
|
dir="notes/$1"
|
||||||
fulldir="$DATA/2-standards/$dir"
|
fulldir="$root/2-standards/$dir"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
fulldir="$(realpath ${1:-$PWD})"
|
||||||
|
dir="${fulldir#$root/}"
|
||||||
fi
|
fi
|
||||||
echo "$dir:" >/tmp/gcn-msg
|
echo "$dir:" >/tmp/gcn-msg
|
||||||
git commit -v --template /tmp/gcn-msg ${@:2} -- $fulldir
|
git commit -v --template /tmp/gcn-msg ${@:2} -- $fulldir
|
||||||
|
|
Loading…
Reference in New Issue