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

If I execute

cal 2013

in terminal, it echoes the calendar for the year 2013. For the matter of fun, I'd like the terminal to echo

This year won't come.

How should I do this? I tried adding it as an alias to .bashrc, but I cannot create aliases with spaces.
Any ideas?

EDIT:

The final solution:

echo "cal() { if [[ \$@ > \"2012\" ]]; then command echo \"This year won't come.\"; else command cal \"\$@\"; fi; }" >> ~/.profile && source ~/.profile
share|improve this question
    
Enclose the function definition in single quotes (echo 'cal() {...}') and you can get rid of all the backquotes. – glenn jackman May 20 '11 at 23:50
up vote 3 down vote accepted

Stick the function in your .profile or .bash_profile

Note it is a function, not a shell script. You can also just paste that into your shell prompt. Putting it in a profile allows future login sessions to get that function defined.

share|improve this answer
    
One problem though, when I restart terminal, it doesn't work anymore, I need to do "source .profile" again. Any ideas how to make it permanent? – Richard Rodriguez May 21 '11 at 13:09
    
RiMMER: Hmm. Your terminal must not be giving you a login shell, which is a bit strange. You can put it in .bashrc then, which will be used for all interactive shells. – Seth Robertson May 21 '11 at 19:57

You must log in to answer this question.

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