|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Remote install: curl -fsSL https://raw.githubusercontent.com/YOUR_USERNAME/YOUR_REPO/main/alias.sh | bash |
| 4 | + |
| 5 | +# Define aliases |
| 6 | +declare -A ALIASES=( |
| 7 | + # Docker |
| 8 | + ["dps"]="docker ps -a --size --format \"table {{.Names}}\t{{.Status}}\t{{.RunningFor}}\t{{.Size}}\"" |
| 9 | + ["di"]="docker images" |
| 10 | + ["dex"]="docker exec -it" |
| 11 | + ["dlog"]="docker logs -f" |
| 12 | + ["dstop"]="docker stop \$(docker ps -aq)" |
| 13 | + ["drm"]="docker rm \$(docker ps -aq)" |
| 14 | + ["dri"]="docker rmi \$(docker images -q)" |
| 15 | + ["dprune"]="docker system prune -af" |
| 16 | + |
| 17 | + # Docker Compose |
| 18 | + ["dcu"]="docker compose up -d" |
| 19 | + ["dcd"]="docker compose down" |
| 20 | + ["dcl"]="docker compose logs -f" |
| 21 | + ["dcr"]="docker compose restart" |
| 22 | + |
| 23 | + # Git |
| 24 | + ["gs"]="git status" |
| 25 | + ["ga"]="git add" |
| 26 | + ["gaa"]="git add ." |
| 27 | + ["gc"]="git commit -m" |
| 28 | + ["gp"]="git push" |
| 29 | + ["gpl"]="git pull" |
| 30 | + ["gco"]="git checkout" |
| 31 | + ["gb"]="git branch" |
| 32 | + ["gd"]="git diff" |
| 33 | + ["glog"]="git log --oneline --graph --decorate -10" |
| 34 | + |
| 35 | + # General |
| 36 | + ["cls"]="clear" |
| 37 | + ["ll"]="ls -la" |
| 38 | + ["la"]="ls -A" |
| 39 | + [".."]="cd .." |
| 40 | + ["..."]="cd ../.." |
| 41 | + ["myip"]="curl -s ipecho.net/plain; echo" |
| 42 | + ["ports"]="netstat -tulanp" |
| 43 | + ["h"]="history" |
| 44 | +) |
| 45 | + |
| 46 | +BASHRC="$HOME/.bashrc" |
| 47 | + |
| 48 | +# Ensure .bashrc exists |
| 49 | +touch "$BASHRC" |
| 50 | + |
| 51 | +echo "Installing aliases..." |
| 52 | +echo "" |
| 53 | + |
| 54 | +added=0 |
| 55 | +skipped=0 |
| 56 | + |
| 57 | +for alias_name in "${!ALIASES[@]}"; do |
| 58 | + alias_cmd="${ALIASES[$alias_name]}" |
| 59 | + alias_line="alias $alias_name='$alias_cmd'" |
| 60 | + |
| 61 | + # Check if alias already exists |
| 62 | + if grep -q "^alias $alias_name=" "$BASHRC"; then |
| 63 | + echo " [skip] $alias_name" |
| 64 | + ((skipped++)) |
| 65 | + else |
| 66 | + echo "$alias_line" >> "$BASHRC" |
| 67 | + echo " [add] $alias_name" |
| 68 | + ((added++)) |
| 69 | + fi |
| 70 | +done |
| 71 | + |
| 72 | +echo "" |
| 73 | +echo "================================" |
| 74 | +echo " Added: $added | Skipped: $skipped" |
| 75 | +echo "================================" |
| 76 | +echo "" |
| 77 | +echo "Run 'source ~/.bashrc' or restart terminal to apply" |
0 commit comments