Here's a breakdown of my .zshrc file, explaining each alias, export, and function to help you understand how I’ve customized my terminal workflow.
Â
Aliases
Aliases simplify repetitive commands, saving time and effort. Here are the ones I’ve configured:
Â
1. YOLO Git Commit
alias yolo='git add . && git commit -m "YOLO commit" && git push origin main'
Purpose : For those "quick and dirty" git commits when working on a personal project.
How it works :
Stages all changes (git add .).
Commits with a default message "YOLO commit".
Pushes to the main branch.
2. TypeScript YOLO Commit
alias tsyolo='npx tsc && git add . && git commit -m "YOLO commit" && git push origin main'
Purpose : Adds TypeScript compilation to the YOLO commit process.
How it works :
Runs the TypeScript compiler (npx tsc).
Stages all changes, commits, and pushes like the yolo alias.
3. Edit .zshrc
alias zedit='cursor ~/.zshrc'
Purpose : Quickly opens the .zshrc file in the editor.
How it works :
Uses cursor (replace with your preferred editor if necessary).
4. Reload .zshrc
alias zsource='source ~/.zshrc'
Purpose : Reloads the shell configuration without restarting the terminal.
How it works :
Sources the .zshrc file, applying any changes.
5. Kill Process on Port 3000
alias kill3000="lsof -t -i :3000 | xargs kill -9"
Purpose : Terminates any process using port 3000.
How it works :
Finds the process ID (lsof -t -i :3000).
Kills the process forcefully (kill -9).
6. Download YouTube Videos
alias download-youtube="node /Volumes/SSD/scripts/youtube-downloader-communicator/add-video.js"
Purpose : Triggers a Node.js script to download YouTube videos.
How it works :
Executes the script with Node.js. Ensure the script exists at the specified path.
Exports
Exports modify the environment variables for enhanced functionality.
Â
1. Prevent Homebrew Cleanup
export HOMEBREW_NO_INSTALL_CLEANUP=1
Purpose : Stops Homebrew from automatically removing old versions of installed formulae during updates.
2. Adjust PATH
export PATH="/opt/homebrew/bin:$PATH"
Purpose : Ensures Homebrew binaries are prioritized in the PATH variable.
How it works :
Adds /opt/homebrew/bin to the front of the PATH.
Functions
Functions are more flexible than aliases and allow more complex behavior.
Â
1. Find an Alias
aliasfinder() {
alias | fzf --preview="echo {} | cut -d'=' -f2-" --height=20 --border --preview-window=down:3:wrap
}
Purpose : Search through aliases interactively.
How it works :
Lists all aliases.
Pipes them to fzf (fuzzy finder).
Displays the full command in a preview window.
2. Restart Docker Containers
alias docker-restart='docker compose down && docker compose up -d'
Purpose : Restarts Docker containers with a single command.
How it works :
Stops and removes the containers (docker compose down).
Starts them again in detached mode (docker compose up -d).
These customizations make my workflow smoother, enabling quick actions and saving me from repetitive typing. Feel free to adapt these commands to your own .zshrc and optimize your terminal experience!
Â