This Bash script is designed to quickly and efficiently create new Bash scripts with executable permissions and a shebang line. It also ensures that the script file opens in a mousepad immediately after creation for easy start.
Automatic Shebang Line: Adds a #!/bin/bash line to the new script, ensuring it runs with Bash. Executable Permissions: Automatically sets executable permissions on the new script file. Filename Handling: Ensures the script filename has a .sh extension. Error Handling: Provides clear error messages and prevents overwriting existing files. Background Editing: Opens the newly created script in the mousepad text editor. Usage To use the script, run it with the desired name for your new Bash script as an argument. Optionally, you can add a verbosity flag -v to get detailed output.
./mkscript.sh <script_name>
Put this script in /usr/local/bin and remove '.sh' extension so you can run this globally and without './' cp mkscript.sh mkscript sudo mv mkscript /usr/local/bin
./mkscript.sh my_script This will create a file named my_script.sh, make it executable, add a shebang line, and open it in vim.
<script_name>: The name for the new script. If the .sh extension is not provided, it will be added automatically.
Clone the repository to your local machine:
git clone https://github.com/0Reab/bash-script-creator.git Navigate to the script directory:
cd bash-script-creator Make the script executable:
chmod +x mkscript.sh
The script will not overwrite if filename conflicts with existing files in the directory but don't test your luck :D. You can customize the script to use a different text editor by changing the vim command in the script. Contributing Feel free to fork this repository and submit pull requests if you have any improvements or additional features you'd like to add. :D