Page 1 of 1

[Solved] Bash Aliases used through MATE launcher menu

Posted: Sat Jan 26, 2013 8:21 pm
by RobertLM78
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 :)).

Re: Bash Aliases used through MATE launcher menu

Posted: Sun Jan 27, 2013 4:06 am
by bjornmu
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.

Re: Bash Aliases used through MATE launcher menu

Posted: Sun Jan 27, 2013 5:03 am
by RobertLM78
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 :).

Re: Bash Aliases used through MATE launcher menu

Posted: Sun Jan 27, 2013 6:06 am
by bjornmu
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

Re: Bash Aliases used through MATE launcher menu

Posted: Sun Jan 27, 2013 3:16 pm
by RobertLM78
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 ;)).

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

Posted: Sun Jan 27, 2013 3:48 pm
by bjornmu
Ah yes, space should never have been allowed in file or directory names. Too late to change that now. :roll:

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

Posted: Mon Jan 28, 2013 9:06 pm
by RobertLM78
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 :).