[READ-ONLY] Mirror of https://github.com/mrgnw/dotfiles. My shell customizations - aliases, functions, and themes.
dotfiles shell zinit zsh
0

Configure Feed

Select the types of activity you want to include in your feed.

Update dev.zsh

-75
-75
dev.zsh
··· 1 - # infer tool from current directory 2 - get_tool() { 3 - if [[ -f pyproject.toml ]]; then 4 - echo "uv" 5 - elif [[ -f package.json ]]; then 6 - echo "bun" 7 - elif [[ -f Package.swift ]]; then 8 - echo "swift" 9 - elif [[ -f main.go ]]; then 10 - echo "go" 11 - elif [[ -f compose.yml || -f compose.yaml ]]; then 12 - echo "docker-compose" 13 - elif [[ -f docker-compose.yml || -f docker-compose.yaml ]]; then 14 - echo "docker-compose" 15 - else 16 - echo "" 17 - fi 18 - } 19 - 20 - # Define the command for each tool & operation (+-«») 21 - map_tool_command() { 22 - local tool=$1 23 - local operation=$2 24 - 25 - case $tool in 26 - uv) 27 - case $operation in 28 - +) echo "add" ;; 29 - -) echo "remove" ;; 30 - ») echo "run" ;; 31 - «) echo "sync" ;; 32 - esac 33 - ;; 34 - bun|swift|go) 35 - case $operation in 36 - +) echo "add" ;; 37 - -) echo "remove" ;; 38 - ») echo "run" ;; 39 - «) echo "update" ;; 40 - esac 41 - ;; 42 - docker-compose) 43 - case $operation in 44 - +) echo "pull" ;; 45 - -) echo "down" ;; 46 - ») echo "up" ;; 47 - «) echo "pull" ;; 48 - esac 49 - ;; 50 - brew) 51 - case $operation in 52 - +) echo "install" ;; 53 - -) echo "uninstall" ;; 54 - ») echo "upgrade" ;; 55 - «) echo "update" ;; 56 - esac 57 - ;; 58 - esac 59 - } 60 - 61 - run_tool_command() { 62 - local operation=$1 63 - shift 64 - local tool=$(get_tool) 65 - echo $tool 66 - tool=${tool:-brew} 67 - command=$(map_tool_command $tool $operation) 68 - echo "$tool $command" "$@" 69 - $tool $command "$@" 70 - } 71 - 72 - +() { run_tool_command + "$@" } 73 - -() { run_tool_command - "$@" } 74 - «() { run_tool_command « "$@" } 75 - »() { run_tool_command » "$@" }