dotfiles

Personal dotfiles
git clone https://git.bracken.jp/dotfiles.git
Log | Files | Refs | LICENSE

paths (1499B)


      1 # .paths
      2 
      3 # Cleanly remove $1 from $PATH
      4 path_remove() {
      5   if [ -n "$ZSH_VERSION" ]; then
      6     local paths=("${(s/:/)PATH}")
      7     paths=("${(@)paths:#$1}")
      8     export PATH="${(j/:/)paths}"
      9   else
     10     PATH=$(echo $PATH | sed "s:^$1\:::;s:\:$1\::\::;s:\:$1::")
     11   fi
     12 }
     13 
     14 # Move/add $1 to the start of $PATH
     15 path_prepend() {
     16   path_remove "$1"
     17   if [ -d "$1" ]; then
     18     export PATH="$1:$PATH"
     19   fi
     20 }
     21 
     22 # Move/add $1 to the end of $PATH
     23 path_append() {
     24   path_remove "$1"
     25   if [ -d "$1" ]; then
     26     export PATH="$PATH:$1"
     27   fi
     28 }
     29 
     30 # Push /usr/local/bin to the front of PATH
     31 path_prepend "/usr/local/bin"
     32 
     33 # Google Cloud SDK
     34 path_prepend "$SRC_ROOT/google-cloud-sdk/bin"
     35 
     36 # Flutter
     37 path_prepend "$SRC_ROOT/depot_tools"
     38 path_prepend "$SRC_ROOT/goma"
     39 path_prepend "$SRC_ROOT/flutter/flutter/bin"
     40 path_prepend "$SRC_ROOT/flutter/flutter/bin/cache/dart-sdk/bin"
     41 
     42 # Fuchsia
     43 path_prepend "$SRC_ROOT/fuchsia/.jiri_root/bin"
     44 if [[ -e "$SRC_ROOT/fuchsia/.jiri_root/scripts/fx-env.sh" ]]; then
     45   source "$SRC_ROOT/fuchsia/.jiri_root/scripts/fx-env.sh"
     46 fi
     47 
     48 # Homebrew
     49 if [[ "$(uname)" == "Darwin" ]]; then
     50   path_prepend "$HOME/.homebrew/bin"
     51 fi
     52 
     53 # Ruby gems
     54 if which ruby >/dev/null && which gem >/dev/null; then
     55   path_prepend "$(ruby -r rubygems -e 'puts Gem.user_dir')/bin"
     56 fi
     57 
     58 # Python modules
     59 if which python3 >/dev/null; then
     60   path_prepend "$(python3 -m site --user-base)/bin"
     61 fi
     62 
     63 # Rust packages
     64 path_prepend "$HOME/.cargo/bin"
     65 
     66 # Personal bin directory
     67 path_prepend "$HOME/.local/bin"
     68 path_prepend "$HOME/bin"