3 ms·
Simplest I can think of: $ echo 'cat > "$@"' >editor $ chmod +x editor $ GIT_EDITOR=./editor git commit -a stuff [master b2d3915] stuff
by unhammer 10y ago
Simplest I can think of:
$ echo 'cat > "$@"' >editor
$ chmod +x editor
$ GIT_EDITOR=./editor git commit -a
stuff
[master b2d3915] stuff
1 file changed, 1 insertion(+)
You'll need to hit enter before ^D.
You can add simple Emacs-like keybindings by changing that into
$ echo 'rlwrap cat > "$@"' >editor
Or just learn ed:
$ GIT_EDITOR=ed git commit --amend -a
256
1c
stuff and more stuff
.
w
271
[master c5092a6] stuff and more stuff
Date: Thu Apr 6 12:58:18 2017 +0200
1 file changed, 1 insertion(+)
(the numbers are ed telling me how much was read and written; `1c` means change the first line; `.` means I'm done inserting (go back to command mode) and `w` means write/save; exit with ^D)
- evacchi 10y agoThanks for the tips!
- kevinmgranger 10y agoIf anyone is having trouble getting the first one working, you need a shebang at the top of the file! $ printf '#!/usr/bin/env sh\ncat > "$@"\n' > editor But the second point is more valid. Ed is the standard editor.
- unhammer 10y agoWhat system are you on that needs the shebang? bash 4 on Ubuntu seems to just run it in bash, though I guess it probably shouldn't :-)