Using Ratpoison/Aliasing

From Wikibooks, open books for an open world
Jump to navigation Jump to search

The command shell[edit | edit source]

Ratpoison has a built-in "run" dialog, a quick way to launch any program without having to start a console. Type C-t ! to get a little command box from which you can launch your program. This is most useful for launching graphical applications without tying up a console, as you won't be able to see any of the output of any purely command line programs.

From the same command prompt you can invoke the ratpoison command to tweak settings and do various actions. All these commands can be looked up in the mainpage, and they are all preceded by ratpoison -c.

For example, to set the "rudeness level" to five (will be explained soon) you type ratpoison -c rudeness 5.

All these commands can of course be executed from within a console window; C-t ! is simply a more convenient variant of a command shell.

Aliasing[edit | edit source]

As mentioned before, ratpoison can be thought of as GNU Screen for window managing; like command line shells, it is possible to alias long commands to shorter versions.

This can be done through the extended command ability (which resembles C-t !), which is invoked via "C-t :". This opens a little box just like C-t ! does, but instead of executing shell commands, the input will be sent to ratpoison which will attempt to interpret this input as a ratpoison command; suppose one often runs Mozilla Firefox, but one grew weary of always opening a shell with C-t c and then typing in "mozilla-firefox &" (the ampersand is necessary so you can use the terminal for other things, otherwise the terminal will simply display any error or informative messages Firefox emits), or "C-t ! mozilla-firefox"?

One could decide to use a shorter name- input C-t :, and enter in "alias firefox exec mozilla-firefox", which would allow one to simply C-t: firefox, and Firefox would open up; one could even go C-t: "alias f exec mozilla-firefox" if they were rather lazy, and used no other programs beginning with the letter "f".

Aliasing is not limited to regular program names- if one drops the "exec", one could alias the command "quit" to "q": "C-t : alias q quit".

As a matter of fact, all the keyboard shortcuts one has learned for ratpoison, like C-t p, they all are actually aliases for longer commands! C-t q (which quits ratpoison) is actually an alias for C-t : quit. This is another area of borrowing from Emacs- Emacs similarly represents all keys on a keyboard and all combinations thereof, as aliases of Emacs functions.

(In these examples the command "exec" is necessary to have ratpoison evaluate the succeeding string as a shell command, and not another ratpoison command. Please see the official documentation on exec for more details; exec essentially does the same thing as C-t !).