[Solved] Bash Aliases used through MATE launcher menu

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
User avatar
RobertLM78
Level 3
Level 3
Posts: 183
Joined: Sat Apr 28, 2012 4:19 am
Location: US

[Solved] Bash Aliases used through MATE launcher menu

Post 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 :)).
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Gateway DX4860, Sapphire Radeon HD 5450, 8 GB RAM, Mint 17.3 64-bit (Rosa), MATE
AMD Ryzen 3-3100, AMD Radeon RX 570, 16 GB RAM, Mint 21 (Vanessa), MATE
User avatar
bjornmu
Level 3
Level 3
Posts: 189
Joined: Wed Dec 19, 2012 2:50 am
Location: Trondheim, Norway

Re: Bash Aliases used through MATE launcher menu

Post 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.
User avatar
RobertLM78
Level 3
Level 3
Posts: 183
Joined: Sat Apr 28, 2012 4:19 am
Location: US

Re: Bash Aliases used through MATE launcher menu

Post 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 :).
Gateway DX4860, Sapphire Radeon HD 5450, 8 GB RAM, Mint 17.3 64-bit (Rosa), MATE
AMD Ryzen 3-3100, AMD Radeon RX 570, 16 GB RAM, Mint 21 (Vanessa), MATE
User avatar
bjornmu
Level 3
Level 3
Posts: 189
Joined: Wed Dec 19, 2012 2:50 am
Location: Trondheim, Norway

Re: Bash Aliases used through MATE launcher menu

Post 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
User avatar
RobertLM78
Level 3
Level 3
Posts: 183
Joined: Sat Apr 28, 2012 4:19 am
Location: US

Re: Bash Aliases used through MATE launcher menu

Post 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 ;)).
Gateway DX4860, Sapphire Radeon HD 5450, 8 GB RAM, Mint 17.3 64-bit (Rosa), MATE
AMD Ryzen 3-3100, AMD Radeon RX 570, 16 GB RAM, Mint 21 (Vanessa), MATE
User avatar
bjornmu
Level 3
Level 3
Posts: 189
Joined: Wed Dec 19, 2012 2:50 am
Location: Trondheim, Norway

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

Post by bjornmu »

Ah yes, space should never have been allowed in file or directory names. Too late to change that now. :roll:
User avatar
RobertLM78
Level 3
Level 3
Posts: 183
Joined: Sat Apr 28, 2012 4:19 am
Location: US

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

Post 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 :).
Gateway DX4860, Sapphire Radeon HD 5450, 8 GB RAM, Mint 17.3 64-bit (Rosa), MATE
AMD Ryzen 3-3100, AMD Radeon RX 570, 16 GB RAM, Mint 21 (Vanessa), MATE
Locked

Return to “Scripts & Bash”