On Saturday, September 21, 2024, Chet Ramey <chet.ra...@case.edu> wrote:

> On 9/21/24 1:03 AM, Oğuz wrote:
>
>> On Saturday, September 21, 2024, Koichi Murase <myoga.mur...@gmail.com
>> <mailto:myoga.mur...@gmail.com>> wrote:
>>
>>     Emacs has `auto-mode-alist'. VS Code has `files.associations'.
>>
>>
>> I think he meant a command line option. Like something you can put in
>> FCEDIT
>>
>
> I did. But if there aren't any options to select the syntax editing mode,
> you can use an approach like this:
>
> : ${EDITOR:=emacs}
>
> case $1 in
> *.bash) FN=$1 MV=':' ;;
> *)      FN=${1}.bash MV=mv ;;
> esac


plz consider separate file existance check

ext=bash

*) i=1 f=${1}.$i.$ext
.. esac

# why do u =${1} instead =$1.blabla ... ?

 while [[ -e "$f" ]] ; do
f=${1}.$[ ++i ].$ext
 done

# the reason i use $[ instead $(( was cause long ago it benchmarked faster

greets ..

$MV "$1" "$FN"
> $EDITOR "$FN"
> $MV "$FN" "$1"
>
> Wrap that in a script or function and assign it to FCEDIT. You could
> also use ln and rm instead of mv, but this works. And test it; I didn't.
>
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>                  ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/
>

Reply via email to