Skip to content

Instantly share code, notes, and snippets.

@donfreiday
Created February 14, 2024 14:03
Show Gist options
  • Save donfreiday/25a4254ee0b0fb5c974dea6f36384ce8 to your computer and use it in GitHub Desktop.
Save donfreiday/25a4254ee0b0fb5c974dea6f36384ce8 to your computer and use it in GitHub Desktop.
.bashrc
shopt -s checkwinsize # check the window size after each command and, if necessary, update the values of LINES and COLUMNS.
shopt -s cdspell # Correct typos when changing directory
# -R: show ANSI colors correctly; -i: case insensitive search
export LESS="-R -i"
# Color for manpages in less makes manpages a little easier to read
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 EDITOR=vim
# To have colors for ls and all grep commands such as grep, egrep and zgrep
export CLICOLOR=1
alias dotfiles="/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME"
alias ls='ls --color=auto'
alias ll='ls -lAhF'
alias l='ls -1'
# Bash completion
# TODO: Clean this up
[[ $PS1 && -f /usr/share/bash-completion/bash_completion ]] && . /usr/share/bash-completion/bash_completion
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
source "$HOME/bash_completion.d/gradle-completion.bash"
# hstr
# fix for non-legacy tiocsti
function hstrnotiocsti {
{ READLINE_LINE="$( { </dev/tty hstr ${READLINE_LINE}; } 2>&1 1>&3 3>&- )"; } 3>&1;
READLINE_POINT=${#READLINE_LINE}
}
alias hh=hstr # hh to be alias for hstr
export HSTR_CONFIG=hicolor # get more colors
shopt -s histappend # append new history items to .bash_history
export HISTCONTROL=ignorespace # leading space hides commands from history
export HISTFILESIZE= # increase history file size (default is 500)
export HISTSIZE=${HISTFILESIZE} # increase history size (default is 500)
# ensure synchronization between bash memory and history file
export PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}"
# if this is interactive shell, then bind hstr to Ctrl-r (for Vi mode check doc)
if [[ $- =~ .*i.* ]]; then bind -x '"\C-r": "hstrnotiocsti"'; fi
export HSTR_TIOCSTI=n
export PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[33m\]\$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/')\[\033[00m\] $ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment