Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recognize zsh parameter/variable definitions #96

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions desk
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,14 @@ cmd_current() {
# Last clause in the grep regexp accounts for fish functions.
len=$((${#NAME} + 2))
(( len > longest )) && longest=$len
local DOCLINE=$(
local BOTHLINES=$(
grep -B 1 -E \
"^(alias ${NAME}=|export ${NAME}=|(function )?${NAME}( )?\()|function $NAME" "$DESKPATH" \
| grep "#")

"^(alias ${NAME}=|export ${NAME}=|(function )?${NAME}( )?\()|function $NAME|^typeset (-[a-zA-Z]+)? ${NAME}" \
"$DESKPATH")
local DOCLINE=$(echo "${BOTHLINES}"|sed -n 1p)
if [[ $BOTHLINES == *typeset* ]]; then
NAME="\${${NAME}}"
fi
if [ -z "$DOCLINE" ]; then
out+=" ${NAME}"$'\n'
else
Expand Down Expand Up @@ -276,6 +279,7 @@ get_callables() {
| sed 's/alias \([^= ]*\)=.*/\1/' \
| sed 's/export \([^= ]*\)=.*/\1/' \
| sed -E "s/(function )?(${FNAME_CHARS}+) ?\(\).*/\2/" \
| sed 's/typeset \(-[a-zA-Z]\+\)\? \([^=]\+\)=.*/\2/' \
| sed -E "s/function (${FNAME_CHARS}+).*/\1/"
}

Expand Down