stow/bash/.bashrc

82 lines
2.1 KiB
Bash
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Do nothing if not running an interactive shell
case $- in
*i*) ;;
*) return;;
esac
# Environment variables
export TERM="xterm-256color"
export EDITOR="vi"
export VISUAL="vi"
export PATH="$PATH:$HOME/.local/bin/:$HOME/go/bin/"
export CDPATH=".:$HOME"
export XDG_CONFIG_HOME="$HOME/.config/"
export XDG_DATA_HOME="$HOME/.local/share/"
export XDG_STATE_HOME="$HOME/.local/state/"
# The Prompt
export PS1='\[\e[38;2;161;161;0m\]\u\[\e[0m\]@\[\e[34m\]\h\[\e[0m\]:\[\e[32m\]\W\[\e[0m\]\$ '
# History settings
shopt -s histappend # Append to the history file instead of overwriting it
HISTCONTROL=ignoreboth # Don't put duplicate lines or lines beginning with a space in the history file
HISTSIZE=-1 # Don't limit the number of history lines stored
HISTFILESIZE=-1 # Don't truncate the history when reading the history file at the start of a shell session
# Pager settings
# Use lesspipe if it exists
if command -v lesspipe >/dev/null; then
declare lesspath
lesspath="$(command -v lesspipe)"
export LESSOPEN="| $lesspath %s";
export LESSCLOSE="$lesspath %s %s";
fi
# Enable colors in less
export LESS_TERMCAP_mb=""
export LESS_TERMCAP_md=""
export LESS_TERMCAP_me=""
export LESS_TERMCAP_se=""
export LESS_TERMCAP_so=""
export LESS_TERMCAP_ue=""
export LESS_TERMCAP_us=""
# Enable dircolors
if [[ -x "$(command -v dircolors)" ]]; then
if [[ -r ~/.config/shell/dircolors ]]; then
eval "$(dircolors -b ~/.config/shell/dircolors)"
else
eval "$(dircolors -b)"
fi
fi
# Safety features
set -o noclobber # Enable features to prevent accidental file deletion
# Shell expansion features
shopt -s globstar # Enable "**" to match recursively when globbing
# Interactive features
set -o vi
# Aliases
source ~/.config/shell/aliasrc
# Functions
md() {
mkdir -p "$1" && cd "$1" || return
}
# Automatically run tmux if we aren't already in a session and there's no matching session already running
if [[ -z "$TMUX" ]] && ! tmux list-sessions | grep --quiet "$HOSTNAME"; then
tmux new -s "$HOSTNAME"
fi
# AUtomatically run X if this is a login tty
[[ "$(tty)" == "/dev/tty1" ]] && ! pgrep -x Xorg >/dev/null && startx