Skip to content

Instantly share code, notes, and snippets.

@mhulse
Created November 24, 2019 05:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhulse/6c4eff377a0608cf5f1e49000566db0c to your computer and use it in GitHub Desktop.
Save mhulse/6c4eff377a0608cf5f1e49000566db0c to your computer and use it in GitHub Desktop.
Dot files stuffs, putting here as I’m trying to switch to oh-my-zsh (https://github.com/mhulse/dotfizzles)
#!/usr/bin/env bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$(cd -P "$(dirname "$SOURCE")" >/dev/null 2>&1 && pwd)"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DOTFIZZLES="$(cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd)"
export DOTFIZZLES
# shellcheck source=/Users/mhulse/dotfizzles/src/defaults.bash
source "$DOTFIZZLES/defaults.bash"
# shellcheck source=/Users/mhulse/dotfizzles/src/aliases.bash
source "$DOTFIZZLES/aliases.bash"
# shellcheck source=/Users/mhulse/dotfizzles/src/functions.bash
source "$DOTFIZZLES/functions.bash"
# shellcheck source=/Users/mhulse/dotfizzles/src/common.bash
source "$DOTFIZZLES/common.bash"
# shellcheck source=/Users/mhulse/dotfizzles/src/history.bash
source "$DOTFIZZLES/history.bash"
# shellcheck source=/Users/mhulse/dotfizzles/src/completers.bash
source "$DOTFIZZLES/completers.bash"
# shellcheck source=/Users/mhulse/dotfizzles/src/prompts.bash
source "$DOTFIZZLES/prompts.bash"
# Create a `.bash_pending` file for testing new stuff:
# shellcheck source=/Users/mhulse/.bash_pending
[[ -f "$HOME/.bash_pending" ]] \
&& source "$HOME/.bash_pending"
# http://git-scm.com/book/en/Customizing-Git-Git-Configuration
# https://github.com/tiimgreen/github-cheat-sheet#git-configurations
# http://haacked.com/archive/2014/07/28/github-flow-aliases/
# Docs can be accessed via: `$ man git-<command>` (e.g. `$ man git-push`)
# There are 3 levels of git config:
# 1) Project
# Only available for the current project and stored in `.git/config` in the project’s directory:
# $ git config user.name "John Doe"
# 2) Global
# Available for all projects for the current user and stored in `~/.gitconfig`:
# $ git config --global user.name "John Doe"
# 3) System
# Available for all the users/projects and stored in `/etc/gitconfig`:
# $ git config --system user.name "John Doe"
[alias]
a = add
aa = add --all
aliases = config --get-regexp alias
amend = commit --all --amend
bclean = "!f() { git branch --merged ${1-master} | grep -v " ${1-master}$" | xargs -r git branch -d; }; f"
bdone = "!f() { git checkout ${1-master} && git up && git bclean ${1-master}; }; f"
br = branch
branches = branch -a
brm = branch --move # <new-branch-name>
c = commit
cam = !git add --all && git commit --message
cge = config --global --edit
cg = config --global # <option> <value>
cm = commit --message
co = checkout
cob = checkout -b # <new-branch-name>
col = checkout -
com = checkout master
comf = checkout origin/master # <file-path> OR <file-name>
df = diff
fps = !git fetch && git pull && git status
g = grep -I
lg = log --patch
lol = log --graph --oneline --date-order --decorate --color --all -n 250
# Focus on the most important information in this colorful, graphical display:
loq = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --
pb = publish-branch
pf = push --force
pn = push --set-upstream origin head
# Delete any local branches which have been deleted from the remote:
prune = fetch --prune
rb = rbranch
rbm = rebase master
rbmi = rebase --interactive master
rc = rank-contributors
remotes = remote --verbose
rv = review
s = status
# Stash new files you haven’t caught with a `git add` yet:
sa = stash save --include-untracked
save = !git add --all && git commit -m 'SAVEPOINT'
sm = show-merges
st = status --short --branch
tags = tag --list
# Set things up the way they were before the last commit:
undo = reset --mixed head~1
up = !git pull --rebase --prune $@ && git submodule update --init --recursive
wip = !git add --update && git commit --message="WIP"
wipe = !git add --all && git commit --quiet --message='WIPE SAVEPOINT' && git reset head~1 --hard
[core]
autocrlf = false
# Custom global `.gitignore` file:
excludesfile = ~/.gitignore
# Treat spaces before tabs, lines that are indented with 8 or more spaces, and all kinds of trailing whitespace as an error:
whitespace = space-before-tab,indent-with-non-tab,trailing-space
# Watch for case changes:
ignorecase = false
[push]
# Make it easier to push your local branch to a branch named the same thing in your target: remote.
default = simple
# Always send your local tags up along with a git push:
followTags = true
[merge]
conflictstyle = diff3
# Ensures that you get an error unless every merge is fast-forward:
ff = only
log = true
[rerere]
enabled = 1
[branch]
autosetuprebase = always
[color]
# Use colors in Git commands that are capable of colored output when
# outputting to the terminal:
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
[color "status"]
added = yellow
changed = green
untracked = cyan
[help]
autocorrect = 1
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[status]
# Shows all of the files underneath a new directory during a git status:
showUntrackedFiles = all
[transfer]
# Do some extra checks when receiving or sending changes (this can make transfers a bit slower):
fsckobjects = true
#!/usr/bin/env bash
"\e[1~": beginning-of-line
"\e[4~": end-of-line
# this makes the "delete" key work rather than
# just entering a ~
"\e[3~": delete-char
# these allow you to use ctrl+left/right arrow keys
# to jump the cursor over words
"\e[5C": forward-word
"\e[5D": backward-word
# these allow you to start typing a command and
# use the up/down arrow to auto complete from
# commands in your history.
# Here "\e" indicates the escape character. The first two sequences are
# normally generated by the up and down arrows, respectively. The second two
# are generated by the arrows when the terminal is in an alternate input mode.
"\e[A": history-search-backward
"\e[B": history-search-forward
"\eOA": history-search-backward
"\eOB": history-search-forward
"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e\e[C": forward-word
"\e\e[D": backward-word
"\e[2~": quoted-insert
# Use Unicode & do NOT use the "8bit hack" to input/output non-ASCII characters
# See http://code.google.com/p/iterm2/wiki/Keybindings
set input-meta on
set output-meta on
set convert-meta off
# Turn on case insensitivity for tab-completion
# Ex.: type "doc<tab>" to search for "Documents"
set completion-ignore-case on
set expand-tilde on
set show-all-if-ambiguous on
set visible-stats on
set editing-mode nano
# Bind the Tab key to cycle completions one at a time instead of listing them all
# and requiring you to type characters until there’s only one match.
TAB: menu-complete
# Binding Shift-Tab to go backward:
"\e[Z": "\e-1\C-i"
# Option-z to run cd - followed by ls, returning you to the previous directory
# in your stack and doing a file listing.
"\ez": 'cd -\015ls\015'
# Set mark-symlinked-directories as -- by default -- bash doesn't put a / after
# symlinks when doing autocomplete. This fixes that.
set mark-symlinked-directories on
set prefer-visible-bell on
# Assign ^W (Ctrl-w) to be unix-filename-rubout instead of the default unix-word-rubout.
# This makes it so when you have your cursor (|) positioned here foo/bar/test.txt|
# and hit C-w, it just deletes up to the first / character. This makes fixing
# things a bit easier. It also works within a path.
"\C-w": unix-filename-rubout
"": unix-filename-rubout
# Bind a key to glob-expand-word which will take a bash glob -- say * -- and
# replace the glob with all the files that match that glob.
"\C-x*": glob-expand-word
#!/usr/bin/env bash
# Quicker navigation:
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
# List Atom packages:
alias atompkgs="apm list --installed --bare"
# Start blender from command line, used for debugging:
alias blender="/Applications/blender.app/Contents/MacOS/blender"
# Path to the Chrome executable (>=v59/macOS);
alias chrome="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"
# Removes a bunch of crap from your finder:
alias cleanup="find . -name '*.DS_Store' -type f -ls -delete && find . -name 'Thumbs.db' -type f -ls -delete"
# List VS Code packages:
alias codepkgs="code --list-extensions | sed 's/^.*\.//'"
# Show where you copy:
alias cp="cp -v"
# Print date/time (e.g. `2019-10-03 11:32:27`)
alias dt='date "+%F %T"'
# Flush out the DNS cache:
alias flushdns="dscacheutil -flushcache"
# Git:
alias g="git"
alias ga="git a"
alias gaa="git aa"
alias gcm="git cm"
alias gcam="git cam"
alias gco="git co"
alias gcob="git cob"
alias gcol="git col"
alias gcom="git com"
alias gs="git s"
alias gst="git st"
alias pull="git pull"
alias push="git push"
alias pushf="git pf"
alias pushn="git pn"
alias save="git save"
# Open current directory in Finder.app:
alias o="open ."
# Open current directory in Finder.app and VS Code:
alias oo="open . && code ."
# Color grep:
alias grep="grep --color=auto"
# Opens up the IOS Simulator without launching xcode:
alias iossimulator="(cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/ && open -a iPhone\ Simulator.app)"
# Get info on connections for en0:
alias ipinfo0="ipconfig getpacket en0"
# Get info on connections for en1:
alias ipinfo1="ipconfig getpacket en1"
# Restart dock:
alias killdock="killall -KILL Dock"
# Remove “duplicates” from the “Open With” Right-Click Menu in Mac OS X:
alias killdups='/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain user;killall Finder;echo "Open With has been rebuilt, Finder will relaunch"'
# All files, in long format:
alias l="ls -lFG"
# All files, including dotfiles, in long format:
alias la="ls -laFG"
# Last command:
alias lc="!!"
# Last command as `sudo`:
alias lcs="sudo !!"
# Hides `.` and `..`, shows hidden items and ending slashes for
# directories, and sorts in reverse chronological order:
alias ll="ls -lAtrFhG"
# Your local ip address:
alias localip="ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'"
# Use unit suffixes:
alias ls="command ls -Gh"
# Only show directories:
alias lsd='ls -lFG | grep "^d"'
# Only show dot files:
alias lsh="ls -ld .??*"
# Display open sockets:
alias lsock="sudo /usr/sbin/lsof -i -P"
# Display only open TCP sockets:
alias lsockt="sudo /usr/sbin/lsof -nP | grep TCP"
# Display only open UDP sockets:
alias lsocku="sudo /usr/sbin/lsof -nP | grep UDP"
# Sort files by size:
alias lss="ls -s | sort -n"
# Create intermediate directories as required:
alias mkdir="mkdir -p"
# Public facing ip address:
alias myip="curl ip.appspot.com"
# Show all open TCP/IP sockets:
alias netcons="lsof -i"
# All listening connections:
alias openports="sudo lsof -i | grep LISTEN"
# Copy the PWD to the Clipboard
alias pwdc="pwd | tr -d '\n' | pbcopy && pwd"
# Default pip:
alias pip=pip3
# Default Python:
alias python=python3
# Quickly search for file:
alias qfind="find . -name "
# Quick Look!
# $ cd /Library/Desktop\ Pictures
# $ qlf "Jaguar Aqua Graphite.jpg"
alias qlf='qlmanage -p "$@" >& /dev/null'
# Copy `src` to `dest` using `rcopy src dest` and delete files no longer
# present in the source:
alias rcopy="rsync -az --stats --progress --delete"
# Say something with speech synthesis:
alias say="espeak"
# All ipfw rules inc/ blocked IPs:
alias showblocked="sudo ipfw list"
# Show beginning and end of provided file (`skim foo.txt`):
alias skim="(head -5; tail -5) <"
# Enable forwarding of the authentication agent connection:
alias ssh="ssh -A"
# Upper/lower case input string:
alias tolower="pbpaste | tr "[:upper:]" "[:lower:]" | pbcopy"
alias toupper="pbpaste | tr "[:lower:]" "[:upper:]" | pbcopy"
# Apache Tomcat start:
# $ tomcat
# $ tomcat start
# Tomcat stop:
# $ tomcat stop
alias tomcat=catalina
# Trim whitespace (`tws file.txt`):
alias tws="sed -i 's/[ \t]*$//' "
# Grepping for pesky unicode characters:
alias unigrep='grep -P "[^\x00-\x7F]"'
# Weather from current location:
alias weather="curl -s 'http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=en|us|brooklyn-ny|11215' | sed -n '/Currently:/ s/.*: \(.*\): \([0-9]*\)\([CF]\).*/\2°\3, \1/p'"
# XAMPP shortcuts:
alias xampp="sudo /Applications/XAMPP/xamppfiles/xampp restart"
alias xampp_stop="sudo /Applications/XAMPP/xamppfiles/xampp stop"
alias xampp_start="sudo /Applications/XAMPP/xamppfiles/xampp start"
alias xo='function __xo() { xampp && open "http://"$1; }; __xo'
#!/usr/bin/env bash
# Enable colorized output for `ls` command:
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
# Default editor:
export EDITOR=vim
# For Homebrew:
export PATH="/usr/local/sbin:$PATH"
# Custom scripts:
[[ -d "$HOME/scripts" ]] \
&& export PATH=$HOME/scripts:$PATH
# Postgres.app
# http://postgresapp.com/
# Instead of doing this at the prompt:
# $ '/Applications/Postgres.app/Contents/Versions/9.6/bin'/psql -p5432
# You can now do this:
# $ psql
[[ -d "/Applications/Postgres.app" ]] \
&& export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/late‌st/bin
# Ruby: rbenv (alternative to RVM)
# Remove RVM before installing: `$ rvm implode`
# Install using: `brew install rbenv`
# List available versions: `rbenv install -l`
# Install a version: `rbenv install 2.6.5`
# Select that version using: `rbenv global 2.6.5`
# Check your installation using: `ruby -v`
# Use Bundler to manage your gems!
if [ -d "$HOME/.rbenv/bin" ] ; then
export PATH="$HOME/.rbenv/bin":$PATH
eval "$(rbenv init -)"
fi
# Golang:
if [ -d "$HOME/go/bin" ] ; then
export PATH=${PATH}:$HOME/go/bin
fi
# Java
# You may need to run:
# $ java --request
# and click “More Info…” to visit the Java Developer Kit download website.
export JRE_HOME=$(/usr/libexec/java_home)
export JAVA_HOME=$(/usr/libexec/java_home)
# Apache Tomcat
# http://tomcat.apache.org/
export CATALINA_HOME='/Applications/tomcat' # Symlinked to latest Tomcat version.
# Check the window size after each command and, if necessary, update the
# values of LINES and COLUMNS:
shopt -s checkwinsize
# Turn on recursive globbing (bash 4.x):
shopt -s globstar
# SDKMAN!
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] \
&& source "$HOME/.sdkman/bin/sdkman-init.sh"
# Node Version Manager (nvm):
export NVM_DIR="$HOME/.nvm"
NVM_HOMEBREW="/usr/local/opt/nvm/nvm.sh"
[ -s "$NVM_HOMEBREW" ] && \. "$NVM_HOMEBREW"
# Node.js/Node Package Manager (npm):
[ -x "$(command -v npm)" ] \
&& export NODE_PATH=$NODE_PATH:`npm root -g`
#!/usr/bin/env bash
# Autocomplete for Homebrew:
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
# Autocomplete for Node:
if [[ -e ~/.node-completion ]]; then
shopt -s progcomp
for f in $(command ls ~/.node-completion); do
f="$HOME/.node-completion/$f"
test -f "$f" && . "$f"
done
fi
# Autocomplete for npm:
if [[ `which npm` ]]; then
eval "$(npm completion 2>/dev/null)"
fi
# Autocomplete for pip:
if [[ `which pip` ]]; then
eval "`pip completion --bash`"
fi
# Autocomplete for Grunt:
if [[ `which grunt` ]]; then
eval "$(grunt --completion=bash)"
fi
#!/usr/bin/env bash
# Disables shadow on screenshots:
defaults write com.apple.screencapture disable-shadow -bool true
#!/usr/bin/env bash
# Quick and dirty calculator. Goes right to ruby and lets you print out
# the results of math operations, or other ruby expressions.
function calc() {
ruby -e "puts $*"
}
# Reloads session:
function reload() {
source "$HOME/.bash_profile"
# for f in "$HOME/.bash/"*; do
# source "$f"
# done
}
# https://unix.stackexchange.com/q/269077/67282
# fromhex A52A2A
# fromhex "#A52A2A"
# BLUE_VIOLET=$(fromhex "#8A2BE2")
function fromhex() {
hex=$1
if [[ $hex == "#"* ]]; then
hex=$(echo $1 | awk '{print substr($0,2)}')
fi
r=$(printf '0x%0.2s' "$hex")
g=$(printf '0x%0.2s' ${hex#??})
b=$(printf '0x%0.2s' ${hex#????})
echo -e `printf "%03d" "$(((r<75?0:(r-35)/40)*6*6+(g<75?0:(g-35)/40)*6+(b<75?0:(b-35)/40)+16))"`
}
function myip() {
# GNU vs BSD hostname:
(hostname -i &> /dev/null)
if [ $? -eq 0 ]; then
echo `hostname -i`
else
# Default to eth0 IP, for MAC:
echo `ipconfig getifaddr en0`
fi
}
# Google the parameter:
function google() {
links http://google.com/search?q=$(echo "$@" | sed s/\ /+/g)
}
# Awesome! cd AND la. (I never use 'cd' anymore):
function cl() {
cd "$@" && la
}
# Repeat a command N times.
# You can do something like: "repeat 3 echo 'hi'"
function repeat() {
local i max
max=$1
shift
for ((i=1; i <= max ; i++)); do
eval "$@"
done
}
# Git branch details:
function parse_git_dirty() {
[[ $(git status 2> /dev/null | tail -n1) != *"working directory clean"* ]] && echo "*"
}
function parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
}
# Find symlinks recursive:
function findlinks() {
find "$@" -type l -exec ls -l {} \;
}
# Extract based upon file ext:
function ex() {
if [ -f $1 ]; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via >extract<" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
# Compress with tar + bzip2:
function bz2() {
tar cvpjf $1.tar.bz2 $1
}
function man() {
/usr/bin/man "$@" || (help "$@" 2> /dev/null && help "$@" | less)
}
# Use DNS to query wikipedia (wiki QUERY):
function wiki() {
dig +short txt $1.wp.dg.cx
}
# Remove line n from a file (removeline N FILE):
function removeline() {
sed -i $1d $2
}
# Get the country of a specific IP address using ip2location (ip2loc IP):
function ip2loc() {
wget -qO - www.ip2location.com/$1 | grep "<span id=\"dgLookup__ctl2_lblICountry\">" | sed 's/<[^>]*>//g; s/^[\t]*//; s/&quot;/"/g; s/</</g; s/>/>/g; s/&amp;/\&/g'
}
# Find file under the current directory:
function ff() {
/usr/bin/find . -name "$@"
}
# Find file whose name starts with a given string:
function ffs() {
/usr/bin/find . -name "$@"'*'
}
# Find file whose name ends with a given string:
function ffe() {
/usr/bin/find . -name '*'"$@"
}
# Search for a file using MacOS Spotlight’s metadata:
function spotlight() {
mdfind "kMDItemDisplayName == '$@'wc"
}
# Display useful host related informaton:
function ii() {
echo -e "\nYou are logged on ${RED}$HOST"
echo -e "\nAdditionnal information:$NC " ; uname -a
echo -e "\n${RED}Users logged on:$NC " ; w -h
echo -e "\n${RED}Current date :$NC " ; date
echo -e "\n${RED}Machine stats :$NC " ; uptime
echo -e "\n${RED}Current network location :$NC " ; scselect
echo -e "\n${RED}Public facing IP Address :$NC " ;myip
#echo -e "\n${RED}DNS Configuration:$NC " ; scutil --dns
echo
}
# Grabs headers from web page:
function httpheaders() {
/usr/bin/curl -I -L "$@"
}
# Download a web page and show info on what took time:
function httpdebug() {
/usr/bin/curl "$@" -o /dev/null -w "dns: %{time_namelookup} connect: %{time_connect} pretransfer: %{time_pretransfer} starttransfer: %{time_starttransfer} total: %{time_total}\n"
}
# `cd` into the last focused Finder window:
function cdfinder(){
cd "$(osascript -e 'tell application "Finder"' \
-e 'set myname to POSIX path of (target of window 1 as alias)' \
-e 'end tell' 2>/dev/null)"
}
# Generates a random password:
function randpassw() {
if [ -z $1 ]; then
MAXSIZE=10
else
MAXSIZE=$1
fi
array1=(
q w e r t y u i o p a s d f g h j k l z x c v b n m Q W E R T Y U I O P A S D
F G H J K L Z X C V B N M 1 2 3 4 5 6 7 8 9 0
\! \@ \$ \% \^ \& \* \! \@ \$ \% \^ \& \* \@ \$ \% \^ \& \*
)
MODNUM=${#array1[*]}
pwd_len=0
while [ $pwd_len -lt $MAXSIZE ]
do
index=$(($RANDOM%$MODNUM))
echo -n "${array1[$index]}"
((pwd_len++))
done
echo
}
# Image width:
function width() {
echo $(sips -g pixelWidth $1 | grep -oE "[[:digit:]]{1,}$")
}
# Image height:
function height() {
echo $(sips -g pixelHeight $1 | grep -oE "[[:digit:]]{1,}$")
}
# All the dig info, because I can never remember it:
function digga() {
dig +nocmd $1 any +multiline +noall +answer
}
# Copy w/progress:
function cp_p() {
rsync -WavP --human-readable --progress $1 $2
}
# Pretty print JSON:
function cjson() {
local url=$(echo $1)
if [[ "http" == $url[0,4] ]] ; then
curl --silent $url | python -mjson.tool | pygmentize -O style=monokai -f console256 -g
else
cat $url | python -mjson.tool | pygmentize -O style=monokai -f console256 -g
fi
}
# Shortcut function to control Apache Tomcat Catalina script:
function catalina() {
# Long-hand version:
# Start:
# $CATALINA_HOME/bin/startup.sh
# ... or:
# $CATALINA_HOME/bin/catalina.sh start
# Stop:
# $CATALINA_HOME/bin/shutdown.sh
# ... or:
# $CATALINA_HOME/bin/catalina.sh stop
# See .bash_aliases for related alias.
$CATALINA_HOME/bin/catalina.sh ${1:-start};
}
# Freshen up your HomeBrew!
# $ frewshbrew [cask]
function freshbrew() {
brew doctor
brew update
brew upgrade
if [[ "$1" = "cask" ]]; then
brew cask outdated | xargs brew cask reinstall
fi
brew cleanup
brew doctor
}
# Freshen up your Ruby:
function freshruby() {
if which rvm >/dev/null; then
# Update rvm:
# rvm get stable
# Update rvm Ruby:
# rvm install ruby --latest && rvm use current
# Upgrade RubyGems:
gem update --system
# Update rvm gems:
gem update
else
echo "rvm not installed"
fi
}
# Get application’s bundle identifier from its root path:
function bid() {
mdls "$1" | grep kMDItemCF | cut -d '"' -f2
}
# Toggle invisible files in the Finder (e.g. `$ toggle`):
function toggle() {
local current=$(defaults read com.apple.finder AppleShowAllFiles)
case "$current" in
1|TRUE|True|true|YES|Yes|yes)
defaults write com.apple.finder AppleShowAllFiles -boolean false
echo "Hidden files invisible!"
;;
*)
defaults write com.apple.finder AppleShowAllFiles -boolean true
echo "Hidden files visible!"
;;
esac
killall Finder /System/Library/CoreServices/Finder.app
echo "You can also use CMD + SHIFT + . (introduced in macOS Sierra)"
}
#!/usr/bin/env bash
# http://unix.stackexchange.com/questions/1288/preserve-bash-history-in-multiple-terminal-windows
# http://superuser.com/questions/137438/how-to-unlimited-bash-shell-history
# https://www.kernel.org/doc/man-pages/online/pages/man3/strftime.3.html
export HISTCONTROL=ignoredups:erasedups # no duplicate entries
export HISTSIZE=100000 # big big history
export HISTFILESIZE=100000 # big big history
export HISTTIMEFORMAT="%a %h %d - %r " # timestamps
shopt -s histappend # append to history, don't overwrite it
# Save and reload the history after each command finishes
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
# NOTE: The below bindings can be found in the `/.inputrc` file.
# If you don’t feel like utilizing both files for your particular setup, but
# want fuzzy history search goodness, then just copy and paste the code in this
# file (uncomment the below lines) into your chosen `profile` and you’ll be set.
#
# bind '"\e[A": history-search-backward'
# bind '"\e[B": history-search-forward'
#!/usr/bin/env bash
# Reset colors:
RESET=$(tput sgr0)
# Erase to end of line:
ERASE=$(tput el || tput ce)
#-------------------------------------------------------------------------------
function background() {
local colors
local color
colors=(92 93 57 21 27 33 39 45 51 50 49 48 47 46 82 118 154 190 226 220 214 208 202 196)
color=$((RANDOM % colors))
tput setab "$color"
}
#-------------------------------------------------------------------------------
# https://github.com/mhulse/dotfizzles/issues/213
source "/usr/local/opt/git/etc/bash_completion.d/git-prompt.sh"
# Unstaged (*) and staged (+) changes will be shown next to the branch name.
GIT_PS1_SHOWDIRTYSTATE=1
# If something is stashed, then a '$' will be shown next to the branch name.
GIT_PS1_SHOWSTASHSTATE=1
# If there're untracked files, then a '%' will be shown next to the branch name.
GIT_PS1_SHOWUNTRACKEDFILES=1
# See the difference between HEAD and its upstream.
# A "<" indicates you are behind, ">" indicates you are ahead, "<>" indicates
# you have diverged and "=" indicates that there is no difference.
GIT_PS1_SHOWUPSTREAM=("auto" "verbose" "name")
# See more information about the identity of commits.
GIT_PS1_DESCRIBE_STYLE="default"
# Colored hint about the current dirty state.
GIT_PS1_SHOWCOLORHINTS=1
#-------------------------------------------------------------------------------
printf "%s" \
"$RESET" \
"$(background)" \
"\w" \
"$(__git_ps1)" \
"$ERASE" \
"$RESET" \
"\n" \
"▌"
#!/usr/bin/env bash
function prompt_command() {
PS1=$("$DOTFIZZLES/prompt_command")
export PS1
}
export PROMPT_DIRTRIM=2
export PROMPT_COMMAND=prompt_command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment