Trying to clean some things up

This commit is contained in:
Reid 'arrdem' McKenzie 2018-01-16 12:33:54 -08:00
parent 439cd48963
commit 2aa979cf0e
2 changed files with 13 additions and 12 deletions

5
_goto
View file

@ -1,7 +1,8 @@
#!/usr/bin/zsh
function _goto {
for label in $(_awk '{print $1}' `_gotofile`)
for label in $(_awk '{print $1;}' `_goto_file`)
do
compadd "$@" $label
compadd "$@" "${label}"
done
};

View file

@ -7,21 +7,21 @@ function _awk {
which gawk &>/dev/null && gawk $@
};
function _gotofile {
echo "${GOTO_FILE:-${HOME/.labels.tsv}}"
function _goto_file {
echo "${GOTO_FILE:-${HOME}/.labels.tsv}"
};
function _make_label {
printf '%s %s\n' "$1" $(echo "$2" | tr -d "$HOME/") >> `_gotofile`
printf '%s %s\n' "$1" $(echo "$2" | tr -d "$HOME/") >> `_goto_file`
};
function label {
if [ "${#}" -eq 0 ]; then
if [[ "${#}" -eq 0 ]]; then
echo "Usage: $ label <name> [dir]"
echo " creates a label which goto can cd to"
elif [ -d "${2}" ]; then
elif [[ -d "${2}" ]]; then
_make_label "${1}" "${2}"
else
elsep
_make_label "${1}" "${PWD}"
fi
};
@ -31,9 +31,9 @@ function goto {
echo "Usage: $ goto <name>"
echo " jumps to a record set by label"
elif [[ "$1" == "ls" ]]; then
_awk "{ print \$1 }" `_gotofile` | column -t
_awk '{print $1;}' `_goto_file` | column -t
else
dir=$(_awk "/^$1\s/ {print \$2;exit;}" `_gotofile` | head -n 1)
dir=$(_awk "/^$1\s/ {print \$2;exit;}" `_goto_file` | head -n 1)
if [[ "${dir}" != "/*" ]]; then
dir="${HOME}/${dir}"
fi