Skip to content
Snippets Groups Projects
Commit 89a22175 authored by James Vasile's avatar James Vasile
Browse files

Refactor login rc scripts

parent 24b4a35b
No related branches found
No related tags found
No related merge requests found
# .bashrc
# ~/.profile will run before this on login
# Source other bash files
if [ -f ~/.shellrc ]; then
source ~/.shellrc
fi
# global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Setup direnv, which we use to handle python virtual environments
eval "$(direnv hook bash)"
# Add git branch to prompt
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
......@@ -14,206 +24,19 @@ parse_git_branch() {
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
# Fix ls colors, bash specific
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
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"
# 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
......@@ -224,15 +47,17 @@ 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"
# BCVI is a utility for proxying commands over ssh
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
dedupe_path
# Use emacs-style bindings on the command line. Can also set to 'vi' but not to 'vim'
set -o emacs
set -o vi
# Emacs Modeline
# Local Variables:
......
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
echo "`date` - sourced ~/.profile by $SHELL" >> /tmp/profile_run_flag.txt
# Emacs Modeline
# Local Variables:
# mode: shell-script
# End:
# 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"
################################################################################
##
## 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:
if [ -f ~/.profile ]; then
source ~/.profile
fi
# .zshrc
if [ -f ~/.shellrc ]; then
source ~/.shellrc
fi
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# cd
#setopt auto_cd
#cdpath=($HOME/src $HOME/OTS/clients)
setopt auto_pushd
# Enable ctrl-left and ctrl-right. These codes are terminal-dependent. I did
# `cat > /dev/null` then hit the keys I wanted and saw the codes.
bindkey '^[[1;5C' emacs-forward-word
bindkey '^[[1;5D' emacs-backward-word
# Fix ls colors
alias ls="ls --color=auto"
# Integrate zsh into shell
eval "$(direnv hook zsh)"
################################################################################
##
## ZPLUG
##
# Load ZPlug
if [[ -a /usr/share/zplug/init.zsh ]]; then
source /usr/share/zplug/init.zsh
else
if [[ ! -a ~/.zplug/upstream/init.zsh ]]; then
mkdir -p ~/.zplug/upstream
git clone https://github.com/zplug/zplug ~/.zplug/upstream
fi
source ~/.zplug/upstream/init.zsh
fi
# Pass and Opass completion
zplug "ninrod/pass-zsh-completion", frozen:1 #, defer:2
compdef _pass opass
zstyle ':completion::complete:opass::' prefix "$HOME/.ots-password-store"
# opass() {
# PASSWORD_STORE_DIR=$HOME/.ots-password-store pass $@
# }
# Powerline10K
zplug "romkatv/powerlevel10k", as:theme, depth:1
# Install plugins if there are plugins that have not been installed
if ! zplug check --verbose; then
zplug install
fi
# Then, source plugins and add commands to $PATH
zplug load
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# Integrate zoxide directory switching into zsh shell
eval "$(zoxide init --hook pwd zsh)"
# Give user systemd scripts my env. I'm not sure that I need both of
# these lines.
systemctl --user import-environment &> /dev/null
systemctl --user import-environment PATH GPG_AGENT_INFO
dedupe_path
echo "`date` - sourced ~/.zshrc by $SHELL" >> /tmp/profile_run_flag.txt
# Emacs Modeline
# Local Variables:
# mode: shell-script
# End:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment