diff --git a/Brewfile b/Brewfile index 2bd5e909309..598dbdeb373 100644 --- a/Brewfile +++ b/Brewfile @@ -1,43 +1,107 @@ -cask_args appdir: '/Applications' - +# Taps +tap 'caskroom/cask' +tap 'caskroom/fonts' +tap 'caskroom/versions' tap 'homebrew/bundle' -tap 'puma/puma' +tap 'azure/draft' + +# Upgrade ruby & bash +brew 'ruby' +brew 'bash' -brew 'ack' +# Install ZSH +brew 'zsh' +brew 'zsh-completions' + +# Install GNU core utilities (those that come with macOS are outdated) brew 'coreutils' -brew 'go' -brew 'grc' -brew 'imagemagick' -brew 'jp2a' + +# Install GNU `find`, `locate`, `updatedb`, and `xargs`, g-prefixed +brew 'findutils' + +# Install more recent versions of some macOS tools +brew 'grep' + +# Install Binaries +brew 'awscli' +brew 'git' +brew 'hub' +brew 'tree' +brew 'mackup' +brew 'mas' +brew 'trash' +cask 'android-platform-tools' brew 'jq' -brew 'libcaca', args: ['with-imlib2'] -brew 'libgit2' -brew 'openssl' -brew 'node' -brew 'readline' -brew 'postgresql' -brew 'puma/puma/puma-dev' -brew 'ruby-build' -brew 'rbenv' -brew 'roundup' -brew 'spaceman-diff' -brew 'spark' +brew 'reattach-to-user-namespace' +brew 'the_silver_searcher' +brew 'tmux' brew 'unrar' brew 'wget' +brew 'httpie' + +# development +brew 'nvm' brew 'yarn' -brew 'youtube-dl' +brew 'nvim' +cask 'docker' +cask 'kitematic' +cask 'sourcetree' +cask 'visual-studio-code' +cask 'pritunl' +cask 'meld' +cask 'dotnet-sdk' +brew 'vault' +cask 'mono-mdk' +cask 'rider' +# Required by SQLWorkbenchJ +cask 'java8' +cask 'sqlworkbenchj' +cask 'robo-3t' +cask 'google-cloud-sdk' +brew 'go' +brew 'kubernetes-cli' +brew 'kubernetes-helm' +brew 'azure/draft/draft' +brew 'lastpass-cli' -cask '1password' -cask 'adium' -cask 'atom' +# Apps cask 'firefox' -cask 'garmin-express' cask 'google-chrome' -cask 'handbrake' -cask 'mapbox-studio' -cask 'seashore' +cask 'google-backup-and-sync' +cask 'iterm2' cask 'slack' -cask 'steam' -cask 'transmission' -cask 'tunnelbear' cask 'vlc' +cask 'android-file-transfer' + +# Research +#cask 'anaconda' + +# Quicklook +cask 'qlcolorcode' +cask 'qlmarkdown' +cask 'quicklook-json' +cask 'quicklook-csv' +cask 'qlstephen' + +# Fonts +cask 'font-source-code-pro' +cask 'font-source-sans-pro' +cask 'font-source-serif-pro' +cask 'font-anonymice-powerline' +cask 'font-awesome-terminal-fonts' +cask 'font-consolas-for-powerline' +cask 'font-droid-sans-mono-for-powerline' +cask 'font-firacode-nerd-font' +cask 'font-firacode-nerd-font-mono' +cask 'font-hack' +cask 'font-hack-nerd-font' +cask 'font-inconsolata-for-powerline' +cask 'font-iosevka' +cask 'font-iosevka-nerd-font' +cask 'font-iosevka-nerd-font-mono' +cask 'font-menlo-for-powerline' +cask 'font-source-code-pro' +cask 'font-source-code-pro-for-powerline' + +# Install Mac App Store apps +# mas 'Paw', id: 584653203 diff --git a/README.md b/README.md index 30586a84fe4..551ee5806cb 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ symlinked without extension into `$HOME` when you run `script/bootstrap`. A lot of stuff. Seriously, a lot of stuff. Check them out in the file browser above and see what components may mesh up with you. -[Fork it](https://github.com/holman/dotfiles/fork), remove what you don't +[Fork it](https://github.com/noxxious/dotfiles/fork), remove what you don't use, and build on what you do use. ## components @@ -51,7 +51,7 @@ There's a few special files in the hierarchy. Run this: ```sh -git clone https://github.com/holman/dotfiles.git ~/.dotfiles +git clone https://github.com/noxxious/dotfiles.git ~/.dotfiles cd ~/.dotfiles script/bootstrap ``` diff --git a/anaconda/env.zsh b/anaconda/env.zsh new file mode 100644 index 00000000000..b8c0e10e52f --- /dev/null +++ b/anaconda/env.zsh @@ -0,0 +1 @@ +. /usr/local/anaconda3/etc/profile.d/conda.sh \ No newline at end of file diff --git a/anaconda/path.zsh b/anaconda/path.zsh new file mode 100644 index 00000000000..b2f41d12803 --- /dev/null +++ b/anaconda/path.zsh @@ -0,0 +1 @@ +export PATH=/usr/local/anaconda3/bin:"$PATH" \ No newline at end of file diff --git a/atom.symlink/atom.coffee b/atom.symlink/atom.coffee deleted file mode 100644 index 297b7b6f0ac..00000000000 --- a/atom.symlink/atom.coffee +++ /dev/null @@ -1 +0,0 @@ -# Atom customization goes here. diff --git a/atom.symlink/config.cson b/atom.symlink/config.cson deleted file mode 100644 index 75f0db72ff4..00000000000 --- a/atom.symlink/config.cson +++ /dev/null @@ -1,73 +0,0 @@ -"*": - "atom-beautify": - crystal: - beautify_on_save: true - css: - beautify_on_save: true - html: - beautify_on_save: true - js: - disabled: true - jsx: - disabled: true - markdown: - beautify_on_save: true - nginx: - beautify_on_save: true - ruby: - default_beautifier: "Ruby Beautify" - "autocomplete-modules": - babelPluginModuleResolver: true - webpack: true - core: - closeDeletedFileTabs: true - closeEmptyWindows: false - disabledPackages: [ - "background-tips" - "exception-reporting" - "metrics" - ] - followSymlinks: false - hideGitIgnoredFiles: true - ignoredNames: [ - ".bundle" - ".git" - "log" - "repositories" - "tmp" - "vendor" - ] - telemetryConsent: "no" - editor: - fontFamily: "Menlo" - fontSize: 15 - invisibles: {} - showIndentGuide: true - softWrapAtPreferredLineLength: true - "go-plus": - panelDisplayMode: "closed" - "linter-eslint": - useGlobalEslint: true - "prettier-atom": - formatOnSaveOptions: - enabled: true - "release-notes": - viewedVersion: "0.89.0" - "spell-check": - grammars: [ - "text.plain" - "source.gfm" - "text.git-commit" - "text.html.basic" - ] - stylefmt: - formatOnSave: true - welcome: - showOnStartup: false -".js.jsx.react.source": - editor: - autoIndent: true -".js.jsx.source": - editor: - autoIndent: false - autoIndentOnPaste: false diff --git a/atom.symlink/init.coffee b/atom.symlink/init.coffee deleted file mode 100644 index 3b5ebc569f7..00000000000 --- a/atom.symlink/init.coffee +++ /dev/null @@ -1 +0,0 @@ -# Add any auto-loaded Atom code on init here. diff --git a/bin/atom-package-backup b/bin/atom-package-backup deleted file mode 100755 index 25f8a451b95..00000000000 --- a/bin/atom-package-backup +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -# -# Usage: atom-package-backup -# -# Saves a list of your currently installed atom packages to -# ~/.dotfiles/atom.symlink/packages.txt suitable for install -# via atom-package-install - -set -e - -apm list --installed --bare > ~/.dotfiles/atom.symlink/packages.txt diff --git a/bin/atom-package-install b/bin/atom-package-install deleted file mode 100755 index 218bf414ee1..00000000000 --- a/bin/atom-package-install +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# -# Usage: atom-package-install -# -# Installs the atom packages listed in your packages.txt file -# located at ~/.dotfiles/atom.symlink/packages.txt -# -# You can generate a new list based on currently installed -# packages via atom-package-backup - -set -e - -apm install --packages-file ~/.dotfiles/atom.symlink/packages.txt diff --git a/bin/battery-status b/bin/battery-status deleted file mode 100755 index eef28a826d2..00000000000 --- a/bin/battery-status +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -# -# battery-status -# -# A quick little indicator for battery status on your Mac laptop, suitable for -# display in your prompt. - -battstat=$(pmset -g batt) -time_left=$(echo $battstat | - tail -1 | - cut -f2 | - awk -F"; " '{print $3}' | - cut -d' ' -f1 -) - -if [[ $(pmset -g ac) == *"No adapter attached."* ]] -then - emoji='🔋' -else - emoji='🔌' -fi - -if [[ $time_left == *"(no"* || $time_left == *"not"* ]] -then - time_left='⌛️ ' -fi - -if [[ $time_left == *"0:00"* ]] -then - time_left='⚡️ ' -fi - -printf "\033[1;92m$emoji $time_left \033[0m" diff --git a/bin/brew_update b/bin/brew_update new file mode 100755 index 00000000000..ca97b750c18 --- /dev/null +++ b/bin/brew_update @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +brew update +brew upgrade +brew cleanup +brew doctor + +for app in $(brew cask list); do + cver="$(brew cask info "${app}" | head -n 1 | cut -d " " -f 2)" + ivers=$(ls -1 "/usr/local/Caskroom/${app}/.metadata/" | tr '\n' ' ' | sed -e 's/ $//') + aivers=(${ivers}) + nvers=$(echo ${#aivers[@]}) + echo "[*] Found ${app} in cask list. Latest available version is ${cver}. You have installed version(s): ${ivers}" + if [[ ${nvers} -eq 1 ]]; then + echo "${ivers}" | grep -q "^${cver}$" && { #echo "[*] Latest version already installed :) Skipping changes ..." + continue; } + fi + echo "[+] Fixing from ${ivers} to ${cver} ..." + brew cask uninstall "${app}" --force + brew cask install "${app}" +done diff --git a/bin/cloudapp b/bin/cloudapp deleted file mode 100755 index 1ec555ab660..00000000000 --- a/bin/cloudapp +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env ruby -# -# cloudapp -# Zach Holman / @holman -# -# Uploads a file from the command line to CloudApp, drops it into your -# clipboard (on a Mac, at least). -# -# Example: -# -# cloudapp drunk-blake.png -# -# This requires Aaron Russell's cloudapp_api gem: -# -# gem install cloudapp_api -# -# Requires you set your CloudApp credentials in ~/.cloudapp as a simple file of: -# -# email -# password - -require 'rubygems' - -['json', 'cloudapp_api'].each do |gem| - begin - require gem - rescue LoadError - puts "You need to install #{gem}: gem install #{gem}" - exit!(1) - end -end - -config_file = "#{ENV['HOME']}/.cloudapp" -unless File.exist?(config_file) - puts "You need to type your email and password (one per line) into "+ - "`~/.cloudapp`" - exit!(1) -end - -email,password = File.read(config_file).split("\n") - -if ARGV[0].nil? - puts "You need to specify a file to upload." - exit!(1) -end - -urls = [] -ARGV.each do |x| - CloudApp.authenticate(email,password) - puts "Attempting to upload #{x}" - url = CloudApp::Item.create(:upload, {:file => x}).url - - # Say it for good measure. - puts "Uploaded #{x} to #{url}" - - # Get the embed link. - url = "#{url}/#{ARGV[0].split('/').last}" - urls << url -end - -# Copy it to your (Mac's) clipboard. -`echo '#{urls.join(',')}' | tr -d "\n" | pbcopy` diff --git a/bin/dont_index b/bin/dont_index new file mode 100755 index 00000000000..262128c40ad --- /dev/null +++ b/bin/dont_index @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +find $1 -type d \( -name "node_modules" -o -name "bower_modules" \) -exec touch "{}/.metadata_never_index" \; diff --git a/bin/dot b/bin/dot index 4d3455621c0..4417419fe3b 100755 --- a/bin/dot +++ b/bin/dot @@ -7,10 +7,10 @@ export ZSH=$HOME/.dotfiles # Set macOS defaults -$ZSH/macos/set-defaults.sh +#$ZSH/macos/set-defaults.sh # Install homebrew -$ZSH/homebrew/install.sh 2>&1 +$ZSH/homebrew/install.sh # Upgrade homebrew echo "› brew update" diff --git a/bin/fasd b/bin/fasd new file mode 100755 index 00000000000..b1e64f4148c --- /dev/null +++ b/bin/fasd @@ -0,0 +1,624 @@ +#!/usr/bin/env sh + +# Fasd (this file) can be sourced or executed by any POSIX compatible shell. + +# Fasd is originally written based on code from z (https://github.com/rupa/z) +# by rupa deadwyler under the WTFPL license. Most if not all of the code has +# been rewritten. + +# Copyright (C) 2011, 2012 by Wei Dai. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +fasd() { + + # make zsh do word splitting inside this function + [ "$ZSH_VERSION" ] && emulate sh && setopt localoptions + + case $1 in + --init) shift + while [ "$1" ]; do + case $1 in + env) + { # source rc files if present + [ -s "/etc/fasdrc" ] && . "/etc/fasdrc" + [ -s "$HOME/.fasdrc" ] && . "$HOME/.fasdrc" + + # set default options + [ -z "$_FASD_DATA" ] && _FASD_DATA="$HOME/.fasd" + [ -z "$_FASD_BLACKLIST" ] && _FASD_BLACKLIST="--help" + [ -z "$_FASD_SHIFT" ] && _FASD_SHIFT="sudo busybox" + [ -z "$_FASD_IGNORE" ] && _FASD_IGNORE="fasd ls echo" + [ -z "$_FASD_SINK" ] && _FASD_SINK=/dev/null + [ -z "$_FASD_TRACK_PWD" ] && _FASD_TRACK_PWD=1 + [ -z "$_FASD_MAX" ] && _FASD_MAX=2000 + [ -z "$_FASD_BACKENDS" ] && _FASD_BACKENDS=native + [ -z "$_FASD_FUZZY" ] && _FASD_FUZZY=2 + [ -z "$_FASD_VIMINFO" ] && _FASD_VIMINFO="$HOME/.viminfo" + [ -z "$_FASD_RECENTLY_USED_XBEL" ] && \ + _FASD_RECENTLY_USED_XBEL="$HOME/.local/share/recently-used.xbel" + + if [ -z "$_FASD_AWK" ]; then + # awk preferences + local awk; for awk in mawk gawk original-awk nawk awk; do + $awk "" && _FASD_AWK=$awk && break + done + fi + } >> "${_FASD_SINK:-/dev/null}" 2>&1 + ;; + + auto) cat <> "$_FASD_SINK" 2>&1 + +EOS + ;; + + posix-alias) cat <& /dev/null || fasd -d'; +EOS + ;; + + zsh-hook) cat <> "$_FASD_SINK" 2>&1 +} +autoload -Uz add-zsh-hook +add-zsh-hook preexec _fasd_preexec + +EOS + ;; + + bash-hook) cat <> "$_FASD_SINK" 2>&1 +} + +# add bash hook +case \$PROMPT_COMMAND in + *_fasd_prompt_func*) ;; + *) PROMPT_COMMAND="_fasd_prompt_func;\$PROMPT_COMMAND";; +esac + +EOS + ;; + + posix-hook) cat <> "$_FASD_SINK" 2>&1 +} +case \$PS1 in + *_fasd_ps1_func*) ;; + *) export PS1="\\\$(_fasd_ps1_func)\$PS1";; +esac + +EOS + ;; + + tcsh-hook) cat <& /dev/null'; +EOS + + ;; + + zsh-ccomp) cat <> "$_FASD_SINK" | \\ + sort -nr | sed 's/^[^ ]*[ ]*//' | while read -r line; do + compadd -U -V fasd "\$line" + done + compstate[insert]=menu # no expand + } + _fasd_zsh_word_complete_f() { _fasd_zsh_word_complete f ; } + _fasd_zsh_word_complete_d() { _fasd_zsh_word_complete d ; } + _fasd_zsh_word_complete_trigger() { + local _fasd_cur="\${words[CURRENT]}" + eval \$(fasd --word-complete-trigger _fasd_zsh_word_complete \$_fasd_cur) + } + # define zle widgets + zle -C fasd-complete complete-word _generic + zstyle ':completion:fasd-complete:*' completer _fasd_zsh_word_complete + zstyle ':completion:fasd-complete:*' menu-select + + zle -C fasd-complete-f complete-word _generic + zstyle ':completion:fasd-complete-f:*' completer _fasd_zsh_word_complete_f + zstyle ':completion:fasd-complete-f:*' menu-select + + zle -C fasd-complete-d complete-word _generic + zstyle ':completion:fasd-complete-d:*' completer _fasd_zsh_word_complete_d + zstyle ':completion:fasd-complete-d:*' menu-select +} + +EOS + ;; + + zsh-ccomp-install) cat <> "$_FASD_SINK" | sed -n "\\\$s/^.*'\\\\(.*\\\\)'/\\\\1/p") + \${COMP_LINE#* }" | while read -r line; do + quote_readline "\$line" 2>/dev/null || \\ + printf %q "\$line" 2>/dev/null && \\ + printf \\\\n + done) + local IFS=\$'\\n'; COMPREPLY=( \$RESULT ) +} +_fasd_bash_hook_cmd_complete() { + for cmd in \$*; do + complete -F _fasd_bash_cmd_complete \$cmd + done +} + +EOS + ;; + + bash-ccomp-install) cat <$`{}]\{1,\}/\1 /g' + ;; + + --proc) shift # process commands + # stop if we don't own $_FASD_DATA or $_FASD_RO is set + [ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return + + # blacklists + local each; for each in $_FASD_BLACKLIST; do + case " $* " in *\ $each\ *) return;; esac + done + + # shifts + while true; do + case " $_FASD_SHIFT " in + *\ $1\ *) shift;; + *) break;; + esac + done + + # ignores + case " $_FASD_IGNORE " in + *\ $1\ *) return;; + esac + + shift; fasd --add "$@" # add all arguments except command + ;; + + --add|-A) shift # add entries + # stop if we don't own $_FASD_DATA or $_FASD_RO is set + [ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return + + # find all valid path arguments, convert them to simplest absolute form + local paths="$(while [ "$1" ]; do + [ -e "$1" ] && printf %s\\n "$1"; shift + done | sed '/^[^/]/s@^@'"$PWD"'/@ + s@/\.\.$@/../@;s@/\(\./\)\{1,\}@/@g;:0 + s@[^/][^/]*//*\.\./@/@;t 0 + s@^/*\.\./@/@;s@//*@/@g;s@/\.\{0,1\}$@@;s@^$@/@' 2>> "$_FASD_SINK" \ + | tr '\n' '|')" + + # add current pwd if the option is set + [ "$_FASD_TRACK_PWD" = "1" -a "$PWD" != "$HOME" ] && paths="$paths|$PWD" + + [ -z "${paths##\|}" ] && return # stop if we have nothing to add + + # maintain the file + local tempfile + tempfile="$(mktemp "$_FASD_DATA".XXXXXX)" || return + $_FASD_AWK -v list="$paths" -v now="$(date +%s)" -v max="$_FASD_MAX" -F"|" ' + BEGIN { + split(list, files, "|") + for(i in files) { + path = files[i] + if(path == "") continue + paths[path] = path # array for checking + rank[path] = 1 + time[path] = now + } + } + $2 >= 1 { + if($1 in paths) { + rank[$1] = $2 + 1 / $2 + time[$1] = now + } else { + rank[$1] = $2 + time[$1] = $3 + } + count += $2 + } + END { + if(count > max) + for(i in rank) print i "|" 0.9*rank[i] "|" time[i] # aging + else + for(i in rank) print i "|" rank[i] "|" time[i] + }' "$_FASD_DATA" 2>> "$_FASD_SINK" >| "$tempfile" + if [ $? -ne 0 -a -f "$_FASD_DATA" ]; then + env rm -f "$tempfile" + else + env mv -f "$tempfile" "$_FASD_DATA" + fi + ;; + + --delete|-D) shift # delete entries + # stop if we don't own $_FASD_DATA or $_FASD_RO is set + [ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return + + # turn valid arguments into entry-deleting sed commands + local sed_cmd="$(while [ "$1" ]; do printf %s\\n "$1"; shift; done | \ + sed '/^[^/]/s@^@'"$PWD"'/@;s@/\.\.$@/../@;s@/\(\./\)\{1,\}@/@g;:0 + s@[^/][^/]*//*\.\./@/@;t 0 + s@^/*\.\./@/@;s@//*@/@g;s@/\.\{0,1\}$@@ + s@^$@/@;s@\([.[\/*^$]\)@\\\1@g;s@^\(.*\)$@/^\1|/d@' 2>> "$_FASD_SINK")" + + # maintain the file + local tempfile + tempfile="$(mktemp "$_FASD_DATA".XXXXXX)" || return + + sed "$sed_cmd" "$_FASD_DATA" 2>> "$_FASD_SINK" >| "$tempfile" + + if [ $? -ne 0 -a -f "$_FASD_DATA" ]; then + env rm -f "$tempfile" + else + env mv -f "$tempfile" "$_FASD_DATA" + fi + ;; + + --query) shift # query the db, --query [$typ ["$fnd" [$mode]]] + [ -f "$_FASD_DATA" ] || return # no db yet + [ "$1" ] && local typ="$1" + [ "$2" ] && local fnd="$2" + [ "$3" ] && local mode="$3" + + # cat all backends + local each _fasd_data; for each in $_FASD_BACKENDS; do + _fasd_data="$_fasd_data +$(fasd --backend $each)" + done + [ "$_fasd_data" ] || _fasd_data="$(cat "$_FASD_DATA")" + + # set mode specific code for calculating the prior + case $mode in + rank) local prior='times[i]';; + recent) local prior='sqrt(100000/(1+t-la[i]))';; + *) local prior='times[i] * frecent(la[i])';; + esac + + if [ "$fnd" ]; then # dafault matching + local bre="$(printf %s\\n "$fnd" | sed 's/\([*\.\\\[]\)/\\\1/g + s@ @[^|]*@g;s/\$$/|/')" + bre='^[^|]*'"$bre"'[^|/]*|' + local _ret="$(printf %s\\n "$_fasd_data" | grep "$bre")" + [ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do + [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" + done)" + if [ "$_ret" ]; then + _fasd_data="$_ret" + else # no case mathcing + _ret="$(printf %s\\n "$_fasd_data" | grep -i "$bre")" + [ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do + [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" + done)" + if [ "$_ret" ]; then + _fasd_data="$_ret" + elif [ "${_FASD_FUZZY:-0}" -gt 0 ]; then # fuzzy matching + local fuzzy_bre="$(printf %s\\n "$fnd" | \ + sed 's/\([*\.\\\[]\)/\\\1/g;s/\$$/|/ + s@\(\\\{0,1\}[^ ]\)@\1[^|/]\\{0,'"$_FASD_FUZZY"'\\}@g + s@ @[^|]*@g')" + fuzzy_bre='^[^|]*'"$fuzzy_bre"'[^|/]*|' + _ret="$(printf %s\\n "$_fasd_data" | grep -i "$fuzzy_bre")" + [ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do + [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" + done)" + [ "$_ret" ] && _fasd_data="$_ret" || _fasd_data= + fi + fi + else # no query arugments + _fasd_data="$(printf %s\\n "$_fasd_data" | while read -r line; do + [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" + done)" + fi + + # query the database + [ "$_fasd_data" ] && printf %s\\n "$_fasd_data" | \ + $_FASD_AWK -v t="$(date +%s)" -F"|" ' + function frecent(time) { + dx = t-time + if( dx < 3600 ) return 6 + if( dx < 86400 ) return 4 + if( dx < 604800 ) return 2 + return 1 + } + { + if(!paths[$1]) { + times[$1] = $2 + la[$1] = $3 + paths[$1] = 1 + } else { + times[$1] += $2 + if($3 > la[$1]) la[$1] = $3 + } + } + END { + for(i in paths) printf "%-10s %s\n", '"$prior"', i + }' - 2>> "$_FASD_SINK" + ;; + + --backend) + case $2 in + native) cat "$_FASD_DATA";; + viminfo) + < "$_FASD_VIMINFO" sed -n '/^>/{s@~@'"$HOME"'@ + s/^..// + p + }' | $_FASD_AWK -v t="$(date +%s)" '{ + t -= 60 + print $0 "|1|" t + }' + ;; + recently-used) + local nl="$(printf '\\\nX')"; nl="${nl%X}" # slash newline for sed + tr -d '\n' < "$_FASD_RECENTLY_USED_XBEL" | \ + sed 's@file:/@'"$nl"'@g;s@count="@'"$nl"'@g' | sed '1d;s/".*$//' | \ + tr '\n' '|' | sed 's@|/@'"$nl"'@g' | $_FASD_AWK -F'|' '{ + sum = 0 + for( i=2; i<=NF; i++ ) sum += $i + print $1 "|" sum + }' + ;; + *) eval "$2";; + esac + ;; + + *) # parsing logic and processing + local fnd= last= _FASD_BACKENDS="$_FASD_BACKENDS" _fasd_data= comp= exec= + while [ "$1" ]; do case $1 in + --complete) [ "$2" = "--" ] && shift; set -- $2; local lst=1 r=r comp=1;; + --query|--add|--delete|-A|-D) fasd "$@"; return $?;; + --version) [ -z "$comp" ] && echo "1.0.1" && return;; + --) while [ "$2" ]; do shift; fnd="$fnd $1"; last="$1"; done;; + -*) local o="${1#-}"; while [ "$o" ]; do case $o in + s*) local show=1;; + l*) local lst=1;; + i*) [ -z "$comp" ] && local interactive=1 show=1;; + r*) local mode=rank;; + t*) local mode=recent;; + e*) o="${o#?}"; if [ "$o" ]; then # there are characters after "-e" + local exec="$o" # anything after "-e" + else # use the next argument + local exec="${2:?"-e: Argument needed "}" + shift + fi; break;; + b*) o="${o#?}"; if [ "$o" ]; then + _FASD_BACKENDS="$o" + else + _FASD_BACKENDS="${2:?"-b: Argument needed"}" + shift + fi; break;; + B*) o="${o#?}"; if [ "$o" ]; then + _FASD_BACKENDS="$_FASD_BACKENDS $o" + else + _FASD_BACKENDS="$_FASD_BACKENDS ${2:?"-B: Argument needed"}" + shift + fi; break;; + a*) local typ=e;; + d*) local typ=d;; + f*) local typ=f;; + R*) local r=r;; + [0-9]*) local _fasd_i="$o"; break;; + h*) [ -z "$comp" ] && echo "fasd [options] [query ...] +[f|a|s|d|z] [options] [query ...] + options: + -s list paths with scores + -l list paths without scores + -i interactive mode + -e set command to execute on the result file + -b only use backend + -B add additional backend + -a match files and directories + -d match directories only + -f match files only + -r match by rank only + -t match by recent access only + -R reverse listing order + -h show a brief help message + -[0-9] select the nth entry + +fasd [-A|-D] [paths ...] + -A add paths + -D delete paths" >&2 && return;; + esac; o="${o#?}"; done;; + *) fnd="$fnd $1"; last="$1";; + esac; shift; done + + # guess whether the last query is selected from tab completion + case $last in + /?*) if [ -z "$show$lst" -a -${typ:-e} "$last" -a "$exec" ]; then + $exec "$last" + return + fi;; + esac + + local R; [ -z "$r" ] && R=r || R= # let $R be the opposite of $r + fnd="${fnd# }" + + local res + res="$(fasd --query 2>> "$_FASD_SINK")" # query the database + [ $? -gt 0 ] && return + if [ 0 -lt ${_fasd_i:-0} ] 2>> "$_FASD_SINK"; then + res="$(printf %s\\n "$res" | sort -n${R} | \ + sed -n "$_fasd_i"'s/^[^ ]*[ ]*//p')" + elif [ "$interactive" ] || [ "$exec" -a -z "$fnd$lst$show" -a -t 1 ]; then + if [ "$(printf %s "$res" | sed -n '$=')" -gt 1 ]; then + res="$(printf %s\\n "$res" | sort -n${R})" + printf %s\\n "$res" | sed = | sed 'N;s/\n/ /' | sort -nr >&2 + printf "> " >&2 + local i; read i; [ 0 -lt "${i:-0}" ] 2>> "$_FASD_SINK" || return 1 + fi + res="$(printf %s\\n "$res" | sed -n "${i:-1}"'s/^[^ ]*[ ]*//p')" + elif [ "$lst" ]; then + [ "$res" ] && printf %s\\n "$res" | sort -n${r} | sed 's/^[^ ]*[ ]*//' + return + elif [ "$show" ]; then + [ "$res" ] && printf %s\\n "$res" | sort -n${r} + return + elif [ "$fnd" ] && [ "$exec" -o ! -t 1 ]; then # exec or subshell + res="$(printf %s\\n "$res" | sort -n | sed -n '$s/^[^ ]*[ ]*//p')" + else # no args, show + [ "$res" ] && printf %s\\n "$res" | sort -n${r} + return + fi + if [ "$res" ]; then + fasd --add "$res" + [ -z "$exec" ] && exec='printf %s\n' + $exec "$res" + fi + ;; + esac +} + +fasd --init env + +case $- in + *i*) ;; # assume being sourced, do nothing + *) # assume being executed as an executable + if [ -x "$_FASD_SHELL" -a -z "$_FASD_SET" ]; then + _FASD_SET=1 exec $_FASD_SHELL "$0" "$@" + else + fasd "$@" + fi;; +esac + diff --git a/bin/git-author-rewrite b/bin/git-author-rewrite new file mode 100755 index 00000000000..5876a35b258 --- /dev/null +++ b/bin/git-author-rewrite @@ -0,0 +1,19 @@ +#!/bin/sh + +git filter-branch --env-filter ' + +OLD_EMAIL="gytis.raciukaitis@gmail.com" +CORRECT_NAME="Gytis Raciukaitis" +CORRECT_EMAIL="gytis_raciukaitis@lt.ibm.com" + +if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ] +then + export GIT_COMMITTER_NAME="$CORRECT_NAME" + export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL" +fi +if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ] +then + export GIT_AUTHOR_NAME="$CORRECT_NAME" + export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL" +fi +' --tag-name-filter cat -- --branches --tags diff --git a/bin/gitio b/bin/gitio deleted file mode 100755 index 2cd36a3e6d6..00000000000 --- a/bin/gitio +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env ruby -# Usage: gitio URL [CODE] -# -# Turns a github.com URL -# into a git.io URL -# -# Created by @defunkt: -# https://gist.github.com/1209316 -# -# Copies the git.io URL to your clipboard. - -url = ARGV[0] -code = ARGV[1] - -if url !~ /^(https?:\/\/)?(gist\.)?github.com/ - abort "* github.com URLs only" -end - -if url !~ /^http/ - url = "https://#{url}" -end - -if code - code = "-F code=#{code}" -end - -output = `curl -i https://git.io -F 'url=#{url}' #{code} 2> /dev/null` -if output =~ /Location: (.+)\n?/ - puts $1 - `echo #$1 | pbcopy` -else - puts output -end diff --git a/bin/headers b/bin/headers deleted file mode 100755 index 9dd1f72c6e9..00000000000 --- a/bin/headers +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# -# https://github.com/rtomayko/dotfiles/blob/rtomayko/bin/headers - -curl -sv "$@" 2>&1 >/dev/null | - grep -v "^\*" | - grep -v "^}" | - cut -c3- \ No newline at end of file diff --git a/bin/movieme b/bin/movieme deleted file mode 100755 index 115a364f0fa..00000000000 --- a/bin/movieme +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -# -# MOVIE ME as in: "MOVIE ME AN ANIMATED GIF FROM THIS MOVIE, DAMMIT" -# -# Creates an animated gif from a movie file. Uploads to CloudApp. You must also -# have `gifme` and `cloudapp` in your $PATH. -# -# $1 - the path to the movie we're converting. -# $2 - the start time of the finished product. -# This can be in seconds, or it also accepts the "hh:mm:ss[.xxx]" format. -# $3 - the duration of the video sequence. -# This can be in seconds, or it also accepts the "hh:mm:ss[.xxx]" format. -# -# Examples: -# -# movieme -# ~/Desktop/dr-strangelove.mp4 23:12 3 -# ~/Desktop/holman-backflip-on-fire.mov 3.9 1.75 - -# cleanup -rm -rf /tmp/movieme - -# create tmp dir -mkdir -p /tmp/movieme - -# split the movie into constituent frames -ffmpeg -i "$1" -f image2 -vf "scale=iw*sar:ih" -ss $2 -t $3 -r 7 /tmp/movieme/d-%05d.png - -# ANIMATE -gifme /tmp/movieme/* -d 0 diff --git a/bin/mustacheme b/bin/mustacheme deleted file mode 100755 index ad28a39f6e2..00000000000 --- a/bin/mustacheme +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh -# -# mustacheme -# expanded from an idea from Rick Olson (@technoweenie) -# -# Takes a .gif, splits it into constituent frames, mustaches each, restitches -# the gif, and uploads to cloudapp. -# -# This leverages the nifty service mustachify.me, which will analyze your photo, -# identify faces, and add a mustache to your image. -# -# If the .gif is a remote file, we'll download it and blow it up locally. -# -# $1 - the path of the gif -# -# Examples: -# -# mustacheme holman-jumping-off-cliff-into-butter.gif -# mustacheme http://github.com/holman/butter/blob/master/holman-butter.gif -# -# Dependencies: -# -# - ImageMagick. If you're on a Mac, run: -# brew install imagemagick -# - wget -# - cloudapp: https://github.com/holman/dotfiles/blob/master/bin/cloudapp -# - gifme: https://github.com/holman/gifme - -set -e - -# Set up mustacheme temporary working directory -output=/tmp/mustacheme -rm -rf $output -mkdir $output - -if [[ $1 == http* ]] -then - wget $1 -O /tmp/mustache-download.gif - file=/tmp/mustache-download.gif -else - file="$1" -fi - -# Blow apart the GIF -convert $1 -coalesce $output/frame_%03d.gif - -# Mustache each frame -for frame in $output/*.gif -do - url=$(cloudapp $frame | grep Uploaded | awk '{print substr($0, index($0, "http://"))}') - url="$url/$(basename $frame)" - wget "http://mustachify.me/?src=$url" -O "$frame-stache" -done - -# Ding! Fries are done. -gifme $output/*-stache -d 0 diff --git a/bin/res b/bin/res deleted file mode 100755 index 40afcfdf55e..00000000000 --- a/bin/res +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/osascript -# -# A small command line script to change screen resolutions on Mountain Lion. -# -# Primarily I switch between two resolutions on my Retina MacBook Pro: Retina, -# and the full resolution setting. This means for particular apps I use, I can -# quickly jump between seeing more pixels and less. -# -# There doesn't appear to be an easy way to do this without just using -# AppleScript to automate clicking buttons, so that's what this does. -# -# Most of this script is adapted from this helpful answer: -# -# http://apple.stackexchange.com/a/91590 -# -# Make sure "Enable access for assistive devices" is checked in the -# Accessibility section of System Properties. - -local index1, index2 - -set index1 to 3 -- 1440 x 900 (Best for Retina) -set index2 to 5 -- 1920 x 1200 (More Space) - -tell application "System Preferences" - reveal anchor "displaysDisplayTab" of pane "com.apple.preference.displays" -end tell - -local indexToUse - -tell application "System Events" to tell process "System Preferences" to tell window "Built-in Retina Display" - - click radio button "Display" of tab group 1 - click radio button "Scaled" of radio group 1 of tab group 1 - - -- Click the "Scaled" radio button - click radio button "Scaled" of radio group 1 of tab group 1 - - tell tab group 1 - tell radio group 1 of group 1 - -- Depending on what scale option/index is current selected, set the appropriate new option/index to use - if (value of radio button index1) is true then - set indexToUse to index2 - else if (value of radio button index2) is true then - set indexToUse to index1 - end if - - -- Click the radio button for the new scale option/index - click radio button indexToUse - end tell - end tell - - -- If option/index 1 is selected a warning prompt is displayed, click the OK button to dismiss the prompt - if indexToUse = 1 then - click button "OK" of sheet 1 - end if -end tell - -tell application "System Preferences" - quit -end tell diff --git a/bin/todo b/bin/todo deleted file mode 100755 index 8a62cbde29a..00000000000 --- a/bin/todo +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -# -# Creates something for me to do. -# -# I've used literally every todo list, app, program, script, everything. Even -# the ones you are building and haven't released yet. -# -# I've found that they're all nice in their nice ways, but I still don't use -# them, thus defeating the purpose of a todo list. -# -# All `todo` does is put a file on my Desktop with the filename given. That's -# it. I aggressively prune my desktop of old tasks and keep one or two on there -# at a time. Once I've finished a todo, I just delete the file. That's it. -# -# Millions of dollars later and `touch` wins. - -# Run our new web 2.0 todo list application and raise millions of VC dollars. -touch ~/Desktop/"$*" diff --git a/bin/vault-auth b/bin/vault-auth new file mode 100755 index 00000000000..84ee43f17ad --- /dev/null +++ b/bin/vault-auth @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +source $HOME/.localrc + +vault login -method=github \ No newline at end of file diff --git a/docker/aliases.zsh b/docker/aliases.zsh deleted file mode 100644 index 17b10f6bc90..00000000000 --- a/docker/aliases.zsh +++ /dev/null @@ -1,2 +0,0 @@ -alias d='docker $*' -alias d-c='docker-compose $*' diff --git a/dotnet/install.sh b/dotnet/install.sh new file mode 100755 index 00000000000..4f8bfee0b91 --- /dev/null +++ b/dotnet/install.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +info () { + printf "\r [ \033[00;34m..\033[0m ] $1\n" +} + +user () { + printf "\r [ \033[0;33m??\033[0m ] $1\n" +} + +success () { + printf "\r\033[2K [ \033[00;32mOK\033[0m ] $1\n" +} + +fail () { + printf "\r\033[2K [\033[0;31mFAIL\033[0m] $1\n" + echo '' + exit +} + +setup_nuget () { + [ -f ~/.config/NuGet/NuGet.Config ] && return; + + info 'setup NuGet' + user ' - What is your MyGet api key?' + read -e nuget_apikey + + nuget setapikey $nuget_apikey -source https://trustpilot.myget.org/F/libraries/ + + user ' - What is your MyGet username?' + read -e myget_username + user ' - What is your MyGet password?' + read -s myget_password + + nuget sources add -name 'Trustpilot Myget Libraries' -source https://trustpilot.myget.org/F/libraries/ -user $myget_username -pass "${myget_password}" -StorePasswordInClearText + + # Fix dotnet looking into wrong location for config + rm -rf ~/.nuget/NuGet/NuGet.Config + mkdir -p ~/.nuget/NuGet + ln -s ~/.config/NuGet/NuGet.Config ~/.nuget/NuGet/NuGet.Config +} + +setup_nuget +success "./dotnet/install.sh" diff --git a/dotnet/path.zsh b/dotnet/path.zsh new file mode 100644 index 00000000000..4ae97c25e14 --- /dev/null +++ b/dotnet/path.zsh @@ -0,0 +1,4 @@ + + +# Add dotnet path +export PATH="$PATH:/usr/local/share/dotnet:/Library/Frameworks/Mono.framework/Versions/Current/Commands" diff --git a/git/aliases.zsh b/git/aliases.zsh index a442f4bbdec..5ca9fb82462 100644 --- a/git/aliases.zsh +++ b/git/aliases.zsh @@ -6,18 +6,65 @@ then alias git=$hub_path fi -# The rest of my fun git aliases -alias gl='git pull --prune' -alias glog="git log --graph --pretty=format:'%Cred%h%Creset %an: %s - %Creset %C(yellow)%d%Creset %Cgreen(%cr)%Creset' --abbrev-commit --date=relative" -alias gp='git push origin HEAD' - -# Remove `+` and `-` from start of diff lines; just rely upon color. -alias gd='git diff --color | sed "s/^\([^-+ ]*\)[-+ ]/\\1/" | less -r' - -alias gc='git commit' -alias gca='git commit -a' -alias gco='git checkout' -alias gcb='git copy-branch-name' -alias gb='git branch' -alias gs='git status -sb' # upgrade your git if -sb breaks for you. it's fun. -alias gac='git add -A && git commit -m' +# Git Aliases +alias gs='git status' +alias gstsh='git stash' +alias gst='git stash' +alias gsp='git stash pop' +alias gsa='git stash apply' +alias gsh='git show' +alias gshw='git show' +alias gshow='git show' +alias gi='vim .gitignore' +alias gcm='git ci -m' +alias gcim='git ci -m' +alias gci='git ci' +alias gco='git co' +alias gcp='git cp' +alias ga='git add -A' +alias gap='git add -p' +alias guns='git unstage' +alias gunc='git uncommit' +alias gm='git merge' +alias gms='git merge --squash' +alias gam='git amend --reset-author' +alias grv='git remote -v' +alias grr='git remote rm' +alias grad='git remote add' +alias gr='git rebase' +alias gra='git rebase --abort' +alias ggrc='git rebase --continue' +alias gbi='git rebase --interactive' +alias gl='git l' +alias glg='git l' +alias glog='git l' +alias co='git co' +alias gf='git fetch' +alias gfp='git fetch --prune' +alias gfa='git fetch --all' +alias gfap='git fetch --all --prune' +alias gfch='git fetch' +alias gd='git diff' +alias gb='git b' +# Staged and cached are the same thing +alias gdc='git diff --cached -w' +alias gds='git diff --staged -w' +alias gpub='grb publish' +alias gtr='grb track' +alias gpl='git pull' +alias gplr='git pull --rebase' +alias gps='git push' +alias gpsh='git push -u origin `git rev-parse --abbrev-ref HEAD`' +alias gnb='git nb' # new branch aka checkout -b +alias grs='git reset' +alias grsh='git reset --hard' +alias gcln='git clean' +alias gclndf='git clean -df' +alias gclndfx='git clean -dfx' +alias gsm='git submodule' +alias gsmi='git submodule init' +alias gsmu='git submodule update' +alias gt='git t' +alias gbg='git bisect good' +alias gbb='git bisect bad' +alias gdmb='git branch --merged | grep -v "\*" | xargs -n 1 git branch -d' diff --git a/git/completion.zsh b/git/completion.zsh index 81fd2ec7e83..0a609c86ec3 100644 --- a/git/completion.zsh +++ b/git/completion.zsh @@ -1,3 +1,8 @@ +# Makes git auto completion faster favouring for local completions +__git_files () { + _wanted files expl 'local files' _files +} + # Uses git's autocompletion for inner commands. Assumes an install of git's # bash `git-completion` script at $completion below (this is where Homebrew # tosses it, at least). diff --git a/git/gitconfig.symlink b/git/gitconfig.symlink index c936c2b2cf2..7e4ccf2ee61 100644 --- a/git/gitconfig.symlink +++ b/git/gitconfig.symlink @@ -1,33 +1,142 @@ -# Local/private config goes in the include -[include] - path = ~/.gitconfig.local +# set your user tokens as environment variables, such as ~/.secrets +# See the README for examples. [hub] protocol = https +[color] + ui = true +[color "branch"] + current = yellow reverse + local = yellow + remote = green +[color "diff"] + meta = yellow bold + frag = magenta bold + old = red + new = green [alias] - co = checkout promote = !$ZSH/bin/git-promote wtf = !$ZSH/bin/git-wtf rank-contributors = !$ZSH/bin/git-rank-contributors count = !git shortlog -sn -[color] - diff = auto - status = auto - branch = auto - ui = true -[core] - excludesfile = ~/.gitignore - editor = vim -[apply] - whitespace = nowarn + + # add + a = add # add + chunkyadd = add --patch # stage commits chunk by chunk + + # via http://blog.apiaxle.com/post/handy-git-tips-to-stop-you-getting-fired/ + snapshot = !git stash save "snapshot: $(date)" && git stash apply "stash@{0}" + snapshots = !git stash list --grep snapshot + + #via http://stackoverflow.com/questions/5188320/how-can-i-get-a-list-of-git-branches-ordered-by-most-recent-commit + recent-branches = !git for-each-ref --count=15 --sort=-committerdate refs/heads/ --format='%(refname:short)' + + # branch + b = branch -v # branch (verbose) + + # commit + c = commit -m # commit with message + ca = commit -am # commit all with message + ci = commit # commit + amend = commit --amend # ammend your last commit + ammend = commit --amend # ammend your last commit + + # checkout + co = checkout # checkout + nb = checkout -b # create and switch to a new branch (mnemonic: "git new branch branchname...") + + # cherry-pick + cp = cherry-pick -x # grab a change from a branch + + # diff + d = diff # diff unstaged changes + dc = diff --cached # diff staged changes + last = diff HEAD^ # diff last committed change + + # log + l = log --graph --date=short + changes = log --pretty=format:\"%h %cr %cn %Cgreen%s%Creset\" --name-status + short = log --pretty=format:\"%h %cr %cn %Cgreen%s%Creset\" + simple = log --pretty=format:\" * %s\" + shortnocolor = log --pretty=format:\"%h %cr %cn %s\" + + # pull + pl = pull # pull + + # push + ps = push # push + + # rebase + rc = rebase --continue # continue rebase + rs = rebase --skip # skip rebase + + # remote + r = remote -v # show remotes (verbose) + + # reset + unstage = reset HEAD # remove files from index (tracking) + uncommit = reset --soft HEAD^ # go back before last commit, with files in uncommitted state + filelog = log -u # show changes to a file + mt = mergetool # fire up the merge tool + + # stash + ss = stash # stash changes + sl = stash list # list stashes + sa = stash apply # apply stash (restore changes) + sd = stash drop # drop stashes (destory changes) + + # status + s = status # status + st = status # status + stat = status # status + + # tag + t = tag -n # show tags with lines of each tag message + + # svn helpers + svnr = svn rebase + svnd = svn dcommit + svnl = svn log --oneline --show-commit +[format] + pretty = format:%C(blue)%ad%Creset %C(yellow)%h%C(green)%d%Creset %C(blue)%s %C(magenta) [%an]%Creset [mergetool] - keepBackup = false -[difftool] prompt = false -[help] - autocorrect = 1 +[mergetool "nvimdiff"] + cmd="nvim -c 'Gdiff' $MERGED" # use fugitive.vim for 3-way merge + keepbackup=false +[merge] + summary = true + verbosity = 1 + tool = mvimdiff +[apply] + whitespace = nowarn +[branch] + autosetupmerge = true [push] - # See `git help config` (search for push.default) - # for more information on different options of the below setting. - # - # Setting to git 2.0 default to suppress warning message - default = simple + # 'git push' will push the current branch to its tracking branch + # the usual default is to push all branches + default = upstream +[core] + autocrlf = false + editor = vim + excludesfile = /Users/gyr/.gitignore +[advice] + statusHints = false +[diff] + # Git diff will use (i)ndex, (w)ork tree, (c)ommit and (o)bject + # instead of a/b/c/d as prefixes for patches + mnemonicprefix = true + algorithm = patience +[rerere] + # Remember my merges + # http://gitfu.wordpress.com/2008/04/20/git-rerere-rereremember-what-you-did-last-time/ + enabled = true +[include] + Path = ~/.gitconfig.local +[difftool "sourcetree"] + cmd = opendiff \"$LOCAL\" \"$REMOTE\" + path = +[mergetool "sourcetree"] + cmd = /Applications/Sourcetree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\" + trustExitCode = true +[url "git@github.com:"] + insteadOf = https://github.com/ diff --git a/git/gitignore.symlink b/git/gitignore.symlink index 6fd41c0f56e..31af1166765 100644 --- a/git/gitignore.symlink +++ b/git/gitignore.symlink @@ -1,3 +1,47 @@ +# OSX taken from: https://github.com/github/gitignore/blob/master/Global/OSX.gitignore +# ---------------------------------------------------------------------------------------------- .DS_Store +# Thumbnails +._* +# Files that might appear on external disk +.Spotlight-V100 +.Trashes + +# Windows taken from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore +# ---------------------------------------------------------------------------------------------- +# Windows image file caches +Thumbs.db + +# Folder config file +Desktop.ini + +# Tags taken from: https://github.com/github/gitignore/blob/master/Global/Tags.gitignore +# ---------------------------------------------------------------------------------------------- +# Ignore tags created by etags, ctags, gtags (GNU global) and cscope +TAGS +!TAGS/ +tags +!tags/ +.tags +.tags1 +gtags.files +GTAGS +GRTAGS +GPATH +cscope.files +cscope.out +cscope.in.out +cscope.po.out + +# Vim taken from: https://github.com/github/gitignore/blob/master/Global/vim.gitignore +# ---------------------------------------------------------------------------------------------- +[._]*.s[a-w][a-z] +[._]s[a-w][a-z] +*.un~ +Session.vim +.netrwhist *~ -*.swp + +# SASS +# ---------------------------------------------------------------------------------------------- +.sass-cache diff --git a/git/install.sh b/git/install.sh new file mode 100755 index 00000000000..f189430162b --- /dev/null +++ b/git/install.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +info () { + printf "\r [ \033[00;34m..\033[0m ] $1\n" +} + +user () { + printf "\r [ \033[0;33m??\033[0m ] $1\n" +} + +success () { + printf "\r\033[2K [ \033[00;32mOK\033[0m ] $1\n" +} + +fail () { + printf "\r\033[2K [\033[0;31mFAIL\033[0m] $1\n" + echo '' + exit +} + +setup_gitconfig () { + if ! [ -f ~/.gitconfig.local ] + then + + git_credential='cache' + if [ "$(uname -s)" == "Darwin" ] + then + git_credential='osxkeychain' + fi + + user ' - What is your github author name?' + read -e git_authorname + user ' - What is your github author email?' + read -e git_authoremail + + sed -e "s/AUTHORNAME/$git_authorname/g" -e "s/AUTHOREMAIL/$git_authoremail/g" -e "s/GIT_CREDENTIAL_HELPER/$git_credential/g" git/gitconfig.local.symlink.example > ~/.gitconfig.local + fi +} + +setup_gitconfig +success "./git/install.sh" \ No newline at end of file diff --git a/go/install.sh b/go/install.sh new file mode 100755 index 00000000000..78d32dfaa60 --- /dev/null +++ b/go/install.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +info () { + printf "\r [ \033[00;34m..\033[0m ] $1\n" +} + +success () { + printf "\r\033[2K [ \033[00;32mOK\033[0m ] $1\n" +} + +info "Installing golang tools" + +source $(dirname $0)/path.zsh + +go get -v \ + github.com/mdempsky/gocode \ + github.com/uudashr/gopkgs/cmd/gopkgs \ + github.com/ramya-rao-a/go-outline \ + github.com/acroca/go-symbols \ + golang.org/x/tools/cmd/guru \ + golang.org/x/tools/cmd/gorename \ + github.com/derekparker/delve/cmd/dlv \ + github.com/rogpeppe/godef \ + github.com/sqs/goreturns \ + github.com/golang/lint/golint + +success "Installed golang tools" diff --git a/go/path.zsh b/go/path.zsh index 71bd1c338a7..ce5951fb0f7 100644 --- a/go/path.zsh +++ b/go/path.zsh @@ -1,2 +1,3 @@ -export GOPATH=$PROJECTS/go -export PATH="$GOPATH/bin:$PATH" +export GOPATH="${PROJECTS}/go" +export GOROOT="$(brew --prefix golang)/libexec" +export PATH="$GOPATH/bin:$GOROOT/bin:$PATH" diff --git a/google-cloud-sdk/completion.zsh b/google-cloud-sdk/completion.zsh new file mode 100644 index 00000000000..eb5c214971d --- /dev/null +++ b/google-cloud-sdk/completion.zsh @@ -0,0 +1 @@ +source '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc' \ No newline at end of file diff --git a/google-cloud-sdk/path.zsh b/google-cloud-sdk/path.zsh new file mode 100644 index 00000000000..5e17cd2a9d1 --- /dev/null +++ b/google-cloud-sdk/path.zsh @@ -0,0 +1 @@ +source '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc' \ No newline at end of file diff --git a/homebrew/install.sh b/homebrew/install.sh index f01dbdc7f75..eebf4c71c38 100755 --- a/homebrew/install.sh +++ b/homebrew/install.sh @@ -4,12 +4,16 @@ # # This installs some of the common dependencies needed (or at least desired) # using Homebrew. - # Check for Homebrew +info () { + printf "\r [ \033[00;34m..\033[0m ] $1\n" +} +success () { + printf "\r\033[2K [ \033[00;32mOK\033[0m ] $1\n" +} if test ! $(which brew) then echo " Installing Homebrew for you." - # Install the correct homebrew for each OS type if test "$(uname)" = "Darwin" then @@ -18,7 +22,5 @@ then then ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install)" fi - fi - -exit 0 +success "./homebrew/install.sh" \ No newline at end of file diff --git a/macos/install.sh b/macos/install.sh index b8a11de1a9f..a379e0fe60c 100755 --- a/macos/install.sh +++ b/macos/install.sh @@ -1,7 +1,15 @@ +#!/usr/bin/env bash # The Brewfile handles Homebrew-based app and library installs, but there may # still be updates and installables in the Mac App Store. There's a nifty # command line interface to it that we can use to just install everything, so # yeah, let's do that. +info () { + printf "\r [ \033[00;34m..\033[0m ] $1\n" +} + +success () { + printf "\r\033[2K [ \033[00;32mOK\033[0m ] $1\n" +} -echo "› sudo softwareupdate -i -a" sudo softwareupdate -i -a +success "./macos/install.sh" \ No newline at end of file diff --git a/macos/set-defaults.sh b/macos/set-defaults.sh index 03d6f2d9dbe..bf70669a1ab 100755 --- a/macos/set-defaults.sh +++ b/macos/set-defaults.sh @@ -1,41 +1,307 @@ -# Sets reasonable macOS defaults. -# -# Or, in other words, set shit how I like in macOS. -# -# The original idea (and a couple settings) were grabbed from: -# https://github.com/mathiasbynens/dotfiles/blob/master/.macos -# -# Run ./set-defaults.sh and you'll be good to go. - -# Disable press-and-hold for keys in favor of key repeat. -defaults write -g ApplePressAndHoldEnabled -bool false - -# Use AirDrop over every interface. srsly this should be a default. -defaults write com.apple.NetworkBrowser BrowseAllInterfaces 1 - -# Always open everything in Finder's list view. This is important. -defaults write com.apple.Finder FXPreferredViewStyle Nlsv - -# Show the ~/Library folder. -chflags nohidden ~/Library - -# Set a really fast key repeat. -defaults write NSGlobalDomain KeyRepeat -int 1 - -# Set the Finder prefs for showing a few different volumes on the Desktop. -defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true -defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true - -# Run the screensaver if we're in the bottom-left hot corner. -defaults write com.apple.dock wvous-bl-corner -int 5 -defaults write com.apple.dock wvous-bl-modifier -int 0 - -# Hide Safari's bookmark bar. -defaults write com.apple.Safari ShowFavoritesBar -bool false - -# Set up Safari for development. -defaults write com.apple.Safari IncludeInternalDebugMenu -bool true -defaults write com.apple.Safari IncludeDevelopMenu -bool true -defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true -defaults write com.apple.Safari "com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled" -bool true -defaults write NSGlobalDomain WebKitDeveloperExtras -bool true +#!/usr/bin/env bash + +# Thanks to Mathias Bynens! https://mths.be/macos + +# Ask for the administrator password upfront +sudo -v + +# Keep-alive: update existing `sudo` time stamp until `.macos` has finished +while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & + +############################################################################### +# General UI/UX # +############################################################################### + +# Set standby delay to 24 hours (default is 1 hour) +#sudo pmset -a standbydelay 86400 + +# Disable the sound effects on boot +sudo nvram SystemAudioVolume=" " + +# Set sidebar icon size to small +defaults write NSGlobalDomain NSTableViewDefaultSizeMode -int 1 + +# Increase window resize speed for Cocoa applications +defaults write NSGlobalDomain NSWindowResizeTime -float 0.001 + +# Automatically quit printer app once the print jobs complete +defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true + +# Disable the “Are you sure you want to open this application?” dialog +defaults write com.apple.LaunchServices LSQuarantine -bool false + +# Remove duplicates in the “Open With” menu (also see `lscleanup` alias) +/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user + +# Reveal IP address, hostname, OS version, etc. when clicking the clock +# in the login window +sudo defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo HostName + +# Check for software updates daily, not just once per week +defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1 + +# Disable smart quotes as they’re annoying when typing code +defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false + +# Disable smart dashes as they’re annoying when typing code +defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false + +############################################################################### +# Trackpad, mouse, keyboard, Bluetooth accessories, and input # +############################################################################### + +# Increase sound quality for Bluetooth headphones/headsets +defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40 + +# Set language and text formats +# Note: if you’re in the US, replace `EUR` with `USD`, `Centimeters` with +# `Inches`, `en_GB` with `en_US`, and `true` with `false`. +defaults write NSGlobalDomain AppleLanguages -array "en" "nl" +defaults write NSGlobalDomain AppleLocale -string "en_US@currency=EUR" +defaults write NSGlobalDomain AppleMeasurementUnits -string "Centimeters" +defaults write NSGlobalDomain AppleMetricUnits -bool true + +# Set the timezone; see `sudo systemsetup -listtimezones` for other values +sudo systemsetup -settimezone "Europe/Vilnius" > /dev/null + +# Disable auto-correct +defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false + +############################################################################### +# Screen # +############################################################################### + +# Require password immediately after sleep or screen saver begins +defaults write com.apple.screensaver askForPassword -int 1 +defaults write com.apple.screensaver askForPasswordDelay -int 0 + +############################################################################### +# Finder # +############################################################################### + +# Finder: disable window animations and Get Info animations +defaults write com.apple.finder DisableAllAnimations -bool true + +# Finder: show path bar +defaults write com.apple.finder ShowPathbar -bool true + +# When performing a search, search the current folder by default +defaults write com.apple.finder FXDefaultSearchScope -string "SCcf" + +# Disable the warning when changing a file extension +defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false + +# Enable snap-to-grid for icons on the desktop and in other icon views +/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:arrangeBy grid" $HOME/Library/Preferences/com.apple.finder.plist +/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:arrangeBy grid" $HOME/Library/Preferences/com.apple.finder.plist +/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:arrangeBy grid" $HOME/Library/Preferences/com.apple.finder.plist + +# Increase grid spacing for icons on the desktop and in other icon views +/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:gridSpacing 100" $HOME/Library/Preferences/com.apple.finder.plist +/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:gridSpacing 100" $HOME/Library/Preferences/com.apple.finder.plist +/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:gridSpacing 100" $HOME/Library/Preferences/com.apple.finder.plist + +# Increase the size of icons on the desktop and in other icon views +/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:iconSize 40" $HOME/Library/Preferences/com.apple.finder.plist +/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:iconSize 40" $HOME/Library/Preferences/com.apple.finder.plist +/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:iconSize 40" $HOME/Library/Preferences/com.apple.finder.plist + +# Use list view in all Finder windows by default +# Four-letter codes for the other view modes: `icnv`, `clmv`, `Flwv` +defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv" + +# Disable the warning before emptying the Trash +defaults write com.apple.finder WarnOnEmptyTrash -bool false + +# Enable AirDrop over Ethernet and on unsupported Macs running Lion +defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true + +# Show the ~/Library folder +chflags nohidden $HOME/Library + +# Expand the following File Info panes: +# “General”, “Open with”, and “Sharing & Permissions” +defaults write com.apple.finder FXInfoPanesExpanded -dict \ + General -bool true \ + OpenWith -bool true \ + Privileges -bool true + +# Auto hide menu bar +defaults write NSGlobalDomain _HIHideMenuBar -bool false + +############################################################################### +# Dock, Dashboard, and hot corners # +############################################################################### + +# Dark menu bar and dock +defaults write $HOME/Library/Preferences/.GlobalPreferences.plist AppleInterfaceTheme -string "Dark" + +# Enable highlight hover effect for the grid view of a stack (Dock) +defaults write com.apple.dock mouse-over-hilite-stack -bool true + +# Change minimize/maximize window effect +defaults write com.apple.dock mineffect -string "scale" + +# Minimize windows into their application’s icon +defaults write com.apple.dock minimize-to-application -bool true + +# Wipe all (default) app icons from the Dock +# This is only really useful when setting up a new Mac, or if you don’t use +# the Dock to launch apps. +defaults write com.apple.dock persistent-apps -array + +# Show only open applications in the Dock +defaults write com.apple.dock static-only -bool false + +# Group windows by application in Mission Control +defaults write com.apple.dock expose-group-by-app -bool true + +# Disable Dashboard +defaults write com.apple.dashboard mcx-disabled -bool true + +# Don’t show Dashboard as a Space +defaults write com.apple.dock dashboard-in-overlay -bool true + +# Remove the auto-hiding Dock delay +defaults write com.apple.dock autohide-delay -float 0 + +# Remove the animation when hiding/showing the Dock +defaults write com.apple.dock autohide-time-modifier -float 0 + +# Automatically hide and show the Dock +defaults write com.apple.dock autohide -bool true + +# Add iOS & Watch Simulator to Launchpad +#sudo ln -sf "/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app" "/Applications/Simulator.app" +#sudo ln -sf "/Applications/Xcode.app/Contents/Developer/Applications/Simulator (Watch).app" "/Applications/Simulator (Watch).app" + +# Hot corners +# Possible values: +# 0: no-op +# 2: Mission Control +# 3: Show application windows +# 4: Desktop +# 5: Start screen saver +# 6: Disable screen saver +# 7: Dashboard +# 10: Put display to sleep +# 11: Launchpad +# 12: Notification Center +# Top left screen corner → Mission Control +# defaults write com.apple.dock wvous-tl-corner -int 2 +# defaults write com.apple.dock wvous-tl-modifier -int 0 +# Top right screen corner → Put display to sleep +defaults write com.apple.dock wvous-tr-corner -int 10 +defaults write com.apple.dock wvous-tr-modifier -int 0 +# Bottom left screen corner → Start screen saver +# defaults write com.apple.dock wvous-bl-corner -int 5 +# defaults write com.apple.dock wvous-bl-modifier -int 0 +# Bottom right screen corner → Launchpad +defaults write com.apple.dock wvous-br-corner -int 11 +defaults write com.apple.dock wvous-br-modifier -int 0 + +############################################################################### +# Safari & WebKit # +############################################################################### + +# Privacy: don’t send search queries to Apple +defaults write com.apple.Safari UniversalSearchEnabled -bool false +defaults write com.apple.Safari SuppressSearchSuggestions -bool true + +############################################################################### +# Mail # +############################################################################### + +# Disable send and reply animations in Mail.app +defaults write com.apple.mail DisableReplyAnimations -bool true +defaults write com.apple.mail DisableSendAnimations -bool true + +# Copy email addresses as `foo@example.com` instead of `Foo Bar ` in Mail.app +defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false + +# Disable inline attachments (just show the icons) +defaults write com.apple.mail DisableInlineAttachmentViewing -bool true + +# Disable automatic spell checking +defaults write com.apple.mail SpellCheckingBehavior -string "NoSpellCheckingEnabled" + +############################################################################### +# Terminal & iTerm 2 # +############################################################################### + +# Only use UTF-8 in Terminal.app +defaults write com.apple.terminal StringEncodings -array 4 + +# Don’t display the annoying prompt when quitting iTerm +defaults write com.googlecode.iterm2 PromptOnQuit -bool false + +############################################################################### +# Time Machine # +############################################################################### + +# Prevent Time Machine from prompting to use new hard drives as backup volume +defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true + +############################################################################### +# Activity Monitor # +############################################################################### + +# Show the main window when launching Activity Monitor +defaults write com.apple.ActivityMonitor OpenMainWindow -bool true + +# Visualize CPU usage in the Activity Monitor Dock icon +defaults write com.apple.ActivityMonitor IconType -int 5 + +# Show all processes in Activity Monitor +defaults write com.apple.ActivityMonitor ShowCategory -int 0 + +# Sort Activity Monitor results by CPU usage +defaults write com.apple.ActivityMonitor SortColumn -string "CPUUsage" +defaults write com.apple.ActivityMonitor SortDirection -int 0 + +############################################################################### +# Address Book, Dashboard, iCal, TextEdit, and Disk Utility # +############################################################################### + +# Use plain text mode for new TextEdit documents +defaults write com.apple.TextEdit RichText -int 0 +# Open and save files as UTF-8 in TextEdit +defaults write com.apple.TextEdit PlainTextEncoding -int 4 +defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4 + +# Show 24 hours a day +defaults write com.apple.ical "number of hours displayed" 24 + +# Week should start on Monday +defaults write com.apple.ical "first day of the week" 1 + +# Day starts at 9AM +defaults write com.apple.ical "first minute of work hours" 540 + +############################################################################### +# Date & Time # +############################################################################### + +# Custom DateFormat +defaults write com.apple.menuextra.clock DateFormat "EEE MMM d H:mm" + +############################################################################### +# Photos # +############################################################################### + +# Prevent Photos from opening automatically when devices are plugged in +defaults -currentHost write com.apple.ImageCapture disableHotPlug -bool true + +############################################################################### +# Kill affected applications # +############################################################################### + +#for app in "Activity Monitor" "Address Book" "Calendar" "Contacts" "cfprefsd" \ +# "Dock" "Finder" "Mail" "Messages" "Photos" "Safari" "SystemUIServer" \ +# "Terminal" "Tweetbot" "iCal"; do +# killall "${app}" &> /dev/null +#done + +echo "Done. Note that some of these changes require a logout/restart to take effect." + + diff --git a/macup/mackup.cfg.symlink b/macup/mackup.cfg.symlink new file mode 100644 index 00000000000..8a076f8584a --- /dev/null +++ b/macup/mackup.cfg.symlink @@ -0,0 +1,11 @@ +[storage] +#engine = google_drive +#directory = backup +engine = file_system +path = /Volumes/GoogleDrive/My Drive + +[applications_to_sync] +ssh +tunnelblick +docker +vscode diff --git a/node/install.sh b/node/install.sh index 1dff4f43777..8d94a47e3fb 100755 --- a/node/install.sh +++ b/node/install.sh @@ -1,4 +1,28 @@ -if test ! $(which spoof) -then - sudo npm install spoof -g -fi +#!/usr/bin/env bash + +info () { + printf "\r [ \033[00;34m..\033[0m ] $1\n" +} + +success () { + printf "\r\033[2K [ \033[00;32mOK\033[0m ] $1\n" +} + +# Install Node Version Manager +export NVM_DIR="$HOME/.nvm" && ( + rm -rf "$NVM_DIR" + git clone https://github.com/creationix/nvm.git "$NVM_DIR" + cd "$NVM_DIR" + git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" origin ` >/dev/null +) + +echo "NVM installed successfully" + +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm + +# Set default node to be the one installed in the system +nvm alias default system + +success "./node/install.sh" + diff --git a/node/path.zsh b/node/path.zsh new file mode 100644 index 00000000000..535622a269b --- /dev/null +++ b/node/path.zsh @@ -0,0 +1,11 @@ +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm + +# Set default node to be the one installed in the system +nvm alias default system + +# Load Node global installed binaries +export PATH="$HOME/.node/bin:$PATH" + +# Use project specific binaries before global ones +export PATH="node_modules/.bin:vendor/bin:$PATH" \ No newline at end of file diff --git a/npm/install.sh b/npm/install.sh new file mode 100755 index 00000000000..01609360e86 --- /dev/null +++ b/npm/install.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +info () { + printf "\r [ \033[00;34m..\033[0m ] $1\n" +} + +user () { + printf "\r [ \033[0;33m??\033[0m ] $1\n" +} + +success () { + printf "\r\033[2K [ \033[00;32mOK\033[0m ] $1\n" +} + +fail () { + printf "\r\033[2K [\033[0;31mFAIL\033[0m] $1\n" + echo '' + exit +} + +setup_npm () { + registry="https://trustpilot.myget.org/F/npm/npm/" + + + if [ -z `grep ${registry} ~/.npmrc` ]; then + npm config set @trustpilot:registry=${registry} + npm config set always-auth true --registry ${registry} + + info "Adding NPM repo tokens" + npm login --registry ${registry} --scope=@trustpilot + fi + + npm install -g @trustpilot/confocto + confocto setup +} + +setup_npm +success "npm/install.sh" \ No newline at end of file diff --git a/ruby/aliases.zsh b/ruby/aliases.zsh deleted file mode 100644 index 607599fcbd2..00000000000 --- a/ruby/aliases.zsh +++ /dev/null @@ -1,3 +0,0 @@ -alias sc='script/console' -alias sg='script/generate' -alias sd='script/destroy' diff --git a/ruby/completion.zsh b/ruby/completion.zsh deleted file mode 100644 index 87bdc54ad78..00000000000 --- a/ruby/completion.zsh +++ /dev/null @@ -1,22 +0,0 @@ -# Stolen from -# https://github.com/sstephenson/rbenv/blob/master/completions/rbenv.zsh - -if [[ ! -o interactive ]]; then - return -fi - -compctl -K _rbenv rbenv - -_rbenv() { - local word words completions - read -cA words - word="${words[2]}" - - if [ "${#words}" -eq 2 ]; then - completions="$(rbenv commands)" - else - completions="$(rbenv completions "${word}")" - fi - - reply=("${(ps:\n:)completions}") -} \ No newline at end of file diff --git a/ruby/gemrc.symlink b/ruby/gemrc.symlink deleted file mode 100644 index 63e8ac20eba..00000000000 --- a/ruby/gemrc.symlink +++ /dev/null @@ -1,6 +0,0 @@ ---- -:update_sources: true -:verbose: true -:backtrace: false -:benchmark: false -gem: --no-document diff --git a/ruby/irbrc.symlink b/ruby/irbrc.symlink deleted file mode 100644 index f25dcbfb023..00000000000 --- a/ruby/irbrc.symlink +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/ruby -require 'irb/completion' -require 'irb/ext/save-history' -require 'rubygems' - -IRB.conf[:SAVE_HISTORY] = 1000 -IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb_history" - -IRB.conf[:PROMPT_MODE] = :SIMPLE - -IRB.conf[:AUTO_INDENT] = true - -class Object - # list methods which aren't in superclass - def local_methods(obj = self) - (obj.methods - obj.class.superclass.instance_methods).sort - end - - # print documentation - # - # ri 'Array#pop' - # Array.ri - # Array.ri :pop - # arr.ri :pop - def ri(method = nil) - unless method && method =~ /^[A-Z]/ # if class isn't specified - klass = self.kind_of?(Class) ? name : self.class.name - method = [klass, method].compact.join('#') - end - puts `ri '#{method}'` - end -end - -# Copies the result of the last operation you ran in IRB to the system -# clipboard (if you're on macOS). -def cop - last_value = IRB.CurrentContext.last_value - %x[echo '#{last_value}' | pbcopy] - "copied \`#{last_value}' to your clipboard" -end - -def me - User.find_by_login(ENV['USER'].strip) -end - -def r - reload! -end diff --git a/ruby/rbenv.zsh b/ruby/rbenv.zsh deleted file mode 100644 index cb93d589d6a..00000000000 --- a/ruby/rbenv.zsh +++ /dev/null @@ -1,5 +0,0 @@ -# init according to man page -if (( $+commands[rbenv] )) -then - eval "$(rbenv init -)" -fi diff --git a/script/bootstrap b/script/bootstrap index ec33297de17..e7a742e6bb7 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -27,29 +27,6 @@ fail () { exit } -setup_gitconfig () { - if ! [ -f git/gitconfig.local.symlink ] - then - info 'setup gitconfig' - - git_credential='cache' - if [ "$(uname -s)" == "Darwin" ] - then - git_credential='osxkeychain' - fi - - user ' - What is your github author name?' - read -e git_authorname - user ' - What is your github author email?' - read -e git_authoremail - - sed -e "s/AUTHORNAME/$git_authorname/g" -e "s/AUTHOREMAIL/$git_authoremail/g" -e "s/GIT_CREDENTIAL_HELPER/$git_credential/g" git/gitconfig.local.symlink.example > git/gitconfig.local.symlink - - success 'gitconfig' - fi -} - - link_file () { local src=$1 dst=$2 @@ -137,15 +114,16 @@ install_dotfiles () { done } -setup_gitconfig install_dotfiles + # If we're on a Mac, let's install and setup homebrew. if [ "$(uname -s)" == "Darwin" ] then info "installing dependencies" - if source bin/dot | while read -r data; do info "$data"; done - then + bin/dot + + if [ $? -eq 0 ]; then success "dependencies installed" else fail "error installing dependencies" diff --git a/script/install b/script/install index 8d516b2a1fe..84740cfde71 100755 --- a/script/install +++ b/script/install @@ -11,4 +11,8 @@ echo "› brew bundle" brew bundle # find the installers and run them iteratively -find . -name install.sh | while read installer ; do sh -c "${installer}" ; done +installers=`find . -name install.sh` +for installer in $installers ; do + echo "Running: ${installer}"; + sh -c "${installer}"; +done diff --git a/system/aliases.zsh b/system/aliases.zsh index d11780cc3b7..c7e657b2fbb 100644 --- a/system/aliases.zsh +++ b/system/aliases.zsh @@ -1,10 +1,29 @@ # grc overides for ls # Made possible through contributions from generous benefactors like # `brew install coreutils` -if $(gls &>/dev/null) -then - alias ls="gls -F --color" - alias l="gls -lAh --color" - alias ll="gls -l --color" - alias la='gls -A --color' -fi \ No newline at end of file +#if $(gls &>/dev/null) +#then +# alias ls="gls -F --color" +# alias l="gls -lAh --color" +# alias ll="gls -l --color" +# alias la='gls -A --color' +#fi + +# Shortcuts +alias copyssh="pbcopy < $HOME/.ssh/id_rsa.pub" +alias reloaddns="dscacheutil -flushcache && sudo killall -HUP mDNSResponder" +alias weather="curl -4 http://wttr.in" +alias shrug="echo '¯\_(ツ)_/¯' | pbcopy" + +# Directories +alias dotfiles="cd $DOTFILES" +alias library="cd $HOME/Library" +alias projects="cd $HOME/Projects" + +# Vagrant +alias v="vagrant global-status" +alias vup="vagrant up" +alias vhalt="vagrant halt" +alias vssh="vagrant ssh" +alias vreload="vagrant reload" +alias vrebuild="vagrant destroy --force && vagrant up" diff --git a/system/env.zsh b/system/env.zsh index 9a97245a42d..f050a85c9ed 100644 --- a/system/env.zsh +++ b/system/env.zsh @@ -1 +1,4 @@ -export EDITOR='atom' +export EDITOR='nvim' + +# your project folder that we can `c [tab]` to +export PROJECTS=~/Projects \ No newline at end of file diff --git a/system/install.sh b/system/install.sh new file mode 100755 index 00000000000..210b300c663 --- /dev/null +++ b/system/install.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# Create a Projects directory +# This is a default directory for macOS user accounts but doesn't comes pre-installed + +info () { + printf "\r [ \033[00;34m..\033[0m ] $1\n" +} + +success () { + printf "\r\033[2K [ \033[00;32mOK\033[0m ] $1\n" +} + +mkdir -p $HOME/Projects +success "./system/install.sh" + + diff --git a/system/_path.zsh b/system/path.zsh similarity index 55% rename from system/_path.zsh rename to system/path.zsh index 255c2cfca66..480c419f94a 100644 --- a/system/_path.zsh +++ b/system/path.zsh @@ -1,2 +1 @@ -export PATH="./bin:/usr/local/bin:/usr/local/sbin:$ZSH/bin:$PATH" export MANPATH="/usr/local/man:/usr/local/mysql/man:/usr/local/git/man:$MANPATH" diff --git a/tmux/tmux.conf.symlink b/tmux/tmux.conf.symlink new file mode 100644 index 00000000000..5fd4a7d6e5f --- /dev/null +++ b/tmux/tmux.conf.symlink @@ -0,0 +1,93 @@ +# Ring the bell if any background window rang a bell +set -g bell-action any + +# Default termtype. If the rcfile sets $TERM, that overrides this value. +set -g default-terminal screen-256color + +# Keep your finger on ctrl, or don't +bind-key ^D detach-client + +# Create splits and vertical splits +bind-key v split-window -h -p 50 -c "#{pane_current_path}" +bind-key ^V split-window -h -p 50 -c "#{pane_current_path}" +bind-key s split-window -p 50 -c "#{pane_current_path}" +bind-key ^S split-window -p 50 -c "#{pane_current_path}" + +# Pane resize in all four directions using vi bindings. +# Can use these raw but I map them to shift-ctrl- in iTerm. +bind -r H resize-pane -L 5 +bind -r J resize-pane -D 5 +bind -r K resize-pane -U 5 +bind -r L resize-pane -R 5 + +# Smart pane switching with awareness of vim splits. +# Source: https://github.com/christoomey/vim-tmux-navigator +is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?x?)(diff)?$"' +bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L" +bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D" +bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U" +bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R" +bind -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l" + +# Use vi keybindings for tmux commandline input. +# Note that to get command mode you need to hit ESC twice... +set -g status-keys vi + +# Use vi keybindings in copy and choice modes +setw -g mode-keys vi + +# easily toggle synchronization (mnemonic: e is for echo) +# sends input to all panes in a given window. +bind e setw synchronize-panes on +bind E setw synchronize-panes off + +# set first window to index 1 (not 0) to map more to the keyboard layout... +set-option -g base-index 1 +set-window-option -g pane-base-index 1 +set-window-option -g mouse on + +# color scheme (styled as vim-powerline) +set -g status-left-length 52 +set -g status-right-length 451 +set -g status-fg white +set -g status-bg colour234 +set -g pane-border-fg colour245 +set -g pane-active-border-fg colour39 +set -g message-fg colour16 +set -g message-bg colour221 +set -g message-attr bold +set -g status-left '#[fg=colour235,bg=colour252,bold] ❐ #S #[fg=colour252,bg=colour238,nobold]⮀#[fg=colour245,bg=colour238,bold] #(whoami) #[fg=colour238,bg=colour234,nobold]⮀' +set -g window-status-format '#[fg=colour235,bg=colour252,bold] #I #(pwd="#{pane_current_path}"; echo ${pwd####*/}) #W ' +set -g window-status-current-format '#[fg=colour234,bg=colour39]⮀#[fg=black,bg=colour39,noreverse,bold] #{?window_zoomed_flag,#[fg=colour228],} #I #(pwd="#{pane_current_path}"; echo ${pwd####*/}) #W #[fg=colour39,bg=colour234,nobold]⮀' +set-option -g status-interval 2 + +# Patch for OS X pbpaste and pbcopy under tmux. +#set-option -g default-command "which reattach-to-user-namespace > /dev/null && reattach-to-user-namespace -l $SHELL || $SHELL" + +# Screen like binding +unbind C-b +set -g prefix C-a +bind a send-prefix + +# No escape time for vi mode +set -sg escape-time 0 + +# Screen like binding for last window +unbind l +bind C-a last-window + +# Bigger history +set -g history-limit 10000 + +# New windows/pane in $PWD +bind c new-window -c "#{pane_current_path}" + +# Fix key bindings broken in tmux 2.1 +set -g assume-paste-time 0 + +# force a reload of the config file +unbind r +bind r source-file ~/.tmux.conf \; display "Reloaded!" + +# Local config +if-shell "[ -f ~/.tmux.conf.user ]" 'source ~/.tmux.conf.user' \ No newline at end of file diff --git a/vault/install.sh b/vault/install.sh new file mode 100755 index 00000000000..d4d1569399d --- /dev/null +++ b/vault/install.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +info () { + printf "\r [ \033[00;34m..\033[0m ] $1\n" +} + +user () { + printf "\r [ \033[0;33m??\033[0m ] $1\n" +} + +success () { + printf "\r\033[2K [ \033[00;32mOK\033[0m ] $1\n" +} + +setup_vault () { + + vault_addr='export VAULT_ADDR=https://vault.trustpilot.com' + + touch $HOME/.localrc + grep -q "$vault_addr" $HOME/.localrc && return; + + info 'setup Vault' + user ' - Enter your Git Hub Personal access token for vault (read:org):' + read -e github_apikey + + vault_github_token='export VAULT_AUTH_GITHUB_TOKEN='$github_apikey + + grep -q "$vault_addr" $HOME/.localrc || echo "$vault_addr" >> $HOME/.localrc + grep -q "$vault_github_token" $HOME/.localrc || echo "$vault_github_token" >> $HOME/.localrc + + source $HOME/.localrc + + vault login -method=github +} + +setup_aws_role () { + go get github.com/trustpilot/aws-role +} + +info "Running: ./vault/install.sh" +setup_vault +setup_aws_role +success "./vault/install.sh" \ No newline at end of file diff --git a/vim/vimrc.symlink b/vim/vimrc.symlink deleted file mode 100644 index 0463e21b902..00000000000 --- a/vim/vimrc.symlink +++ /dev/null @@ -1,4 +0,0 @@ -syntax on - -" Wrap gitcommit file types at the appropriate length -filetype indent plugin on diff --git a/vimify/editrc.symlink b/vimify/editrc.symlink new file mode 100644 index 00000000000..c6333bd1bc1 --- /dev/null +++ b/vimify/editrc.symlink @@ -0,0 +1,3 @@ +bind -v +bind "^R" em-inc-search-prev +#bind \\t rl_complete diff --git a/vimify/inputrc.symlink b/vimify/inputrc.symlink new file mode 100644 index 00000000000..e6238a8f800 --- /dev/null +++ b/vimify/inputrc.symlink @@ -0,0 +1 @@ +set editing-mode vi \ No newline at end of file diff --git a/xcode/aliases.zsh b/xcode/aliases.zsh deleted file mode 100644 index 53dc5922efe..00000000000 --- a/xcode/aliases.zsh +++ /dev/null @@ -1,2 +0,0 @@ -alias ios="open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app" -alias watchos="open /Applications/Xcode.app/Contents/Developer/Applications/Simulator\ \(Watch\).app" diff --git a/zsh/0000_before.zsh b/zsh/0000_before.zsh new file mode 100644 index 00000000000..8dd1b948467 --- /dev/null +++ b/zsh/0000_before.zsh @@ -0,0 +1,7 @@ +# Load any user customizations prior to load +# +if [ -d $HOME/.zsh.before/ ]; then + if [ "$(ls -A $HOME/.zsh.before/)" ]; then + for config_file ($HOME/.zsh.before/*.zsh) source $config_file + fi +fi diff --git a/zsh/aliases.zsh b/zsh/aliases.zsh index b88e3aa5a1b..3138dc76e6b 100644 --- a/zsh/aliases.zsh +++ b/zsh/aliases.zsh @@ -1,3 +1,117 @@ -alias reload!='. ~/.zshrc' +# Aliases in this file are bash and zsh compatible -alias cls='clear' # Good 'ol Clear Screen command +# Don't change. The following determines where YADR is installed. +ZSH=$HOME/.dotfiles + +# Get operating system +platform='unknown' +unamestr=$(uname) +if [[ $unamestr == 'Linux' ]]; then + platform='linux' +elif [[ $unamestr == 'Darwin' ]]; then + platform='darwin' +fi + +# PS +alias psa="ps aux" +alias psg="ps aux | grep " +alias psr='ps aux | grep ruby' + +# Moving around +alias cdb='cd -' +alias cls='clear;ls' + +# Show human friendly numbers and colors +alias df='df -h' +alias du='du -h -d 2' + +if [[ $platform == 'linux' ]]; then + alias ll='ls -alh --color=auto' + alias ls='ls --color=auto' +elif [[ $platform == 'darwin' ]]; then + alias ll='ls -alGh' + alias ls='ls -Gh' +fi + +# show me files matching "ls grep" +alias lsg='ll | grep' + +# Alias Editing +TRAPHUP() { + source $ZSH/zsh/aliases.zsh +} + +alias ae='vim $ZSH/zsh/aliases.zsh' #alias edit +alias ar='source $ZSH/zsh/aliases.zsh' #alias reload +alias gar="killall -HUP -u \"$USER\" zsh" #global alias reload + +# vim using +mvim --version > /dev/null 2>&1 +MACVIM_INSTALLED=$? +if [ $MACVIM_INSTALLED -eq 0 ]; then + alias vim="mvim -v" +fi + +# vim using +nvim --version > /dev/null 2>&1 +NVIM_INSTALLED=$? +if [ $NVIM_INSTALLED -eq 0 ]; then + alias vim="nvim -v" +fi + +# mimic vim functions +alias :q='exit' + +# vimrc editing +alias ve='vim ~/.vimrc' + +# zsh profile editing +alias ze='vim ~/.zshrc' + +# Common shell functions +alias less='less -r' +alias tf='tail -f' +alias l='less' +alias lh='ls -alt | head' # see the last modified files +alias screen='TERM=screen screen' +alias cl='clear' + +# Zippin +alias gz='tar -zcvf' + +alias ka9='killall -9' +alias k9='kill -9' + + +# TODOS +# This uses NValt (NotationalVelocity alt fork) - http://brettterpstra.com/project/nvalt/ +# to find the note called 'todo' +alias todo='open nvalt://find/todo' + +alias hpr='hub pull-request' +alias grb='git recent-branches' + +# Finder +alias showFiles='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app' +alias hideFiles='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app' + +# Homebrew +alias brewu='brew_update' + +# Global aliases +alias -g ...='../..' +alias -g ....='../../..' +alias -g .....='../../../..' +alias -g C='| wc -l' +alias -g H='| head' +alias -g L="| less" +alias -g N="| /dev/null" +alias -g S='| sort' +alias -g G='| grep' # now you can do: ls foo G something + +# Functions +# +# (f)ind by (n)ame +# usage: fn foo +# to find all files containing 'foo' in the name +function fn() { ls **/*$1* } \ No newline at end of file diff --git a/zsh/colors.zsh b/zsh/colors.zsh new file mode 100644 index 00000000000..72c6d763dfb --- /dev/null +++ b/zsh/colors.zsh @@ -0,0 +1 @@ +export GREP_COLOR='1;33' diff --git a/zsh/completion.zsh b/zsh/completion.zsh deleted file mode 100644 index 1862eecec55..00000000000 --- a/zsh/completion.zsh +++ /dev/null @@ -1,5 +0,0 @@ -# matches case insensitive for lowercase -zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' - -# pasting with tabs doesn't perform completion -zstyle ':completion:*' insert-tab pending diff --git a/zsh/config.zsh b/zsh/config.zsh deleted file mode 100644 index 8ca7389e218..00000000000 --- a/zsh/config.zsh +++ /dev/null @@ -1,39 +0,0 @@ -export LSCOLORS="exfxcxdxbxegedabagacad" -export CLICOLOR=true - -fpath=($ZSH/functions $fpath) - -autoload -U $ZSH/functions/*(:t) - -HISTFILE=~/.zsh_history -HISTSIZE=10000 -SAVEHIST=10000 - -setopt NO_BG_NICE # don't nice background tasks -setopt NO_HUP -setopt NO_LIST_BEEP -setopt LOCAL_OPTIONS # allow functions to have local options -setopt LOCAL_TRAPS # allow functions to have local traps -setopt HIST_VERIFY -setopt SHARE_HISTORY # share history between sessions ??? -setopt EXTENDED_HISTORY # add timestamps to history -setopt PROMPT_SUBST -setopt CORRECT -setopt COMPLETE_IN_WORD -setopt IGNORE_EOF - -setopt APPEND_HISTORY # adds history -setopt INC_APPEND_HISTORY SHARE_HISTORY # adds history incrementally and share it across sessions -setopt HIST_IGNORE_ALL_DUPS # don't record dupes in history -setopt HIST_REDUCE_BLANKS - -# don't expand aliases _before_ completion has finished -# like: git comm-[tab] -setopt complete_aliases - -bindkey '^[^[[D' backward-word -bindkey '^[^[[C' forward-word -bindkey '^[[5D' beginning-of-line -bindkey '^[[5C' end-of-line -bindkey '^[[3~' delete-char -bindkey '^?' backward-delete-char diff --git a/zsh/custom_prompt_path.zsh b/zsh/custom_prompt_path.zsh new file mode 100644 index 00000000000..a6194c8ccd3 --- /dev/null +++ b/zsh/custom_prompt_path.zsh @@ -0,0 +1,4 @@ +#Load themes from yadr and from user's custom prompts (themes) in ~/.zsh.prompts +autoload promptinit +fpath=($ZSH/zsh/prezto-themes $HOME/.zsh.prompts $fpath) +promptinit diff --git a/zsh/fasd.zsh b/zsh/fasd.zsh new file mode 100644 index 00000000000..a91c34dd406 --- /dev/null +++ b/zsh/fasd.zsh @@ -0,0 +1,7 @@ +# jump to recently used items +alias a='fasd -a' # any +alias s='fasd -si' # show / search / select +alias d='fasd -d' # directory +alias f='fasd -f' # file +alias z='fasd_cd -d' # cd, same functionality as j in autojump +alias zz='fasd_cd -d -i' # interactive directory jump diff --git a/zsh/install.sh b/zsh/install.sh new file mode 100755 index 00000000000..ece6d1f9d6d --- /dev/null +++ b/zsh/install.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env zsh + +info () { + printf "\r [ \033[00;34m..\033[0m ] $1\n" +} + +success () { + printf "\r\033[2K [ \033[00;32mOK\033[0m ] $1\n" +} + +# Source Prezto. +if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then + source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" + zprezto-update +else + echo "Installing zprezto" + git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto" 2>/dev/null + source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" +fi + +info "Installing zpresto contrib" + +if [[ -d "${ZDOTDIR:-$HOME}/.zprezto/contrib" ]]; then + cd -q -- "${ZDOTDIR:-$HOME}/.zprezto/contrib" || return 7 + if git pull --ff-only; then + info "Syncing zprezto contrib submodules" + git submodule update --recursive + return $? + fi +else + echo "Installing zprezto contrib" + git clone --recursive https://github.com/belak/prezto-contrib "${ZDOTDIR:-$HOME}/.zprezto/contrib" 2>/dev/null +fi + +success "./zsh/install.sh" + + + + + + diff --git a/zsh/key-bindings.zsh b/zsh/key-bindings.zsh new file mode 100644 index 00000000000..4eb39a27049 --- /dev/null +++ b/zsh/key-bindings.zsh @@ -0,0 +1,16 @@ +# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html +# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Zle-Builtins +# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Standard-Widgets + +bindkey -v # Use vi key bindings +bindkey '^r' history-incremental-search-backward # [Ctrl-r] - Search backward incrementally for a specified string. The string may begin with ^ to anchor the search to the beginning of the line. + +# emacs style +bindkey '^a' beginning-of-line +bindkey '^e' end-of-line + +# Make numpad enter work +bindkey -s "^[Op" "0" +bindkey -s "^[Ol" "." +bindkey -s "^[OM" "^M" + diff --git a/zsh/last-command.zsh b/zsh/last-command.zsh new file mode 100644 index 00000000000..9f7486bf675 --- /dev/null +++ b/zsh/last-command.zsh @@ -0,0 +1,7 @@ +# Use Ctrl-x,Ctrl-l to get the output of the last command +zmodload -i zsh/parameter +insert-last-command-output() { +LBUFFER+="$(eval $history[$((HISTCMD-1))])" +} +zle -N insert-last-command-output +bindkey "^X^L" insert-last-command-output diff --git a/zsh/noglob.zsh b/zsh/noglob.zsh new file mode 100644 index 00000000000..ede67c9d7bc --- /dev/null +++ b/zsh/noglob.zsh @@ -0,0 +1,4 @@ +# Don't try to glob with zsh so you can do +# stuff like ga *foo* and correctly have +# git add the right stuff +alias git='noglob git' diff --git a/zsh/prezto-themes/prompt_agnoster_setup b/zsh/prezto-themes/prompt_agnoster_setup new file mode 100644 index 00000000000..16d18c91585 --- /dev/null +++ b/zsh/prezto-themes/prompt_agnoster_setup @@ -0,0 +1,141 @@ +# vim:ft=zsh ts=2 sw=2 sts=2 +# +# agnoster's Theme - https://gist.github.com/3712874 +# A Powerline-inspired theme for ZSH +# +# # README +# +# In order for this theme to render correctly, you will need a +# [Powerline-patched font](https://gist.github.com/1595572). +# +# In addition, I recommend the +# [Solarized theme](https://github.com/altercation/solarized/) and, if you're +# using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app - +# it has significantly better color fidelity. +# +# # Goals +# +# The aim of this theme is to only show you *relevant* information. Like most +# prompts, it will only show git information when in a git working directory. +# However, it goes a step further: everything from the current user and +# hostname to whether the last call exited with an error to whether background +# jobs are running in this shell will all be displayed automatically when +# appropriate. + +### Segment drawing +# A few utility functions to make it easy and re-usable to draw segmented prompts + +CURRENT_BG='NONE' +SEGMENT_SEPARATOR='⮀' + +# Customizations + +# Checks if working tree is dirty +# From robbyrussell/oh-my-zsh +parse_git_dirty() { + local SUBMODULE_SYNTAX='' + local GIT_STATUS='' + local CLEAN_MESSAGE='nothing to commit (working directory clean)' + if [[ "$(command git config --get oh-my-zsh.hide-status)" != "1" ]]; then + if [[ $POST_1_7_2_GIT -gt 0 ]]; then + SUBMODULE_SYNTAX="--ignore-submodules=dirty" + fi + if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then + GIT_STATUS=$(command git status -s ${SUBMODULE_SYNTAX} -uno 2> /dev/null | tail -n1) + else + GIT_STATUS=$(command git status -s ${SUBMODULE_SYNTAX} 2> /dev/null | tail -n1) + fi + if [[ -n $GIT_STATUS ]]; then + echo "$ZSH_THEME_GIT_PROMPT_DIRTY" + else + echo "$ZSH_THEME_GIT_PROMPT_CLEAN" + fi + else + echo "$ZSH_THEME_GIT_PROMPT_CLEAN" + fi +} + +# Takes two arguments, background and foreground. Both can be omitted, +# rendering default background/foreground. +prompt_segment() { + local bg fg + [[ -n $1 ]] && bg="%K{$1}" || bg="%k" + [[ -n $2 ]] && fg="%F{$2}" || fg="%f" + if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then + echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} " + else + echo -n "%{$bg%}%{$fg%} " + fi + CURRENT_BG=$1 + [[ -n $3 ]] && echo -n $3 +} + +# End the prompt, closing any open segments +prompt_end() { + if [[ -n $CURRENT_BG ]]; then + echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" + else + echo -n "%{%k%}" + fi + echo -n "%{%f%}" + CURRENT_BG='' +} + +### Prompt components +# Each component will draw itself, and hide itself if no information needs to be shown + +# Context: user@hostname (who am I and where am I) +prompt_context() { + local user=`whoami` + + if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then + prompt_segment black default "%(!.%{%F{yellow}%}.)$user@%m" + fi +} + +# Git: branch/detached head, dirty status +prompt_git() { + local ref dirty + if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then + ZSH_THEME_GIT_PROMPT_DIRTY='±' + dirty=$(parse_git_dirty) + ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)" + if [[ -n $dirty ]]; then + prompt_segment yellow black + else + prompt_segment green black + fi + echo -n "${ref/refs\/heads\//⭠ }$dirty" + fi +} + +# Dir: current working directory +prompt_dir() { + prompt_segment blue black '%~' +} + +# Status: +# - was there an error +# - am I root +# - are there background jobs? +prompt_status() { + local symbols + symbols=() + [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘" + [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡" + [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙" + + [[ -n "$symbols" ]] && prompt_segment black default "$symbols" +} + +## Main prompt +build_prompt() { + RETVAL=$? + prompt_status + prompt_context + prompt_dir + prompt_git + prompt_end +} + +PROMPT='%{%f%b%k%}$(build_prompt) ' diff --git a/zsh/prezto-themes/prompt_kylewest_setup b/zsh/prezto-themes/prompt_kylewest_setup new file mode 100644 index 00000000000..c67b5e49aa5 --- /dev/null +++ b/zsh/prezto-themes/prompt_kylewest_setup @@ -0,0 +1,57 @@ +# +# A theme based on sorin theme +# * ruby info shown on the right +# * git info on the left +# * editor mode as $> or <# +# * single line prompt +# +# Authors: +# Sorin Ionescu +# Kyle West + +function prompt_kylewest_precmd { + setopt LOCAL_OPTIONS + unsetopt XTRACE KSH_ARRAYS + + # Get Git repository information. + if (( $+functions[git-info] )); then + git-info on + git-info + fi + + # Get ruby information + if (( $+functions[ruby-info] )); then + ruby-info + fi +} + +function prompt_kylewest_setup { + setopt LOCAL_OPTIONS + unsetopt XTRACE KSH_ARRAYS + prompt_opts=(cr percent subst) + + # Load required functions. + autoload -Uz add-zsh-hook + + # Add hook for calling git-info before each command. + add-zsh-hook precmd prompt_kylewest_precmd + + # editor + zstyle ':prezto:module:editor:info:completing' format '%B%F{red}...%f%b' + zstyle ':prezto:module:editor:info:keymap:primary' format "%B%F{green}$>%f%b" + zstyle ':prezto:module:editor:info:keymap:alternate' format "%B%F{magenta}<#%f%b" + + # ruby info (rvm, rbenv) + zstyle ':prezto:module:ruby:info:version' format '[ %v ]' + + # vcs + zstyle ':prezto:module:git:info:branch' format '%F{yellow}%b%f' + zstyle ':prezto:module:git:info:dirty' format '%B%F{red}!%f%b' + zstyle ':prezto:module:git:info:keys' format 'prompt' '- %b%D ' + + # prompts + PROMPT='%F{cyan}%c%f ${git_info[prompt]}${editor_info[keymap]} ' + RPROMPT='%F{blue}${ruby_info[version]}' +} + +prompt_kylewest_setup "$@" diff --git a/zsh/prezto-themes/prompt_noxxious_setup b/zsh/prezto-themes/prompt_noxxious_setup new file mode 100644 index 00000000000..634b1ec8cf8 --- /dev/null +++ b/zsh/prezto-themes/prompt_noxxious_setup @@ -0,0 +1,82 @@ +# +# A theme based on steeef theme +# * RVM/Rbenv info shown on the right +# * Git branch info on the left +# * Single line prompt +# +# Authors: +# Steve Losh +# Bart Trojanowski +# Brian Carper +# steeef +# Sorin Ionescu +# Yan Pritzker + +function prompt_skwp_precmd { + setopt LOCAL_OPTIONS + unsetopt XTRACE KSH_ARRAYS + + # Get Git repository information. + if (( $+functions[git-info] )); then + git-info on + git-info + fi + + # Get ruby information + if (( $+functions[ruby-info] )); then + ruby-info + fi + + # Get ruby information + if (( $+functions[node-info] )); then + node-info + fi +} + +function prompt_skwp_setup { + setopt LOCAL_OPTIONS + unsetopt XTRACE KSH_ARRAYS + prompt_opts=(cr percent subst) + + autoload -Uz add-zsh-hook + + add-zsh-hook precmd prompt_skwp_precmd + + # Use extended color pallete if available. + if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then + __PROMPT_SKWP_COLORS=( + "%F{81}" # turquoise + "%F{166}" # orange + "%F{135}" # purple + "%F{161}" # hotpink + "%F{118}" # limegreen + ) + else + __PROMPT_SKWP_COLORS=( + "%F{cyan}" + "%F{yellow}" + "%F{magenta}" + "%F{red}" + "%F{green}" + ) + fi + + # git + zstyle ':prezto:module:git:info:branch' format "${__PROMPT_SKWP_COLORS[1]}%b%f" + zstyle ':prezto:module:git:info:added' format "${__PROMPT_SKWP_COLORS[5]}●%f" + zstyle ':prezto:module:git:info:deleted' format "${__PROMPT_SKWP_COLORS[2]}●%f" + zstyle ':prezto:module:git:info:modified' format "${__PROMPT_SKWP_COLORS[4]}●%f" + zstyle ':prezto:module:git:info:untracked' format "${__PROMPT_SKWP_COLORS[3]}●%f" + zstyle ':prezto:module:git:info:keys' format 'prompt' '(%b%d%a%m%u)' + + # ruby info (rvm, rbenv) + zstyle ':prezto:module:ruby:info:version' format '[%v]' + + # %v - Node.js version. + zstyle ':prezto:module:node:info:version' format '[%v]' + + PROMPT="${__PROMPT_SKWP_COLORS[3]}%n%f@${__PROMPT_SKWP_COLORS[2]}%m%f ${__PROMPT_SKWP_COLORS[5]}%~%f "'$git_info[prompt]'"$ " + RPROMPT='%F{blue}${node_info[version]}${ruby_info[version]}' +} + +prompt_skwp_setup "$@" diff --git a/zsh/prezto-themes/prompt_skwp_setup b/zsh/prezto-themes/prompt_skwp_setup new file mode 100644 index 00000000000..c45eb8a2e17 --- /dev/null +++ b/zsh/prezto-themes/prompt_skwp_setup @@ -0,0 +1,74 @@ +# +# A theme based on steeef theme +# * RVM/Rbenv info shown on the right +# * Git branch info on the left +# * Single line prompt +# +# Authors: +# Steve Losh +# Bart Trojanowski +# Brian Carper +# steeef +# Sorin Ionescu +# Yan Pritzker + +function prompt_skwp_precmd { + setopt LOCAL_OPTIONS + unsetopt XTRACE KSH_ARRAYS + + # Get Git repository information. + if (( $+functions[git-info] )); then + git-info on + git-info + fi + + # Get ruby information + if (( $+functions[ruby-info] )); then + ruby-info + fi +} + +function prompt_skwp_setup { + setopt LOCAL_OPTIONS + unsetopt XTRACE KSH_ARRAYS + prompt_opts=(cr percent subst) + + autoload -Uz add-zsh-hook + + add-zsh-hook precmd prompt_skwp_precmd + + # Use extended color pallete if available. + if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then + __PROMPT_SKWP_COLORS=( + "%F{81}" # turquoise + "%F{166}" # orange + "%F{135}" # purple + "%F{161}" # hotpink + "%F{118}" # limegreen + ) + else + __PROMPT_SKWP_COLORS=( + "%F{cyan}" + "%F{yellow}" + "%F{magenta}" + "%F{red}" + "%F{green}" + ) + fi + + # git + zstyle ':prezto:module:git:info:branch' format "${__PROMPT_SKWP_COLORS[1]}%b%f" + zstyle ':prezto:module:git:info:added' format "${__PROMPT_SKWP_COLORS[5]}●%f" + zstyle ':prezto:module:git:info:deleted' format "${__PROMPT_SKWP_COLORS[2]}●%f" + zstyle ':prezto:module:git:info:modified' format "${__PROMPT_SKWP_COLORS[4]}●%f" + zstyle ':prezto:module:git:info:untracked' format "${__PROMPT_SKWP_COLORS[3]}●%f" + zstyle ':prezto:module:git:info:keys' format 'prompt' '(%b%d%a%m%u)' + + # ruby info (rvm, rbenv) + zstyle ':prezto:module:ruby:info:version' format '[%v]' + + PROMPT="${__PROMPT_SKWP_COLORS[3]}%n%f@${__PROMPT_SKWP_COLORS[2]}%m%f ${__PROMPT_SKWP_COLORS[5]}%~%f "'$git_info[prompt]'"$ " + RPROMPT='%F{blue}${ruby_info[version]}' +} + +prompt_skwp_setup "$@" diff --git a/zsh/prezto-themes/prompt_steeef_simplified_setup b/zsh/prezto-themes/prompt_steeef_simplified_setup new file mode 100644 index 00000000000..14b16da9ae2 --- /dev/null +++ b/zsh/prezto-themes/prompt_steeef_simplified_setup @@ -0,0 +1,98 @@ +# +# A theme based on Steve Losh's Extravagant Prompt with vcs_info integration. +# +# Authors: +# Steve Losh +# Bart Trojanowski +# Brian Carper +# steeef_simplified +# Sorin Ionescu +# +# Screenshots: +# http://i.imgur.com/HyRvv.png +# + +function prompt_steeef_simplified_precmd { + # Check for untracked files or updated submodules since vcs_info does not. + if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then + branch_format="(${_prompt_steeef_simplified_colors[1]}%b%f%u%c${_prompt_steeef_simplified_colors[4]}●%f)" + else + branch_format="(${_prompt_steeef_simplified_colors[1]}%b%f%u%c)" + fi + + zstyle ':vcs_info:*:prompt:*' formats "${branch_format}" + + vcs_info 'prompt' + + if (( $+functions[python-info] )); then + python-info + fi + + # Get ruby information + if (( $+functions[ruby-info] )); then + ruby-info + fi +} + +function prompt_steeef_simplified_setup { + setopt LOCAL_OPTIONS + unsetopt XTRACE KSH_ARRAYS + prompt_opts=(cr percent subst) + + # Load required functions. + autoload -Uz add-zsh-hook + autoload -Uz vcs_info + + # Add hook for calling vcs_info before each command. + add-zsh-hook precmd prompt_steeef_simplified_precmd + + # Use extended color pallete if available. + if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then + _prompt_steeef_simplified_colors=( + "%F{81}" # Turquoise + "%F{166}" # Orange + "%F{135}" # Purple + "%F{161}" # Hotpink + "%F{118}" # Limegreen + ) + else + _prompt_steeef_simplified_colors=( + "%F{cyan}" + "%F{yellow}" + "%F{magenta}" + "%F{red}" + "%F{green}" + ) + fi + + # Formats: + # %b - branchname + # %u - unstagedstr (see below) + # %c - stagedstr (see below) + # %a - action (e.g. rebase-i) + # %R - repository path + # %S - path in the repository + local branch_format="(${_prompt_steeef_simplified_colors[1]}%b%f%u%c)" + local action_format="(${_prompt_steeef_simplified_colors[5]}%a%f)" + local unstaged_format="${_prompt_steeef_simplified_colors[2]}●%f" + local staged_format="${_prompt_steeef_simplified_colors[5]}●%f" + + # Set vcs_info parameters. + zstyle ':vcs_info:*' enable bzr git hg svn + zstyle ':vcs_info:*:prompt:*' check-for-changes true + zstyle ':vcs_info:*:prompt:*' unstagedstr "${unstaged_format}" + zstyle ':vcs_info:*:prompt:*' stagedstr "${staged_format}" + zstyle ':vcs_info:*:prompt:*' actionformats "${branch_format}${action_format}" + zstyle ':vcs_info:*:prompt:*' formats "${branch_format}" + zstyle ':vcs_info:*:prompt:*' nvcsformats "" + + # Set python-info parameters. + zstyle ':prezto:module:python:info:virtualenv' format '(%v)' + + # Define prompts. + PROMPT="${_prompt_steeef_simplified_colors[3]}%n%f@${_prompt_steeef_simplified_colors[2]}%m%f ${_prompt_steeef_simplified_colors[5]}%~%f "'${vcs_info_msg_0_}'"$ " + RPROMPT='%F{blue}${ruby_info[version]}' +} + +prompt_steeef_simplified_setup "$@" + diff --git a/zsh/prompt.zsh b/zsh/prompt.zsh deleted file mode 100644 index fabc959bcb6..00000000000 --- a/zsh/prompt.zsh +++ /dev/null @@ -1,72 +0,0 @@ -autoload colors && colors -# cheers, @ehrenmurdick -# http://github.com/ehrenmurdick/config/blob/master/zsh/prompt.zsh - -if (( $+commands[git] )) -then - git="$commands[git]" -else - git="/usr/bin/git" -fi - -git_branch() { - echo $($git symbolic-ref HEAD 2>/dev/null | awk -F/ {'print $NF'}) -} - -git_dirty() { - if $(! $git status -s &> /dev/null) - then - echo "" - else - if [[ $($git status --porcelain) == "" ]] - then - echo "on %{$fg_bold[green]%}$(git_prompt_info)%{$reset_color%}" - else - echo "on %{$fg_bold[red]%}$(git_prompt_info)%{$reset_color%}" - fi - fi -} - -git_prompt_info () { - ref=$($git symbolic-ref HEAD 2>/dev/null) || return -# echo "(%{\e[0;33m%}${ref#refs/heads/}%{\e[0m%})" - echo "${ref#refs/heads/}" -} - -# This assumes that you always have an origin named `origin`, and that you only -# care about one specific origin. If this is not the case, you might want to use -# `$git cherry -v @{upstream}` instead. -need_push () { - if [ $($git rev-parse --is-inside-work-tree 2>/dev/null) ] - then - number=$($git cherry -v origin/$(git symbolic-ref --short HEAD) 2>/dev/null | wc -l | bc) - - if [[ $number == 0 ]] - then - echo " " - else - echo " with %{$fg_bold[magenta]%}$number unpushed%{$reset_color%}" - fi - fi -} - -directory_name() { - echo "%{$fg_bold[cyan]%}%1/%\/%{$reset_color%}" -} - -battery_status() { - if [[ $(sysctl -n hw.model) == *"Book"* ]] - then - $ZSH/bin/battery-status - fi -} - -export PROMPT=$'\n$(battery_status)in $(directory_name) $(git_dirty)$(need_push)\n› ' -set_prompt () { - export RPROMPT="%{$fg_bold[cyan]%}%{$reset_color%}" -} - -precmd() { - title "zsh" "%m" "%55<...<%~" - set_prompt -} diff --git a/zsh/rm.zsh b/zsh/rm.zsh new file mode 100644 index 00000000000..26508a3a175 --- /dev/null +++ b/zsh/rm.zsh @@ -0,0 +1,2 @@ +# Override rm -i alias which makes rm prompt for every action +alias rm='nocorrect rm' diff --git a/zsh/secrets.zsh b/zsh/secrets.zsh new file mode 100644 index 00000000000..bbbe9c3ebf8 --- /dev/null +++ b/zsh/secrets.zsh @@ -0,0 +1,3 @@ +if [ -e ~/.secrets ]; then + source ~/.secrets +fi diff --git a/zsh/theme.zsh b/zsh/theme.zsh new file mode 100644 index 00000000000..0990bf3bfdf --- /dev/null +++ b/zsh/theme.zsh @@ -0,0 +1 @@ +prompt spaceship diff --git a/zsh/vi-mode.zsh b/zsh/vi-mode.zsh new file mode 100644 index 00000000000..7257528ae1f --- /dev/null +++ b/zsh/vi-mode.zsh @@ -0,0 +1,3 @@ +set -o vi +export EDITOR=nvim +export VISUAL=nvim diff --git a/zsh/window.zsh b/zsh/window.zsh deleted file mode 100644 index 805cb92d6f2..00000000000 --- a/zsh/window.zsh +++ /dev/null @@ -1,19 +0,0 @@ -# From http://dotfiles.org/~_why/.zshrc -# Sets the window title nicely no matter where you are -function title() { - # escape '%' chars in $1, make nonprintables visible - a=${(V)1//\%/\%\%} - - # Truncate command, and join lines. - a=$(print -Pn "%40>...>$a" | tr -d "\n") - - case $TERM in - screen) - print -Pn "\ek$a:$3\e\\" # screen title (in ^A") - ;; - xterm*|rxvt) - print -Pn "\e]2;$2\a" # plain xterm title ($3 for pwd) - ;; - esac -} - diff --git a/zsh/zlogin.symlink b/zsh/zlogin.symlink new file mode 100644 index 00000000000..16fae45e0f6 --- /dev/null +++ b/zsh/zlogin.symlink @@ -0,0 +1,26 @@ +# +# Executes commands at login post-zshrc. +# +# Authors: +# Sorin Ionescu +# + +# Execute code that does not affect the current session in the background. +{ + # Compile the completion dump to increase startup speed. + zcompdump="${ZDOTDIR:-$HOME}/.zcompdump" + if [[ -s "$zcompdump" && (! -s "${zcompdump}.zwc" || "$zcompdump" -nt "${zcompdump}.zwc") ]]; then + zcompile "$zcompdump" + fi +} &! + +# Execute code only if STDERR is bound to a TTY. +[[ -o INTERACTIVE && -t 2 ]] && { + + # Print a random, hopefully interesting, adage. + if (( $+commands[fortune] )); then + fortune -s + print + fi + +} >&2 diff --git a/zsh/zlogout.symlink b/zsh/zlogout.symlink new file mode 100644 index 00000000000..b5d9858c080 --- /dev/null +++ b/zsh/zlogout.symlink @@ -0,0 +1,19 @@ +# +# Executes commands at logout. +# +# Authors: +# Sorin Ionescu +# + +# Execute code only if STDERR is bound to a TTY. +[[ -o INTERACTIVE && -t 2 ]] && { + +SAYINGS=( + "So long and thanks for all the fish.\n -- Douglas Adams" + "Good morning! And in case I don't see ya, good afternoon, good evening and goodnight.\n --Truman Burbank" +) + +# Print a randomly-chosen message: +echo $SAYINGS[$(($RANDOM % ${#SAYINGS} + 1))] + +} >&2 diff --git a/zsh/zpreztorc.symlink b/zsh/zpreztorc.symlink new file mode 100644 index 00000000000..a9ce5f8dab0 --- /dev/null +++ b/zsh/zpreztorc.symlink @@ -0,0 +1,235 @@ +# -*- mode: shell -*- +# vi: set ft=shell : +# +# General +# + +# Set case-sensitivity for completion, history lookup, etc. +zstyle ':prezto:*:*' case-sensitive 'no' + +# Color output (auto set to 'no' on dumb terminals). +zstyle ':prezto:*:*' color 'yes' + +# Add additional directories to load prezto modules from +#zstyle ':prezto:load' pmodule-dirs $HOME/.zprezto-contrib + +# Set the Zsh modules to load (man zshmodules). +# zstyle ':prezto:load' zmodule 'attr' 'stat' + +# Set the Zsh functions to load (man zshcontrib). +zstyle ':prezto:load' zfunction 'zargs' 'zmv' + +# Set the Prezto modules to load (browse modules). +# The order matters. +zstyle ':prezto:load' pmodule \ + 'environment' \ + 'terminal' \ + 'editor' \ + 'history' \ + 'directory' \ + 'spectrum' \ + 'utility' \ + 'completion' \ + 'archive' \ + 'fasd' \ + 'git' \ + 'osx' \ + 'history-substring-search' \ + 'ssh' \ + 'node' \ + 'tmux' \ + 'docker' \ + 'syntax-highlighting' \ + 'contrib-clipboard' \ + 'contrib-prompt' \ + 'prompt' + +# +# Autosuggestions +# + +# Set the query found color. +# zstyle ':prezto:module:autosuggestions:color' found '' + +# +# Completions +# + +# Set the entries to ignore in static */etc/hosts* for host completion. +# zstyle ':prezto:module:completion:*:hosts' etc-host-ignores \ +# '0.0.0.0' '127.0.0.1' + +# +# Editor +# + +# Set the key mapping style to 'emacs' or 'vi'. +zstyle ':prezto:module:editor' key-bindings 'vi' + +# Auto convert .... to ../.. +zstyle ':prezto:module:editor' dot-expansion 'yes' + +# Allow the zsh prompt context to be shown. +zstyle ':prezto:module:editor' ps-context 'yes' + +# +# Git +# + +# Ignore submodules when they are 'dirty', 'untracked', 'all', or 'none'. +# zstyle ':prezto:module:git:status:ignore' submodules 'all' + +# +# GNU Utility +# + +# Set the command prefix on non-GNU systems. +# zstyle ':prezto:module:gnu-utility' prefix 'g' + +# +# History Substring Search +# + +# Set the query found color. +# zstyle ':prezto:module:history-substring-search:color' found '' + +# Set the query not found color. +# zstyle ':prezto:module:history-substring-search:color' not-found '' + +# Set the search globbing flags. +# zstyle ':prezto:module:history-substring-search' globbing-flags '' + +# +# macOS +# + +# Set the keyword used by `mand` to open man pages in Dash.app +# zstyle ':prezto:module:osx:man' dash-keyword 'manpages' + +# +# Pacman +# + +# Set the Pacman frontend. +# zstyle ':prezto:module:pacman' frontend 'yaourt' + +# +# Prompt +# + +# Set the prompt theme to load. +# Setting it to 'random' loads a random theme. +# Auto set to 'off' on dumb terminals. +zstyle ':prezto:module:prompt' theme 'sorin' + +# Set the working directory prompt display length. +# By default, it is set to 'short'. Set it to 'long' (without '~' expansion) +# for longer or 'full' (with '~' expansion) for even longer prompt display. +# zstyle ':prezto:module:prompt' pwd-length 'short' + +# Set the prompt to display the return code along with an indicator for non-zero +# return codes. This is not supported by all prompts. +zstyle ':prezto:module:prompt' show-return-val 'yes' + +# +# Python + +# + +# Auto switch the Python virtualenv on directory change. +zstyle ':prezto:module:python:virtualenv' auto-switch 'yes' + +# Automatically initialize virtualenvwrapper if pre-requisites are met. +zstyle ':prezto:module:python:virtualenv' initialize 'yes' + +# +# Ruby +# + +# Auto switch the Ruby version on directory change. +# zstyle ':prezto:module:ruby:chruby' auto-switch 'yes' + +# +# Screen +# + +# Auto start a session when Zsh is launched in a local terminal. +# zstyle ':prezto:module:screen:auto-start' local 'yes' + +# Auto start a session when Zsh is launched in a SSH connection. +# zstyle ':prezto:module:screen:auto-start' remote 'yes' + +# +# SSH +# + +# Set the SSH identities to load into the agent. +zstyle ':prezto:module:ssh:load' identities 'id_rsa' 'id_rsa2' 'id_github' + +# +# Syntax Highlighting +# + +# Set syntax highlighters. +# By default, only the main highlighter is enabled. +zstyle ':prezto:module:syntax-highlighting' highlighters \ + 'main' \ + 'brackets' \ + 'pattern' \ + 'line' \ + 'cursor' \ + 'root' + +# Set syntax highlighting styles. +# zstyle ':prezto:module:syntax-highlighting' styles \ +# 'builtin' 'bg=blue' \ +# 'command' 'bg=blue' \ +# 'function' 'bg=blue' +# +# Set syntax pattern styles. +zstyle ':prezto:module:syntax-highlighting' pattern \ + 'rm*-rf*' 'fg=white,bold,bg=red' +# +# Terminal +# + +# Auto set the tab and window titles. +zstyle ':prezto:module:terminal' auto-title 'yes' + +# Set the window title format. +zstyle ':prezto:module:terminal:window-title' format '%n@%m: %s' + +# Set the tab title format. +zstyle ':prezto:module:terminal:tab-title' format '%m: %s' + +# Set the terminal multiplexer title format. +zstyle ':prezto:module:terminal:multiplexer-title' format '%s' + +# +# Tmux +# + +# Auto start a session when Zsh is launched in a local terminal. +# zstyle ':prezto:module:tmux:auto-start' local 'yes' + +# Auto start a session when Zsh is launched in a SSH connection. +# zstyle ':prezto:module:tmux:auto-start' remote 'yes' + +# Integrate with iTerm2. +# zstyle ':prezto:module:tmux:iterm' integrate 'yes' + +# Set the default session name: +zstyle ':prezto:module:tmux:session' name 'default' + +# +# Utility +# + +# Enabled safe options. This aliases cp, ln, mv and rm so that they prompt +# before deleting or overwriting files. Set to 'no' to disable this safer +# behavior. +# zstyle ':prezto:module:utility' safe-ops 'yes' + +if [[ -s "${0:h}/.localrc" ]]; then + source "${0:h}/.localrc" +fi diff --git a/zsh/zprofile.symlink b/zsh/zprofile.symlink new file mode 100644 index 00000000000..c699f7d12a4 --- /dev/null +++ b/zsh/zprofile.symlink @@ -0,0 +1,67 @@ +# +# Browser +# + +if [[ "$OSTYPE" == darwin* ]]; then + export BROWSER='open' +fi + +# +# Editors +# + +export EDITOR='nano' +export VISUAL='nano' +export PAGER='less' + +# +# Language +# + +if [[ -z "$LANG" ]]; then + export LANG='en_US.UTF-8' +fi + +# +# Paths +# + +# Ensure path arrays do not contain duplicates. +typeset -gU cdpath fpath mailpath path + +# Set the list of directories that cd searches. +# cdpath=( +# $cdpath +# ) + +# Set the list of directories that Zsh searches for programs. +path=( + /usr/local/{bin,sbin} + $path +) + +# +# Less +# + +# Set the default Less options. +# Mouse-wheel scrolling has been disabled by -X (disable screen clearing). +# Remove -X and -F (exit if the content fits on one screen) to enable it. +export LESS='-F -g -i -M -R -S -w -X -z-4' + +# Set the Less input preprocessor. +# Try both `lesspipe` and `lesspipe.sh` as either might exist on a system. +if (( $#commands[(i)lesspipe(|.sh)] )); then + export LESSOPEN="| /usr/bin/env $commands[(i)lesspipe(|.sh)] %s 2>&-" +fi + +# +# Temporary Files +# + +if [[ ! -d "$TMPDIR" ]]; then + export TMPDIR="/tmp/$LOGNAME" + mkdir -p -m 700 "$TMPDIR" +fi + +TMPPREFIX="${TMPDIR%/}/zsh" diff --git a/zsh/zshenv.symlink b/zsh/zshenv.symlink new file mode 100644 index 00000000000..88df6debe40 --- /dev/null +++ b/zsh/zshenv.symlink @@ -0,0 +1,15 @@ +# +# Defines environment variables. +# +# Authors: +# Sorin Ionescu +# + +# Ensure that a non-login, non-interactive shell has a defined environment. +if [[ "$SHLVL" -eq 1 && ! -o LOGIN && -s "${ZDOTDIR:-$HOME}/.zprofile" ]]; then + source "${ZDOTDIR:-$HOME}/.zprofile" +fi + +# Path to your dotfiles installation. +export DOTFILES=$HOME/.dotfiles +export ZSH=~/.dotfiles \ No newline at end of file diff --git a/zsh/zshrc.symlink b/zsh/zshrc.symlink index 9ce55833097..340846a4477 100644 --- a/zsh/zshrc.symlink +++ b/zsh/zshrc.symlink @@ -1,9 +1,6 @@ # shortcut to this dotfiles path is $ZSH export ZSH=$HOME/.dotfiles -# your project folder that we can `c [tab]` to -export PROJECTS=~/Code - # Stash your environment variables in ~/.localrc. This means they'll stay out # of your main dotfiles repository (which may be public, like this one), but # you'll have access to them in your scripts. @@ -12,25 +9,49 @@ then source ~/.localrc fi +# Source Prezto. +if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then + source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" +fi + # all of our zsh files typeset -U config_files config_files=($ZSH/**/*.zsh) +# Load any user environment customizations prior to load +for file in ${(M)config_files:#*/*env.zsh} +do + source $file +done + # load the path files -for file in ${(M)config_files:#*/path.zsh} +for file in ${(M)config_files:#*/*path.zsh} do source $file done -# load everything but the path and completion files -for file in ${${config_files:#*/path.zsh}:#*/completion.zsh} +# path, the 0 in the filename causes this to load first + +pathAppend() { + # Only adds to the path if it's not already there + if ! echo $PATH | egrep -q "(^|:)$1($|:)" ; then + PATH=$PATH:$1 + fi +} + +# Remove duplicate entries from PATH +PATH=$(echo "$PATH" | awk -v RS=':' -v ORS=":" '!a[$1]++{if (NR > 1) printf ORS; printf $a[$1]}') +pathAppend "$ZSH/bin" + +# load everything but the path, environment and completion files +for file in ${${config_files:#*/path.zsh}:#*/completion.zsh:#*/env.zsh} do source $file done # initialize autocomplete here, otherwise functions won't be loaded -autoload -U compinit -compinit +#autoload -U compinit +#compinit # load every completion after autocomplete loads for file in ${(M)config_files:#*/completion.zsh} @@ -47,4 +68,5 @@ autoload -U down-line-or-beginning-search zle -N up-line-or-beginning-search zle -N down-line-or-beginning-search bindkey "^[[A" up-line-or-beginning-search # Up -bindkey "^[[B" down-line-or-beginning-search # Down \ No newline at end of file +bindkey "^[[B" down-line-or-beginning-search # Down + diff --git a/zsh/zzzz_after.zsh b/zsh/zzzz_after.zsh new file mode 100644 index 00000000000..8e2404bb48f --- /dev/null +++ b/zsh/zzzz_after.zsh @@ -0,0 +1,6 @@ +# Load any custom after code +if [ -d $HOME/.zsh.after/ ]; then + if [ "$(ls -A $HOME/.zsh.after/)" ]; then + for config_file ($HOME/.zsh.after/*.zsh) source $config_file + fi +fi