Created
February 13, 2016 22:17
-
-
Save edrex/6ff6bf552227765bb901 to your computer and use it in GitHub Desktop.
ZSH e(dit) and p(roject) commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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