How do I launch an editor from a shell script?

前端 未结 7 474
野性不改
野性不改 2021-02-04 03:44

I would like my tcsh script to launch an editor (e.g., vi, emacs):

#!/bin/tcsh
vi my_file

This starts up vi with my_file but first displays a w

7条回答
  •  星月不相逢
    2021-02-04 04:39

    I wanted to do something similar. I wanted an alias that would find the last file I was working on, and open it in vi(1) for editing. Anyway, I couldn't figure out how to do it as a readable alias (in tcsh) so I just created an ugly shell script (csh because I'm old) instead:

    #!/bin/csh
    
    set DIR = "~/www/TooMuchRock/shows/"
    
    set file = $DIR`ls -t $DIR | head -1`
    set tty = `tty`
    
    vi $file <$tty >$tty
    

    (1) kraftwerk:bin> which vi vi: aliased to /usr/local/bin/vim -u ~/.exrc

提交回复
热议问题