Creating Desktop Shortcuts for Terminal Apps with Randomly Generated Number Filenames using Command Line Arguments
In this article, we will discuss how to create desktop shortcuts for terminal apps with randomly generated number filenames using command line arguments. This can be useful in various scenarios, such as creating unique and easy-to-remember shortcuts for frequently used terminal commands.
Prerequisites
Before we begin, make sure you have the following:
- A terminal app installed on your computer
- Basic knowledge of command line arguments and scripting
Generating Randomly Generated Number Filenames
To generate a randomly generated number filename, we can use the following command:
filename=$(mktemp -u | sed 's/\//_/g')
This command uses the mktemp command to generate a unique temporary filename, and then uses the sed command to replace any forward slashes with underscores. The resulting filename is stored in the filename variable.
Creating the Desktop Shortcut
To create the desktop shortcut, we can use the following command:
echo "[Desktop Entry]
Version=1.0
Type=Application
Terminal=true
Name=$filename
Exec=gnome-terminal -- $filename
Icon=utilities-terminal
Path=$PWD
StartupNotify=false" > $filename.desktop
This command creates a new desktop entry file with the name stored in the filename variable. The desktop entry specifies that the app is a terminal app, sets the name and icon, and specifies the command to execute when the shortcut is clicked. The gnome-terminal command is used to launch the terminal app with the filename as an argument.
Setting the Desktop Shortcut as an Executable
To set the desktop shortcut as an executable, we can use the following command:
chmod +x $filename.desktop
This command adds execute permissions to the desktop shortcut file, allowing it to be run as a command.
Adding the Desktop Shortcut to the Desktop
To add the desktop shortcut to the desktop, we can use the following command:
cp $filename.desktop ~/Desktop
This command copies the desktop shortcut file to the desktop, making it easily accessible.
In this article, we have discussed how to create desktop shortcuts for terminal apps with randomly generated number filenames using command line arguments. By following the steps outlined in this article, you can easily create unique and easy-to-remember shortcuts for frequently used terminal commands.