# .bashrc # # note: this file is executed by interactive non-login shell # if it needs to execute for login shells too (i.e. virtual # tty) see .bash_profile. something like the following may # work: test -f ~/.bashrc && . ~/.bashrc if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then SESSION_TYPE=ssh fi LC_ALL="en_US.UTF-8" # This PS1 is completed at the end, allowing statuses to be included between the directory and closing $ if [ "$SESSION_TYPE" = "ssh" ]; then HOST_COLOR="\[\e[38;5;124m\]" else HOST_COLOR="\[\e[38;5;148m\]" fi PS1="[\u@${HOST_COLOR}\h\[\e[m\]:\[\e[36m\]\W\[\e[m\]\[\e[m\]]\[\e[m\]" END_PS1="\$\[\e[m\] " # This is the original PS1 #PS1="[\u@\[\e[38;5;148m\]\h\[\e[m\]:\[\e[36m\]\W\[\e[m\]\[\e[m\]]\[\e[m\]\$\[\e[m\] " PATH="${HOME}/bin:${HOME}/.local/bin:${PATH}" # OpenBSD # FreeBSD # Darwin # Linux OS_NAME=`uname` # Disable bash deprecation warning on OS X if [ "$OS_NAME" == "Darwin" ]; then export BASH_SILENCE_DEPRECATION_WARNING=1 fi # Disable AWS SAM Telemetry export SAM_CLI_TELEMETRY=0 # Enable starship if possible #STARSHIP=`which starship 2> /dev/null` #if [ -x "$STARSHIP" ]; then # eval "$(starship init bash)" #fi # Enable flutter if [ -d "$HOME/bin/flutter/" ]; then PATH="${HOME}/bin/flutter/bin:${PATH}" export CHROME_EXECUTABLE=chromium fi # Enable android studio if [ -d "$HOME/bin/android-studio/bin" ]; then PATH="${HOME}/bin/android-studio/bin:${PATH}" export JAVA_HOME="${HOME}/bin/android-studio/jre" fi # Set the AndroidSDK path if [ -d "$HOME/.AndroidSDK" ]; then export ANDROID_SDK_ROOT=$HOME/.AndroidSDK/ PATH=$HOME/.AndroidSDK/tools/bin:$PATH fi # Erlang/Kerl KERL=`which kerl 2> /dev/null` if [ -x "$KERL" ]; then # kerl breaks the manpath if [ "$OS_NAME" != "Darwin" ]; then export MANPATH=$(grep manpath /etc/man.conf | awk '{ print $2 }' | paste -s -d:) fi if [ -f $HOME/.config/bash_completions/kerl ]; then . $HOME/.config/bash_completions/kerl fi if [ "$OS_NAME" == "Darwin" ]; then export KERL_BUILD_BACKEND="git" export KERL_CONFIGURE_OPTIONS="--disable-hipe --without-javac --with-dynamic-trace=dtrace" fi if [ "$OS_NAME" == "Linux" ]; then export KERL_BUILD_BACKEND="git" export KERL_CONFIGURE_OPTIONS="--without-javac --with-dynamic-trace=systemtap" fi fi if [ -d "$HOME/.virtualenvs/erlang" ]; then . ~/.virtualenvs/erlang/activate fi ERL=`which erl 2> /dev/null` if [ -x "$ERL" ]; then # +pc unicode Output strings as unicode by default # -kernal shell_history enabled Enable erl repl history export ERL_AFLAGS="+pc unicode -kernel shell_history enabled" fi # Enable rust and cargo # if [ -x $HOME/.cargo/bin/cargo ]; then # PATH="${HOME}/.cargo/bin:${PATH}" # fi if [ -f "$HOME/.cargo/env" ]; then source "$HOME/.cargo/env" fi # Enable nodejs #if [ -d /usr/local/lib/nodejs ]; then # NJS_VERSION=v16.8.0 # NJS_DISTRO=linux-x64 # PATH=/usr/local/lib/nodejs/node-$NJS_VERSION-$NJS_DISTRO/bin:$PATH #fi if [ -f "$HOME/.deno/env" ]; then . "/home/jason/.deno/env" fi # Enable go if [ -d /usr/local/go/bin ]; then PATH=$PATH:/usr/local/go/bin fi if [ -d $HOME/go/bin ]; then PATH=$PATH:$HOME/go/bin fi ####### # Docker/Podman/OrbStack DOCKER_PATH=`which docker 2> /dev/null` #PODMAN_PATH=`which podman 2> /dev/null` #echo $PODMAN_PATH #if [ -n "$PODMAN_PATH" ]; then # source <(podman completion bash) # # Enable docker if it's podman # if [ -z $DOCKER_PATH ]; then # alias docker=podman # fi #fi # Enable docker completions on OS X if [ -n $DOCKER_PATH ] && [ -d /Applications/Docker.app/Contents/Resources/etc/ ]; then # Docker for Mac seems to switch the filenames sometimes. if [ -f /Applications/Docker.app/Contents/Resources/etc/docker ]; then . /Applications/Docker.app/Contents/Resources/etc/docker elif [ -f /Applications/Docker.app/Contents/Resources/etc/docker-compose.bash-completion ]; then . /Applications/Docker.app/Contents/Resources/etc/docker-compose.bash-completion fi . /Applications/Docker.app/Contents/Resources/etc/docker-compose.bash-completion fi ####### # Nix # Enable nix if [ -f $HOME/.nix-profile/etc/profile.d/nix.sh ]; then . $HOME/.nix-profile/etc/profile.d/nix.sh fi ####### # Homebrew # Enable Homebrew if [ -x /opt/homebrew/bin/brew ]; then export HOMEBREW_NO_ANALYTICS=1 #export LDFLAGS="-L/opt/homebrew/lib" #export CPPFLAGS="-I/opt/homebrew/include" eval "$(/opt/homebrew/bin/brew shellenv)" # Enable bash-completions for homebrew installed bash if [ -f /opt/homebrew/etc/bash_completion ]; then . /opt/homebrew/etc/bash_completion fi # Enable pyenv if [ -x /opt/homebrew/bin/DISALBEDpyenv ]; then # Prevent linking against system libpython when building alias brew='env PATH="${PATH//$(pyenv root)\/shims:/}" brew' export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init --path)" eval "$(pyenv init -)" fi fi #if [[ -x /usr/local/bin/pyenv || -x $HOME/bin/pyenv ]]; then # # FreeBSD, probably linux # eval "$(pyenv init -)" #fi # Default install instructions if [[ -x $HOME/.pyenv/bin ]]; then eval "$($HOME/.pyenv/bin/pyenv init -)" export PATH=$HOME/.pyenv/bin:$PATH fi function install-pylsp() { # a little shortcut for installing the helpers i use for python # IDE features [ ! -z "${VIRTUAL_ENV}" ] \ && pip install -U --upgrade-strategy eager \ black \ flake8 \ flake8-docstrings \ flake8-import-order \ mypy \ jedi-language-server \ || echo 'Not in a venv.' } __workon() { source ~/.virtualenvs/$1/bin/activate } __mkvirtualenv() { python -mvenv ~/.virtualenvs/$1 . $HOME/.virtualenvs/$1/bin/activate } alias workon=__workon alias mkvirtualenv=__mkvirtualenv # Enable asdf (virtual environments) ASDF=`which asdf 2> /dev/null` if [ -x "$ASDF" ]; then export ASDF_DATA_DIR="$HOME/.asdf" export PATH="$ASDF_DATA_DIR/shims:$PATH" . <(asdf completion bash) fi # This conflicts with pyenv, which i tend to prefer. # As a result this should be enabled per-project via direnv # echo ". /opt/homebrew/opt/asdf/libexec/asdf.sh" >> .envrc #if [ -f /opt/homebrew/opt/asdf/libexec/asdf.sh ]; then # # brew # . /opt/homebrew/opt/asdf/libexec/asdf.sh #fi #if [ -f "$HOME/.asdf/asdf.sh" ]; then # . "$HOME/.asdf/asdf.sh" # . "$HOME/.asdf/completions/asdf.bash" #fi ####### # Enable system bash completions ## Debian derivative if [ -f /etc/bash_completion ]; then . /etc/bash_completion fi ## Void [[ $PS1 && -f /usr/share/bash-completion/bash_completion ]] && . /usr/share/bash-completion/bash_completion ## FreeBSD [[ -n $PS1 && -f /usr/local/share/bash-completion/bash_completion.sh ]] && \ source /usr/local/share/bash-completion/bash_completion.sh if [[ $OS_NAME == "FreeBSD" || $OS_NAME == "OpenBSD" ]]; then export XDG_RUNTIME_DIR=/var/run/user/`id -u` fi ####### # FZF FZF=`which fzf 2> /dev/null` if [ -x "$FZF" ]; then eval "$(fzf --bash)" fi ## TCL/TK via homebrew ## OS X packages an outdated and deprecated version that doesn't really ## work. if [ -d /opt/homebrew/opt/tcl-tk/bin ]; then PATH=/opt/homebrew/opt/tcl-tk/bin:$PATH fi # password-store completions if [ -f /usr/local/share/bash-completion/completions/pass ]; then source /usr/local/share/bash-completion/completions/pass fi if [ -f /usr/local/share/bash-completion/completions/pass-otp ]; then source /usr/local/share/bash-completion/completions/pass-otp fi ####### #TERM="xterm-256color" # direnv's use_nix will overwrite TMPDIR so it needs to be hard coded to /tmp/ #EMACS_SERVER_SOCKET="/tmp/emacs$(id -u)/server" #EMACS_SERVER_SOCKET="${TMPDIR:-/tmp}/emacs$(id -u)/server" #EDITOR="emacsclient -s ${EMACS_SERVER_SOCKET}" export EDITOR='emacsclient -c' alias e="${EDITOR}" # History settings #export HISTTIMEFORMAT="[%F %T] " export HISTSIZE=99999 # Store unlimited entries. Default: 500 export HISTFILESIZE=999999999 # Unlimited file size # Store history immediately ## history -r rereads export PROMPT_COMMAND="history -a;history -r; ${PROMPT_COMMAND}" #export PROMPT_COMMAND="history -a; ${PROMPT_COMMAND}" export HISTCONTROL="ignoredups" export HISTIGNORE="ls:cd" shopt -s histappend # append entries rather than overwrite shopt -s cmdhist # Store multi-line commands as a single line # Aliases #alias ls='ls --color' #alias fixfileperm='find /music -type f -exec chmod 0644 {} \;' #alias cleanremotebranches='git branch --merged | grep -v "\*" | xargs -n 1 git branch -d; git branch -r --merged master | grep -iv "master" | sed "s/origin\///" | xargs -n 1 git push --delete origin' alias ducks='du -cks * |sort -rn |head -11' alias define='sdcv' #alias cleanstale="git clean -fd -e'!__pycache__' -e'!*.py[cod]'" #alias dry-cleanstale="git clean -fdn -e'!__pycache__' -e'!*.py[cod]'" # Enable direnv (https://github.com/direnv/direnv/) DIRENV=`which direnv 2> /dev/null` if [ -x "$DIRENV" ]; then eval "$(direnv hook bash)" fi show_virtual_env() { if [[ -n "$VIRTUAL_ENV" && -n "$DIRENV_DIR" ]]; then echo "($(basename $VIRTUAL_ENV))" fi } export -f show_virtual_env PS1='$(show_virtual_env)'$PS1 # Git Related function delete-branches() { # Interactive branch deleter git branch | grep --invert-match '\*' | cut -c 3- | fzf --multi --preview="git log {} --" | xargs git branch --delete --force } XCODE_SELECT=`which xcode-select 2> /dev/null` if [[ -x $XCODE_SELECT ]]; then OSX_GIT_COMPLETION=`xcode-select -p`/usr/share/git-core/git-completion.bash if [[ -f $OSX_GIT_COMPLETION ]]; then source $OSX_GIT_COMPLETION fi OSX_GIT_PROMPT=`xcode-select -p`/usr/share/git-core/git-prompt.sh if [[ -f $OSX_GIT_PROMPT ]]; then source $OSX_GIT_PROMPT fi fi # The Gemini earbuds don't sync the volume. This turns up the hardware volume control alias geminiup="dbus-send --print-reply --system --dest=org.bluez /org/bluez/hci0/dev_7C_C4_EF_CC_45_43 org.bluez.MediaControl1.VolumeUp" alias geminidown="dbus-send --print-reply --system --dest=org.bluez /org/bluez/hci0/dev_7C_C4_EF_CC_45_43 org.bluez.MediaControl1.VolumeDown" # Enable firefox touchscreen scrolling # export MOZ_USE_XINPUT2=1 export MOZ_ENABLE_WAYLAND=1 export XCURSOR_SIZE=32 # GPG ssh key #export GPG_TTY=$(tty) export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" # Enable warpdir (https://rc4.net/wd-rs/) WARPDIR=`which warpdir 2> /dev/null` if [[ -x $WARPDIR ]]; then eval "$(warpdir hook bash)" fi # Enable terraform completions TERRAFORM=`which terraform 2> /dev/null` if [[ -x $TERRAFORM ]]; then complete -C $TERRAFORM terraform fi # texinfo is keg-only, which means it was not symlinked into /opt/homebrew, # because macOS already provides this software and installing another version # in parallel can cause all kinds of trouble. if [ -d /opt/homebrew/opt/texinfo/bin ]; then export PATH="/opt/homebrew/opt/texinfo/bin:$PATH" fi if [ -d "$HOME/.nvm" ] && [ -s $HOME/.nvm/nvm.sh ]; then export NVM_DIR="${HOME}/.nvm" . "$NVM_DIR/nvm.sh" if [ -s "$NVM_DIR/bash_completion" ]; then . "$NVM_DIR/bash_completion" fi fi # If __git_ps1 is enabled, set that up. if [[ $(type -t __git_ps1) == function ]]; then GIT_PS1_SHOWDIRTYSTATE=1 # Show unstaged and staged indicators GIT_PS1_SHOWUNTRACKEDFILES=1 # show % for untracked files # GIT_PS1_SHOWUPSTREAM=auto # show +/- changes with upstream PS1=$PS1'$(__git_ps1 " (%s)")' # Alternatively, for a slightly faster prompt, __git_ps1 can be # used for PROMPT_COMMAND in Bash with two parameters,
 and
    # , which are strings you would put in $PS1 before and after
    # the status string generated by the git-prompt machinery.
    # DISABLED because this doesn't work with $(show_virtualenv)
    #export PROMPT_COMMAND="__git_ps1 '${PS1}' '${END_PS1}'; ${PROMPT_COMMAND}"
