Skip to content
Snippets Groups Projects
.shellrc 6.6 KiB
Newer Older
James Vasile's avatar
James Vasile committed
# This is a file of shell source meant to be sourced from .bash_rc and .zshrc

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

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

## This sometimes does output, so do it before powershell prompt
if [ "$TERM" != "linux" ]; then
    xmodmap ~/.xmodmap &
fi

# include Mycroft commands
source ~/.profile_mycroft

# 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

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


########################
##
## Path Fiddling
##
dedupe_path() {
    # Remove duplicate pathnames from the path environment variable
    export PATH=$(~/src/infra/bin/deduped_path)
}
show_path() {
    echo $PATH | perl -lne 'BEGIN{$/ = ":"} print "$.) $_"'
}
ccd() {
    if [ $# -eq 0 ]; then
        pushd ~ > /dev/null
    elif [ " $1" = " -" ]; then
        pushd "$OLDPWD" > /dev/null
    else
        pushd "$@" > /dev/null
    fi
}

# Set GOPATH for golang
export GOPATH=/usr/local/src/golang
export PATH="$GOPATH/bin:$PATH"
export PATH="/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:$PATH"
# export PATH="$ANDROID_HOME/platform-tools:$PATH"

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

# Add to path
export PATH="~/src/3p/git-scripts:$PATH"
export PATH="~/.roswell/bin:$PATH"
export PATH="~/Python/venv/general/bin:$PATH"
export PATH="~/.local/bin:$PATH"
export PATH="~/bin:$PATH"


########################
## COLORS (and diff)
##

# Miscellaneous one-off variables
## Diff is hard to read. Colors help.
alias diff=colordiff
alias kittydiff="kitty +kitten diff"
alias icat="kitty +kitten icat"
alias gitdiff="git difftool --no-symlinks --dir-diff"
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

# 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'

################################################################################
##
## App-Specific Aliases and Functions
##

# 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
export GUIX_EXTRA_PROFILES=$HOME/.guix-extra-profiles
export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
export PATH="~/.guix-profile/bin:$PATH"
#export EMACSLOADPATH="/home/james/.guix-profile/share/emacs/site-lisp"
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
# Nix Package Manager
export PATH="~/.nix-profile/bin:$PATH"
James Vasile's avatar
James Vasile committed
################################################################################
##
## EDITING
##

# 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'

# Open in vim
alias e="~/src/infra/bin/edit-in-nvim"
# Open in emacs
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"
# }

# Find a running nvim and open it there
export EDITOR=~/src/infra/bin/edit-in-nvim
# Just pop open a new nvim, now that we're doing most things in emacs.
# For transient things that care about EDITOR, nvim works pretty well.
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

################################################################################
##
## PERL
##

export PATH="$PATH:~/perl5/bin" # add to end of path
PERL5LIB="/home/james/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB;
PERL_LOCAL_LIB_ROOT="/home/james/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
PERL_MB_OPT="--install_base \"/home/james/perl5\""; export PERL_MB_OPT;
PERL_MM_OPT="INSTALL_BASE=/home/james/perl5"; export PERL_MM_OPT;


################################################################################
##
## 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

################################################################################
##
## OTS AND PASSWORDS
##

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"

# 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


echo "`date` - sourced ~/.shellrc by $SHELL" >> /tmp/profile_run_flag.txt

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