Create a clickable desktop shortcut for an alias
To be exact there is a method, i.e. running the alias in an interactive shell;
I.e., create a desktop file with the following Exec=
line:
Exec=bash -c 'exec bash -i <<<"gotoheaven"'
-
bash -c '[...]'
: starts a non-interactive shell (this is required to take advantage of the<<<
redirection) and runs[...]
in it; -
exec bash -i <<<"gotoheaven"
: replaces the non-interactive shell with an interactive shell and redirectsgotoheaven
to the interactive shell's STDIN, which sources~/.bashrc
and runs the alias.
However since this requires more or less the same effort of copy-pasting the command from the alias into the new desktop file but runs an additional shell, I suggest you to just go for copy-pasting the command from the alias into the new desktop file as outlined in one of the answers to this question.
You seem to be stuck on the fact that the shortcut must run the alias and not an identical command, which just doesn't make sense unless you need to run the command in the environment set by ~/.bashrc
(which doesn't seem to be the case). Just create a desktop file that runs the same command.
Aliases belong to shell, they aren't external commands. So it's impossible to create shortcut for alias.
However, it is possible to take the command you reference in alias and create .desktop file which is basically shortcut and after Exec= put the command you wish to run
Here's an example of what it would look like:
[Desktop Entry]
Name=MyAppName
Type=Application
Exec=xdg-open /path/to/heaven
Terminal=false
Icon=/path/to/image.png
field is optional. Terminal=
part must be placed to indicate whether the output needs to be shown on terminal or not. In your case, I assume it's not necessary since you are using xdg-open
to open some file
You may need to make the file executable by right clicking the file , opening Properties, and checking "Execute" under Permissions tab
Or alternatively through chmod +x /path/to/MyAppName.desktop