Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i add a command line prompt as the $EDITOR when committing in svn and git

Is it possible to have a small shell script to replace the $EDTIOR for git and svn?

So when a person not familiar with vi or emacs makes a commit and forgets to add a -m "fixed the foo bug" parameters it would not open an editor they do not know how to exit, but instead it would just prompt

Please proved a sentence on what this commit contains:

and the user just writes a small sentence, hits enter, and off it goes.

like image 597
Christoffer Björkskog Avatar asked Oct 24 '22 12:10

Christoffer Björkskog


2 Answers

For git you can edit your config file. Add editor to core section, and point to editor of your choice. For example notepad++ and git under cygwin:

[core]
    editor = git-core-editor.sh

Contents of git-core-editor.sh(put it in cygwin/bin directory) :

#!/bin/sh
"C:/Program Files (x86)/Notepad++/notepad++.exe" -multiInst -notabbar -nosession `cygpath -w -a "$*"`
like image 194
gor Avatar answered Oct 27 '22 10:10

gor


There's a reason we have nano, you know.

But you could use a small bash script:

#!/bin/sh
set -e
# Show the message template so the user knows what's up
cat $1
echo "Type your message, or press return to abort:"
head -n1 > $1
like image 45
Josh Lee Avatar answered Oct 27 '22 11:10

Josh Lee