Skip to content

Instantly share code, notes, and snippets.

@mourner
Last active December 12, 2022 09:19
Show Gist options
  • Select an option

  • Save mourner/3f48a3a1b0fa747ac0abf8770fbce085 to your computer and use it in GitHub Desktop.

Select an option

Save mourner/3f48a3a1b0fa747ac0abf8770fbce085 to your computer and use it in GitHub Desktop.

Revisions

  1. mourner revised this gist Aug 26, 2022. 1 changed file with 21 additions and 23 deletions.
    44 changes: 21 additions & 23 deletions .bash_profile
    Original file line number Diff line number Diff line change
    @@ -1,40 +1,38 @@
    #!/usr/bin/env bash
    export VOLTA_HOME="$HOME/.volta"
    export BUN_INSTALL="/Users/mourner/.bun"

    export PATH="$PATH:/usr/local/bin"
    export PATH="$PATH:~/.cargo/bin"
    export PATH="$PATH:/usr/local/opt/python/libexec/bin"
    export PATH="$PATH:/usr/local/opt/coreutils/libexec/gnubin"
    export PATH="$PATH:~/go/bin/"
    export PATH="$PATH:/usr/local/opt/ruby/bin"
    export PATH="$PATH:~/.volta/bin"
    export PATH="/Applications/Sublime Text.app/Contents/SharedSupport/bin:$PATH"
    export PATH="$VOLTA_HOME/bin:$PATH"
    export PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH"
    export PATH="/opt/homebrew/opt/grep/libexec/gnubin:$PATH"
    export PATH="$BUN_INSTALL/bin:$PATH"

    export VOLTA_HOME="~/.volta"
    eval "$(/opt/homebrew/bin/brew shellenv)"

    export EDITOR="subl -w"

    export HISTSIZE=32768
    export HISTFILESIZE=${HISTSIZE}
    export HISTCONTROL='ignoreboth'

    export PYTHONIOENCODING='UTF-8'
    export LESS_TERMCAP_md="$(tput setaf 166)"
    export MANPAGER="less -X"
    export LANG="en_US"
    export LC_ALL="en_US.UTF-8"
    export HOMEBREW_NO_ENV_HINTS=1

    shopt -s nocaseglob
    shopt -s histappend
    shopt -s cdspell
    shopt -s autocd
    shopt -s globstar

    source /usr/local/etc/profile.d/z.sh
    source /usr/local/etc/profile.d/bash_completion.sh
    source /usr/local/etc/bash_completion.d/git-prompt.sh
    source /usr/local/etc/bash_completion.d/git-completion.bash
    [ -f ~/.fzf.bash ] && source ~/.fzf.bash
    source ~/projects/mbxcli/bin/mapbox.sh
    source /opt/homebrew/etc/profile.d/bash_completion.sh
    source /opt/homebrew/etc/bash_completion.d/git-prompt.sh
    source /opt/homebrew/etc/bash_completion.d/git-completion.bash
    source /opt/homebrew/etc/profile.d/z.sh

    source ~/.bash_prompt
    source ~/.aliases
    source ~/.functions
    source ~/.fzf.bash

    source ~/projects/mbxcli/bin/mapbox.sh

    alias g="git"
    __git_complete g __git_main

    . "$HOME/.cargo/env"
  2. mourner revised this gist Mar 15, 2022. 3 changed files with 23 additions and 221 deletions.
    76 changes: 10 additions & 66 deletions .aliases
    Original file line number Diff line number Diff line change
    @@ -1,97 +1,51 @@
    # Easier navigation: .., ..., ...., ....., ~ and -
    alias ..="cd .."
    alias ...="cd ../.."
    alias ....="cd ../../.."
    alias .....="cd ../../../.."
    alias ~="cd ~" # `cd` is probably faster to type though
    alias -- -="cd -"

    # Shortcuts
    alias db="cd ~/Dropbox"
    alias dl="cd ~/Downloads"
    alias dt="cd ~/Desktop"
    alias p="cd ~/Projects"
    alias p="cd ~/projects"
    alias g="git"
    __git_complete g __git_main
    alias h="history"
    alias j="jobs"
    alias v="vim"
    alias m="mate ."
    alias s="subl ."
    alias o="open"
    alias oo="open ."
    alias ts="tig status"
    alias rclonesync="rclone sync --fast-list -P --stats-one-line --transfers 16"
    alias l="ls -l -G"
    alias la="ls -la -G"
    alias ls="command ls -G"
    export LSCOLORS='BxBxhxDxfxhxhxhxhxcxcx'

    # 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
    alias sudo='sudo ' # Enable aliases to be sudo’ed

    # List all files colorized in long format
    alias l="ls -l ${colorflag}"
    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'

    # List all files colorized in long format, including dot files
    alias la="ls -la ${colorflag}"
    alias chrome='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'

    # 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:'

    # Enable aliases to be sudo’ed
    alias sudo='sudo '

    # Gzip-enabled `curl`
    alias gurl="curl --compressed"

    # Get OS X Software Updates, and update installed Ruby gems, Homebrew, npm, and their installed packages
    alias update='sudo softwareupdate -i -a; brew update; brew upgrade; brew cleanup; npm update npm -g; npm update -g; sudo gem update'

    alias brewout='brew update > /dev/null; brew outdated'
    alias brewup='brew update > /dev/null; brew upgrade; brew cleanup'

    # IP addresses
    alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
    alias localip="ipconfig getifaddr en1"
    alias ips="ifconfig -a | grep -o 'inet6\? \(\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)\|[a-fA-F0-9:]\+\)' | sed -e 's/inet6* //'"

    # Enhanced WHOIS lookups
    alias whois="whois -h whois-servers.net"

    # Flush Directory Service cache
    alias flush="dscacheutil -flushcache && killall -HUP mDNSResponder"

    # Clean up LaunchServices to remove duplicates in the “Open With” menu
    alias lscleanup="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder"

    # View HTTP traffic
    alias sniff="sudo ngrep -d 'en1' -t '^(GET|POST) ' 'tcp and port 80'"
    alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E \"Host\: .*|GET \/.*\""

    # Canonical hex dump; some systems have this symlinked
    command -v hd > /dev/null || alias hd="hexdump -C"

    # OS X has no `md5sum`, so use `md5` as a fallback
    command -v md5sum > /dev/null || alias md5sum="md5"

    # OS X has no `sha1sum`, so use `shasum` as a fallback
    command -v sha1sum > /dev/null || alias sha1sum="shasum"

    # Trim new lines and copy to clipboard
    alias c="tr -d '\n' | pbcopy"

    # Recursively delete `.DS_Store` files
    alias cleanup="find . -type f -name '*.DS_Store' -ls -delete"

    # ROT13-encode text. Works for decoding, too! ;)
    alias rot13='tr a-zA-Z n-za-mN-ZA-M'

    # Empty the Trash on all mounted volumes and the main HDD
    # Also, clear Apple’s System Logs to improve shell startup speed
    alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl"

    # Show/hide hidden files in Finder
    alias show="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
    alias hide="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
    @@ -123,13 +77,3 @@ alias badge="tput bel"
    # For example, to list all directories that contain a certain file:
    # find . -name .gitattributes | map dirname
    alias map="xargs -n1"

    # One of @janmoesen’s ProTip™s
    for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do
    alias "$method"="lwp-request -m '$method'"
    done

    # Stuff I never really use but cannot delete either because of http://xkcd.com/530/
    alias stfu="osascript -e 'set volume output muted true'"
    alias pumpitup="osascript -e 'set volume 7'"
    alias hax="growlnotify -a 'Activity Monitor' 'System error' -m 'WTF R U DOIN'"
    28 changes: 12 additions & 16 deletions .bash_profile
    Original file line number Diff line number Diff line change
    @@ -12,33 +12,29 @@ export VOLTA_HOME="~/.volta"

    export EDITOR="subl -w"

    export HISTSIZE='10000'
    export HISTFILESIZE="${HISTSIZE}"
    export HISTSIZE=32768
    export HISTFILESIZE=${HISTSIZE}
    export HISTCONTROL='ignoreboth'

    export NODE_REPL_HISTORY=~/.node_history
    export NODE_REPL_HISTORY_SIZE='10000'
    export NODE_REPL_MODE='sloppy'

    export PYTHONIOENCODING='UTF-8'
    export LESS_TERMCAP_md="$(tput setaf 166)"
    export MANPAGER="less -X"
    export LANG="en_US"
    export LC_ALL="en_US.UTF-8"

    source ~/.bash_prompt
    source ~/.aliases

    shopt -s nocaseglob # Case-insensitive globbing (used in pathname expansion)
    shopt -s histappend # Append to the Bash history file, rather than overwriting it
    shopt -s cdspell # Autocorrect typos in path names when using `cd`
    shopt -s autocd # e.g. `**/qux` will enter `./foo/bar/baz/qux`
    shopt -s globstar # Recursive globbing, e.g. `echo **/*.txt`
    shopt -s nocaseglob
    shopt -s histappend
    shopt -s cdspell
    shopt -s autocd
    shopt -s globstar

    source /usr/local/etc/profile.d/z.sh
    source /usr/local/etc/profile.d/bash_completion.sh
    source /usr/local/etc/bash_completion.d/git-prompt.sh
    source /usr/local/etc/bash_completion.d/git-completion.bash

    source ~/projects/mbxcli/bin/mapbox.sh
    [ -f ~/.fzf.bash ] && source ~/.fzf.bash
    source ~/projects/mbxcli/bin/mapbox.sh

    source ~/.bash_prompt
    source ~/.aliases
    source ~/.functions
    140 changes: 1 addition & 139 deletions .functions
    Original file line number Diff line number Diff line change
    @@ -1,63 +1,5 @@
    #!/usr/bin/env bash

    # Create a new directory and enter it
    function mkd() {
    mkdir -p "$@" && cd "$_";
    }

    # Change working directory to the top-most Finder window location
    function cdf() { # short for `cdfinder`
    cd "$(osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)')";
    }

    # Create a .tar.gz archive, using `zopfli`, `pigz` or `gzip` for compression
    function targz() {
    local tmpFile="${@%/}.tar";
    tar -cvf "${tmpFile}" --exclude=".DS_Store" "${@}" || return 1;

    size=$(
    stat -f"%z" "${tmpFile}" 2> /dev/null; # macOS `stat`
    stat -c"%s" "${tmpFile}" 2> /dev/null; # GNU `stat`
    );

    local cmd="";
    if (( size < 52428800 )) && hash zopfli 2> /dev/null; then
    # the .tar file is smaller than 50 MB and Zopfli is available; use it
    cmd="zopfli";
    else
    if hash pigz 2> /dev/null; then
    cmd="pigz";
    else
    cmd="gzip";
    fi;
    fi;

    echo "Compressing .tar ($((size / 1000)) kB) using \`${cmd}\`";
    "${cmd}" -v "${tmpFile}" || return 1;
    [ -f "${tmpFile}" ] && rm "${tmpFile}";

    zippedSize=$(
    stat -f"%z" "${tmpFile}.gz" 2> /dev/null; # macOS `stat`
    stat -c"%s" "${tmpFile}.gz" 2> /dev/null; # GNU `stat`
    );

    echo "${tmpFile}.gz ($((zippedSize / 1000)) kB) created successfully.";
    }

    # Determine size of a file or total size of a directory
    function fs() {
    if du -b /dev/null > /dev/null 2>&1; then
    local arg=-sbh;
    else
    local arg=-sh;
    fi
    if [[ -n "$@" ]]; then
    du $arg -- "$@";
    else
    du $arg .[^.]* ./*;
    fi;
    }

    # Use Git’s colored diff when available
    hash git &>/dev/null;
    if [ $? -eq 0 ]; then
    @@ -84,15 +26,6 @@ function server() {
    python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port";
    }

    # Start a PHP server from a directory, optionally specifying the port
    # (Requires PHP 5.4.0+.)
    function phpserver() {
    local port="${1:-4000}";
    local ip=$(ipconfig getifaddr en1);
    sleep 1 && open "http://${ip}:${port}/" &
    php -S "${ip}:${port}";
    }

    # Compare original and gzipped file size
    function gz() {
    local origsize=$(wc -c < "$1");
    @@ -102,58 +35,7 @@ function gz() {
    printf "gzip: %d bytes (%2.2f%%)\n" "$gzipsize" "$ratio";
    }

    # Run `dig` and display the most useful info
    function digga() {
    dig +nocmd "$1" any +multiline +noall +answer;
    }

    # Show all the names (CNs and SANs) listed in the SSL certificate
    # for a given domain
    function getcertnames() {
    if [ -z "${1}" ]; then
    echo "ERROR: No domain specified.";
    return 1;
    fi;

    local domain="${1}";
    echo "Testing ${domain}";
    echo ""; # newline

    local tmp=$(echo -e "GET / HTTP/1.0\nEOT" \
    | openssl s_client -connect "${domain}:443" -servername "${domain}" 2>&1);

    if [[ "${tmp}" = *"-----BEGIN CERTIFICATE-----"* ]]; then
    local certText=$(echo "${tmp}" \
    | openssl x509 -text -certopt "no_aux, no_header, no_issuer, no_pubkey, \
    no_serial, no_sigdump, no_signame, no_validity, no_version");
    echo "Common Name:";
    echo ""; # newline
    echo "${certText}" | grep "Subject:" | sed -e "s/^.*CN=//" | sed -e "s/\/emailAddress=.*//";
    echo ""; # newline
    echo "Subject Alternative Name(s):";
    echo ""; # newline
    echo "${certText}" | grep -A 1 "Subject Alternative Name:" \
    | sed -e "2s/DNS://g" -e "s/ //g" | tr "," "\n" | tail -n +2;
    return 0;
    else
    echo "ERROR: Certificate not found.";
    return 1;
    fi;
    }

    # Normalize `open` across Linux, macOS, and Windows.
    # This is needed to make the `o` function (see below) cross-platform.
    if [ ! $(uname -s) = 'Darwin' ]; then
    if grep -q Microsoft /proc/version; then
    # Ubuntu on Windows using the Linux subsystem
    alias open='explorer.exe';
    else
    alias open='xdg-open';
    fi
    fi

    # `o` with no arguments opens the current directory, otherwise opens the given
    # location
    # `o` with no arguments opens the current directory, otherwise opens the given location
    function o() {
    if [ $# -eq 0 ]; then
    open .;
    @@ -162,30 +44,10 @@ function o() {
    fi;
    }

    # `tre` is a shorthand for `tree` with hidden files and color enabled, ignoring
    # the `.git` directory, listing directories first. The output gets piped into
    # `less` with options to preserve color and line numbers, unless the output is
    # small enough for one screen.
    function tre() {
    tree -aC -I '.git|node_modules|bower_components' --dirsfirst "$@" | less -FRNX;
    }

    opusall() {
    parallel --verbose opusenc --bitrate 96 {} {.}.opus ::: $@
    }

    aacall() {
    parallel --verbose afconvert {} -d aac -f m4af -b 96000 -q 127 -s 2 {.}.m4a ::: $@
    }

    curltime() {
    curl -so /dev/null -w "\
    namelookup: %{time_namelookup}s\n\
    connect: %{time_connect}s\n\
    appconnect: %{time_appconnect}s\n\
    pretransfer: %{time_pretransfer}s\n\
    redirect: %{time_redirect}s\n\
    starttransfer: %{time_starttransfer}s\n\
    -------------------------\n\
    total: %{time_total}s\n" "$@"
    }
  3. mourner revised this gist Mar 14, 2022. 1 changed file with 42 additions and 50 deletions.
    92 changes: 42 additions & 50 deletions .bash_profile
    Original file line number Diff line number Diff line change
    @@ -1,52 +1,44 @@
    #!/usr/bin/env bash

    export PATH="/usr/local/bin:$PATH";
    export PATH="~/.cargo/bin:$PATH";
    export PATH="/usr/local/opt/python/libexec/bin:$PATH";
    export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH";
    export PATH="~/go/bin/:$PATH";
    export PATH="/usr/local/opt/ruby/bin:$PATH";

    export VOLTA_HOME="$HOME/.volta"
    export PATH="$VOLTA_HOME/bin:$PATH"

    export EDITOR="subl -w";

    export HISTSIZE='10000';
    export HISTFILESIZE="${HISTSIZE}";
    export HISTCONTROL='ignoreboth';

    export NODE_REPL_HISTORY=~/.node_history;
    export NODE_REPL_HISTORY_SIZE='10000';
    export NODE_REPL_MODE='sloppy';

    export PYTHONIOENCODING='UTF-8';

    export LESS_TERMCAP_md="$(tput setaf 166)";
    export MANPAGER="less -X";

    export LANG="en_US";
    export LC_ALL="en_US.UTF-8";

    source ~/.bash_prompt;
    source ~/.functions;

    shopt -s nocaseglob; # Case-insensitive globbing (used in pathname expansion)
    shopt -s histappend; # Append to the Bash history file, rather than overwriting it
    shopt -s cdspell; # Autocorrect typos in path names when using `cd`
    shopt -s autocd; # e.g. `**/qux` will enter `./foo/bar/baz/qux`
    shopt -s globstar; # Recursive globbing, e.g. `echo **/*.txt`

    # Add `killall` tab completion for common apps
    complete -o "nospace" -W "Contacts Calendar Dock Finder Mail Safari iTunes SystemUIServer Terminal Twitter" killall;

    source /usr/local/etc/profile.d/z.sh;
    source /usr/local/etc/profile.d/bash_completion.sh;
    source /usr/local/etc/bash_completion.d/git-prompt.sh;
    source /usr/local/etc/bash_completion.d/git-completion.bash;

    source ~/.aliases;

    [ -f ~/.fzf.bash ] && source ~/.fzf.bash;

    source ~/projects/mbxcli/bin/mapbox.sh ;
    export PATH="$PATH:/usr/local/bin"
    export PATH="$PATH:~/.cargo/bin"
    export PATH="$PATH:/usr/local/opt/python/libexec/bin"
    export PATH="$PATH:/usr/local/opt/coreutils/libexec/gnubin"
    export PATH="$PATH:~/go/bin/"
    export PATH="$PATH:/usr/local/opt/ruby/bin"
    export PATH="$PATH:~/.volta/bin"

    export VOLTA_HOME="~/.volta"

    export EDITOR="subl -w"

    export HISTSIZE='10000'
    export HISTFILESIZE="${HISTSIZE}"
    export HISTCONTROL='ignoreboth'

    export NODE_REPL_HISTORY=~/.node_history
    export NODE_REPL_HISTORY_SIZE='10000'
    export NODE_REPL_MODE='sloppy'

    export PYTHONIOENCODING='UTF-8'
    export LESS_TERMCAP_md="$(tput setaf 166)"
    export MANPAGER="less -X"
    export LANG="en_US"
    export LC_ALL="en_US.UTF-8"

    source ~/.bash_prompt
    source ~/.aliases

    shopt -s nocaseglob # Case-insensitive globbing (used in pathname expansion)
    shopt -s histappend # Append to the Bash history file, rather than overwriting it
    shopt -s cdspell # Autocorrect typos in path names when using `cd`
    shopt -s autocd # e.g. `**/qux` will enter `./foo/bar/baz/qux`
    shopt -s globstar # Recursive globbing, e.g. `echo **/*.txt`

    source /usr/local/etc/profile.d/z.sh
    source /usr/local/etc/profile.d/bash_completion.sh
    source /usr/local/etc/bash_completion.d/git-prompt.sh
    source /usr/local/etc/bash_completion.d/git-completion.bash

    source ~/projects/mbxcli/bin/mapbox.sh
    [ -f ~/.fzf.bash ] && source ~/.fzf.bash
  4. mourner revised this gist Mar 14, 2022. 1 changed file with 288 additions and 0 deletions.
    288 changes: 288 additions & 0 deletions Solarized.terminal
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,288 @@
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>ANSIBlueColor</key>
    <data>
    YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS
    AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGmCwwXHR4lVSRudWxs1Q0ODxAR
    EhMUFRZcTlNDb21wb25lbnRzVU5TUkdCXE5TQ29sb3JTcGFjZV8QEk5TQ3VzdG9tQ29s
    b3JTcGFjZVYkY2xhc3NPECQwLjEyMDExNTAyNzIgMC4zMDczNTY5MzkyIDAuODQ2ODc1
    IDFPEBwwIDAuMjA2MzM2MDIxNCAwLjg0OTIzNjEzMDcAEAGAAoAF0xgRGRobHFVOU0lD
    Q1lOU1NwYWNlSUSAA4AEEAxPEQIkAAACJGFwcGwEAAAAbW50clJHQiBYWVogB+EABwAH
    AA0AFgAgYWNzcEFQUEwAAAAAQVBQTAAAAAAAAAAAAAAAAAAAAAAAAPbWAAEAAAAA0y1h
    cHBsyhqVgiV/EE04mRPV0eoVggAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAK
    ZGVzYwAAAPwAAABlY3BydAAAAWQAAAAjd3RwdAAAAYgAAAAUclhZWgAAAZwAAAAUZ1hZ
    WgAAAbAAAAAUYlhZWgAAAcQAAAAUclRSQwAAAdgAAAAgY2hhZAAAAfgAAAAsYlRSQwAA
    AdgAAAAgZ1RSQwAAAdgAAAAgZGVzYwAAAAAAAAALRGlzcGxheSBQMwAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBJbmMuLCAy
    MDE3AABYWVogAAAAAAAA81EAAQAAAAEWzFhZWiAAAAAAAACD3wAAPb////+7WFlaIAAA
    AAAAAEq/AACxNwAACrlYWVogAAAAAAAAKDgAABELAADIuXBhcmEAAAAAAAMAAAACZmYA
    APKnAAANWQAAE9AAAApbc2YzMgAAAAAAAQxCAAAF3v//8yYAAAeTAAD9kP//+6L///2j
    AAAD3AAAwG7SHyAhIlokY2xhc3NuYW1lWCRjbGFzc2VzXE5TQ29sb3JTcGFjZaIjJFxO
    U0NvbG9yU3BhY2VYTlNPYmplY3TSHyAmJ1dOU0NvbG9yoiYkAAgAEQAaACQAKQAyADcA
    SQBMAFEAUwBaAGAAawB4AH4AiwCgAKcAzgDtAO8A8QDzAPoBAAEKAQwBDgEQAzgDPQNI
    A1EDXgNhA24DdwN8A4QAAAAAAAACAQAAAAAAAAAoAAAAAAAAAAAAAAAAAAADhw==
    </data>
    <key>ANSIBrightBlueColor</key>
    <data>
    YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS
    AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxARElVO
    U1JHQlxOU0NvbG9yU3BhY2VWJGNsYXNzTxAeMCAwLjAwMDI0ODEwOTU2NiAwLjgxMDQ4
    NzY4OTQAEAGAAtIUFRYXWiRjbGFzc25hbWVYJGNsYXNzZXNXTlNDb2xvcqIWGFhOU09i
    amVjdAgRGiQpMjdJTFFTV11kand+n6GjqLO8xMcAAAAAAAABAQAAAAAAAAAZAAAAAAAA
    AAAAAAAAAAAA0A==
    </data>
    <key>ANSIWhiteColor</key>
    <data>
    YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS
    AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGmCwwXHR4lVSRudWxs1Q0ODxAR
    EhMUFRZcTlNDb21wb25lbnRzVU5TUkdCXE5TQ29sb3JTcGFjZV8QEk5TQ3VzdG9tQ29s
    b3JTcGFjZVYkY2xhc3NPECUwLjg1NzQyMTg3NSAwLjg1NzQyMTg3NSAwLjg1NzQyMTg3
    NSAxTxAnMC44MjM5OTQ1MTczIDAuODIzOTk0NTE3MyAwLjgyMzk5NDUxNzMAEAGAAoAF
    0xgRGRobHFVOU0lDQ1lOU1NwYWNlSUSAA4AEEAxPEQIkAAACJGFwcGwEAAAAbW50clJH
    QiBYWVogB+EABwAHAA0AFgAgYWNzcEFQUEwAAAAAQVBQTAAAAAAAAAAAAAAAAAAAAAAA
    APbWAAEAAAAA0y1hcHBsyhqVgiV/EE04mRPV0eoVggAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAKZGVzYwAAAPwAAABlY3BydAAAAWQAAAAjd3RwdAAAAYgAAAAUclhZ
    WgAAAZwAAAAUZ1hZWgAAAbAAAAAUYlhZWgAAAcQAAAAUclRSQwAAAdgAAAAgY2hhZAAA
    AfgAAAAsYlRSQwAAAdgAAAAgZ1RSQwAAAdgAAAAgZGVzYwAAAAAAAAALRGlzcGxheSBQ
    MwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBB
    cHBsZSBJbmMuLCAyMDE3AABYWVogAAAAAAAA81EAAQAAAAEWzFhZWiAAAAAAAACD3wAA
    Pb////+7WFlaIAAAAAAAAEq/AACxNwAACrlYWVogAAAAAAAAKDgAABELAADIuXBhcmEA
    AAAAAAMAAAACZmYAAPKnAAANWQAAE9AAAApbc2YzMgAAAAAAAQxCAAAF3v//8yYAAAeT
    AAD9kP//+6L///2jAAAD3AAAwG7SHyAhIlokY2xhc3NuYW1lWCRjbGFzc2VzXE5TQ29s
    b3JTcGFjZaIjJFxOU0NvbG9yU3BhY2VYTlNPYmplY3TSHyAmJ1dOU0NvbG9yoiYkAAgA
    EQAaACQAKQAyADcASQBMAFEAUwBaAGAAawB4AH4AiwCgAKcAzwD5APsA/QD/AQYBDAEW
    ARgBGgEcA0QDSQNUA10DagNtA3oDgwOIA5AAAAAAAAACAQAAAAAAAAAoAAAAAAAAAAAA
    AAAAAAADkw==
    </data>
    <key>BackgroundColor</key>
    <data>
    YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS
    AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxARElVO
    U1JHQlxOU0NvbG9yU3BhY2VWJGNsYXNzTxAsMC4wMTEwMjczNDUzMiAwLjA4OTkzMzQ5
    MzUzIDAuMTE1NDg0MzY1IDAuOQAQAYAC0hQVFhdaJGNsYXNzbmFtZVgkY2xhc3Nlc1dO
    U0NvbG9yohYYWE5TT2JqZWN0CBEaJCkyN0lMUVNXXWRqd36tr7G2wcrS1QAAAAAAAAEB
    AAAAAAAAABkAAAAAAAAAAAAAAAAAAADe
    </data>
    <key>BlinkText</key>
    <false/>
    <key>CommandString</key>
    <string></string>
    <key>CursorBlink</key>
    <false/>
    <key>CursorColor</key>
    <data>
    YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS
    AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxARElVO
    U1JHQlxOU0NvbG9yU3BhY2VWJGNsYXNzTxAnMC40NDA1ODAyNDg4IDAuNTA5NjI5MzA5
    MiAwLjUxNjg1Nzk4MTcAEAGAAtIUFRYXWiRjbGFzc25hbWVYJGNsYXNzZXNXTlNDb2xv
    cqIWGFhOU09iamVjdAgRGiQpMjdJTFFTV11kand+qKqssbzFzdAAAAAAAAABAQAAAAAA
    AAAZAAAAAAAAAAAAAAAAAAAA2Q==
    </data>
    <key>CursorType</key>
    <integer>0</integer>
    <key>Font</key>
    <data>
    YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS
    AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGkCwwVFlUkbnVsbNQNDg8QERIT
    FFZOU1NpemVYTlNmRmxhZ3NWTlNOYW1lViRjbGFzcyNALAAAAAAAABAQgAKAA18QEEZp
    cmFNb25vLVJlZ3VsYXLSFxgZGlokY2xhc3NuYW1lWCRjbGFzc2VzVk5TRm9udKIZG1hO
    U09iamVjdAgRGiQpMjdJTFFTWF5nbnd+hY6QkpSnrLfAx8oAAAAAAAABAQAAAAAAAAAc
    AAAAAAAAAAAAAAAAAAAA0w==
    </data>
    <key>FontAntialias</key>
    <true/>
    <key>FontHeightSpacing</key>
    <real>1.05</real>
    <key>FontWidthSpacing</key>
    <integer>1</integer>
    <key>ProfileCurrentVersion</key>
    <real>2.0699999999999998</real>
    <key>RunCommandAsShell</key>
    <true/>
    <key>SelectionColor</key>
    <data>
    YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS
    AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxARElVO
    U1JHQlxOU0NvbG9yU3BhY2VWJGNsYXNzTxAoMC4wNTY3NTg5MDMyMyAwLjIzMTQxNjAy
    OTYgMC4yODgxMzUyNTg4ABABgALSFBUWF1okY2xhc3NuYW1lWCRjbGFzc2VzV05TQ29s
    b3KiFhhYTlNPYmplY3QIERokKTI3SUxRU1ddZGp3fqmrrbK9xs7RAAAAAAAAAQEAAAAA
    AAAAGQAAAAAAAAAAAAAAAAAAANo=
    </data>
    <key>ShowActiveProcessArgumentsInTabTitle</key>
    <false/>
    <key>ShowActiveProcessArgumentsInTitle</key>
    <false/>
    <key>ShowActiveProcessInTabTitle</key>
    <false/>
    <key>ShowActiveProcessInTitle</key>
    <true/>
    <key>ShowCommandKeyInTitle</key>
    <false/>
    <key>ShowDimensionsInTitle</key>
    <false/>
    <key>ShowRepresentedURLInTabTitle</key>
    <true/>
    <key>ShowRepresentedURLInTitle</key>
    <true/>
    <key>ShowRepresentedURLPathInTabTitle</key>
    <false/>
    <key>ShowRepresentedURLPathInTitle</key>
    <false/>
    <key>ShowShellCommandInTitle</key>
    <false/>
    <key>ShowTTYNameInTitle</key>
    <false/>
    <key>ShowWindowSettingsNameInTitle</key>
    <false/>
    <key>TerminalType</key>
    <string>xterm-256color</string>
    <key>TextBoldColor</key>
    <data>
    YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS
    AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxARElVO
    U1JHQlxOU0NvbG9yU3BhY2VWJGNsYXNzTxAmMC41MDU5OTE5MzU3IDAuNTY0ODU4Mzc3
    IDAuNTYzNjM2NTQxNAAQAYAC0hQVFhdaJGNsYXNzbmFtZVgkY2xhc3Nlc1dOU0NvbG9y
    ohYYWE5TT2JqZWN0CBEaJCkyN0lMUVNXXWRqd36nqauwu8TMzwAAAAAAAAEBAAAAAAAA
    ABkAAAAAAAAAAAAAAAAAAADY
    </data>
    <key>TextColor</key>
    <data>
    YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS
    AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGmCwwXHR4lVSRudWxs1Q0ODxAR
    EhMUFRZcTlNDb21wb25lbnRzVU5TUkdCXE5TQ29sb3JTcGFjZV8QEk5TQ3VzdG9tQ29s
    b3JTcGFjZVYkY2xhc3NPECcwLjY5NDQzMDkzNiAwLjc1NjM1NzYwMjUgMC43NzA3NDIx
    ODc1IDFPECcwLjYxOTM4MDI5NTMgMC43MDg1OTY0MDg0IDAuNzI0MDQ0NjgwNgAQAYAC
    gAXTGBEZGhscVU5TSUNDWU5TU3BhY2VJRIADgAQQDE8RAiQAAAIkYXBwbAQAAABtbnRy
    UkdCIFhZWiAH4QAHAAcADQAWACBhY3NwQVBQTAAAAABBUFBMAAAAAAAAAAAAAAAAAAAA
    AAAA9tYAAQAAAADTLWFwcGzKGpWCJX8QTTiZE9XR6hWCAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAApkZXNjAAAA/AAAAGVjcHJ0AAABZAAAACN3dHB0AAABiAAAABRy
    WFlaAAABnAAAABRnWFlaAAABsAAAABRiWFlaAAABxAAAABRyVFJDAAAB2AAAACBjaGFk
    AAAB+AAAACxiVFJDAAAB2AAAACBnVFJDAAAB2AAAACBkZXNjAAAAAAAAAAtEaXNwbGF5
    IFAzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0
    IEFwcGxlIEluYy4sIDIwMTcAAFhZWiAAAAAAAADzUQABAAAAARbMWFlaIAAAAAAAAIPf
    AAA9v////7tYWVogAAAAAAAASr8AALE3AAAKuVhZWiAAAAAAAAAoOAAAEQsAAMi5cGFy
    YQAAAAAAAwAAAAJmZgAA8qcAAA1ZAAAT0AAACltzZjMyAAAAAAABDEIAAAXe///zJgAA
    B5MAAP2Q///7ov///aMAAAPcAADAbtIfICEiWiRjbGFzc25hbWVYJGNsYXNzZXNcTlND
    b2xvclNwYWNloiMkXE5TQ29sb3JTcGFjZVhOU09iamVjdNIfICYnV05TQ29sb3KiJiQA
    CAARABoAJAApADIANwBJAEwAUQBTAFoAYABrAHgAfgCLAKAApwDRAPsA/QD/AQEBCAEO
    ARgBGgEcAR4DRgNLA1YDXwNsA28DfAOFA4oDkgAAAAAAAAIBAAAAAAAAACgAAAAAAAAA
    AAAAAAAAAAOV
    </data>
    <key>UseBrightBold</key>
    <true/>
    <key>blackColour</key>
    <data>
    BAtzdHJlYW10eXBlZIHoA4QBQISEhAdOU0NvbG9yAISECE5TT2JqZWN0AIWEAWMBhARm
    ZmZmg7JNIT2DkvUjPoO+F0s+AYY=
    </data>
    <key>blueColour</key>
    <data>
    BAtzdHJlYW10eXBlZIHoA4QBQISEhAdOU0NvbG9yAISECE5TT2JqZWN0AIWEAWMBhARm
    ZmZmgyqcAj6DtOHsPoO+RUg/AYY=
    </data>
    <key>brightBlackColour</key>
    <data>
    BAtzdHJlYW10eXBlZIHoA4QBQISEhAdOU0NvbG9yAISECE5TT2JqZWN0AIWEAWMBhARm
    ZmZmg+ZzgjyDs44BPoNahyM+AYY=
    </data>
    <key>brightBlueColour</key>
    <data>
    BAtzdHJlYW10eXBlZIHoA4QBQISEhAdOU0NvbG9yAISECE5TT2JqZWN0AIWEAWMBhARm
    ZmZmg7yT4T6DEXcCP4POUAQ/AYY=
    </data>
    <key>brightCyanColour</key>
    <data>
    BAtzdHJlYW10eXBlZIHoA4QBQISEhAdOU0NvbG9yAISECE5TT2JqZWN0AIWEAWMBhARm
    ZmZmg7CIAT+Dj5oQP4N8ShA/AYY=
    </data>
    <key>brightGreenColour</key>
    <data>
    BAtzdHJlYW10eXBlZIHoA4QBQISEhAdOU0NvbG9yAISECE5TT2JqZWN0AIWEAWMBhARm
    ZmZmgzyujT6DFZy2PoOYFsQ+AYY=
    </data>
    <key>brightMagentaColour</key>
    <data>
    BAtzdHJlYW10eXBlZIHoA4QBQISEhAdOU0NvbG9yAISECE5TT2JqZWN0AIWEAWMBhARm
    ZmZmgxMjsj6D+uazPoNkyTc/AYY=
    </data>
    <key>brightRedColour</key>
    <data>
    BAtzdHJlYW10eXBlZIHoA4QBQISEhAdOU0NvbG9yAISECE5TT2JqZWN0AIWEAWMBhARm
    ZmZmgyfkPT+D/15aPoMgl5Y9AYY=
    </data>
    <key>brightWhiteColour</key>
    <data>
    BAtzdHJlYW10eXBlZIHoA4QBQISEhAdOU0NvbG9yAISECE5TT2JqZWN0AIWEAWMBhARm
    ZmZmg49LfT+D0Dt1P4MGM10/AYY=
    </data>
    <key>brightYellowColour</key>
    <data>
    BAtzdHJlYW10eXBlZIHoA4QBQISEhAdOU0NvbG9yAISECE5TT2JqZWN0AIWEAWMBhARm
    ZmZmg1MTpj6DeHnQPoPQg+A+AYY=
    </data>
    <key>columnCount</key>
    <integer>120</integer>
    <key>cyanColour</key>
    <data>
    BAtzdHJlYW10eXBlZIHoA4QBQISEhAdOU0NvbG9yAISECE5TT2JqZWN0AIWEAWMBhARm
    ZmZmg4VRFj6DfyESP4PkZwY/AYY=
    </data>
    <key>greenColour</key>
    <data>
    BAtzdHJlYW10eXBlZIHoA4QBQISEhAdOU0NvbG9yAISECE5TT2JqZWN0AIWEAWMBhARm
    ZmZmg9lI5j6DIYkKP4PVjKU8AYY=
    </data>
    <key>magentaColour</key>
    <data>
    BAtzdHJlYW10eXBlZIHoA4QBQISEhAdOU0NvbG9yAISECE5TT2JqZWN0AIWEAWMBhARm
    ZmZmg/4CRz+DBTzdPYMgzt4+AYY=
    </data>
    <key>name</key>
    <string>Solarized</string>
    <key>noWarnProcesses</key>
    <array>
    <dict>
    <key>ProcessName</key>
    <string>screen</string>
    </dict>
    <dict>
    <key>ProcessName</key>
    <string>tmux</string>
    </dict>
    <dict>
    <key>ProcessName</key>
    <string>bash</string>
    </dict>
    <dict>
    <key>ProcessName</key>
    <string>-bash</string>
    </dict>
    </array>
    <key>redColour</key>
    <data>
    BAtzdHJlYW10eXBlZIHoA4QBQISEhAdOU0NvbG9yAISECE5TT2JqZWN0AIWEAWMBhARm
    ZmZmg6i7UT+DUATePYMl2hA+AYY=
    </data>
    <key>rowCount</key>
    <integer>40</integer>
    <key>type</key>
    <string>Window Settings</string>
    <key>warnOnShellCloseAction</key>
    <integer>0</integer>
    <key>whiteColour</key>
    <data>
    BAtzdHJlYW10eXBlZIHoA4QBQISEhAdOU0NvbG9yAISECE5TT2JqZWN0AIWEAWMBhARm
    ZmZmgzqGaj+D2tdjP4NYPUw/AYY=
    </data>
    <key>yellowColour</key>
    <data>
    BAtzdHJlYW10eXBlZIHoA4QBQISEhAdOU0NvbG9yAISECE5TT2JqZWN0AIWEAWMBhARm
    ZmZmg0DAJT+DB17vPoM4Y8A8AYY=
    </data>
    </dict>
    </plist>
  5. mourner created this gist Mar 14, 2022.
    135 changes: 135 additions & 0 deletions .aliases
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,135 @@
    # Easier navigation: .., ..., ...., ....., ~ and -
    alias ..="cd .."
    alias ...="cd ../.."
    alias ....="cd ../../.."
    alias .....="cd ../../../.."
    alias ~="cd ~" # `cd` is probably faster to type though
    alias -- -="cd -"

    # Shortcuts
    alias db="cd ~/Dropbox"
    alias dl="cd ~/Downloads"
    alias dt="cd ~/Desktop"
    alias p="cd ~/Projects"
    alias g="git"
    __git_complete g __git_main
    alias h="history"
    alias j="jobs"
    alias v="vim"
    alias m="mate ."
    alias s="subl ."
    alias o="open"
    alias oo="open ."
    alias ts="tig status"
    alias rclonesync="rclone sync --fast-list -P --stats-one-line --transfers 16"

    # 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 l="ls -l ${colorflag}"

    # List all files colorized in long format, including dot files
    alias la="ls -la ${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:'

    # Enable aliases to be sudo’ed
    alias sudo='sudo '

    # Gzip-enabled `curl`
    alias gurl="curl --compressed"

    # Get OS X Software Updates, and update installed Ruby gems, Homebrew, npm, and their installed packages
    alias update='sudo softwareupdate -i -a; brew update; brew upgrade; brew cleanup; npm update npm -g; npm update -g; sudo gem update'

    alias brewout='brew update > /dev/null; brew outdated'
    alias brewup='brew update > /dev/null; brew upgrade; brew cleanup'

    # IP addresses
    alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
    alias localip="ipconfig getifaddr en1"
    alias ips="ifconfig -a | grep -o 'inet6\? \(\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)\|[a-fA-F0-9:]\+\)' | sed -e 's/inet6* //'"

    # Enhanced WHOIS lookups
    alias whois="whois -h whois-servers.net"

    # Flush Directory Service cache
    alias flush="dscacheutil -flushcache && killall -HUP mDNSResponder"

    # Clean up LaunchServices to remove duplicates in the “Open With” menu
    alias lscleanup="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder"

    # View HTTP traffic
    alias sniff="sudo ngrep -d 'en1' -t '^(GET|POST) ' 'tcp and port 80'"
    alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E \"Host\: .*|GET \/.*\""

    # Canonical hex dump; some systems have this symlinked
    command -v hd > /dev/null || alias hd="hexdump -C"

    # OS X has no `md5sum`, so use `md5` as a fallback
    command -v md5sum > /dev/null || alias md5sum="md5"

    # OS X has no `sha1sum`, so use `shasum` as a fallback
    command -v sha1sum > /dev/null || alias sha1sum="shasum"

    # Trim new lines and copy to clipboard
    alias c="tr -d '\n' | pbcopy"

    # Recursively delete `.DS_Store` files
    alias cleanup="find . -type f -name '*.DS_Store' -ls -delete"

    # ROT13-encode text. Works for decoding, too! ;)
    alias rot13='tr a-zA-Z n-za-mN-ZA-M'

    # Empty the Trash on all mounted volumes and the main HDD
    # Also, clear Apple’s System Logs to improve shell startup speed
    alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl"

    # Show/hide hidden files in Finder
    alias show="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
    alias hide="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"

    # Hide/show all desktop icons (useful when presenting)
    alias hidedesktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
    alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"

    # URL-encode strings
    alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);"'

    # Merge PDF files
    # Usage: `mergepdf -o output.pdf input{1,2,3}.pdf`
    alias mergepdf='/System/Library/Automator/Combine\ PDF\ Pages.action/Contents/Resources/join.py'

    # Disable Spotlight
    alias spotoff="sudo mdutil -a -i off"
    # Enable Spotlight
    alias spoton="sudo mdutil -a -i on"

    # PlistBuddy alias, because sometimes `defaults` just doesn’t cut it
    alias plistbuddy="/usr/libexec/PlistBuddy"

    # Ring the terminal bell, and put a badge on Terminal.app’s Dock icon
    # (useful when executing time-consuming commands)
    alias badge="tput bel"

    # Intuitive map function
    # For example, to list all directories that contain a certain file:
    # find . -name .gitattributes | map dirname
    alias map="xargs -n1"

    # One of @janmoesen’s ProTip™s
    for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do
    alias "$method"="lwp-request -m '$method'"
    done

    # Stuff I never really use but cannot delete either because of http://xkcd.com/530/
    alias stfu="osascript -e 'set volume output muted true'"
    alias pumpitup="osascript -e 'set volume 7'"
    alias hax="growlnotify -a 'Activity Monitor' 'System error' -m 'WTF R U DOIN'"
    52 changes: 52 additions & 0 deletions .bash_profile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,52 @@
    #!/usr/bin/env bash

    export PATH="/usr/local/bin:$PATH";
    export PATH="~/.cargo/bin:$PATH";
    export PATH="/usr/local/opt/python/libexec/bin:$PATH";
    export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH";
    export PATH="~/go/bin/:$PATH";
    export PATH="/usr/local/opt/ruby/bin:$PATH";

    export VOLTA_HOME="$HOME/.volta"
    export PATH="$VOLTA_HOME/bin:$PATH"

    export EDITOR="subl -w";

    export HISTSIZE='10000';
    export HISTFILESIZE="${HISTSIZE}";
    export HISTCONTROL='ignoreboth';

    export NODE_REPL_HISTORY=~/.node_history;
    export NODE_REPL_HISTORY_SIZE='10000';
    export NODE_REPL_MODE='sloppy';

    export PYTHONIOENCODING='UTF-8';

    export LESS_TERMCAP_md="$(tput setaf 166)";
    export MANPAGER="less -X";

    export LANG="en_US";
    export LC_ALL="en_US.UTF-8";

    source ~/.bash_prompt;
    source ~/.functions;

    shopt -s nocaseglob; # Case-insensitive globbing (used in pathname expansion)
    shopt -s histappend; # Append to the Bash history file, rather than overwriting it
    shopt -s cdspell; # Autocorrect typos in path names when using `cd`
    shopt -s autocd; # e.g. `**/qux` will enter `./foo/bar/baz/qux`
    shopt -s globstar; # Recursive globbing, e.g. `echo **/*.txt`

    # Add `killall` tab completion for common apps
    complete -o "nospace" -W "Contacts Calendar Dock Finder Mail Safari iTunes SystemUIServer Terminal Twitter" killall;

    source /usr/local/etc/profile.d/z.sh;
    source /usr/local/etc/profile.d/bash_completion.sh;
    source /usr/local/etc/bash_completion.d/git-prompt.sh;
    source /usr/local/etc/bash_completion.d/git-completion.bash;

    source ~/.aliases;

    [ -f ~/.fzf.bash ] && source ~/.fzf.bash;

    source ~/projects/mbxcli/bin/mapbox.sh ;
    14 changes: 14 additions & 0 deletions .bash_prompt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    #!/usr/bin/env bash

    export TERM='xterm-256color';

    tput sgr0;
    reset=$(tput sgr0);
    green=$(tput setaf 190);
    orange=$(tput setaf 172);
    purple=$(tput setaf 141);

    GIT_PS1_SHOWDIRTYSTATE=1;
    GIT_PS1_STATESEPARATOR='';
    PS1="\[${green}\]\w\[${purple}\]\$(__git_ps1)\[${orange}\] → \[${reset}\]";
    PS2="\[${orange}\]→ \[${reset}\]";
    191 changes: 191 additions & 0 deletions .functions
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,191 @@
    #!/usr/bin/env bash

    # Create a new directory and enter it
    function mkd() {
    mkdir -p "$@" && cd "$_";
    }

    # Change working directory to the top-most Finder window location
    function cdf() { # short for `cdfinder`
    cd "$(osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)')";
    }

    # Create a .tar.gz archive, using `zopfli`, `pigz` or `gzip` for compression
    function targz() {
    local tmpFile="${@%/}.tar";
    tar -cvf "${tmpFile}" --exclude=".DS_Store" "${@}" || return 1;

    size=$(
    stat -f"%z" "${tmpFile}" 2> /dev/null; # macOS `stat`
    stat -c"%s" "${tmpFile}" 2> /dev/null; # GNU `stat`
    );

    local cmd="";
    if (( size < 52428800 )) && hash zopfli 2> /dev/null; then
    # the .tar file is smaller than 50 MB and Zopfli is available; use it
    cmd="zopfli";
    else
    if hash pigz 2> /dev/null; then
    cmd="pigz";
    else
    cmd="gzip";
    fi;
    fi;

    echo "Compressing .tar ($((size / 1000)) kB) using \`${cmd}\`";
    "${cmd}" -v "${tmpFile}" || return 1;
    [ -f "${tmpFile}" ] && rm "${tmpFile}";

    zippedSize=$(
    stat -f"%z" "${tmpFile}.gz" 2> /dev/null; # macOS `stat`
    stat -c"%s" "${tmpFile}.gz" 2> /dev/null; # GNU `stat`
    );

    echo "${tmpFile}.gz ($((zippedSize / 1000)) kB) created successfully.";
    }

    # Determine size of a file or total size of a directory
    function fs() {
    if du -b /dev/null > /dev/null 2>&1; then
    local arg=-sbh;
    else
    local arg=-sh;
    fi
    if [[ -n "$@" ]]; then
    du $arg -- "$@";
    else
    du $arg .[^.]* ./*;
    fi;
    }

    # Use Git’s colored diff when available
    hash git &>/dev/null;
    if [ $? -eq 0 ]; then
    function diff() {
    git diff --no-index --color-words "$@";
    }
    fi;

    # Create a data URL from a file
    function dataurl() {
    local mimeType=$(file -b --mime-type "$1");
    if [[ $mimeType == text/* ]]; then
    mimeType="${mimeType};charset=utf-8";
    fi
    echo "data:${mimeType};base64,$(openssl base64 -in "$1" | tr -d '\n')";
    }

    # Start an HTTP server from a directory, optionally specifying the port
    function server() {
    local port="${1:-8000}";
    sleep 1 && open "http://localhost:${port}/" &
    # Set the default Content-Type to `text/plain` instead of `application/octet-stream`
    # And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files)
    python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port";
    }

    # Start a PHP server from a directory, optionally specifying the port
    # (Requires PHP 5.4.0+.)
    function phpserver() {
    local port="${1:-4000}";
    local ip=$(ipconfig getifaddr en1);
    sleep 1 && open "http://${ip}:${port}/" &
    php -S "${ip}:${port}";
    }

    # Compare original and gzipped file size
    function gz() {
    local origsize=$(wc -c < "$1");
    local gzipsize=$(gzip -c "$1" | wc -c);
    local ratio=$(echo "$gzipsize * 100 / $origsize" | bc -l);
    printf "orig: %d bytes\n" "$origsize";
    printf "gzip: %d bytes (%2.2f%%)\n" "$gzipsize" "$ratio";
    }

    # Run `dig` and display the most useful info
    function digga() {
    dig +nocmd "$1" any +multiline +noall +answer;
    }

    # Show all the names (CNs and SANs) listed in the SSL certificate
    # for a given domain
    function getcertnames() {
    if [ -z "${1}" ]; then
    echo "ERROR: No domain specified.";
    return 1;
    fi;

    local domain="${1}";
    echo "Testing ${domain}";
    echo ""; # newline

    local tmp=$(echo -e "GET / HTTP/1.0\nEOT" \
    | openssl s_client -connect "${domain}:443" -servername "${domain}" 2>&1);

    if [[ "${tmp}" = *"-----BEGIN CERTIFICATE-----"* ]]; then
    local certText=$(echo "${tmp}" \
    | openssl x509 -text -certopt "no_aux, no_header, no_issuer, no_pubkey, \
    no_serial, no_sigdump, no_signame, no_validity, no_version");
    echo "Common Name:";
    echo ""; # newline
    echo "${certText}" | grep "Subject:" | sed -e "s/^.*CN=//" | sed -e "s/\/emailAddress=.*//";
    echo ""; # newline
    echo "Subject Alternative Name(s):";
    echo ""; # newline
    echo "${certText}" | grep -A 1 "Subject Alternative Name:" \
    | sed -e "2s/DNS://g" -e "s/ //g" | tr "," "\n" | tail -n +2;
    return 0;
    else
    echo "ERROR: Certificate not found.";
    return 1;
    fi;
    }

    # Normalize `open` across Linux, macOS, and Windows.
    # This is needed to make the `o` function (see below) cross-platform.
    if [ ! $(uname -s) = 'Darwin' ]; then
    if grep -q Microsoft /proc/version; then
    # Ubuntu on Windows using the Linux subsystem
    alias open='explorer.exe';
    else
    alias open='xdg-open';
    fi
    fi

    # `o` with no arguments opens the current directory, otherwise opens the given
    # location
    function o() {
    if [ $# -eq 0 ]; then
    open .;
    else
    open "$@";
    fi;
    }

    # `tre` is a shorthand for `tree` with hidden files and color enabled, ignoring
    # the `.git` directory, listing directories first. The output gets piped into
    # `less` with options to preserve color and line numbers, unless the output is
    # small enough for one screen.
    function tre() {
    tree -aC -I '.git|node_modules|bower_components' --dirsfirst "$@" | less -FRNX;
    }

    opusall() {
    parallel --verbose opusenc --bitrate 96 {} {.}.opus ::: $@
    }

    aacall() {
    parallel --verbose afconvert {} -d aac -f m4af -b 96000 -q 127 -s 2 {.}.m4a ::: $@
    }

    curltime() {
    curl -so /dev/null -w "\
    namelookup: %{time_namelookup}s\n\
    connect: %{time_connect}s\n\
    appconnect: %{time_appconnect}s\n\
    pretransfer: %{time_pretransfer}s\n\
    redirect: %{time_redirect}s\n\
    starttransfer: %{time_starttransfer}s\n\
    -------------------------\n\
    total: %{time_total}s\n" "$@"
    }