Skip to content

Instantly share code, notes, and snippets.

@lzkelley
Created December 22, 2018 20:56
Show Gist options
  • Save lzkelley/535aeeb80d2c247adb2e7613488e7bfb to your computer and use it in GitHub Desktop.
Save lzkelley/535aeeb80d2c247adb2e7613488e7bfb to your computer and use it in GitHub Desktop.
#!/bin/bash
# Detect which `ls` flavor is in use
if ls --color > /dev/null 2>&1; then # GNU `ls`
colorflag="--color"
else # OS X `ls`
colorflag="-G"
fi
# List all files colorized in long format
alias ll="ls -lhF ${colorflag}"
# List all files colorized in long format in reverse time ordering
alias lt="ls -lFtr ${colorflag}"
# List all files colorized in long format, including dot files
alias la="ls -laF ${colorflag}"
# Always use color output for `ls`
alias ls="command ls ${colorflag}"
export LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:'
# This sets the terminal emulator to xterm-color when working with gnu screen
export TERM='xterm-256color'
export EDITOR='emacs'
# Add Colors to ls command
# see http://norbauer.com/notebooks/code/notes/ls-colors-and-terminal-app for codes, x = default (foreground,background ...)
export CLICOLOR=1
export LSCOLORS=ExFxDxDxbxxxxxxxxxxxxx
# Larger bash history (allow 32k entries; default is 500)
export HISTSIZE=32768;
export HISTFILESIZE=$HISTSIZE;
export HISTCONTROL=ignoredups;
# Prefer US English and use UTF-8
export LANG="en_US.UTF-8";
export LC_ALL="en_US.UTF-8";
# Highlight section titles in manual pages
export LESS_TERMCAP_md="${yellow}";
# Don’t clear the screen after quitting a manual page
export MANPAGER="less -X";
# Always enable colored `grep` output
export GREP_OPTIONS="--color=auto";
# Modify Other Settings
# ----------------------------------
# Case-insensitive globbing (used in pathname expansion)
shopt -s nocaseglob;
# Append to the Bash history file, rather than overwriting it
shopt -s histappend;
# Autocorrect typos in path names when using `cd`
shopt -s cdspell;
# Enable some Bash 4 features when possible:
# * `autocd`, e.g. `**/qux` will enter `./foo/bar/baz/qux`
# * Recursive globbing, e.g. `echo **/*.txt`
for option in autocd globstar; do
shopt -s "$option" 2> /dev/null;
# Make Tab autocomplete regardless of filename case
set completion-ignore-case on
# List all matches in case multiple possible completions are possible
set show-all-if-ambiguous on
# Immediately add a trailing slash when autocompleting symlinks to directories
set mark-symlinked-directories on
# Use the text that has already been typed as the prefix for searching through
# commands (i.e. more intelligent Up/Down behavior)
"\e[A":history-search-backward # up-arrow navigates history search based on whats already entered
"\e[B":history-search-forward # down-arrow "
# If there are more than 200 possible completions for a word, ask to show them all
set completion-query-items 200
# Show extra file information when completing, like `ls -F` does
set visible-stats on
# Be more intelligent when autocompleting by also looking at the text after
# the cursor. For example, when the current line is "cd ~/src/mozil", and
# the cursor is on the "z", pressing Tab will not autocomplete it to "cd
# ~/src/mozillail", but to "cd ~/src/mozilla". (This is supported by the
# Readline used by Bash 4.)
set skip-completed-text on
# Allow UTF-8 input and output, instead of showing stuff like $'\0123\0456'
set input-meta on
set output-meta on
set convert-meta off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment