This script provides a highly configurable action menu that streamlines the execution of frequently used commands. Designed for easy setup and customization, it allows users to create personalized options, enabling efficient management of tasks directly from the terminal. Ideal for both individual and shared environments.
Simple Bash Action Menu
The Simple Bash Action Menu is a versatile and easily configurable script designed to streamline the execution of frequently used terminal commands. It supports a range of usage options, allowing it to be customized for specific users or run globally. The menu can even launch automatically upon terminal startup for a more seamless user experience.
Key Features
- User Validation: Ensures that the script is not run as the
www-data
user, promoting secure operations. - Interactive Menu: Provides a color-coded terminal interface, enhancing user interaction.
- Customizable Actions: Users can easily expand the menu by adding new actions tailored to their needs.
- Integration Options: Supports the creation of command aliases and automatic script execution at user login.
Getting Started
To deploy the Simple Bash Action Menu, clone the repository and adjust permission settings to make the script executable:
# Clone the repository
git clone https://github.com/HugoALVES7/simple_bash_action_menu.git
# Make the script executable
chmod +x /path/to/script/menu.sh
Adding and Customizing Actions
Enhancing the action menu involves modifying the show_options()
and main_menu()
functions. Users can include their own actions as follows:
echo " ${YELLOW}3${RESET} - Action 3"
echo " ${YELLOW}4${RESET} - Git pull my website" # Example
In the main_menu()
, simply add a case
for the new action:
case "$choice" in
1) action_1 ;;
2) action_2 ;;
3) action_3 ;;
4) pull_website;; # Example
The script allows adding custom functions for specific actions too:
action_1() {
# Replace this with actual logic, e.g.,
cd /var/www/my_website
git pull
}
Integration Options
Effortlessly integrate the action menu script within daily workflows by configuring it as an alias or running it upon login. Examples include:
# For current user
echo "alias command_name='/path/to/script/menu.sh'" >> ~/.bashrc
source ~/.bashrc
# For all users
echo "alias command_name='/path/to/script/menu.sh'" | sudo tee -a /etc/bash.bashrc
source /etc/bash.bashrc
Security Considerations
The script incorporates safeguards to prevent unauthorized modifications by implementing a security check against the www-data
user, thus maintaining system integrity.
Conclusion
The Simple Bash Action Menu is a powerful tool that simplifies users' interaction with the command line by providing a customizable, user-friendly interface. It is particularly beneficial for those who need quick access to recurring tasks while ensuring safe execution and easy integration into existing workflows.