#! /bin/zsh # # this file: # https://dataswamp.org/~incal/conf/.zsh/find-command # # works with Emacs `find-command' in: # https://dataswamp.org/~incal/emacs-init/ide/find-command.el find-zsh-command () { local cmd=$1 local fs=("${(@f)$(\grep --exclude-dir="*" -e "^\(alias $cmd=\|$cmd\ *()\)" ~/.zsh{rc,env,/(.*|*)}(N) | cut -d ':' -f 1 | sort -u)}") local ono=$fs[1] if [[ ! -z $ono ]]; then store-file-path $ono store-cmd-str $cmd fi for f in $fs; do echo-with-color green "${f//$HOME/~}" done } store-cmd-str () { local str=$1 echo -n $str > $CMD_STR } store-file-path () { local f=$1 local fpath=$(readlink -f $f) if [[ -f $fpath ]]; then echo -n $fpath > $CMD_FILE else no-file-msg $fpath fi } alias l=store-file-path