Optimizing CLI Efficiency: My Cross-Server Command Management Solution
2024-12-14
During server migration workflows, I encountered significant latency issues when executing routine commands on newly configured Linux instances. This operational friction motivated me to adapt an existing local command management tool into a distributed synchronization solution.
So a small tool has been born, which is amid to make it more efficient when using the CLI.
Cross-server synchronization
multi-terminal integration (supports bash/zsh/sh)
Download script: fastcode.sh(A version with multi-server synchronization functionality, but it requires server support. A server deployment tutorial will be released later when there is time.)
Initial development focused on local machine operation and using txt to storage, with subsequent optimization implementing rsync-based updates and conflict resolution for multi-server environments.
And it simpler to use the offline version: fastcode-offline-version.sh, just need to put in your local path and set alias.
Installation Steps
Modify configuration:
# Edit fastcode.sh, modify the following settings
CLIENT_ID="Your client name"
# Example: Server-No1
API_KEY="Your API key"
# Default: your-token
If you encounter permission issues, check file permissions:
chmod +x ~/bin/fastcode
Create personal bin directory and install:
mkdir -p ~/bin
mv fastcode.sh ~/bin/fastcode
chmod +x ~/bin/fastcode
Add to environment variables (if not already added):
echo 'alias fastcode="$HOME/bin/fastcode/fastcode.sh"' >> ~/.bashrc
# If using bash
echo 'alias fastcode="$HOME/bin/fastcode/fastcode.sh"' >> ~/.zshrc
# If using zsh
source ~/.bashrc # or source ~/.zshrc
chmod +x $HOME/bin/fastcode/fastcode.sh
Now you can use the
fastcode
command directly
Notes:
After installation, use
fastcode -host
to check if the configuration is correctIf command not found, make sure you have executed the source command
If you encounter permission issues, check file permissions:
chmod +x ~/bin/fastcode
Usage Instructions
Basic Commands
fastcode -f keyword
- Search commandsfastcode -all
- Show all commands (including IDs)fastcode -add
- Add new commandfastcode -edit ID
- Edit specified commandfastcode -host
- Show current host label
Command Categories
Commands can be divided into two categories based on server type:
Current server only - Only visible on the current server
Common to all servers - Visible on all servers
Adding Commands
When using fastcode -add
to add commands:
Select command type (current server/all servers)
Select or create category
Enter command content
Enter command description (optional)
Editing Commands
Use fastcode -all
to view all commands and their IDs, then use fastcode -edit ID
to edit a specific command.