fi

# Helper Functions
at-finit() {
    local OPTIND name adminuser password
    while getopts "n:u:" opt; do
        case $opt in
            n)
                name=$OPTARG
                ;;
            u)
                adminuser=$OPTARG
                ;;
            \?)
                # quit on arg error
                return 1
                ;;
        esac
    done

    if [ -z "$name" ]; then
        echo "-n required"
        return 1
    fi
    if [ -z "$adminuser" ]; then
        echo "-u required"
        return 1
    fi

    repopath="$HOME/Code/Museum/$name.fossil"
    printf "path is: $repopath\n"

    stty -echo
    printf "Set admin password: "
    read password
    stty echo
    printf "\n"

    fossil init --template $HOME/Sync/Files/template-repo-v1.fossil --admin-user "$adminuser" "$repopath" > /dev/null
    fossil user -R $repopath password $adminuser $password

    chmod 0664 $repopath
    rsync --perms $repopath jason@depot.waldorf._.antitech.org:/var/www/htdocs/depot.antitech.org
    chmod 0644 $repopath

    urluser=$(echo $adminuser | jq "@uri" -jRr)
    urlpasswd=$(echo $password | jq "@uri" -jRr)
    echo "Defining remote..."
    fossil remote-url -R $repopath https://$urluser:$urlpasswd@depot.antitech.org/$name/

    printf "\nSuccess. View your public repository at https://depot.antitech.org/${name}/\n"
}

# voze downloader
vozegrab() {
    curl -O "https://audit-tool-backend.voze.com/files/audio/$1" \
         -H "Content-Type: application/json" \
         -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJmam9zIiwibWFpbGJveCI6IjU1NTUiLCJleHAiOjE5NTMyNDgxNjd9.aHz-km0y7F7XVYe-vRIhwMOFZujzxO-zfLYDhPCx_5Y"
}

# Close off the PS1 with the $
PS1=${PS1}${END_PS1}