[Solved] Bash Aliases used through MATE launcher menu

Forum rules
Before you post please read this

[Solved] Bash Aliases used through MATE launcher menu

Postby RobertLM78 on Sat Jan 26, 2013 8:21 pm

For a little more background, I'm using the classic style menus in MATE. I have a bash alias that I'd like to run through the menu (i.e. Mozo/"Main Menu") - is there a way to do this? Specifically this alias calls to rename a file and launch a program, but nothing I've tried seems to yield anything (i.e. I've tried putting different quotes around the alias, as well as switching from "application" to "application in terminal" options within mozo, the latter is the option that seems to make sense to me). Anyway, the real question is can an alias be used by main menu which uses a simple command (mv) then launches an application? Thanks for reading :).

(By the way, the alias works just fine through the terminal, but I'd rather use the main menu here, since the primary function of the alias is to launch the program :)).
Last edited by RobertLM78 on Sun Jan 27, 2013 3:16 pm, edited 1 time in total.
Dell Dimension 4600i, ATI Rage 128, 1 GB RAM, Linux Mint 13 32-bit, MATE edition
Dell Latitude D400, Intel Graphics, 1 GB RAM, Linux Mint 13 32-bit, MATE edition
Gateway DX4860, Sapphire Radeon HD 5450, 6 GB RAM, Linux Mint 13 64-bit, MATE edition
User avatar
RobertLM78
Level 3
Level 3
 
Posts: 166
Joined: Sat Apr 28, 2012 4:19 am
Location: US

Linux Mint is funded by ads and donations.
 

Re: Bash Aliases used through MATE launcher menu

Postby bjornmu on Sun Jan 27, 2013 4:06 am

No that can't work, only bash knows your aliases, they only make sense from within bash. MATE has no clue. The alternative would be to write a small bash script and run that instead.
User avatar
bjornmu
Level 3
Level 3
 
Posts: 156
Joined: Wed Dec 19, 2012 2:50 am
Location: Trondheim, Norway

Re: Bash Aliases used through MATE launcher menu

Postby RobertLM78 on Sun Jan 27, 2013 5:03 am

bjornmu wrote:No that can't work, only bash knows your aliases, they only make sense from within bash. MATE has no clue. The alternative would be to write a small bash script and run that instead.

Thanks for the reply Bjorn. I was starting to think that might be the case - it looks like I got some reading to do in bash scripting :).
[noobquestion] So, can the menu then run the bash script (i.e. make a menu item that executes the script)? [/noobquestion]
Speaking to another person about this topic, it was suggested that I have the mv command auto-ran upon exit from the program, which would equally as well for my need - but I'm not sure how to go about doing that. Ah well, the bash script is probably the way to go :).
Dell Dimension 4600i, ATI Rage 128, 1 GB RAM, Linux Mint 13 32-bit, MATE edition
Dell Latitude D400, Intel Graphics, 1 GB RAM, Linux Mint 13 32-bit, MATE edition
Gateway DX4860, Sapphire Radeon HD 5450, 6 GB RAM, Linux Mint 13 64-bit, MATE edition
User avatar
RobertLM78
Level 3
Level 3
 
Posts: 166
Joined: Sat Apr 28, 2012 4:19 am
Location: US

Re: Bash Aliases used through MATE launcher menu

Postby bjornmu on Sun Jan 27, 2013 6:06 am

A bash script starts with the line
Code: Select all
#!/bin/bash

Then add whatever command you want to run, one per line.

If this is to run from the menu, the file name needs to be the same every time, is it? If so, store this script as e,g, /home/<user name>/myscript.sh (choose a more meaningful name :) ) and add that to the menu. You must also make it executable:
Code: Select all
chmod a+x myscript.sh
User avatar
bjornmu
Level 3
Level 3
 
Posts: 156
Joined: Wed Dec 19, 2012 2:50 am
Location: Trondheim, Norway

Re: Bash Aliases used through MATE launcher menu

Postby RobertLM78 on Sun Jan 27, 2013 3:16 pm

Thanks Bjorn, I got a nice little bash script working now :D. (Indeed, the file name stays the same, except for a silly space that gets added when it is saved from within the application, which causes problems later down the line when I go to restart ;)).
Dell Dimension 4600i, ATI Rage 128, 1 GB RAM, Linux Mint 13 32-bit, MATE edition
Dell Latitude D400, Intel Graphics, 1 GB RAM, Linux Mint 13 32-bit, MATE edition
Gateway DX4860, Sapphire Radeon HD 5450, 6 GB RAM, Linux Mint 13 64-bit, MATE edition
User avatar
RobertLM78
Level 3
Level 3
 
Posts: 166
Joined: Sat Apr 28, 2012 4:19 am
Location: US

Re: [Solved] Bash Aliases used through MATE launcher menu

Postby bjornmu on Sun Jan 27, 2013 3:48 pm

Ah yes, space should never have been allowed in file or directory names. Too late to change that now. :roll:
User avatar
bjornmu
Level 3
Level 3
 
Posts: 156
Joined: Wed Dec 19, 2012 2:50 am
Location: Trondheim, Norway

Re: [Solved] Bash Aliases used through MATE launcher menu

Postby RobertLM78 on Mon Jan 28, 2013 9:06 pm

bjornmu wrote:Ah yes, space should never have been allowed in file or directory names. Too late to change that now. :roll:

Well, I guess it's really the result of running a cross-platform application whose native platform (which was Mac OS) didn't seem to have a problem with silly spaces :) (and of course doesn't allow entering '_'s ;) ). A bit tempermental the thing is really, in theory the -load parameter for the application shouldn't have had a problem with the space as long as the the path and filename were in quotes, but as it turned out, doing that didn't work :(.

Anyway, I'm quite pleased with what I've got going now, if not ideal. Thanks again for the help Bjorn :).
Dell Dimension 4600i, ATI Rage 128, 1 GB RAM, Linux Mint 13 32-bit, MATE edition
Dell Latitude D400, Intel Graphics, 1 GB RAM, Linux Mint 13 32-bit, MATE edition
Gateway DX4860, Sapphire Radeon HD 5450, 6 GB RAM, Linux Mint 13 64-bit, MATE edition
User avatar
RobertLM78
Level 3
Level 3
 
Posts: 166
Joined: Sat Apr 28, 2012 4:19 am
Location: US

Linux Mint is funded by ads and donations.
 

Return to Scripts & Bash

Who is online

Users browsing this forum: No registered users and 3 guests