Clean up .bashrc, add .bashrc.local for kanaya

This commit is contained in:
Lexi / Zoe 2019-01-07 01:02:09 +01:00
parent 2b05ae3f30
commit 3f12c22c0f
Signed by: binaryDiv
GPG Key ID: F8D4956E224DA232
2 changed files with 57 additions and 55 deletions

92
.bashrc
View File

@ -1,5 +1,5 @@
# #
# ~/.bashrc # ~/.bashrc -- global .bashrc, includes ~/.bashrc.local
# #
# If not running interactively, don't do anything # If not running interactively, don't do anything
@ -9,13 +9,15 @@
set -o noclobber set -o noclobber
shopt -s checkwinsize shopt -s checkwinsize
export HISTCONTROL=ignorespace export HISTCONTROL=ignorespace
export PROMPT_DIRTRIM=3
# Color output # Color output and default options
export TERM=xterm-color export TERM=xterm-color
export GREP_OPTS='--color=auto' export GREP_OPTS='--color=auto'
export LS_OPTS='--color=auto -hFN --group-directories-first' export LS_OPTS='--color=auto -hFN --group-directories-first'
export LESS="--RAW-CONTROL-CHARS -i" export LESS="--RAW-CONTROL-CHARS -i"
# Colored man pages
man() { man() {
env \ env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \ LESS_TERMCAP_mb=$(printf "\e[1;31m") \
@ -28,96 +30,76 @@ man() {
man "$@" man "$@"
} }
# Set default options
alias ls='ls ${LS_OPTS}' alias ls='ls ${LS_OPTS}'
alias grep='grep ${GREP_OPTS}' alias grep='grep ${GREP_OPTS}'
# Aliases and color output # Common shortcut aliases
alias l='ls -l' alias l='ls -l'
alias la='ls -a' alias la='ls -a'
alias ll='ls -la' alias ll='ls -la'
alias dusch='du -sch'
alias sorth='sort -hr' alias sorth='sort -hr'
alias ps-grep='ps -ef | grep'
# Push the queerfeminist agenda
alias woman='man' alias woman='man'
alias enby='man' alias enby='man'
# Stop Ctrl-S from doing terminally things in vim # X application aliases
vim() alias gvimr='gvim --remote-silent'
{ alias xclip_='xclip -selection clipboard'
# TODO fix mime stuff
alias xo='xdg-open'
# Wine aliases
alias wine32='env WINEARCH=win32 WINEPREFIX="$HOME/.wine32" wine'
# Stop Ctrl-S from doing terminally things in vim/vimdiff
vim() {
local STTYOPTS="$(stty --save)" local STTYOPTS="$(stty --save)"
stty stop '' -ixoff stty stop '' -ixoff
command vim "$@" command vim "$@"
stty "$STTYOPTS" stty "$STTYOPTS"
} }
vimdiff() vimdiff() {
{
local STTYOPTS="$(stty --save)" local STTYOPTS="$(stty --save)"
stty stop '' -ixoff stty stop '' -ixoff
command vimdiff "$@" command vimdiff "$@"
stty "$STTYOPTS" stty "$STTYOPTS"
} }
alias gvimr='gvim --remote-silent' # yay without parameters does "pacman -Syu" but I don't want it to do this
alias xo='xdg-open' yay() {
[[ $# -gt 0 ]] || { echo "error: no operation specified (use -h for help)"; return 1; }
alias ps-grep='ps aux | grep' command yay "$@"
alias wine32='env WINEARCH=win32 WINEPREFIX="$HOME/.wine32" wine'
# TODO: aliases/functions auslagern?
alias xclip_='xclip -selection clipboard'
xclip-greppassword() {
grepstr="Password: "
filename="$1"
if [ "$#" -ge 2 ]; then
grepstr="$1"
filename="$2"
fi
grep -m 1 "$grepstr" "$filename" | cut -d " " -f 2 | xclip -r -selection clipboard
} }
calc()
{
echo "$@" | bc
}
#alias su="su -l"
# Create and cd to tmp dir # Create and cd to tmp dir
alias cdtmp='cd $(mktemp -d -p ~/tmp/)' alias cdtmp='cd $(mktemp -d -p ~/tmp/)'
# yay without parameters does "pacman -Syu" but I don't it to do this calc() {
yay() { echo "$@" | bc
if [ $# -eq 0 ]; then
echo "error: no operation specified (use -h for help)"
return 1
else
command yay "$@"
fi
} }
# Define colors for bash prompt (will also be used in .bashrc.local)
TRED='\[\e[0;31m\]' # Red
TGREEN='\[\e[0;32m\]' # Green
TBLUE='\[\e[1;34m\]' # Blue
TWHITEB='\[\e[1;37m\]' # White bold
TRESET='\[\e[0m\]' # Text Reset
# Bash prompt # Set default prompt
PS1='[\u@\h \W]\$ '
TRED='\[\e[0;31m\]' # Red
TGREEN='\[\e[0;32m\]' # Green
TBLUE='\[\e[1;34m\]' # Blue
TWHITEB='\[\e[1;37m\]' # White bold
TRESET='\[\e[0m\]' # Text Reset
if [[ ${EUID} == 0 ]] ; then if [[ ${EUID} == 0 ]] ; then
PS1="${TRED}\u@\h ${TBLUE}\w ${TWHITEB}\$ ${TRESET}" PS1="${TRED}\u@\h ${TBLUE}\w ${TWHITEB}\$ ${TRESET}"
else else
PS1="${TGREEN}\u@\h ${TBLUE}\w ${TWHITEB}\$ ${TRESET}" PS1="${TGREEN}\u@\h ${TBLUE}\w ${TWHITEB}\$ ${TRESET}"
fi fi
export PROMPT_DIRTRIM=3 # Include host-specific bashrc
[[ -f ~/.bashrc.local ]] && source ~/.bashrc.local
# Clean up environment variables
unset TRED TGREEN TBLUE TWHITEB TRESET unset TRED TGREEN TBLUE TWHITEB TRESET

20
local/.bashrc.kanaya Normal file
View File

@ -0,0 +1,20 @@
#
# ~/.bashrc.local -- kanaya version
#
# Assume colors are set in global .bashrc:
# - TRED
# - TGREEN
# - TBLUE
# - TWHITEB (bold)
# - TRESET
# Set host-specific bash prompt: "user@host pwd $ "
# (This is the default prompt for now... TODO)
#if [[ ${EUID} == 0 ]] ; then
# PS1="${TRED}\u@\h ${TBLUE}\w ${TWHITEB}\$ ${TRESET}"
#else
# PS1="${TGREEN}\u@\h ${TBLUE}\w ${TWHITEB}\$ ${TRESET}"
#fi