diff options
| author | jason | 2023-11-13 20:25:12 -0700 |
|---|---|---|
| committer | jason | 2024-04-02 18:03:30 -0600 |
| commit | 2e1f10a9fc1f31723022ca61418353abb1efe83f (patch) | |
| tree | d7d6e956e8a629999754d76147b4651757ddc72b /bash | |
| parent | 248de0782a4b91fb3d4a94e1059e04857437c2b7 (diff) | |
| download | dotfiles-2e1f10a9fc1f31723022ca61418353abb1efe83f.tar.gz dotfiles-2e1f10a9fc1f31723022ca61418353abb1efe83f.zip | |
toward posix standard bashrc for ksh
Diffstat (limited to 'bash')
| -rw-r--r-- | bash/.bashrc | 99 |
1 files changed, 52 insertions, 47 deletions
diff --git a/bash/.bashrc b/bash/.bashrc index 4efeb31..4c3a902 100644 --- a/bash/.bashrc +++ b/bash/.bashrc | |||
| @@ -13,61 +13,63 @@ END_PS1="\$\[\e[m\] " | |||
| 13 | #PS1="[\u@\[\e[38;5;148m\]\h\[\e[m\]:\[\e[36m\]\W\[\e[m\]\[\e[m\]]\[\e[m\]\$\[\e[m\] " | 13 | #PS1="[\u@\[\e[38;5;148m\]\h\[\e[m\]:\[\e[36m\]\W\[\e[m\]\[\e[m\]]\[\e[m\]\$\[\e[m\] " |
| 14 | PATH="${HOME}/bin:${HOME}/.local/bin:${PATH}" | 14 | PATH="${HOME}/bin:${HOME}/.local/bin:${PATH}" |
| 15 | 15 | ||
| 16 | # OpenBSD | ||
| 16 | # FreeBSD | 17 | # FreeBSD |
| 17 | # Darwin | 18 | # Darwin |
| 18 | # Linux | 19 | # Linux |
| 19 | OS_NAME=`uname` | 20 | OS_NAME=`uname` |
| 20 | 21 | ||
| 21 | # Disable bash deprecation warning on OS X | 22 | # Disable bash deprecation warning on OS X |
| 22 | export BASH_SILENCE_DEPRECATION_WARNING=1 | 23 | if [ "$OS_NAME" == "Darwin" ]; then |
| 23 | 24 | export BASH_SILENCE_DEPRECATION_WARNING=1 | |
| 25 | fi | ||
| 24 | # Disable AWS SAM Telemetry | 26 | # Disable AWS SAM Telemetry |
| 25 | export SAM_CLI_TELEMETRY=0 | 27 | export SAM_CLI_TELEMETRY=0 |
| 26 | 28 | ||
| 27 | # Enable starship if possible | 29 | # Enable starship if possible |
| 28 | STARSHIP=`which starship 2> /dev/null` | 30 | STARSHIP=`which starship 2> /dev/null` |
| 29 | if [[ -x $STARSHIP ]]; then | 31 | if [ -x "$STARSHIP" ]; then |
| 30 | eval "$(starship init bash)" | 32 | eval "$(starship init bash)" |
| 31 | fi | 33 | fi |
| 32 | 34 | ||
| 33 | # Enable flutter | 35 | # Enable flutter |
| 34 | if [ -d $HOME/bin/flutter/ ]; then | 36 | if [ -d "$HOME/bin/flutter/" ]; then |
| 35 | PATH="${HOME}/bin/flutter/bin:${PATH}" | 37 | PATH="${HOME}/bin/flutter/bin:${PATH}" |
| 36 | export CHROME_EXECUTABLE=chromium | 38 | export CHROME_EXECUTABLE=chromium |
| 37 | fi | 39 | fi |
| 38 | 40 | ||
| 39 | # Enable android studio | 41 | # Enable android studio |
| 40 | if [ -d $HOME/bin/android-studio/bin ]; then | 42 | if [ -d "$HOME/bin/android-studio/bin" ]; then |
| 41 | PATH="${HOME}/bin/android-studio/bin:${PATH}" | 43 | PATH="${HOME}/bin/android-studio/bin:${PATH}" |
| 42 | export JAVA_HOME="${HOME}/bin/android-studio/jre" | 44 | export JAVA_HOME="${HOME}/bin/android-studio/jre" |
| 43 | fi | 45 | fi |
| 44 | 46 | ||
| 45 | # Set the AndroidSDK path | 47 | # Set the AndroidSDK path |
| 46 | if [ -d $HOME/.AndroidSDK ]; then | 48 | if [ -d "$HOME/.AndroidSDK" ]; then |
| 47 | export ANDROID_SDK_ROOT=$HOME/.AndroidSDK/ | 49 | export ANDROID_SDK_ROOT=$HOME/.AndroidSDK/ |
| 48 | PATH=$HOME/.AndroidSDK/tools/bin:$PATH | 50 | PATH=$HOME/.AndroidSDK/tools/bin:$PATH |
| 49 | fi | 51 | fi |
| 50 | 52 | ||
| 51 | # Erlang/Kerl | 53 | # Erlang/Kerl |
| 52 | KERL=`which kerl 2> /dev/null` | 54 | KERL=`which kerl 2> /dev/null` |
| 53 | if [ -x $KERL ]; then | 55 | if [ -x "$KERL" ]; then |
| 54 | if [ -f $HOME/.config/bash_completions/kerl ]; then | 56 | if [ -f $HOME/.config/bash_completions/kerl ]; then |
| 55 | source $HOME/.config/bash_completions/kerl | 57 | . $HOME/.config/bash_completions/kerl |
| 56 | fi | 58 | fi |
| 57 | if [[ $OS_NAME == "Darwin" ]]; then | 59 | if [ "$OS_NAME" == "Darwin" ]; then |
| 58 | export KERL_BUILD_BACKEND="git" | 60 | export KERL_BUILD_BACKEND="git" |
| 59 | export KERL_CONFIGURE_OPTIONS="--disable-hipe --without-javac --with-dynamic-trace=dtrace" | 61 | export KERL_CONFIGURE_OPTIONS="--disable-hipe --without-javac --with-dynamic-trace=dtrace" |
| 60 | fi | 62 | fi |
| 61 | if [[ $OS_NAME == "Linux" ]]; then | 63 | if [ "$OS_NAME" == "Linux" ]; then |
| 62 | export KERL_BUILD_BACKEND="git" | 64 | export KERL_BUILD_BACKEND="git" |
| 63 | export KERL_CONFIGURE_OPTIONS="--without-javac --with-dynamic-trace=systemtap" | 65 | export KERL_CONFIGURE_OPTIONS="--without-javac --with-dynamic-trace=systemtap" |
| 64 | fi | 66 | fi |
| 65 | fi | 67 | fi |
| 66 | if [ -d $HOME/.virtualenvs/erlang ]; then | 68 | if [ -d "$HOME/.virtualenvs/erlang" ]; then |
| 67 | source ~/.virtualenvs/erlang/activate | 69 | . ~/.virtualenvs/erlang/activate |
| 68 | fi | 70 | fi |
| 69 | ERL=`which erl 2> /dev/null` | 71 | ERL=`which erl 2> /dev/null` |
| 70 | if [ -x $ERL ]; then | 72 | if [ -x "$ERL" ]; then |
| 71 | # +pc unicode Output strings as unicode by default | 73 | # +pc unicode Output strings as unicode by default |
| 72 | # -kernal shell_history enabled Enable erl repl history | 74 | # -kernal shell_history enabled Enable erl repl history |
| 73 | export ERL_AFLAGS="+pc unicode -kernel shell_history enabled" | 75 | export ERL_AFLAGS="+pc unicode -kernel shell_history enabled" |
| @@ -77,16 +79,16 @@ fi | |||
| 77 | # if [ -x $HOME/.cargo/bin/cargo ]; then | 79 | # if [ -x $HOME/.cargo/bin/cargo ]; then |
| 78 | # PATH="${HOME}/.cargo/bin:${PATH}" | 80 | # PATH="${HOME}/.cargo/bin:${PATH}" |
| 79 | # fi | 81 | # fi |
| 80 | if [ -f $HOME/.cargo/env ]; then | 82 | if [ -f "$HOME/.cargo/env" ]; then |
| 81 | source "$HOME/.cargo/env" | 83 | source "$HOME/.cargo/env" |
| 82 | fi | 84 | fi |
| 83 | 85 | ||
| 84 | # Enable nodejs | 86 | # Enable nodejs |
| 85 | if [ -d /usr/local/lib/nodejs ]; then | 87 | #if [ -d /usr/local/lib/nodejs ]; then |
| 86 | NJS_VERSION=v16.8.0 | 88 | # NJS_VERSION=v16.8.0 |
| 87 | NJS_DISTRO=linux-x64 | 89 | # NJS_DISTRO=linux-x64 |
| 88 | PATH=/usr/local/lib/nodejs/node-$NJS_VERSION-$NJS_DISTRO/bin:$PATH | 90 | # PATH=/usr/local/lib/nodejs/node-$NJS_VERSION-$NJS_DISTRO/bin:$PATH |
| 89 | fi | 91 | #fi |
| 90 | 92 | ||
| 91 | # Enable go | 93 | # Enable go |
| 92 | if [ -d /usr/local/go/bin ]; then | 94 | if [ -d /usr/local/go/bin ]; then |
| @@ -99,13 +101,14 @@ fi | |||
| 99 | 101 | ||
| 100 | DOCKER_PATH=`which docker 2> /dev/null` | 102 | DOCKER_PATH=`which docker 2> /dev/null` |
| 101 | PODMAN_PATH=`which podman 2> /dev/null` | 103 | PODMAN_PATH=`which podman 2> /dev/null` |
| 102 | if [[ -n $PODMAN_PATH ]]; then | 104 | #echo $PODMAN_PATH |
| 103 | source <(podman completion bash) | 105 | #if [ -n "$PODMAN_PATH" ]; then |
| 104 | # Enable docker if it's podman | 106 | # source <(podman completion bash) |
| 105 | if [ -z $DOCKER_PATH ]; then | 107 | # # Enable docker if it's podman |
| 106 | alias docker=podman | 108 | # if [ -z $DOCKER_PATH ]; then |
| 107 | fi | 109 | # alias docker=podman |
| 108 | fi | 110 | # fi |
| 111 | #fi | ||
| 109 | 112 | ||
| 110 | # Enable docker completions on OS X | 113 | # Enable docker completions on OS X |
| 111 | if [ -n $DOCKER_PATH ] && [ -d /Applications/Docker.app/Contents/Resources/etc/ ]; then | 114 | if [ -n $DOCKER_PATH ] && [ -d /Applications/Docker.app/Contents/Resources/etc/ ]; then |
| @@ -124,7 +127,7 @@ fi | |||
| 124 | 127 | ||
| 125 | # Enable nix | 128 | # Enable nix |
| 126 | if [ -f $HOME/.nix-profile/etc/profile.d/nix.sh ]; then | 129 | if [ -f $HOME/.nix-profile/etc/profile.d/nix.sh ]; then |
| 127 | source $HOME/.nix-profile/etc/profile.d/nix.sh | 130 | . $HOME/.nix-profile/etc/profile.d/nix.sh |
| 128 | fi | 131 | fi |
| 129 | 132 | ||
| 130 | ####### | 133 | ####### |
| @@ -137,22 +140,24 @@ if [ -x /opt/homebrew/bin/brew ]; then | |||
| 137 | #export LDFLAGS="-L/opt/homebrew/lib" | 140 | #export LDFLAGS="-L/opt/homebrew/lib" |
| 138 | #export CPPFLAGS="-I/opt/homebrew/include" | 141 | #export CPPFLAGS="-I/opt/homebrew/include" |
| 139 | eval "$(/opt/homebrew/bin/brew shellenv)" | 142 | eval "$(/opt/homebrew/bin/brew shellenv)" |
| 140 | fi | ||
| 141 | 143 | ||
| 142 | # Enable bash-completions for homebrew installed bash | 144 | # Enable bash-completions for homebrew installed bash |
| 143 | if [ -f /opt/homebrew/etc/bash_completion ]; then | 145 | if [ -f /opt/homebrew/etc/bash_completion ]; then |
| 144 | . /opt/homebrew/etc/bash_completion | 146 | . /opt/homebrew/etc/bash_completion |
| 145 | fi | 147 | fi |
| 146 | 148 | ||
| 147 | # Enable pyenv | 149 | |
| 148 | if [ -x /opt/homebrew/bin/pyenv ]; then | 150 | # Enable pyenv |
| 149 | # Prevent linking against system libpython when building | 151 | if [ -x /opt/homebrew/bin/pyenv ]; then |
| 150 | alias brew='env PATH="${PATH//$(pyenv root)\/shims:/}" brew' | 152 | # Prevent linking against system libpython when building |
| 151 | export PYENV_ROOT="$HOME/.pyenv" | 153 | alias brew='env PATH="${PATH//$(pyenv root)\/shims:/}" brew' |
| 152 | export PATH="$PYENV_ROOT/bin:$PATH" | 154 | export PYENV_ROOT="$HOME/.pyenv" |
| 153 | eval "$(pyenv init --path)" | 155 | export PATH="$PYENV_ROOT/bin:$PATH" |
| 154 | eval "$(pyenv init -)" | 156 | eval "$(pyenv init --path)" |
| 157 | eval "$(pyenv init -)" | ||
| 158 | fi | ||
| 155 | fi | 159 | fi |
| 160 | |||
| 156 | if [[ -x /usr/local/bin/pyenv || -x $HOME/bin/pyenv ]]; then | 161 | if [[ -x /usr/local/bin/pyenv || -x $HOME/bin/pyenv ]]; then |
| 157 | # FreeBSD, probably linux | 162 | # FreeBSD, probably linux |
| 158 | eval "$(pyenv init -)" | 163 | eval "$(pyenv init -)" |
| @@ -163,7 +168,7 @@ __workon() { | |||
| 163 | } | 168 | } |
| 164 | __mkvirtualenv() { | 169 | __mkvirtualenv() { |
| 165 | python -mvenv ~/.virtualenvs/$1 | 170 | python -mvenv ~/.virtualenvs/$1 |
| 166 | source ~/.virtualenvs/$1/bin/activate | 171 | . $HOME/.virtualenvs/$1/bin/activate |
| 167 | } | 172 | } |
| 168 | alias workon=__workon | 173 | alias workon=__workon |
| 169 | alias mkvirtualenv=__mkvirtualenv | 174 | alias mkvirtualenv=__mkvirtualenv |
| @@ -187,7 +192,7 @@ if [ -f /etc/bash_completion ]; then | |||
| 187 | fi | 192 | fi |
| 188 | 193 | ||
| 189 | ## FreeBSD | 194 | ## FreeBSD |
| 190 | [[ $PS1 && -f /usr/local/share/bash-completion/bash_completion.sh ]] && \ | 195 | [[ -n $PS1 && -f /usr/local/share/bash-completion/bash_completion.sh ]] && \ |
| 191 | source /usr/local/share/bash-completion/bash_completion.sh | 196 | source /usr/local/share/bash-completion/bash_completion.sh |
| 192 | 197 | ||
| 193 | if [[ $OS_NAME == "FreeBSD" || $OS_NAME == "OpenBSD" ]]; then | 198 | if [[ $OS_NAME == "FreeBSD" || $OS_NAME == "OpenBSD" ]]; then |
| @@ -212,8 +217,8 @@ fi | |||
| 212 | 217 | ||
| 213 | ## OpenBSD | 218 | ## OpenBSD |
| 214 | if [ -f /usr/local/share/fzf/bash/key-bindings.bash ]; then | 219 | if [ -f /usr/local/share/fzf/bash/key-bindings.bash ]; then |
| 215 | source /usr/local/share/fzf/bash/key-bindings.bash | 220 | . /usr/local/share/fzf/bash/key-bindings.bash |
| 216 | source /usr/local/share/fzf/bash/completion.bash | 221 | . /usr/local/share/fzf/bash/completion.bash |
| 217 | fi | 222 | fi |
| 218 | 223 | ||
| 219 | ## TCL/TK via homebrew | 224 | ## TCL/TK via homebrew |
| @@ -239,14 +244,14 @@ alias e="${EDITOR}" | |||
| 239 | #export HISTTIMEFORMAT="[%F %T] " | 244 | #export HISTTIMEFORMAT="[%F %T] " |
| 240 | export HISTSIZE=99999 # Store unlimited entries. Default: 500 | 245 | export HISTSIZE=99999 # Store unlimited entries. Default: 500 |
| 241 | export HISTFILESIZE=999999999 # Unlimited file size | 246 | export HISTFILESIZE=999999999 # Unlimited file size |
| 242 | #shopt -s histappend # append entries rather than overwrite | ||
| 243 | shopt -s cmdhist # Store multi-line commands as a single line | ||
| 244 | # Store history immediately | 247 | # Store history immediately |
| 245 | ## history -r rereads | 248 | ## history -r rereads |
| 246 | export PROMPT_COMMAND="history -a;history -r; ${PROMPT_COMMAND}" | 249 | export PROMPT_COMMAND="history -a;history -r; ${PROMPT_COMMAND}" |
| 247 | #export PROMPT_COMMAND="history -a; ${PROMPT_COMMAND}" | 250 | #export PROMPT_COMMAND="history -a; ${PROMPT_COMMAND}" |
| 248 | export HISTCONTROL="ignoredups" | 251 | export HISTCONTROL="ignoredups" |
| 249 | export HISTIGNORE="ls:cd" | 252 | export HISTIGNORE="ls:cd" |
| 253 | shopt -s histappend # append entries rather than overwrite | ||
| 254 | shopt -s cmdhist # Store multi-line commands as a single line | ||
| 250 | 255 | ||
| 251 | # Aliases | 256 | # Aliases |
| 252 | #alias ls='ls --color' | 257 | #alias ls='ls --color' |
| @@ -259,7 +264,7 @@ alias define='sdcv' | |||
| 259 | 264 | ||
| 260 | # Enable direnv (https://github.com/direnv/direnv/) | 265 | # Enable direnv (https://github.com/direnv/direnv/) |
| 261 | DIRENV=`which direnv 2> /dev/null` | 266 | DIRENV=`which direnv 2> /dev/null` |
| 262 | if [[ -x $DIRENV ]]; then | 267 | if [ -x "$DIRENV" ]; then |
| 263 | eval "$(direnv hook bash)" | 268 | eval "$(direnv hook bash)" |
| 264 | fi | 269 | fi |
| 265 | show_virtual_env() { | 270 | show_virtual_env() { |