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

2 Answers 2

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

a quick alternative, in case it helps anyone in the future

to add a "Save Image As.." keyboard shortcut to Chrome as Shift-Ctrl-S

command: bash -c "xdotool click 3 && sleep 0.5 && xdotool key v;"

also, if you're organized enough to keep a separate file with your shortcuts & then sourcing it at the end of ~/.bashrc for example, the following works & can comes in handy ;)

command: bash -c ". /tmp/keyboardShortcutsFcns && tefAliasFcn"

content of the "/tmp/keyboardShortcutsFcns" file from the above example:

# test fcn to be called ( maybe ? ) from a keyboard shortcut tefAliasFcn(){ notify-send "tef alias function called succesfully !"; }

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.