Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Is it possible to use an alias within a custom shortcut?

For example, suppose I have the alias

alias cal="google-chrome --new-window calendar.google.com"

Can I create a custom shortcut that binds "Ctrl+Alt+C" to "cal"?

I have tried but it doesn't seem to work.

share|improve this question

1 Answer 1

No, the commands run by keyboard bindings are not parsed via a shell. Your best bet is to create a directory bin in your homedir (mkdir -p ~/bin). Write a script named cal that runs your command, save it in ~/bin and make it executable.

$ mkdir -p ~/bin
$ cat > ~/bin/cal << 'EOF'
#!/bin/sh
exec google-chrome --new-window calendar.google.com
EOF
$ chmod +x ~/bin/cal

If you didn't have a bin directory in your homedir already, you need to log out and back in again for it to be added to your PATH. Once that is done, binding a keyboard binding to run "cal" should do what you want.

share|improve this answer

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.