Skip to content

Useful Commands

Bash

Display ANSI colors with their color-code.

function colormap() {
    range_start=${1:-1}
    range_end=${2:-255}

    for i in $(seq $range_start $range_end); do
        echo -en "\e[48;5;${i}m  ${(l:3::0:)i}  \e[0m "
        [[ $((i % 10)) -eq 0 ]] && echo
    done
    return 0
}

The colormap function will print the ANSI colors with codes in your terminal.

$ colormap           # (000 - 255)
$ colormap 200       # (200 - 255)
$ colormap 100 120   # (100 - 120)

Docker

Clear all caches, images, containers, volumes of Docker.

docker system prune -a --volumes --force

Git

Beautiful Oneline - git log

alias glog="git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --branches"
$ glog # (1)!
* 6914e04 - (HEAD -> main, origin/main) 📝 Update docs/index.md (5 hours ago) <Anshul Raj Verma>
*   3d91241 - Merge branch 'new/friends-page' (5 hours ago) <Anshul Raj Verma>
|\
| * 6160ae5 - 💅 Update UI of friends.md (5 hours ago) <Anshul Raj Verma>
| * 42b52d8 - 🔨 Add friends.md to Home nav (6 hours ago) <Anshul Raj Verma>
| * bef45f6 -  Setup to add friends on website (2 days ago) <Anshul Raj Verma>
|/
* 59340cf - ref:  Add starship.md in Bash (2 days ago) <Anshul Raj Verma>
* ecc8e94 -  Add new nav item "References" (3 days ago) <Anshul Raj Verma>
* 3bea521 -  Add Rust icon on about page (5 days ago) <Anshul Raj Verma>
  1. Date: 10-04-2024

Python

Remove all cache file specify to a Python project

function pycls() {
    find . -name '.DS_Store' -type f -delete
    find . -type d -name "__pycache__" -exec rm -rfv {} \; 2>/dev/null
    find . -type d -name ".ipynb_checkpoints" -exec rm -rfv {} \; 2>/dev/null
    find . -type d -name ".ruff_cache" -exec rm -rfv {} \; 2>/dev/null
    find . -type f -name "*.pyc" -exec rm -fv {} \; 2>/dev/null
}
$ pwd
/User/Home  # For MacOS
$ pycls  # Remove all cache files and folders in the directory and sub-dirs

HomeBrew

Update, Clean and Doctor

brew update && brew cleanup --prune=all && brew doctor

Uninstall unused dependencies

brew autoremove # (1)!
  1. Check docs for autoremove command.

Arc

Change ARC.app Icon

arc logos

Source Gist

defaults write company.thebrowser.Browser currentAppIconName candy # favorite
Candy Arc Hologram Neon Fluted Glass Schoolbook Colorful
candy hologram neon flutedGlass schoolbook colorful