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
@ -9,13 +9,15 @@
set -o noclobber
shopt -s checkwinsize
export HISTCONTROL=ignorespace
export PROMPT_DIRTRIM=3
# Color output
# Color output and default options
export TERM=xterm-color
export GREP_OPTS='--color=auto'
export LS_OPTS='--color=auto -hFN --group-directories-first'
export LESS="--RAW-CONTROL-CHARS -i"
# Colored man pages
man() {
env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
@ -28,96 +30,76 @@ man() {
man "$@"
}
# Set default options
alias ls='ls ${LS_OPTS}'
alias grep='grep ${GREP_OPTS}'
# Aliases and color output
# Common shortcut aliases
alias l='ls -l'
alias la='ls -a'
alias ll='ls -la'
alias dusch='du -sch'
alias sorth='sort -hr'
alias ps-grep='ps -ef | grep'
# Push the queerfeminist agenda
alias woman='man'
alias enby='man'
# Stop Ctrl-S from doing terminally things in vim
vim()
{
# X application aliases
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)"
stty stop '' -ixoff
command vim "$@"
stty "$STTYOPTS"
}
vimdiff()
{
vimdiff() {
local STTYOPTS="$(stty --save)"
stty stop '' -ixoff
command vimdiff "$@"
stty "$STTYOPTS"
}
alias gvimr='gvim --remote-silent'
alias xo='xdg-open'
alias ps-grep='ps aux | grep'
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
# yay without parameters does "pacman -Syu" but I don't want it to do this
yay() {
[[ $# -gt 0 ]] || { echo "error: no operation specified (use -h for help)"; return 1; }
command yay "$@"
}
calc()
{
echo "$@" | bc
}
#alias su="su -l"
# Create and cd to tmp dir
alias cdtmp='cd $(mktemp -d -p ~/tmp/)'
# yay without parameters does "pacman -Syu" but I don't it to do this
yay() {
if [ $# -eq 0 ]; then
echo "error: no operation specified (use -h for help)"
return 1
else
command yay "$@"
fi
calc() {
echo "$@" | bc
}
# 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
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
# Set default prompt
if [[ ${EUID} == 0 ]] ; then
PS1="${TRED}\u@\h ${TBLUE}\w ${TWHITEB}\$ ${TRESET}"
else
PS1="${TGREEN}\u@\h ${TBLUE}\w ${TWHITEB}\$ ${TRESET}"
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

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