简体   繁体   中英

bash alias not working(open git status output files as vim tab)

I am trying to make this alias working:

alias ciao="vim -p `git status --short | awk '{print $2}'; git show --pretty="format:" --name-only`

Basically I would like to open every files, printed by git status , as vim tab. The command works properly when I run it in the prompt directly but I cannot make an alias of it.

Looks like vim -p is applied to the first file printed but not to the others (when the files from git status are more than one).

I would love if somebody can tell me what I am doing wrong: in the alias I pasted there are obvious problems (like escaping), sorry about that.

alias ciao='vim -p $(
    git status --short | awk "{print $2}";
    git show --pretty="format:" --name-only
)'

Anything more complicated than ls -l should be a function, not an alias.

ciao () {
  vim -p $(git status --short | awk '{print $2}'
            git show --pretty="format:" --name-only)
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM