Skip to content

Instantly share code, notes, and snippets.

@edrex
Created February 13, 2016 22:17
Show Gist options
  • Select an option

  • Save edrex/6ff6bf552227765bb901 to your computer and use it in GitHub Desktop.

Select an option

Save edrex/6ff6bf552227765bb901 to your computer and use it in GitHub Desktop.
ZSH e(dit) and p(roject) commands
export EDITOR='emacsclient -t'
# Handy e command to edit in already open emacs
alias e='emacsclient -nc'
printEntryPoint() {
entryPoints=("README.md" "package.json");
for name in "${entryPoints[@]}"; do
[[ -a "$name" ]] && echo "$name" && return
done
echo "."
}
# Usage: p my<TAB>
# cd to project dir, open new editor frame, and print git status
p() {
cd ~/Projects/$1;
e "$(printEntryPoint)";
[[ -a .git ]] && git status;
}
_p() {
_arguments '1: :->project'
case $state in
project)
_files -W ~/Projects
;;
esac
}
compdef _p p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment