181 lines
4.5 KiB
Bash
Executable File
181 lines
4.5 KiB
Bash
Executable File
if [[ $- == *i* ]]; then # in interactive session
|
|
# ble.sh
|
|
# https://github.com/akinomyoga/ble.sh#13-set-up-bashrc
|
|
BLE="${HOME}/programs/ble.sh/out/ble.sh"
|
|
[[ -f ${BLE} ]] && source ${BLE} --noattach
|
|
fi
|
|
|
|
# Navigation
|
|
alias vim="nvim"
|
|
alias lg="lazygit"
|
|
alias ls="eza --long --header --git --group --time-style long-iso"
|
|
alias cat="bat --theme=\"Visual Studio Dark+\""
|
|
alias tree="eza --tree"
|
|
alias la="ls -lhA"
|
|
alias calc="qalc"
|
|
alias dedsstore="find . -name \".DS_Store\" -delete"
|
|
alias c="clear"
|
|
alias dps="docker ps -a --format 'table {{.Names}}\t{{.Status}}\t{{.Image}}'"
|
|
|
|
# History
|
|
HISTSIZE=50000
|
|
HISTFILESIZE=50000
|
|
HISTCONTROL=ignoreboth:erasedups
|
|
HISTIGNORE="ls:ll:cd:pwd:bg:fg:history"
|
|
|
|
if [ "$BASH" != "" ]; then
|
|
# enable bash completion in interactive shells
|
|
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
|
|
. /etc/bash_completion
|
|
fi
|
|
fi
|
|
|
|
if [[ "${OSTYPE}" == "linux-gnu"* ]]; then
|
|
# History
|
|
shopt -s histappend
|
|
# append and reload the history after each command
|
|
PROMPT_COMMAND="history -a; history -n"
|
|
|
|
if [ -z "$SSH_AUTH_SOCK" ]; then
|
|
# Check for a currently running instance of the agent
|
|
RUNNING_AGENT="`ps -ax | grep 'ssh-agent -s' | grep -v grep | wc -l | tr -d '[:space:]'`"
|
|
if [ "$RUNNING_AGENT" = "0" ]; then
|
|
# Launch a new instance of the agent
|
|
ssh-agent -s &> $HOME/.ssh/ssh-agent
|
|
sed -i '/^echo Agent pid.*/d' $HOME/.ssh/ssh-agent
|
|
fi
|
|
eval `\cat $HOME/.ssh/ssh-agent`
|
|
|
|
for key in $(find "${HOME}/.ssh" -type f -name "*.pub"); do
|
|
# Don't add if a key with this fingerprint is already in the agent.
|
|
fp="$(ssh-keygen -lf "${key%.*}" | awk '{print $2}')"
|
|
ssh-add -l |grep -q "${fp}" || ssh-add -q "${key%.*}"
|
|
done
|
|
fi
|
|
|
|
# bind -x '"\C-r"':reset
|
|
fi
|
|
|
|
# Applications
|
|
alias tmux="tmux -2"
|
|
alias grep="grep --color=auto"
|
|
|
|
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
|
|
|
|
# Fix gpg signing
|
|
# https://github.com/keybase/keybase-issues/issues/2798
|
|
export GPG_TTY=$(tty)
|
|
|
|
# Golang
|
|
# NOTE: Go is installed with Homebrew and automatically placed on the path
|
|
export PATH=$PATH:${HOME}/go/bin
|
|
|
|
export TERM="xterm-256color"
|
|
export EDITOR=$(which vim)
|
|
|
|
# Adding applications to path
|
|
if [[ -d ${HOME}/.dotfiles/bin/linux ]]; then
|
|
export PATH=$PATH:${HOME}/.dotfiles/bin/linux
|
|
fi
|
|
if [[ -d ${HOME}/bin ]]; then
|
|
export PATH=$PATH:${HOME}/bin
|
|
fi
|
|
|
|
|
|
# Enable atuin
|
|
# https://docs.atuin.sh
|
|
eval "$(atuin init bash)"
|
|
|
|
# fzf
|
|
#eval "$(fzf --bash)"
|
|
|
|
export FZF_DEFAULT_OPTS=" \
|
|
--color=bg+:#ccd0da,bg:#eff1f5,spinner:#dc8a78,hl:#d20f39 \
|
|
--color=fg:#4c4f69,header:#d20f39,info:#8839ef,pointer:#dc8a78 \
|
|
--color=marker:#dc8a78,fg+:#4c4f69,prompt:#8839ef,hl+:#d20f39"
|
|
|
|
# Override this in .bashrc_local if a nerd font is installed locally.
|
|
export HAVE_NERD_FONT=false
|
|
export HIDE_HOSTNAME=false
|
|
|
|
# Add a local un-tracked bash-rc if present
|
|
if [[ -f ${HOME}/.bashrc_local ]];
|
|
then
|
|
source ${HOME}/.bashrc_local
|
|
fi
|
|
|
|
# Git
|
|
_git_safedel() {
|
|
if [[ "${COMP_LINE}" =~ ^git\ safedel.*$ ]]; then
|
|
__gitcomp_nl "$(__git_heads)"
|
|
else
|
|
__git_main
|
|
fi
|
|
}
|
|
_git_top() {
|
|
if [[ "${COMP_LINE}" =~ ^git\ top.*$ ]]; then
|
|
__gitcomp_nl "$(__git_heads)"
|
|
else
|
|
__git_main
|
|
fi
|
|
}
|
|
|
|
# Add color shortcuts
|
|
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
|
|
c_reset=`tput sgr0`
|
|
c_user=`tput setaf 2; tput bold`
|
|
c_path=`tput setaf 4; tput bold`
|
|
c_git_clean=`tput setaf 2`
|
|
c_git_dirty=`tput setaf 1`
|
|
else
|
|
c_reset=
|
|
c_user=
|
|
c_path=
|
|
c_git_cleanclean=
|
|
c_git_dirty=
|
|
fi
|
|
|
|
prev_status_prompt_minimal () {
|
|
status=$?
|
|
if [ $status -ne 0 ]; then
|
|
red=`tput setaf 1; tput bold`
|
|
echo "${red}${status}${c_reset} "
|
|
fi
|
|
}
|
|
|
|
prev_status_prompt () {
|
|
status=$?
|
|
if [ $status -ne 0 ]; then
|
|
red=`tput setaf 1; tput bold`
|
|
echo " -- ${red}${status}${c_reset}"
|
|
fi
|
|
}
|
|
|
|
git_prompt () {
|
|
if ! git rev-parse --git-dir > /dev/null 2>&1; then
|
|
return 0
|
|
fi
|
|
|
|
git_branch=$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')
|
|
|
|
echo " -- $git_branch"
|
|
}
|
|
|
|
if [ "$BASH" != "" ] && [ "$TMUX" != "" ]; then
|
|
h="\h"
|
|
if [ $HIDE_HOSTNAME = true ]; then
|
|
h=""
|
|
fi
|
|
|
|
# In tmux, hide the path and gitprompt and reduce to one line.
|
|
PS1="\n\$(prev_status_prompt_minimal)${h} "
|
|
elif [ "$BASH" != "" ]; then
|
|
# Prompt
|
|
PS1="\n╔ \w\$(prev_status_prompt)\$(git_prompt) -- \$(date '+%y-%m-%dT%H:%M:%S')\n╚ \h\$ "
|
|
fi
|
|
|
|
# ble.sh
|
|
# https://github.com/akinomyoga/ble.sh#13-set-up-bashrc
|
|
[[ ${BLE_VERSION-} ]] && ble-attach
|
|
|