LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Permanent Command Aliases - Slackware 9.1 (https://www.linuxquestions.org/questions/slackware-14/permanent-command-aliases-slackware-9-1-a-275647/)

erraticassassin 01-09-2005 06:13 AM

Permanent Command Aliases - Slackware 9.1
 
Hi all,

I'd like to set up a couple of permanent command aliases on a laptop running Slackware 9.1. As I understand it, global command aliases should be added to the /etc/profile file in order to make them permanent and have them available to all users. So, I added these lines:

alias dtp="lpr -o page-left=72 page-right=72 page-top=72 page-bottom=72 cpi=12"
alias wallpaper="display -geometry 800x600+0+0 -window root"

The first command is to dump a plain text file to my printer with one inch margins and 12 characters per inch ( I use CUPS as my print spooler). The second is to set a desktop wallpaper - I use fluxbox and the default wallpaper utility, fbsetbg, keeps generating errors.

So... having added these lines to the /etc/profile file, I logged out and logged back in again. Testing the dtp command results in an error message stating that the directory page-left=72 couldn't be found.

As for the wallpaper command - I tested it first in a plain text console and got an error message saying that the X Server wasn't running. This is fine - it implies that the alias was at least recognised. However, once I started X and tried the command from an xterm, it wasn't recognised.

Can anyone provide any hints as to where I'm going wrong?

Cedrik 01-09-2005 06:33 AM

For xterm, try to start it with :
xterm +ls

(ls = login shell, so /etc/profile is loaded)

for the dtp alias, you may have to quote the option

lpr_opts="-o 'page-left=72 page-right=72 page-top=72 page-bottom=72 cpi=12'"
alias dtp="lpr $lpr_opts"

Did you test your lpr command with these options to see if it works before ?

[edit]
Just checked the xterm option, it works with :
xterm -ls

erraticassassin 01-09-2005 09:41 AM

Hi Cedrik,

Yes, I have tried the lpr command with all of the options and it worked fine before. I had to enclose the options in quote marks, but it worked. If I understand correctly, your suggestion is to store the options in a global variable, then invoke the command using the variable? I'll give it a bash anyway* and see what happens. I'll also try the xterm suggestion. Thanks!


* Ouch! No pun intended.

erraticassassin 01-09-2005 03:08 PM

Update: I have amended my /etc/profile file as suggested, and both aliases work perfectly.

Caution! For anyone else reading this, please note the single quotes inside the double quotes in Cedrik's suggestion for lpr, on the line beginning lpr_opts. It won't work without them. See, my laser printer is a cheap ol' Samsung and has a tendency to leave flecks of toner on the printout... and I thought the single quotes were toner flecks at first, and ... mumble mumble mumble...

Anyway! All is right with the world now... :D


All times are GMT -5. The time now is 08:32 AM.