Using an alias in find -exec

前端 未结 7 732
醉酒成梦
醉酒成梦 2021-01-07 19:11

I have a very long command in bash, which I do not want to type all the time, so I put an alias in my .profile

alias foo=\'...\'

Now I want

7条回答
  •  无人及你
    2021-01-07 20:00

    I ran into the same thing and pretty much implemented skjaidev's solution.

    I created a bash script called findVim.sh with the following contents:

    [ roach@sepsis:~ ]$ cat findVim.sh                                                                                                        #!/bin/bash                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
    find . -iname $1 -exec vim '{}' \;
    

    Then I added the the .bashrc alias as:

    [ roach@sepsis:~ ]$ cat ~/.bashrc | grep fvim                                                                                         
    alias fvim='sh ~/findVim.sh'
    

    Finally, I reloaded .bashrc with source ~/.bashrc.

    Anyways long story short I can edit arbitrary script files slightly faster with: $ fvim foo.groovy

提交回复
热议问题