From dd74e1d94f987754e9067912c49565d665eda4ed Mon Sep 17 00:00:00 2001 From: Mark Powers Date: Thu, 17 Dec 2020 12:09:43 -0600 Subject: Add bashrc --- .bash_aliases | 5 ++ .bashrc | 161 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100644 .bashrc diff --git a/.bash_aliases b/.bash_aliases index 57fdf63..54386b0 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -14,3 +14,8 @@ alias backup='bash ~/Scripts/Bash/backup.sh' alias vimtab='vim -c "so ~/.vimtabrc"' alias dic='dict -d gcide' alias ths='dict -d moby-thesaurus' +alias ll='ls -alFh' +alias la='ls -a' +alias l='ls -CF' +alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' + diff --git a/.bashrc b/.bashrc new file mode 100644 index 0000000..42e56b8 --- /dev/null +++ b/.bashrc @@ -0,0 +1,161 @@ +# Most of this is default from my base Ubuntu installation a few years ago + +# If not running interactively, don't do anything +case $- in + *i*) ;; + *) return;; +esac + +HISTCONTROL=ignoreboth +HISTSIZE=1000000 +HISTFILESIZE=2000000 +# append to the history file, don't overwrite it +shopt -s histappend + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# make less more friendly for non-text input files, see lesspipe(1) +[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in + xterm-color|*-256color) color_prompt=yes;; +esac + +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + color_prompt=yes + else + color_prompt= + fi +fi + +if [ "$color_prompt" = yes ]; then + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' +else + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' +fi +unset color_prompt force_color_prompt + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +# colored GCC warnings and errors +export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi +if [ -f ~/.bash_aliases_private ]; then + . ~/.bash_aliases_private +fi + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if ! shopt -oq posix; then + if [ -f /usr/share/bash-completion/bash_completion ]; then + . /usr/share/bash-completion/bash_completion + elif [ -f /etc/bash_completion ]; then + . /etc/bash_completion + fi +fi + +# If this is an xterm set more declarative titles +# "dir: last_cmd" and "actual_cmd" during execution +# If you want to exclude a cmd from being printed see line 156 +case "$TERM" in +xterm*|rxvt*) + PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\$(print_title)\a\]$PS1" + __el_LAST_EXECUTED_COMMAND="" + print_title () + { + __el_FIRSTPART="" + __el_SECONDPART="" + if [ "$PWD" == "$HOME" ]; then + __el_FIRSTPART=$(gettext --domain="pantheon-files" "Home") + else + if [ "$PWD" == "/" ]; then + __el_FIRSTPART="/" + else + __el_FIRSTPART="${PWD##*/}" + fi + fi + if [[ "$__el_LAST_EXECUTED_COMMAND" == "" ]]; then + echo "$__el_FIRSTPART" + return + fi + #trim the command to the first segment and strip sudo + if [[ "$__el_LAST_EXECUTED_COMMAND" == sudo* ]]; then + __el_SECONDPART="${__el_LAST_EXECUTED_COMMAND:5}" + __el_SECONDPART="${__el_SECONDPART%% *}" + else + __el_SECONDPART="${__el_LAST_EXECUTED_COMMAND%% *}" + fi + printf "%s: %s" "$__el_FIRSTPART" "$__el_SECONDPART" + } + put_title() + { + __el_LAST_EXECUTED_COMMAND="${BASH_COMMAND}" + printf "\033]0;%s\007" "$1" + } + + # Show the currently running command in the terminal title: + # http://www.davidpashley.com/articles/xterm-titles-with-bash.html + update_tab_command() + { + # catch blacklisted commands and nested escapes + case "$BASH_COMMAND" in + *\033]0*|update_*|echo*|printf*|clear*|cd*) + __el_LAST_EXECUTED_COMMAND="" + ;; + *) + put_title "${BASH_COMMAND}" + ;; + esac + } + preexec_functions+=(update_tab_command) + ;; +*) + ;; +esac + +# Use vim +export VISUAL="/usr/bin/vim" +export EDITOR="/usr/bin/vim" + +# Add color in manpages for less +export LESS_TERMCAP_mb=$'\E[01;31m' +export LESS_TERMCAP_md=$'\E[01;31m' +export LESS_TERMCAP_me=$'\E[0m' +export LESS_TERMCAP_se=$'\E[0m' +export LESS_TERMCAP_so=$'\E[01;44;33m' +export LESS_TERMCAP_ue=$'\E[0m' +export LESS_TERMCAP_us=$'\E[01;32m' + + +export HISTTIMEFORMAT='%d/%m/%y: ' +shopt -s histappend +shopt -s cmdhist +HISTCONTROL=ignoreboth +HISTIGNORE='ls:bg:fg:history' +PROMPT_COMMAND='history -a' + +source $HOME/.cargo/env + -- cgit v1.2.3