I sometimes use a classical terminal where mcedit is my prefered editor, and often like to pass a line number, to correct a program/script.
To uniformely call them edit source.sh 123
I wrote this script, which I placed as 'edit' in the path:
#!/bin/bash
# - edit a file using mcedit or gedit, depending on X11 or console invoking.
# - jump to specified line, if any.
Xedit=/usr/bin/gedit
if [[ $TERM = "linux" ]]; then
if [ $# -eq 1 ]; then
mcedit $1
else if [ $# -eq 2 ]; then
# echo "edit invoked\t/usr/bin/mcedit +$2 $1" >> /tmp/edit.log
/usr/bin/mcedit +$2 $1
else if [ $# -eq 0 ]; then
/usr/bin/mcedit
fi
fi
fi
else if [[ $TERM = "xterm" ]]; then
# scheint nicht zu helfen
# LANGUAGE=C
export LC_ALL=C
if [ $# -eq 1 ]; then
$Xedit $1
else if [ $# -eq 2 ]; then
# echo "edit invoked\t/usr/bin/scite -open:$1 -goto:$2" >> /tmp/edit.log
# $Xedit -open:$1 -goto:$2
$Xedit +$2 $1
else if [ $# -eq 0 ]; then
$Xedit
fi
fi
fi
fi
fi
Use see old debug instructions from when I used scite, not gedit, as graphical editor.
Something, which doesn't work this way, is opening of multiple files like this:
edit *.html
if there is more than one html-File, so the pattern gets expanded to multiple files.
Valid invocations are:
edit
edit foofile
edit foofile 123
from X or terminal.