aliash is a Python tool designed to manage and manipulate your .bash_aliases file, as well as handle the bash scripts referenced within it. This tool simplifies the process of managing bash scripts and their corresponding aliases, providing a straightforward interface for creating, editing, and organizing scripts.
- Script Management: Easily add, edit, rename, and remove scripts with automatic alias management.
- Alias Management: Keeps your
.bash_aliasesfile organized by linking each script to an alias. - Configurable Paths: Customize script and alias file locations through command-line options or environment variables.
By default, aliash assumes:
- Script Directory:
$HOME/Utilitiesor as specified by theALIASH_SCRIPTS_DIRenvironment variable. - Alias File:
$HOME/.bash_aliasesor as specified by theALIASH_SCRIPTS_FILEenvironment variable.
You can override these paths at runtime with the --script-dir and --bash-aliases-file arguments.
Usage: aliash [OPTIONS] COMMAND [ARGS]...
Manage your .bash_aliases with simplicity and ease!
Options:
--script-dir PATH
--bash-aliases-file PATH
--help Show this message and exit.
Commands:
add Create a new [ALIAS] and put its alias in .bash_aliases
edit Edit an [ALIAS] in the script_dir (requires nano)
find Find an alias in .bash_aliases using a [TAG]
help Display help for an [ALIAS] in .bash_aliases
remove Remove an [ALIAS] from .bash_aliases
rename Rename an [ALIAS] in .bash_aliases
show-all Basically just ls on the script_dir
test Test all methods of aliash
Adding a Script Alias
aliash add helloworld
aliash edit helloworld # Opens the script in nano for editing
aliash show-all # Lists all available scripts
source ~/.bashrc # Reloads the updated bash configuration
helloworld # Runs the new scriptRenaming an Alias
aliash rename helloworld goodbyeworld
aliash show-all
source ~/.bashrc
goodbyeworld # Runs the renamed scriptRemoving an Alias
aliash remove goodbyeworld
aliash find world # Verifies if any alias containing 'world' existsEnvironment Variables
You can configure aliash through the following environment variables:
ALIASH_SCRIPTS_DIR: Directory to store and manage your bash scripts.ALIASH_SCRIPTS_FILE: Path to the .bash_aliases file.
1. Set up a virtual environment and install the project dependencies:
python -m . .aliash
source bin/activate
pip install --upgrade pip
pip install -r requirements.txt
pip install --editable .
aliash --help2. Set up environment variables and alias:
After installing the project, add the following to your login profile (e.g., .bashrc or .bash_profile) to ensure aliash is available in all terminal sessions:
# Define the directory where your bash scripts will be stored
ALIASH_SCRIPTS_DIR="$HOME/Utilities"
mkdir -p "$ALIASH_SCRIPTS_DIR/tmp" # for backups
# Define the path to your .bash_aliases file
ALIASH_SCRIPTS_FILE="$HOME/.bash_aliases"
touch "$ALIASH_SCRIPTS_FILE"
# Set the path to your aliash virtual environment
PATH_TO_ALIASH_VENV="$HOME/aliash/.aliash/"
# Create a shortcut for running aliash
alias aliash='$PATH_TO_ALIASH_VENV/bin/aliash'3. Reload you shell profile
source ~/.bashrc # or source ~/.bash_profileContributions are welcome! Please fork the repository and submit pull requests. Feel free to open issues for feature requests or bug reports.
This project is licensed under the MIT License.
Alias file does not exist!
user@pc:~$ aliash add helpme
Usage: aliash [OPTIONS] COMMAND [ARGS]...
Try 'aliash --help' for help.
Error: Invalid value for '--bash-aliases-file': Path '/home/user/.bash_aliases' does not exist.
Solution:
touch .bash_aliases