General cleanup for readability and maintainability
This commit is contained in:
parent
66a666e4b4
commit
6a102b46c4
|
@ -4,12 +4,9 @@
|
||||||
|
|
||||||
[[ -f ~/.bashrc ]] && . ~/.bashrc
|
[[ -f ~/.bashrc ]] && . ~/.bashrc
|
||||||
|
|
||||||
|
# Do these things if in tty0-tty9
|
||||||
# Set numlock if running in tty.
|
|
||||||
# (numlock for X is set in ~/.xinitrc)
|
|
||||||
case $(tty) in /dev/tty[0-9]*)
|
case $(tty) in /dev/tty[0-9]*)
|
||||||
setleds -D +num
|
setleds -D +num # (numlock for X is set in ~/.xinitrc)
|
||||||
export USING_TTY=1
|
|
||||||
# Temporary fix for a systemd bug related to systemd --user timers that run on login
|
# Temporary fix for a systemd bug related to systemd --user timers that run on login
|
||||||
[[ -z "$DBUS_SESSION_BUS_ADDRESS" ]] && printf "%bWARNING: \$DBUS_SESSION_BUS_ADDRESS is unset! %b\n" "$(tput bold)$(tput setab 1)" "$(tput sgr0)"
|
[[ -z "$DBUS_SESSION_BUS_ADDRESS" ]] && printf "%bWARNING: \$DBUS_SESSION_BUS_ADDRESS is unset! %b\n" "$(tput bold)$(tput setab 1)" "$(tput sgr0)"
|
||||||
;;
|
;;
|
||||||
|
|
102
.bashrc
102
.bashrc
|
@ -3,27 +3,20 @@
|
||||||
# ~/.bashrc
|
# ~/.bashrc
|
||||||
#
|
#
|
||||||
# Thurstylark
|
# Thurstylark
|
||||||
|
#
|
||||||
|
# Reference: https://wiki.thurstylark.com/Bashrc.html
|
||||||
|
|
||||||
### MISC ###
|
### MISC ###
|
||||||
|
|
||||||
# If not running interactively, don't do anything
|
# If not running interactively, don't do anything
|
||||||
[[ $- != *i* ]] && return
|
[[ $- != *i* ]] && return
|
||||||
|
|
||||||
# Use powerline if it's installed
|
HISTCONTROL=ignoreboth # Don't put duplicate lines or lines starting with space in the history.
|
||||||
[ ! -z "$USING_TTY" ] && [ -s "/usr/lib/python3.5/site-packages/powerline/bindings/bash/powerline.sh" ] && {
|
|
||||||
powerline-daemon -q
|
|
||||||
POWERLINE_BASH_CONTINUATION=1
|
|
||||||
POWERLINE_BASH_SELECT=1
|
|
||||||
. /usr/lib/python3.5/site-packages/powerline/bindings/bash/powerline.sh
|
|
||||||
}
|
|
||||||
|
|
||||||
# Don't put duplicate lines or lines starting with space in the history.
|
shopt -s autocd # If a directory is given without any command, CD into it.
|
||||||
# See bash(1) for more options
|
|
||||||
HISTCONTROL=ignoreboth
|
|
||||||
|
|
||||||
# Some programs, such as tee(1), like to use this variable
|
# Some programs, such as tee(1), like to use this variable
|
||||||
LS_COLORS='di=34;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:'
|
export LS_COLORS='di=34;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:'
|
||||||
export LS_COLORS
|
|
||||||
|
|
||||||
# Prefer vim, but if it's not installed, nano will do
|
# Prefer vim, but if it's not installed, nano will do
|
||||||
[[ -s /usr/bin/vim ]] && export EDITOR=vim || export EDITOR=nano
|
[[ -s /usr/bin/vim ]] && export EDITOR=vim || export EDITOR=nano
|
||||||
|
@ -31,54 +24,65 @@ export LS_COLORS
|
||||||
# Enable pkgfile to automatically search for packages if pkgfile is installed
|
# Enable pkgfile to automatically search for packages if pkgfile is installed
|
||||||
[[ -s /usr/share/doc/pkgfile/command-not-found.bash ]] && source /usr/share/doc/pkgfile/command-not-found.bash
|
[[ -s /usr/share/doc/pkgfile/command-not-found.bash ]] && source /usr/share/doc/pkgfile/command-not-found.bash
|
||||||
|
|
||||||
# If a directory is given without any
|
|
||||||
# command, CD into it.
|
|
||||||
shopt -s autocd
|
|
||||||
|
|
||||||
# Enables colored Man pages:
|
# Enables colored Man pages:
|
||||||
man() {
|
man() {
|
||||||
env LESS_TERMCAP_mb=$'\E[01;31m' \
|
env LESS_TERMCAP_mb=$'\E[01;31m' \
|
||||||
LESS_TERMCAP_md=$'\E[01;38;5;74m' \
|
LESS_TERMCAP_md=$'\E[01;38;5;74m' \
|
||||||
LESS_TERMCAP_me=$'\E[0m' \
|
LESS_TERMCAP_me=$'\E[0m' \
|
||||||
LESS_TERMCAP_se=$'\E[0m' \
|
LESS_TERMCAP_se=$'\E[0m' \
|
||||||
LESS_TERMCAP_so=$'\E[38;5;246m' \
|
LESS_TERMCAP_so=$'\E[38;5;246m' \
|
||||||
LESS_TERMCAP_ue=$'\E[0m' \
|
LESS_TERMCAP_ue=$'\E[0m' \
|
||||||
LESS_TERMCAP_us=$'\E[04;38;5;146m' \
|
LESS_TERMCAP_us=$'\E[04;38;5;146m' \
|
||||||
man "$@"
|
man "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Do the same for awman
|
# Do the same for awman
|
||||||
awman() {
|
awman() {
|
||||||
env LESS_TERMCAP_mb=$'\E[01;31m' \
|
env LESS_TERMCAP_mb=$'\E[01;31m' \
|
||||||
LESS_TERMCAP_md=$'\E[01;38;5;74m' \
|
LESS_TERMCAP_md=$'\E[01;38;5;74m' \
|
||||||
LESS_TERMCAP_me=$'\E[0m' \
|
LESS_TERMCAP_me=$'\E[0m' \
|
||||||
LESS_TERMCAP_se=$'\E[0m' \
|
LESS_TERMCAP_se=$'\E[0m' \
|
||||||
LESS_TERMCAP_so=$'\E[38;5;246m' \
|
LESS_TERMCAP_so=$'\E[38;5;246m' \
|
||||||
LESS_TERMCAP_ue=$'\E[0m' \
|
LESS_TERMCAP_ue=$'\E[0m' \
|
||||||
LESS_TERMCAP_us=$'\E[04;38;5;146m' \
|
LESS_TERMCAP_us=$'\E[04;38;5;146m' \
|
||||||
awman "$@"
|
awman "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
### PROMPT ###
|
### PROMPT ###
|
||||||
|
|
||||||
# [hh:mm][username@hostname pwd]$
|
promptsetup() {
|
||||||
if [ -n "$SSH_CLIENT" ]; then
|
# Color definitions for prompt
|
||||||
# Remotely, hostname is red.
|
local fg_brightred='\[$(tput setaf 9)\]'
|
||||||
PS1="\[\033[38;5;4m\][\A]\[$(tput sgr0)\]\[\033[38;5;6m\][\[$(tput bold)\]\[$(tput sgr0)\]\[\033[38;5;14m\]\u\[$(tput sgr0)\]\[$(tput sgr0)\]\[\033[38;5;6m\]@\[$(tput bold)\]\[$(tput sgr0)\]\[\033[38;5;1m\]\h\[$(tput sgr0)\]\[$(tput sgr0)\]\[\033[38;5;6m\] \W]\[$(tput sgr0)\]\[\033[38;5;7m\]\\$ \[$(tput sgr0)\]"
|
local fg_blue='\[$(tput setaf 4)\]'
|
||||||
elif [ -n "$VCSH_REPO_NAME" ]; then
|
local fg_magenta='\[$(tput setaf 13)\]'
|
||||||
# If in a vcsh repo env, add repo name in magenta.
|
local fg_cyan='\[$(tput setaf 6)\]'
|
||||||
PS1="\[\033[38;5;12m\][\[$(tput sgr0)\]\[\033[38;5;4m\]\A\[$(tput sgr0)\]\[\033[38;5;12m\]]\[$(tput sgr0)\]\[\033[38;5;6m\][\[$(tput sgr0)\]\[\033[38;5;14m\]\u\[$(tput sgr0)\]\[\033[38;5;6m\]@\h \[$(tput sgr0)\]\[\033[38;5;13m\]$VCSH_REPO_NAME\[$(tput sgr0)\]\[\033[38;5;6m\] \W]\[$(tput sgr0)\]\[\033[38;5;15m\]\\$ \[$(tput sgr0)\]"
|
local fg_brightcyan='\[$(tput setaf 14)\]'
|
||||||
else
|
local reset='\[$(tput sgr0)\]'
|
||||||
# Locally, hostname is cyan.
|
|
||||||
PS1="\[\033[38;5;4m\][\A]\[$(tput sgr0)\]\[\033[38;5;6m\][\[$(tput bold)\]\[$(tput sgr0)\]\[\033[38;5;14m\]\u\[$(tput sgr0)\]\[$(tput sgr0)\]\[\033[38;5;6m\]@\h \W]\[$(tput sgr0)\]\[\033[38;5;7m\]\\$ \[$(tput sgr0)\]"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
# [hh:mm][username@hostname pwd]$
|
||||||
|
if [ -n "$SSH_CLIENT" ]; then
|
||||||
|
# Remotely, hostname is red.
|
||||||
|
PS1="${fg_blue}[\A]${fg_cyan}[${fg_brightcyan}\u${fg_cyan}@${fg_brightred}\h ${fg_cyan}\W]${reset}\$ "
|
||||||
|
|
||||||
|
elif [ -n "$VCSH_REPO_NAME" ]; then
|
||||||
|
# If in a vcsh repo env, add repo name in magenta.
|
||||||
|
PS1="${fg_blue}[\A]${fg_cyan}[${fg_brightcyan}\u${fg_cyan}@\h ${fg_magenta}$VCSH_REPO_NAME ${fg_cyan}\W]${reset}\$ "
|
||||||
|
|
||||||
|
else
|
||||||
|
# Locally, hostname is cyan.
|
||||||
|
PS1="${fg_blue}[\A]${fg_cyan}[${fg_brightcyan}\u${fg_cyan}@\h \W]${reset}\$ "
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
promptsetup
|
||||||
|
|
||||||
### ALIASES ###
|
### ALIASES ###
|
||||||
|
|
||||||
# Colorize all `ls` output:
|
# Colorize all `ls` output:
|
||||||
alias ls='ls -AF --color=auto'
|
alias ls='ls -AF --color=auto'
|
||||||
|
|
||||||
# Map "la" to `ls -la`
|
# Map "la" to `ls -la`
|
||||||
alias la='ls -laFh --color=auto'
|
alias la='ls -laFh --color=auto'
|
||||||
|
|
||||||
|
@ -98,17 +102,3 @@ alias nmap='sudo -E nmap'
|
||||||
[[ ! -s /usr/bin/weechat ]] && alias weechat='mosh vps -- tmux attach -dt weechat'
|
[[ ! -s /usr/bin/weechat ]] && alias weechat='mosh vps -- tmux attach -dt weechat'
|
||||||
# If you are thurstylark-vps, connect to the existing tmux session locally
|
# If you are thurstylark-vps, connect to the existing tmux session locally
|
||||||
[[ "$HOSTNAME" = "thurstylark-vps" ]] && alias weechat='tmux attach -dt weechat'
|
[[ "$HOSTNAME" = "thurstylark-vps" ]] && alias weechat='tmux attach -dt weechat'
|
||||||
|
|
||||||
chterm() { # Command wrapper to temporarily switch to screen-256color terminfo and back.
|
|
||||||
# This is unfortunately necessary because Debian has literally no package
|
|
||||||
# that provides tmux-256color terminfo, and I have to ssh into debian boxes
|
|
||||||
# all damn day.
|
|
||||||
local oldterm=$TERM
|
|
||||||
export TERM=screen-256color
|
|
||||||
tput init
|
|
||||||
printf "Terminfo is now '%s'\n" "$TERM"
|
|
||||||
$@
|
|
||||||
export TERM=$oldterm
|
|
||||||
tput init
|
|
||||||
printf "Terminfo is now '%s'\n" "$TERM"
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue