[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [feature request] Add ".sh" or ".bash" extension to tmpfile generate
From: |
alex xmb sw ratchev |
Subject: |
Re: [feature request] Add ".sh" or ".bash" extension to tmpfile generated by `fc` |
Date: |
Sun, 22 Sep 2024 11:38:30 +0200 |
On Saturday, September 21, 2024, Chet Ramey <chet.ramey@case.edu> wrote:
> On 9/21/24 1:03 AM, Oğuz wrote:
>
>> On Saturday, September 21, 2024, Koichi Murase <myoga.murase@gmail.com
>> <mailto:myoga.murase@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 chet@case.edu http://tiswww.cwru.edu/~chet/
>
- Re: [feature request] Add ".sh" or ".bash" extension to tmpfile generated by `fc`, (continued)
Re: [feature request] Add ".sh" or ".bash" extension to tmpfile generated by `fc`, Martin D Kealey, 2024/09/20
Re: [feature request] Add ".sh" or ".bash" extension to tmpfile generated by `fc`, Chet Ramey, 2024/09/20
Re: [feature request] Add ".sh" or ".bash" extension to tmpfile generated by `fc`, shynur ., 2024/09/20