Linux
OS-Mgmt
Customterminal

Useful CLI Customizations & Shortcuts for Daily Work

Customizing Bash Prompt

Edit ~/.bashrc and add the following line to enhance your terminal prompt with useful information:

PS1='\[\033[0;31m\]\u@\h\[\033[0m\]@\[\033[1;33m\]\A\[\033[0m\]@\[\033[1;32m\]$(free | awk '\''/Mem:/ {printf "%.2f%%", $3/$2 * 100.0}'\'')\[\033[0m\]@ \[\033[1;34m\][~]\[\033[0m\] \[\033[1;34m\]\w\[\033[0m\] $(git branch 2>/dev/null | grep -e "^\*" | sed "s/*/(/" | sed "s/$/)/")\n\[\033[1;37m\]# \[\033[0m\]'

Features:

  • Shows username, hostname, and current time
  • Displays RAM usage percentage dynamically
  • Shows current working directory and active Git branch

Kubernetes Shortcuts (Aliases)

Add the following aliases in ~/.bashrc or ~/.zshrc to speed up Kubernetes operations:

alias k='kubectl'
alias kgp='kubectl get pods'
alias kgs='kubectl get services'
alias kgn='kubectl get nodes'
alias kd='kubectl describe'
alias kdp='kubectl delete pod'
alias kctx='kubectl config use-context'
alias kns='kubectl config set-context --current --namespace'

Terraform Shortcuts

alias tf='terraform'
alias tfi='terraform init'
alias tfp='terraform plan'
alias tfa='terraform apply'
alias tfd='terraform destroy'

Docker Shortcuts

alias d='docker'
alias dps='docker ps'
alias dpa='docker ps -a'
alias di='docker images'
alias drm='docker rm'
alias drmi='docker rmi'
alias dexec='docker exec -it'
alias dlog='docker logs'

Git Shortcuts

alias gs='git status'
alias ga='git add .'
alias gc='git commit -m'
alias gp='git push'
alias gl='git log --oneline --graph --decorate'
alias gco='git checkout'
alias gb='git branch'

General Productivity Aliases

alias cls='clear'
alias ..='cd ..'
alias ...='cd ../..'
alias l='ls -lah'
alias la='ls -A'
alias ll='ls -alF'
alias c='clear && ls'

Applying Changes

After adding these to your shell configuration file, apply the changes:

source ~/.bashrc  # for Bash
source ~/.zshrc   # for Zsh

🧙 AI Wizard - Instant Page Insights

Click the button below to analyze this page.
Get an AI-generated summary and key insights in seconds.
Powered by Perplexity AI!