From 3f12c22c0fc2025ff9127842a3f443f375a42883 Mon Sep 17 00:00:00 2001 From: binaryDiv Date: Mon, 7 Jan 2019 01:02:09 +0100 Subject: [PATCH] Clean up .bashrc, add .bashrc.local for kanaya --- .bashrc | 92 ++++++++++++++++++-------------------------- local/.bashrc.kanaya | 20 ++++++++++ 2 files changed, 57 insertions(+), 55 deletions(-) create mode 100644 local/.bashrc.kanaya diff --git a/.bashrc b/.bashrc index 4ab8425..b6702cb 100644 --- a/.bashrc +++ b/.bashrc @@ -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 diff --git a/local/.bashrc.kanaya b/local/.bashrc.kanaya new file mode 100644 index 0000000..4352b55 --- /dev/null +++ b/local/.bashrc.kanaya @@ -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 +