Supercharge your terminal and eliminate context switching. This repository contains the essential Bash functions I use daily to accelerate Python and web development. Quickly spin up new projects, run tests, manage databases, and deploy codeβall with simple, memorable commands. Ideal for developers looking to optimize their CLI efficiency.
- Project Scaffolding: Quickly generate Python, Django, and Flask projects with a single command.
- Virtual Environment Management: Automate the creation and activation of Python virtual environments.
- Django CLI Tool: A comprehensive helper (
dj) for all common Django tasks (runserver, migrations, testing, etc.). - Code Quality: Integrate
flake8andautopep8for automatic code style checking and formatting. - Git Automation: Add, commit, and push changes with one command.
- Database Management: Start, stop, and check the status of MySQL/PostgreSQL servers.
- File Templates: Generate pre-configured Python and HTML template files.
Ensure you have the following installed on your system:
- Bash (v4.0+)
- Python 3 and
pip - Virtualenv (
python3 -m pip install virtualenv) - Django (Will be installed by the
djtool, but required for its functions) - Flake8 & Autopep8 (
pip install flake8 autopep8) - Pytest (
pip install pytest) - JSON Server (for the
jsonfunction, install via npm:npm install -g json-server) - Systemd (for database management functions on Linux)
-
Clone or download the repository.
git clone <your-repo-url> cd bash-development-utils
-
Source the functions file in your
.bashrc. The most maintainable method is to source the file externally. Add the following line to the end of your~/.bashrcfile:# Replace /path/to/ with the actual path to the file. if [ -f ~/bash-development-utils/bash_functions.txt ]; then source ~/bash-development-utils/bash_functions.txt fi
For a cleaner setup, you can rename
bash_functions.txtto.bash_functionsand move it to your home directory:cp bash_functions.txt ~/.bash_functionsThen source it from your
~/.bashrclike this:# Source custom bash functions if [ -f ~/.bash_functions ]; then source ~/.bash_functions fi
-
Reload your Bash configuration.
source ~/.bashrc
Once installed, you can use any of the functions below in your terminal.
| Command | Description |
|---|---|
list |
Displays a categorized list of all available custom functions and aliases. |
| Command | Description |
|---|---|
pynew <project_name> |
Creates a complete Python project structure with src/, tests/, docs/, and a virtual environment. |
mkpython <project_name> |
Creates a minimal Python project with a virtual environment. |
activenv |
Activates the virtual environment in the current directory. |
addenv |
Creates a virtual environment in the current directory. |
req |
Installs Python dependencies from requirements.txt in the active virtual environment. |
pp |
Runs main.py in the current directory. |
pa |
Runs app.py in the current directory. |
npy <filename.py> |
Creates a new Python file with a helpful template and makes it executable. |
pstyle <file/dir> |
Checks code style with flake8 and automatically formats it with autopep8. |
ptest |
Runs tests using pytest. |
findfunc <function_name> |
Searches for a function name across all .py files in the current directory. |
mkreq |
Generates a requirements.txt file from the currently installed packages in the virtual environment. |
pyig |
Generates a comprehensive .gitignore file for Python projects. |
The dj function is a powerful CLI tool for managing Django projects.
| Command | Description |
|---|---|
dj new <project_name> |
Creates a new Django project, virtual environment, and initializes Git. |
dj app <app_name> |
Creates a new app within the current Django project. |
dj run |
Starts the Django development server. |
dj -m or --migrate |
Applies database migrations. |
dj -mm or --makemigrations |
Creates new migration files. |
dj -su or --superuser |
Creates a superuser. |
dj test |
Runs the project's test suite. |
dj testcov |
Runs tests with coverage reporting. |
dj shell |
Opens the Django shell. |
dj -c or --check |
Checks the project for common problems. |
dj -cs or --collect |
Collects static files. |
dj -h or --help |
Shows the full help message. |
| Command | Description |
|---|---|
flask <project_name> |
Scaffolds a basic Flask project structure. |
nht <filename.html> |
Creates a basic HTML5 template file. |
dbstart <mysql/postgresql> |
Starts a database server (requires sudo). |
dbstop <mysql/postgresql> |
Stops a database server (requires sudo). |
dbstatus <mysql/postgresql> |
Checks the status of a database server. |
json <file.json> |
Serves a JSON file via json-server for API mocking. |
| Command | Description |
|---|---|
gitit "commit message" |
Executes git add ., git commit -m "message", and git push origin main in sequence. |
The list command also shows useful aliases, including:
cleansub/cleanweb: Organize subtitle or HTML files.md: View Markdown files in the terminal.bat: Usebatcatfor syntax-highlighted file viewing.warp/warpd/warps: Manage Cloudflare WARP VPN connection.mm/ma: Editmain.pyorapp.pywith themicroeditor.sv2/ev2: Start and stop the v2rayA service.ll: List directory contents respecting.gitignore.e.: Open the current directory inranger.ebash/ebashf/etc.: Quick commands to edit Bash configuration files.
Contributions are welcome! Feel free to fork this repository and submit Pull Requests to add new functions, improve existing ones, or enhance the documentation.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFunction) - Commit your Changes (
git commit -m 'Add some AmazingFunction') - Push to the Branch (
git push origin feature/AmazingFunction) - Open a Pull Request
This project is distributed under the MIT License. See the LICENSE file for more information.
Tags: bash productivity python django flask automation developer-tools cli git