link is a minimalist and global utility for creating aliases that surpasses standard Bash alias and symlink mechanisms. It supports files, C/C++ code with automatic compilation, Linux commands, argument passing, and works in any shell (Bash, Zsh, Fish).
Key Features
- Universality
Supports C files, other files, and commands.
Automatically compiles and runs C files with passed arguments.
Creates executable wrappers for commands that support arguments ("$@").
- Global Mode
Using --global creates aliases in ~/.local/bin.
Aliases are available in any shell without ./
- Alias History
All aliases are stored in ~/.link_aliases in the format:
alias = target_or_command
Easy to view all aliases or transfer them to another machine.
- Argument Passing
All aliases automatically support argument passing.
Examples:
up -y
mbl input.txt
notes +10 ~/Documents
- Shell Neutrality
Works in Bash, Zsh, Fish, and any POSIX terminals.
No additional shell configuration needed for commands and C files.
- Automatic C File Compilation
Aliases for .c files compile them on-the-fly and execute.
Example:
link mbl = main_basic_lexer.c --global
mbl input.txt # auto-compiles and runs
- Support for Commands with Spaces and Paths
Can create aliases for complex commands:
link notes = "nano ~/Documents/notes.txt" --global
notes
Installation
- Compile the utility:
gcc link.c -o link
- (Optional) Add to PATH to avoid specifying the path:
mkdir -p ~/.local/bin
export PATH="$HOME/.local/bin:$PATH"
Usage
Create global alias for a command:
./link up = "sudo apt update" --global
up -y # works in any shell
Create global alias for a C file:
./link mbl = main_basic_lexer.c --global
mbl input.txt # auto-compiles and runs
Create local alias (works only in current directory):
./link notes = "nano ~/Documents/notes.txt"
./notes
Check alias history:
cat ~/.link_aliases
# mbl = main_basic_lexer.c
# up = sudo apt update
Advantages Over Standard Bash Methods
Feature | Bash alias | Symlink | link |
---|---|---|---|
Argument support | ✅ (Limited) | ❌ | ✅ |
C files with auto-compile | ❌ | ❌ | ✅ |
Global availability | ❌ (Per-shell) | ✅ | ✅ |
Cross-shell support | ❌ (Shell-specific) | ✅ | ✅ |
Alias history | ❌ | ❌ | ✅ |
Minimal configuration | ❌ (Requires shell config) | ✅ | ✅ |
Future Plans
Add --remove to delete aliases and clean history.
Add alias listing with link --list.
Integration with automation scripts and Makefiles.
Link makes working with aliases convenient, global, and transparent, combining the capabilities of aliases, symlinks, and wrapper scripts in a single tool.