Skip to content
Snippets Groups Projects
.bashrc 6.84 KiB
Newer Older
James Vasile's avatar
James Vasile committed
# .bashrc

# Source other bash files

# global definitions
if [ -f /etc/bashrc ]; then
	. /etc/bashrc
fi

# Add git branch to prompt
parse_git_branch() {
 git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\] $(parse_git_branch)\[\033[00m\]\$ '
#export PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ '



# Pager
## We don't want systemd to use a pager.  We can pipe it if we want to.
export SYSTEMD_PAGER=
export PAGER=vimpager
export VIMPAGER_VIM=nvim

# Miscellaneous one-off variables
## Diff is hard to read. Colors help.
alias diff=colordiff
alias kittydiff="kitty +kitten diff"
alias icat="kitty +kitten icat"

if [ -z DISPLAY ]; then

    # Add kitty and bcvi to our ssh sessions
    alias ssh="kitty +kitten ssh"

    # Set keyboard repeat rate.  After 300 ms, repeat 20 times per second.  I
    # think just putting this in .xinitrc should be sufficient, but apparently
    # that isn't the case.
    xset r rate 300 20

fi

# GIT
source ~/src/infra/bin/git-completion.bash
alias gitdiff="git difftool --no-symlinks --dir-diff"

# Colorize man pages
export LESS_TERMCAP_mb=$'\e[1;32m'
export LESS_TERMCAP_md=$'\e[1;32m'
export LESS_TERMCAP_me=$'\e[0m'
export LESS_TERMCAP_se=$'\e[0m'
export LESS_TERMCAP_so=$'\e[01;33m'
export LESS_TERMCAP_ue=$'\e[0m'
export LESS_TERMCAP_us=$'\e[1;4;31m'

# Fix ls colors
export LS_COLORS="di=34;40:ln=36:so=32:pi=33:ex=31:bd=35;40:cd=35;40:su=35;40:sg=35;40:tw=34;40:ow=34;40"

# User specific aliases and functions
alias ls="ls --color"

# Help latex find our custom latex files
export TEXMFHOME=~/.latex

# This is a mac command, but it's useful here too
alias pbcopy='xclip -selection clipboard'


# Path Fiddling
alias mc='. /usr/lib/mc/mc-wrapper.sh'
function ccd
{
    if [ $# -eq 0 ]; then
        pushd ~ > /dev/null
    elif [ " $1" = " -" ]; then
        pushd "$OLDPWD" > /dev/null
    else
        pushd "$@" > /dev/null
    fi
}

# Add roswell bin to path
export PATH=~/.roswell/bin:$PATH

# Add infra/bin and others to path
export PATH=/home/james/src/infra/bin:~/src/3p/git-scripts:~/.local/bin:$PATH
export PATH=~/Python/venv/general/bin:$PATH

# Set GOPATH for golang
export GOPATH=/usr/local/src/golang
export PATH=$GOPATH/bin:/snap/bin:$PATH

#export ANDROID_HOME=/opt/android-studio
# export ANDROID_HOME=/home/james/Android
# export ANDROID_SDK_ROOT=/home/james/Android
# export PATH=$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH


# Rust and cargo
export PATH=~/.cargo/bin:$PATH
. "$HOME/.cargo/env"

# Passwords

# Standard Linux Password Manager
export PASSWORD_STORE_ENABLE_EXTENSIONS=true
export PASSWORD_STORE_EXTENSIONS_DIR=/usr/lib/password-store/extensions

# Sudo security now depends on gpg security.  Instead of prompting me
# for a password, sudo runs a script that pulls the password from our
# password store.  That works because I've already authenticated to
# keychain.
which gp > /dev/null && export SUDO_ASKPASS=`which gp` && alias sudo="sudo -A"

eval `keychain --quiet --agents gpg,ssh --eval id_rsa`

if [ -f "${HOME}/.gpg-agent-info" ]; then
     . "${HOME}/.gpg-agent-info"
       export GPG_AGENT_INFO
       export SSH_AUTH_SOCK
       export SSH_AGENT_PID
   else
       export GPG_AGENT_INFO=""
fi

# Keyboard/Mouse fiddling
# if [ ! -z "$DISPLAY" ]; then
  # xkeysnail is like xmodmap but python-based
  #xhost +SI:localuser:root
  #pgrep xkeysnail || sudo xkeysnail /home/james/.config/xkeysnail/config.py -q --watch --devices /dev/input/event0 "ThinkPad Compact Bluetooth Keyboard with TrackPoint" &
  # ~/.config/barrier/barrierc.sh &
# fi

# OTS
export OTS_DIR=~/OTS
export OTSREPO=https://svn.opentechstrategies.com/repos/ots/trunk
export OTS_TOOLS_DIR=~/OTS/ext/ots-tools
export OTS_DOCTOOLS_DIR=~/OTS/ext/ots-doctools
export OTS_BOOKKEEPING_DIR=~/OTS/ext/ots-bookkeeping
export OTS_OPASS_STORE_DIR=~/.ots-password-store
alias otspass="PASSWORD_STORE_DIR=~/.ots-password-store pass"
alias opass="PASSWORD_STORE_DIR=~/.ots-password-store ~/OTS/ext/ots-tools/opass"
alias fpass="PASSWORD_STORE_DIR=~/Sync/family/.password-store pass"
alias pass="EDITOR=vim pass"
export SVN_ASKPASS="pass myots/svn"
#alias opass="PASSWORD_STORE_DIR=~/.ots-password-store ~/OTS/utils/opass"

export EDITOR=~/src/infra/bin/edit-in-nvim
export EDITOR=/usr/bin/nvim


# Fix compose key. See https://emacs.stackexchange.com/questions/3650/compose-key-in-emacs-multi-key-is-undefined
export XMODIFIERS=@im=none

# Open in vim
alias e="~/src/infra/bin/edit-in-nvim"
alias e="emacsclient --no-wait -alternate-editor=''"

## Open In Emacs
#function e {
#    # if [ ! -f $1 ]; then
#	# touch $1
#    # fi
#    fname=`realpath "$1"`
#    emacsclient -e "(emux-find-file \"$fname\")" &
#    wmctrl -a "Emacs Editor"
#}

#    #export PAGER="e_blocking"
#    #alias less="e_blocking"

## Python
##

# export PYTHONPATH="/usr/local/src/"

# If we have miniconda setup on this box, source conda.sh
if [ -f "/usr/local/stow/miniconda/opt/etc/profile.d/conda.sh" ]; then
    . /usr/local/stow/miniconda/opt/etc/profile.d/conda.sh
fi

# Setup direnv, which we use to handle python virtual environments
eval "$(direnv hook bash)"
#export PATH=~/.pyenv/shims:~/.pyenv/bin:~/bin:$PATH
#eval "$(pyenv virtualenv-init -)"

# Give user systemd scripts my env
systemctl --user import-environment &> /dev/null

# Chinese Input
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx
export GLFW_IM_MODULE=ibus # Kitty needs this

# Guix
James Vasile's avatar
James Vasile committed
export GUIX_EXTRA_PROFILES=$HOME/.guix-extra-profiles
export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
export PATH=~/.guix-profile/bin:$PATH
James Vasile's avatar
James Vasile committed
#export EMACSLOADPATH="/home/james/.guix-profile/share/emacs/site-lisp"
James Vasile's avatar
James Vasile committed
export INFOPATH="/home/james/.guix-profile/share/info"
GUIX_PROFILE="/home/james/.config/guix/current"
 . "$GUIX_PROFILE/etc/profile"
James Vasile's avatar
James Vasile committed

# Update just one repo
update-repo() {
    sudo apt-get update -o Dir::Etc::sourcelist="sources.list.d/$1.list" \
        -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
}

# change to home if we started at root, which is a weird thing Kitty does since
# we moved to KDE Plasma
if [ "$PWD" = "/" ]; then
  cd ~
fi

# Flutter
alias webdev="flutter packages pub global run webdev"
export CHROME_EXECUTABLE=`which chromium` # tell flutter where chrome is

# This seems to be necessary for snap
export DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/bus"

eval "$(zoxide init bash)"

## START-BCVI
echo $PATH | grep -q /home/james/bin || PATH="/home/james/bin:$PATH"
test -n "$(which bcvi)" && eval "$(bcvi --unpack-term)"
test -n "${BCVI_CONF}"  && alias vi="bcvi"
test -n "${BCVI_CONF}"  && alias suvi="EDITOR='bcvi -c viwait' sudoedit"
test -n "${BCVI_CONF}"  && alias bcp="bcvi -c scpd"
## END-BCVI

# Use emacs-style bindings on the command line.  Can also set to 'vi' but not to 'vim'
set -o emacs

# Emacs Modeline
# Local Variables:
# mode: shell-script
# End: