Skip to content

Instantly share code, notes, and snippets.

@naranyala
Created March 4, 2024 10:27
Show Gist options
  • Save naranyala/13a62ecf23901d94fd41c494e130809b to your computer and use it in GitHub Desktop.
Save naranyala/13a62ecf23901d94fd41c494e130809b to your computer and use it in GitHub Desktop.
#!/bin/bash
# Bash script to initiate a new Python project
# Check if the user wants to create a new directory
read -p "Do you want to create a new directory for your project? (y/n): " create_new_directory
if [ "$create_new_directory" == "y" ]; then
# Get project name from user input
read -p "Enter your project name: " project_name
mkdir "$project_name"
cd "$project_name" || exit
fi
# Create virtual environment
python3 -m venv venv
# Activate virtual environment
source venv/bin/activate
# Create main Python script
touch main.py
echo "# main.py" >>main.py
echo "print('Hello, Python World!')" >>main.py
# Create requirements.txt
touch requirements.txt
# Inform user about the next steps
echo -e "\nYour Python project has been initialized!"
echo -e "To activate the virtual environment, use: \n\n\tsource venv/bin/activate\n"
echo -e "To install dependencies, use: \n\n\tpip install -r requirements.txt\n"
echo -e "To run your Python script, use: \n\n\tpython main.py\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment