Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to make this an alias in zsh?

svn status | grep "^?" | awk -F "      " '{print $2}' | tr "\n" "\0" | xargs -0 svn add

I know it should be something along the lines:

alias sall = "the command"

But as the line mixes " with ' I don't know how to handle that.

share|improve this question
up vote 5 down vote accepted

You can use " for your awk command.

alias sall='svn status | grep "^?" | awk -F " " "{print $2}" | tr "\n" "\0" | xargs -0 svn add'

should work.

share|improve this answer
    
The escaped characters version gives an error about a ' not being matched. But the first version works, if you make it alias sall='svn st...' (no whitespace) – Nerian Feb 17 '11 at 17:54
    
@Nerian: If you use double quotes around the awk command, you'll need to escape the dollar sign: awk -F " " "{print \$2}" – Dennis Williamson Feb 17 '11 at 17:55
2  
Sorry, Bash needs it. Apparently zsh doesn't. After trying both, I see the difference. – Dennis Williamson Feb 17 '11 at 17:57

Use a function.

sall() {
    svn status | sed -rn 's/^\? {7}//p' | xargs -d '\n' svn add
}

(Since svn uses newline as output separator, it makes no sense to convert it to null and back.)

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .