bashrc/.bashrc

105 lines
3.0 KiB
Bash
Raw Normal View History

#!/bin/bash
2016-01-20 17:06:54 +00:00
#
# ~/.bashrc
#
# Thurstylark
#
# Reference: https://wiki.thurstylark.com/Bashrc.html
2016-01-20 17:06:54 +00:00
### MISC ###
2016-01-20 17:06:54 +00:00
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
HISTCONTROL=ignoreboth # Don't put duplicate lines or lines starting with space in the history.
2016-03-31 17:09:10 +00:00
shopt -s autocd # If a directory is given without any command, CD into it.
2016-01-20 17:06:54 +00:00
# Some programs, such as tee(1), like to use this variable
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:'
2016-03-15 14:15:35 +00:00
# Prefer vim, but if it's not installed, nano will do
[[ -s /usr/bin/vim ]] && export EDITOR=vim || export EDITOR=nano
# 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
2016-01-20 17:06:54 +00:00
# Enables colored Man pages:
man() {
env LESS_TERMCAP_mb=$'\E[01;31m' \
LESS_TERMCAP_md=$'\E[01;38;5;74m' \
LESS_TERMCAP_me=$'\E[0m' \
LESS_TERMCAP_se=$'\E[0m' \
LESS_TERMCAP_so=$'\E[38;5;246m' \
LESS_TERMCAP_ue=$'\E[0m' \
LESS_TERMCAP_us=$'\E[04;38;5;146m' \
man "$@"
2016-01-20 17:06:54 +00:00
}
# Do the same for awman
awman() {
env LESS_TERMCAP_mb=$'\E[01;31m' \
LESS_TERMCAP_md=$'\E[01;38;5;74m' \
LESS_TERMCAP_me=$'\E[0m' \
LESS_TERMCAP_se=$'\E[0m' \
LESS_TERMCAP_so=$'\E[38;5;246m' \
LESS_TERMCAP_ue=$'\E[0m' \
LESS_TERMCAP_us=$'\E[04;38;5;146m' \
awman "$@"
}
2016-01-20 17:06:54 +00:00
### PROMPT ###
promptsetup() {
# Color definitions for prompt
local fg_brightred='\[$(tput setaf 9)\]'
local fg_blue='\[$(tput setaf 4)\]'
local fg_magenta='\[$(tput setaf 13)\]'
local fg_cyan='\[$(tput setaf 6)\]'
local fg_brightcyan='\[$(tput setaf 14)\]'
local reset='\[$(tput sgr0)\]'
# [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
}
2016-01-20 17:06:54 +00:00
promptsetup
2016-01-20 17:06:54 +00:00
### ALIASES ###
# Colorize all `ls` output:
alias ls='ls -AF --color=auto'
2016-01-20 17:06:54 +00:00
# Map "la" to `ls -la`
alias la='ls -laFh --color=auto'
2016-01-20 17:06:54 +00:00
# Colorize `grep` output
alias grep='grep --color=auto'
# Change layout of lsblk to include FSTYPE and remove MAJ:MIN, RM, and RO collumns.
alias lsblk='lsblk -o NAME,FSTYPE,SIZE,TYPE,MOUNTPOINT'
2016-01-21 22:21:30 +00:00
# Always use sudo when using nmap.
alias nmap='sudo -E nmap'
# I'm tired of managing weechat configs and multiple nicks
# Reference: https://wiki.thurstylark.com/Weechat.html
2017-01-10 22:37:02 +00:00
# If you don't have weechat installed, connect to the existing tmux session through mosh
[[ ! -s /usr/bin/weechat ]] && alias weechat='mosh vps -- tmux attach -dt weechat'
# If you are thurstylark-vps, connect to the existing tmux session locally
[[ "$HOSTNAME" = "thurstylark-vps" ]] && alias weechat='tmux attach -dt weechat'