More compdef fuckery

This commit is contained in:
Reid 'arrdem' McKenzie 2018-01-16 12:08:09 -08:00
parent 76faa1cf8f
commit 5bc8484332
2 changed files with 6 additions and 11 deletions

2
_goto
View file

@ -5,4 +5,4 @@ function _goto {
done done
}; };
compdef _goto goto complete -o default -F _goto goto

View file

@ -7,16 +7,11 @@ function _awk {
which gawk &>/dev/null && gawk $@ which gawk &>/dev/null && gawk $@
}; };
function _strip_homedir {
};
function _gotofile { function _gotofile {
echo $GOTO_FILE "$HOME/.labels.tsv" | _awk "{print \$1}" echo "${GOTO_FILE:-${HOME/.labels.tsv}}"
};
function _make_label { function _make_label {
printf "%s %s\n" $1 $(echo $2 | tr -d "$HOME/") >> `_gotofile` printf '%s %s\n' "$1" $(echo "$2" | tr -d "$HOME/") >> `_gotofile`
}; };
function label { function label {
@ -38,13 +33,13 @@ function goto {
_awk "{ print \$1 }" `_gotofile` | column -t _awk "{ print \$1 }" `_gotofile` | column -t
else else
dir=$(_awk "/^$1\s/ {print \$2;exit;}" `_gotofile` | head -n 1) dir=$(_awk "/^$1\s/ {print \$2;exit;}" `_gotofile` | head -n 1)
if [[ "$dir" != "/*" ]]; then if [[ "${dir}" != "/*" ]]; then
dir="${HOME}/${dir}" dir="${HOME}/${dir}"
fi fi
if [[ ! -e "$dir" ]]; then if [[ ! -e "${dir}" ]]; then
echo "Error: Label '$1' resolved to missing path '$dir'" echo "Error: Label '$1' resolved to missing path '$dir'"
else else
cd "$dir" cd "${dir}"
fi fi
fi fi
}; };