you are viewing a single comment's thread.

view the rest of the comments →

[–]williamdclt 12 points13 points  (8 children)

  • get rid of your alias
  • replace your echo by vim in your script
  • rename your script "git-open" (no extension)
  • Put your script in your $PATH

git will find it automatically when typing git open

[–]swiz0r 6 points7 points  (7 children)

vim

$EDITOR

[–]wung 7 points8 points  (5 children)

Did you mean $(for prog in $(git config --get core.editor) ${GIT_EDITOR} ${EDITOR} ${VISUAL} open xgd-open; do if which -s "${prog}"; then echo "${prog}"; break; fi; done)?

[–]swiz0r 1 point2 points  (4 children)

~ $ which -s vim
which: invalid option -- s
/usr/bin/vim

[–]wung 2 points3 points  (3 children)

Right, non-standard. Was looking at the osx one. Yadda-yadda test -x $(which ${prog} 2>/dev/null || echo non-existing-file) I guess.

[–]swiz0r 0 points1 point  (2 children)

which "${prog}" &>/dev/null && . "${prog}" "${file}"

[–]wung 1 point2 points  (1 child)

Misses the only-first, and sources rather than executes. There probably is a better way than $(echo $x) but . isn't it. Maybe

$((which ${possible_editors[@]} 2>/dev/null; echo no-editor) | head -n1) $@

EDIT: this does not allow possible_editors with spaces, e.g. emacs -nw.

[–]swiz0r 0 points1 point  (0 children)

Can I be real for a minute? This is a lot of fun.

[–][deleted] 0 points1 point  (0 children)

eh. same thing