Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.