├── .gitignore ├── nvim ├── coc-postinstall.vim ├── plugins.vim └── init.vim ├── runcom ├── .agignore ├── .inputrc ├── .bash_profile └── .tmux.conf ├── git ├── .gitignore_global ├── .gitconfig └── .gitsettings │ └── git-completion.bash ├── install ├── bash.sh ├── mjolnir.sh ├── brew-cask.sh ├── node.sh ├── brew.sh └── nvim.sh ├── osx ├── defaults-chrome.sh ├── dock.sh └── defaults.sh ├── .editorconfig ├── bin ├── plistbuddy ├── json └── dotfiles ├── system ├── .fasd ├── .env.osx ├── .function_text ├── .grep ├── .function_network ├── .completion ├── .path ├── .function ├── .env ├── .alias.osx ├── .function.osx ├── .alias ├── .function_fs ├── .prompt └── .dir_colors ├── remote-install.sh ├── startwork.sh ├── uninstall └── uninstall-cask.sh ├── install.sh ├── etc └── mjolnir │ └── init.lua ├── README.md └── iterm2 └── com.googlecode.iterm2.plist /.gitignore: -------------------------------------------------------------------------------- 1 | system/.custom 2 | plugged 3 | -------------------------------------------------------------------------------- /nvim/coc-postinstall.vim: -------------------------------------------------------------------------------- 1 | exe ":CocInstall coc-json coc-tsserver" 2 | exe ":qa" 3 | -------------------------------------------------------------------------------- /runcom/.agignore: -------------------------------------------------------------------------------- 1 | .git 2 | node_modules 3 | .webpack 4 | packages/web/public/pdfjs 5 | -------------------------------------------------------------------------------- /git/.gitignore_global: -------------------------------------------------------------------------------- 1 | *~ 2 | ._* 3 | *.swp 4 | *.tmp 5 | .DS_Store 6 | .idea 7 | bower_components 8 | -------------------------------------------------------------------------------- /install/bash.sh: -------------------------------------------------------------------------------- 1 | brew install bash 2 | 3 | grep "/opt/homebrew/bin/bash" /private/etc/shells &>/dev/null || sudo bash -c "echo /opt/homebrew/bin/bash >> /private/etc/shells" 4 | chsh -s /opt/homebrew/bin/bash 5 | -------------------------------------------------------------------------------- /osx/defaults-chrome.sh: -------------------------------------------------------------------------------- 1 | # Disable swipe navigation 2 | defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool false 3 | defaults write com.google.Chrome.canary AppleEnableSwipeNavigateWithScrolls -bool false 4 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # top-most EditorConfig file 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | insert_final_newline = true 8 | trim_trailing_whitespace = true 9 | indent_style = space 10 | indent_size = 4 11 | -------------------------------------------------------------------------------- /install/mjolnir.sh: -------------------------------------------------------------------------------- 1 | brew cask install mjolnir 2 | 3 | brew install lua 4 | brew install luarocks 5 | 6 | luarocks install mjolnir.hotkey 7 | luarocks install mjolnir.application 8 | 9 | [ -d ~/.mjolnir ] || ln -sfv "$DOTFILES_DIR/etc/mjolnir/" ~/.mjolnir 10 | -------------------------------------------------------------------------------- /bin/plistbuddy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | PLIST=$1 4 | ACTION=$2 5 | KEY="$3" 6 | VALUE="$4" 7 | 8 | if [ -f "$HOME/Library/Preferences/${PLIST}.plist" ]; then 9 | /usr/libexec/PlistBuddy -c "$ACTION $KEY $VALUE" "$HOME/Library/Preferences/${PLIST}.plist" 10 | fi 11 | 12 | unset PLIST ACTION KEY VALUE 13 | -------------------------------------------------------------------------------- /install/brew-cask.sh: -------------------------------------------------------------------------------- 1 | # Install cask packages 2 | 3 | apps=( 4 | alfred 5 | dropbox 6 | firefox 7 | gitup 8 | google-chrome 9 | iterm2 10 | keka 11 | keycastr 12 | macdown 13 | opera 14 | visual-studio-code 15 | vlc 16 | ) 17 | 18 | brew install "${apps[@]}" --cask 19 | -------------------------------------------------------------------------------- /system/.fasd: -------------------------------------------------------------------------------- 1 | # https://github.com/clvv/fasd#install 2 | 3 | if [[ $(is-executable fasd) ]]; then 4 | 5 | fasd_cache="$HOME/.fasd-init-bash" 6 | if [ "$(command -v fasd)" -nt "$fasd_cache" -o ! -s "$fasd_cache" ]; then 7 | fasd --init posix-alias bash-hook bash-ccomp bash-ccomp-install >| "$fasd_cache" 8 | fi 9 | . "$fasd_cache" 10 | unset fasd_cache 11 | 12 | fi 13 | -------------------------------------------------------------------------------- /install/node.sh: -------------------------------------------------------------------------------- 1 | brew install volta 2 | 3 | volta install node 4 | volta install npm 5 | # TODO: check if it works without starting of a new shell 6 | . ~/.bash_profile 7 | 8 | # Globally install with npm 9 | 10 | packages=( 11 | eslint 12 | http-server 13 | nodemon 14 | release-it 15 | spot 16 | svgo 17 | tldr 18 | vtop 19 | ) 20 | 21 | npm install -g "${packages[@]}" 22 | -------------------------------------------------------------------------------- /bin/json: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | OPT_COLOR="" 4 | 5 | while getopts ":c" OPT; do 6 | case "$OPT" in 7 | c) OPT_COLOR="--color";; 8 | esac 9 | done 10 | 11 | shift $((OPTIND-1)) 12 | 13 | if [ $# -ge 1 ]; then 14 | if [[ "$1" == http* ]]; then 15 | INPUT=$(curl --silent "$1") 16 | elif [ -f "$1" ]; then 17 | INPUT=$(cat "$1") 18 | fi 19 | else 20 | INPUT=$(cat -) 21 | fi 22 | 23 | echo "$INPUT" | underscore print "$OPT_COLOR" 24 | -------------------------------------------------------------------------------- /system/.env.osx: -------------------------------------------------------------------------------- 1 | # Make Sublime the default editor 2 | 3 | export GIT_GUI="gitup" 4 | 5 | # Some app locations 6 | 7 | export CHROME_BIN="$HOME/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" 8 | export CHROME_CANARY_BIN="$HOME/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary" 9 | export FIREFOX_BIN="$HOME/Applications/Firefox.app/Contents/MacOS/firefox-bin" 10 | 11 | # Raise limit for open files and processes 12 | 13 | ulimit -S -n 8192 14 | -------------------------------------------------------------------------------- /system/.function_text: -------------------------------------------------------------------------------- 1 | # Show line, optionally show surrounding lines 2 | 3 | line() { 4 | local LINE_NUMBER=$1 5 | local LINES_AROUND=${2:-0} 6 | sed -n "`expr $LINE_NUMBER - $LINES_AROUND`,`expr $LINE_NUMBER + $LINES_AROUND`p" 7 | } 8 | 9 | # Show duplicate/unique lines 10 | # Source: https://github.com/ain/.dotfiles/commit/967a2e65a44708449b6e93f87daa2721929cb87a 11 | 12 | duplines() { 13 | sort $1 | uniq -d 14 | } 15 | 16 | uniqlines() { 17 | sort $1 | uniq -u 18 | } 19 | -------------------------------------------------------------------------------- /remote-install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | [[ -x `command -v wget` ]] && CMD="wget --no-check-certificate -O -" 4 | [[ -x `command -v curl` ]] >/dev/null 2>&1 && CMD="curl -#L" 5 | 6 | if [ -z "$CMD" ]; then 7 | echo "No curl or wget available. Aborting." 8 | else 9 | echo "Installing dotfiles" 10 | mkdir -p "$HOME/.dotfiles" && \ 11 | eval "$CMD https://github.com/webpro/dotfiles/tarball/master | tar -xzv -C ~/.dotfiles --strip-components=1 --exclude='{.gitignore}'" 12 | . "$HOME/.dotfiles/install.sh" 13 | fi 14 | -------------------------------------------------------------------------------- /system/.grep: -------------------------------------------------------------------------------- 1 | # Tell grep to highlight matches 2 | 3 | if is-supported "grep --color a <<< a"; then 4 | GREP_OPTIONS+=" --color=auto" 5 | fi 6 | 7 | # Avoid VCS folders 8 | 9 | if is-supported "echo | grep --exclude-dir=.cvs ''"; then 10 | for PATTERN in .cvs .git .hg .svn; do 11 | GREP_OPTIONS+=" --exclude-dir=$PATTERN" 12 | done 13 | elif is-supported "echo | grep --exclude=.cvs ''"; then 14 | for PATTERN in .cvs .git .hg .svn; do 15 | GREP_OPTIONS+=" --exclude=$PATTERN" 16 | done 17 | fi 18 | 19 | alias grep="grep $GREP_OPTIONS" 20 | export GREP_COLOR='1;32' 21 | -------------------------------------------------------------------------------- /startwork.sh: -------------------------------------------------------------------------------- 1 | tmuxSessionWork="work" 2 | projectDirectory="cd projects/iconik_web" 3 | tmux start-server 4 | tmux new-session -d -s $tmuxSessionWork -n vim 5 | tmux send-keys "$projectDirectory" C-m 6 | tmux send-keys "clear" C-m 7 | tmux split-window -h 8 | tmux send-keys "$projectDirectory" C-m 9 | tmux send-keys "clear" C-m 10 | tmux select-pane -t 0 11 | tmux new-window -t $tmuxSessionWork:2 -n misc 12 | tmux send-keys "$projectDirectory" C-m 13 | tmux send-keys "clear" C-m 14 | tmux new-window -t $tmuxSessionWork:3 -n bash 15 | tmux select-window -t $tmuxSessionWork:1 16 | tmux attach-session -t $tmuxSessionWork 17 | -------------------------------------------------------------------------------- /system/.function_network: -------------------------------------------------------------------------------- 1 | # Webserver 2 | 3 | srv() { 4 | local PORT=${1:-80} 5 | if [ "$PORT" -le "1024" ]; then 6 | sudo -v 7 | fi 8 | http-server . -p "$PORT" -c-1 9 | } 10 | 11 | # Get IP from hostname 12 | 13 | hostname2ip() { 14 | ping -c 1 "$1" | egrep -m1 -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' 15 | } 16 | 17 | # Upload file to transfer.sh 18 | # https://github.com/dutchcoders/transfer.sh/ 19 | 20 | transfer() { 21 | tmpfile=$( mktemp -t transferXXX ) 22 | curl --progress-bar --upload-file "$1" https://transfer.sh/$(basename $1) >> $tmpfile; 23 | cat $tmpfile; 24 | rm -f $tmpfile; 25 | } 26 | -------------------------------------------------------------------------------- /uninstall/uninstall-cask.sh: -------------------------------------------------------------------------------- 1 | # Uninstall packages 2 | 3 | apps=( 4 | alfred 5 | dropbox 6 | filezilla 7 | firefox 8 | firefox-nightly 9 | gitup 10 | google-chrome 11 | google-chrome-canary 12 | google-drive 13 | iterm2 14 | keka 15 | keycastr 16 | macdown 17 | opera 18 | sublime-text3 19 | sourcetree 20 | virtualbox 21 | vlc 22 | ) 23 | 24 | brew cask uninstall "${apps[@]}" 25 | 26 | # Quick Look Plugins (https://github.com/sindresorhus/quick-look-plugins) 27 | brew cask uninstall qlcolorcode qlstephen qlmarkdown quicklook-json qlprettypatch quicklook-csv betterzipql webpquicklook suspicious-package && qlmanage -r 28 | 29 | # Uninstall Caskroom 30 | 31 | brew untap caskroom/cask 32 | brew untap caskroom/versions 33 | brew uninstall brew-cask 34 | -------------------------------------------------------------------------------- /install/brew.sh: -------------------------------------------------------------------------------- 1 | # Install Homebrew 2 | 3 | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 4 | brew update 5 | brew upgrade 6 | 7 | # Install packages 8 | 9 | apps=( 10 | ag 11 | # bash-completion2 12 | cmake 13 | coreutils 14 | dockutil 15 | ffmpeg 16 | fasd 17 | gifsicle 18 | git 19 | gnu-sed 20 | grep 21 | hub 22 | httpie 23 | imagemagick 24 | jq 25 | mackup 26 | peco 27 | psgrep 28 | python 29 | shellcheck 30 | ssh-copy-id 31 | svn 32 | tmux 33 | tree 34 | neovim 35 | volta 36 | wget 37 | ) 38 | 39 | brew install "${apps[@]}" 40 | 41 | # Git comes with diff-highlight, but isn't in the PATH 42 | ln -sf "$(brew --prefix)/share/git-core/contrib/diff-highlight/diff-highlight" /usr/local/bin/diff-highlight 43 | -------------------------------------------------------------------------------- /system/.completion: -------------------------------------------------------------------------------- 1 | # Bash 2 | 3 | is-executable brew && [ -f $(brew --prefix)/share/bash-completion/bash_completion ] && . $(brew --prefix)/share/bash-completion/bash_completion 4 | 5 | # Dotfiles 6 | 7 | _dotfiles_completions() { 8 | local cur="${COMP_WORDS[COMP_CWORD]}" 9 | COMPREPLY=( $(compgen -W '`dotfiles completion`' -- $cur ) ); 10 | } 11 | 12 | complete -o default -F _dotfiles_completions dotfiles 13 | 14 | # Grunt 15 | 16 | is-executable grunt && eval "$(grunt --completion=bash)" 17 | 18 | # killall 19 | 20 | complete -o "nospace" -W "Contacts Calendar Dock Finder Mail Safari iTunes SystemUIServer Terminal" killall; 21 | 22 | # Homebrew 23 | 24 | is-executable brew && [ -f $(brew --prefix)/Library/Contributions/brew_bash_completion.sh ] && . `brew --prefix`/Library/Contributions/brew_bash_completion.sh 25 | 26 | # Git 27 | source ~/.gitsettings/git-completion.bash 28 | -------------------------------------------------------------------------------- /osx/dock.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | dockutil --no-restart --remove all 4 | dockutil --no-restart --add "$HOME/Applications/Google Chrome.app" 5 | dockutil --no-restart --add "$HOME/Applications/Firefox.app" 6 | dockutil --no-restart --add "$HOME/Applications/Google Chrome Canary.app" 7 | dockutil --no-restart --add "/Applications/Safari.app" 8 | dockutil --no-restart --add "/Applications/Mail.app" 9 | dockutil --no-restart --add "/Applications/Calendar.app" 10 | dockutil --no-restart --add "/Applications/Messages.app" 11 | dockutil --no-restart --add "/Applications/FaceTime.app" 12 | dockutil --no-restart --add "/Applications/iTunes.app" 13 | dockutil --no-restart --add "$HOME/Applications/Keka.app" 14 | dockutil --no-restart --add "$HOME/Applications/iTerm.app" 15 | dockutil --no-restart --add "/Applications/System Preferences.app" 16 | dockutil --no-restart --add "/Applications/Utilities/Console.app" 17 | 18 | killall Dock 19 | -------------------------------------------------------------------------------- /system/.path: -------------------------------------------------------------------------------- 1 | # Start with system path 2 | # Retrieve it from getconf, otherwise it's just current $PATH 3 | 4 | is-executable getconf && PATH=$(command -v getconf PATH) 5 | 6 | # Prepend new items to path (if directory exists) 7 | 8 | prepend-path "/bin" 9 | prepend-path "/usr/bin" 10 | prepend-path "/usr/local/bin" 11 | prepend-path "$DOTFILES_DIR/bin" 12 | prepend-path "$HOME/bin" 13 | prepend-path "/sbin" 14 | prepend-path "/usr/sbin" 15 | prepend-path "/usr/local/sbin" 16 | prepend-path "/opt/homebrew/bin" 17 | prepend-path "/opt/homebrew/sbin" 18 | is-executable brew && prepend-path "$(brew --prefix coreutils)/libexec/gnubin" 19 | prepend-path "$HOME/.volta/bin" 20 | prepend-path "$HOME/.rd/bin" 21 | 22 | # Remove duplicates (preserving prepended items) 23 | # Source: http://unix.stackexchange.com/a/40755 24 | 25 | PATH=`echo -n $PATH | awk -v RS=: '{ if (!arr[$0]++) {printf("%s%s",!ln++?"":":",$0)}}'` 26 | 27 | # Wrap up 28 | 29 | export PATH 30 | -------------------------------------------------------------------------------- /install/nvim.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Link vim configs for neovim 4 | mkdir -p ~/.config/nvim 5 | # ln -sfv "$DOTFILES_DIR/vim/vimrc" ~/.vimrc 6 | ln -sfv "$DOTFILES_DIR/nvim/init.vim" ~/.config/nvim/init.vim 7 | 8 | # Download vim-plug and initialize autoload directory 9 | curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim 10 | 11 | # Install plugins 12 | nvim +PlugInstall +qall 13 | 14 | # Install dependencies for TypeScript support in coc-nvim 15 | cd "$DOTFILES_DIR/nvim/plugged/coc.nvim" 16 | npm install 17 | nvim "+CocInstall coc-json coc-tsserver" 18 | # FIXME: can't execute commands in sequence 19 | # qall works right away and doesn't wait CocInstall command 20 | # Command was taken from 21 | # https://vi.stackexchange.com/questions/34693/how-to-run-multiple-commands-sequentially-in-nvim 22 | # nvim --headless -c "CocInstall coc-json coc-tsserver" -c "qall" 23 | cd ~ 24 | -------------------------------------------------------------------------------- /system/.function: -------------------------------------------------------------------------------- 1 | # Get named var (usage: get "VAR_NAME") 2 | 3 | get() { 4 | echo "${!1}" 5 | } 6 | 7 | # Executable 8 | 9 | is-executable() { 10 | local BIN=$(command -v "$1" 2>/dev/null) 11 | if [[ ! $BIN == "" && -x $BIN ]]; then true; else false; fi 12 | } 13 | 14 | is-supported() { 15 | if [ $# -eq 1 ]; then 16 | if eval "$1" > /dev/null 2>&1; then true; else false; fi 17 | else 18 | if eval "$1" > /dev/null 2>&1; then 19 | echo -n "$2" 20 | else 21 | echo -n "$3" 22 | fi 23 | fi 24 | } 25 | 26 | # Add to path 27 | 28 | prepend-path() { 29 | [ -d $1 ] && PATH="$1:$PATH" 30 | } 31 | 32 | # Show 256 TERM colors 33 | 34 | colors() { 35 | local X=$(tput op) 36 | local Y=$(printf %$((COLUMNS-6))s) 37 | for i in {0..256}; do 38 | o=00$i; 39 | echo -e ${o:${#o}-3:3} $(tput setaf $i;tput setab $i)${Y// /=}$X; 40 | done 41 | } 42 | 43 | # Calculator 44 | 45 | calc() { 46 | echo "$*" | bc -l; 47 | } 48 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Get current dir (so run this script from anywhere) 4 | 5 | export DOTFILES_DIR EXTRA_DIR 6 | DOTFILES_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 7 | EXTRA_DIR="$HOME/.extra" 8 | 9 | # Update dotfiles itself first 10 | 11 | [ -d "$DOTFILES_DIR/.git" ] && git --work-tree="$DOTFILES_DIR" --git-dir="$DOTFILES_DIR/.git" pull origin master 12 | 13 | # Bunch of symlinks 14 | 15 | ln -sfv "$DOTFILES_DIR/runcom/.bash_profile" ~ 16 | ln -sfv "$DOTFILES_DIR/runcom/.inputrc" ~ 17 | ln -sfv "$DOTFILES_DIR/runcom/.tmux.conf" ~ 18 | ln -sfv "$DOTFILES_DIR/runcom/.agignore" ~ 19 | ln -sfv "$DOTFILES_DIR/git/.gitconfig" ~ 20 | ln -sfv "$DOTFILES_DIR/git/.gitignore_global" ~ 21 | ln -sfv "$DOTFILES_DIR/git/.gitsettings" ~ 22 | 23 | # Package managers & packages 24 | 25 | . "$DOTFILES_DIR/install/brew.sh" 26 | . "$DOTFILES_DIR/install/bash.sh" 27 | . "$DOTFILES_DIR/install/node.sh" 28 | . "$DOTFILES_DIR/install/nvim.sh" 29 | 30 | if [ "$(uname)" == "Darwin" ]; then 31 | . "$DOTFILES_DIR/install/brew-cask.sh" 32 | fi 33 | 34 | # Install extra stuff 35 | 36 | if [ -d "$EXTRA_DIR" -a -f "$EXTRA_DIR/install.sh" ]; then 37 | . "$EXTRA_DIR/install.sh" 38 | fi 39 | -------------------------------------------------------------------------------- /runcom/.inputrc: -------------------------------------------------------------------------------- 1 | # Make Tab autocomplete regardless of filename case 2 | set completion-ignore-case on 3 | 4 | # List all matches in case multiple possible completions are possible 5 | set show-all-if-ambiguous on 6 | 7 | # Immediately add a trailing slash when autocompleting symlinks to directories 8 | set mark-symlinked-directories on 9 | 10 | # Show all autocomplete results at once 11 | set page-completions off 12 | 13 | # If there are more than 200 possible completions for a word, ask to show them all 14 | set completion-query-items 200 15 | 16 | # Show extra file information when completing, like `ls -F` does 17 | set visible-stats on 18 | 19 | # Be more intelligent when autocompleting by also looking at the text after 20 | # the cursor. For example, when the current line is "cd ~/src/mozil", and 21 | # the cursor is on the "z", pressing Tab will not autocomplete it to "cd 22 | # ~/src/mozillail", but to "cd ~/src/mozilla". (This is supported by the 23 | # Readline used by Bash 4.) 24 | set skip-completed-text on 25 | 26 | # Allow UTF-8 input and output, instead of showing stuff like $'\0123\0456' 27 | set input-meta on 28 | set output-meta on 29 | set convert-meta off 30 | 31 | # Flip through autocompletion matches with Shift-Tab. 32 | "\e[Z": menu-complete 33 | 34 | # Filtered history search 35 | "\e[A": history-search-backward 36 | "\e[B": history-search-forward 37 | -------------------------------------------------------------------------------- /system/.env: -------------------------------------------------------------------------------- 1 | # History 2 | 3 | export HISTSIZE=32768; 4 | export HISTFILESIZE="${HISTSIZE}"; 5 | export SAVEHIST=4096 6 | export HISTCONTROL=ignoredups:erasedups 7 | 8 | # Enable colors 9 | 10 | export CLICOLOR=1 11 | 12 | # Prefer US English and use UTF-8 13 | 14 | export LC_ALL="en_US.UTF-8" 15 | export LANG="en_US" 16 | 17 | # Highlight section titles in man pages 18 | 19 | export LESS_TERMCAP_md="${yellow}"; 20 | 21 | # Keep showing man page after exit 22 | 23 | export MANPAGER='less -X'; 24 | 25 | # Vim 26 | 27 | export EDITOR="nvim" 28 | export NVIMCONFIGS="$DOTFILES_DIR/nvim/" 29 | # FIXME: usure if it is still needed 30 | # READLINK=$(which greadlink || which readlink) 31 | # export VIMRUNTIME="$(dirname $(dirname $($READLINK -f $(which nvim))))/share/nvim/runtime" 32 | # unset READLINK 33 | 34 | # Case-insensitive globbing (used in pathname expansion) 35 | 36 | shopt -s nocaseglob 37 | 38 | # Recursive globbing with "**" 39 | 40 | if [ ${BASH_VERSINFO[0]} -ge 4 ]; then 41 | shopt -s globstar 42 | fi 43 | 44 | # Append to the Bash history file, rather than overwriting it 45 | 46 | shopt -s histappend 47 | 48 | # Autocorrect typos in path names when using `cd` 49 | 50 | shopt -s cdspell 51 | 52 | # Do not autocomplete when accidentally pressing Tab on an empty line. 53 | 54 | shopt -s no_empty_cmd_completion 55 | 56 | # Check the window size after each command and, if necessary, 57 | # update the values of LINES and COLUMNS. 58 | 59 | shopt -s checkwinsize 60 | 61 | # Fix Ctrl+S issue (prevent from forward search in bash) 62 | stty -ixon 63 | 64 | # Delete words in path with Ctrl-W 65 | bind '\C-w:backward-kill-word' 66 | 67 | # GPG 68 | export GPG_TTY=$(tty) 69 | -------------------------------------------------------------------------------- /runcom/.bash_profile: -------------------------------------------------------------------------------- 1 | # If not running interactively, don't do anything 2 | 3 | [ -z "$PS1" ] && return 4 | 5 | # OS 6 | 7 | if [ "$(uname -s)" = "Darwin" ]; then 8 | OS="OSX" 9 | else 10 | OS=$(uname -s) 11 | fi 12 | 13 | # Resolve DOTFILES_DIR (assuming ~/.dotfiles on distros without readlink and/or $BASH_SOURCE/$0) 14 | 15 | READLINK=$(which greadlink || which readlink) 16 | CURRENT_SCRIPT=$BASH_SOURCE 17 | 18 | if [[ -n $CURRENT_SCRIPT && -x "$READLINK" ]]; then 19 | SCRIPT_PATH=$($READLINK -f "$CURRENT_SCRIPT") 20 | DOTFILES_DIR=$(dirname "$(dirname "$SCRIPT_PATH")") 21 | elif [ -d "$HOME/.dotfiles" ]; then 22 | DOTFILES_DIR="$HOME/.dotfiles" 23 | else 24 | echo "Unable to find dotfiles, exiting." 25 | return # `exit 1` would quit the shell itself 26 | fi 27 | 28 | # Finally we can source the dotfiles (order matters) 29 | 30 | for DOTFILE in "$DOTFILES_DIR"/system/.{function,function_*,path,env,alias,completion,grep,prompt,custom}; do 31 | [ -f "$DOTFILE" ] && . "$DOTFILE" 32 | done 33 | 34 | if [ "$OS" = "OSX" ]; then 35 | for DOTFILE in "$DOTFILES_DIR"/system/.{env,alias,function}.osx; do 36 | [ -f "$DOTFILE" ] && . "$DOTFILE" 37 | done 38 | fi 39 | 40 | # Set LSCOLORS 41 | 42 | # eval "$(dircolors "$DOTFILES_DIR"/system/.dir_colors)" 43 | 44 | # Hook for extra/custom stuff 45 | 46 | EXTRA_DIR="$HOME/.extra" 47 | 48 | if [ -d "$EXTRA_DIR" ]; then 49 | for EXTRAFILE in "$EXTRA_DIR"/runcom/*.sh; do 50 | [ -f "$EXTRAFILE" ] && . "$EXTRAFILE" 51 | done 52 | fi 53 | 54 | # Clean up 55 | 56 | unset READLINK CURRENT_SCRIPT SCRIPT_PATH DOTFILE 57 | 58 | # Export 59 | 60 | export OS DOTFILES_DIR EXTRA_DIR 61 | 62 | eval "$(/opt/homebrew/bin/brew shellenv)" 63 | 64 | alias vim="nvim" 65 | -------------------------------------------------------------------------------- /nvim/plugins.vim: -------------------------------------------------------------------------------- 1 | " ======================================== 2 | " Vim plugin configuration 3 | " ======================================== 4 | " 5 | " This file contains the list of plugin installed using plugin manager. 6 | 7 | call plug#begin(expand('$NVIMCONFIGS/plugged')) 8 | 9 | " Generic 10 | 11 | Plug 'scrooloose/nerdtree' 12 | Plug 'scrooloose/nerdcommenter' 13 | Plug 'ctrlpvim/ctrlp.vim' 14 | Plug 'bling/vim-airline' 15 | Plug 'vim-airline/vim-airline-themes' 16 | Plug 'terryma/vim-multiple-cursors' 17 | Plug 'rbgrouleff/bclose.vim' 18 | Plug 'Raimondi/delimitMate' 19 | Plug 'jeetsukumaran/vim-buffergator' 20 | " Plug 'lyokha/vim-xkbswitch' 21 | Plug 'tpope/vim-sensible' 22 | Plug 'tpope/vim-surround' 23 | Plug 'tpope/vim-abolish' 24 | Plug 'rking/ag.vim' 25 | " Plug 'sagarrakshe/toggle-bool' 26 | " jumps to particluar line of file 27 | Plug 'wsdjeg/vim-fetch' 28 | 29 | " Git 30 | 31 | Plug 'tpope/vim-fugitive' 32 | Plug 'airblade/vim-gitgutter' 33 | 34 | " Syntax hightlighting & colors 35 | 36 | Plug 'scrooloose/syntastic' 37 | Plug 'altercation/vim-colors-solarized' 38 | Plug 'trusktr/seti.vim' 39 | Plug 'myshov/vim-color-smycking' 40 | 41 | " Completion & snippets 42 | 43 | " Plug 'SirVer/ultisnips' 44 | Plug 'honza/vim-snippets' 45 | Plug 'neoclide/coc.nvim', {'branch': 'master', 'do': 'yarn install --frozen-lockfile'} 46 | 47 | " JavaScript 48 | 49 | Plug 'pangloss/vim-javascript' 50 | Plug 'moll/vim-node' 51 | Plug 'mxw/vim-jsx' 52 | 53 | " TypeScript 54 | Plug 'leafgarland/typescript-vim' 55 | Plug 'ianks/vim-tsx' 56 | 57 | " Integrations 58 | 59 | Plug 'christoomey/vim-tmux-navigator' 60 | 61 | " Other 62 | 63 | Plug 'tpope/vim-markdown' 64 | Plug 'mattn/emmet-vim' 65 | Plug 'junegunn/goyo.vim' 66 | 67 | " Initialize plugin system 68 | 69 | call plug#end() 70 | -------------------------------------------------------------------------------- /git/.gitconfig: -------------------------------------------------------------------------------- 1 | [user] 2 | name = Alexander Myshov 3 | email = simplex.light@gmail.com 4 | signingkey = CA638CF761F11C7A 5 | 6 | [github] 7 | user = myshov 8 | 9 | [core] 10 | excludesfile = ~/.gitignore_global 11 | editor = vim 12 | 13 | [alias] 14 | st = status 15 | sts = status -sb 16 | stl = ls-files -m -o --exclude-standard 17 | ci = commit 18 | br = branch 19 | co = checkout 20 | cr = clone --recursive 21 | df = diff --word-diff 22 | unstage = reset --hard HEAD 23 | l = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit 24 | ll = log --pretty=oneline --graph --abbrev-commit 25 | lm = log --pretty=format:'* %s (%h)' 26 | lg = log -p 27 | g = grep --break --heading --line-number 28 | amend = commit --amend --reuse-message=HEAD 29 | contrib = shortlog --summary --numbered 30 | show-ignored = "! git clean -ndX | perl -pe 's/Would remove/Ignored:/'" 31 | ld = "!sh -c \"git log --since '${1:-1} days ago' --oneline --author $(git config user.email)\" -" 32 | pr = "!f() { git fetch -fu ${2:-origin} refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f" 33 | 34 | [push] 35 | default = simple 36 | 37 | [color] 38 | ui = auto 39 | [color "branch"] 40 | current = yellow reverse 41 | local = yellow 42 | remote = green 43 | [color "diff"] 44 | meta = yellow bold 45 | frag = magenta bold 46 | old = red bold 47 | new = green bold 48 | [color "status"] 49 | added = yellow 50 | changed = green 51 | untracked = cyan 52 | [color "diff-highlight"] 53 | oldNormal = "red bold" 54 | oldHighlight = "red bold 52" 55 | newNormal = "green bold" 56 | newHighlight = "green bold 22" 57 | [commit] 58 | gpgsign = false 59 | -------------------------------------------------------------------------------- /runcom/.tmux.conf: -------------------------------------------------------------------------------- 1 | # Add mouse mode 2 | set -g mouse on 3 | 4 | # Setup mouse wheel 5 | bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e'" 6 | bind -n WheelDownPane select-pane -t= \; send-keys -M 7 | 8 | # Toggle mouse on with ^B m 9 | bind m \ 10 | set -g mouse on \;\ 11 | display 'Mouse: ON' 12 | 13 | # Toggle mouse off with ^B M 14 | bind M \ 15 | set -g mouse off \;\ 16 | display 'Mouse: OFF' 17 | 18 | # Smart pane switching with awareness of vim splits 19 | # See: https://github.com/christoomey/vim-tmux-navigator 20 | is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?x?)(diff)?$"' 21 | bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L" 22 | bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D" 23 | bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U" 24 | bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R" 25 | bind -n C-\\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l" 26 | 27 | # Appearance 28 | 29 | set -g default-terminal "screen-256color" 30 | # Define my custom menu bar 31 | # status bar colors 32 | set -g status-bg black 33 | set -g status-fg white 34 | 35 | # alignment settings 36 | set-option -g status-justify centre 37 | 38 | # status left options 39 | set-option -g status-left '#[fg=green][#[bg=black,fg=cyan]#S#[fg=green]]' 40 | set-option -g status-left-length 20 41 | 42 | # window list options 43 | setw -g automatic-rename on 44 | set-window-option -g window-status-format '#[fg=cyan,dim]#I#[fg=blue]:#[default]#W#[fg=grey,dim]#F' 45 | set-window-option -g window-status-current-format '#[bg=blue,fg=cyan,bold]#I#[bg=blue,fg=cyan]:#[fg=colour230]#W#[fg=dim]#F' 46 | set -g base-index 1 47 | 48 | # status right options 49 | set -g status-right '#[fg=green][#[fg=blue]%Y-%m-%d #[fg=white]%H:%M#[default] #(/usr/local/bin/xkbswitch -ge | sed 's/RussianWin/RU/')#[fg=green]]' 50 | 51 | # Status bar refresh rate (seconds) 52 | set -g status-interval 1 53 | -------------------------------------------------------------------------------- /system/.alias.osx: -------------------------------------------------------------------------------- 1 | # Shortcuts 2 | 3 | alias gg="$GIT_GUI" 4 | 5 | alias chrome="open -a ~/Applications/Google\ Chrome.app" 6 | alias canary="open -a ~/Applications/Google\ Chrome\ Canary.app" 7 | alias firefox="open -a ~/Applications/Firefox.app" 8 | 9 | # Exclude OSX specific files in ZIP archives 10 | 11 | alias zip="zip -x *.DS_Store -x *__MACOSX* -x *.AppleDouble*" 12 | 13 | # Open iOS Simulator 14 | 15 | alias ios="open /Applications/Xcode.app/Contents/Developer/Applications/iOS\ Simulator.app" 16 | 17 | # Flush DNS 18 | 19 | alias flushdns="dscacheutil -flushcache && killall -HUP mDNSResponder" 20 | 21 | # Start screen saver 22 | 23 | alias afk="/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine" 24 | 25 | # Log off 26 | 27 | alias logoff="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend" 28 | 29 | # Show/hide desktop icons 30 | 31 | alias desktopshow="defaults write com.apple.finder CreateDesktop -bool true && killfinder" 32 | alias desktophide="defaults write com.apple.finder CreateDesktop -bool false && killfinder" 33 | 34 | # Clean up LaunchServices to remove duplicates in the "Open With" menu 35 | 36 | alias lscleanup="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder" 37 | 38 | # Empty trash on mounted volumes and main HDD, and clear system logs 39 | 40 | alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl" 41 | 42 | # Reload native apps 43 | 44 | alias killfinder="killall Finder" 45 | alias killdock="killall Dock" 46 | alias killmenubar="killall SystemUIServer NotificationCenter" 47 | alias killosx="killfinder && killdock && killmenubar" 48 | 49 | ## Kill all the tabs in Chrome to free up memory 50 | 51 | alias chromekill="ps ux | grep '[C]hrome Helper --type=renderer' | grep -v extension-process | tr -s ' ' | cut -d ' ' -f2 | xargs kill" 52 | -------------------------------------------------------------------------------- /system/.function.osx: -------------------------------------------------------------------------------- 1 | # Open man page as PDF 2 | 3 | manpdf() { 4 | man -t "$1" | open -f -a /Applications/Preview.app/ 5 | } 6 | 7 | # Dev 8 | 9 | d() { 10 | $EDITOR_ALT ${1:-.} 11 | $GIT_GUI ${1:-.} 12 | } 13 | 14 | # Show and select the given file(s) in the Finder 15 | # Source: https://github.com/janmoesen/tilde/blob/348c90caf004b7185816e620f240fd2406e4eace/.bash/commands#L259-L299 16 | 17 | show() { 18 | # Default to the current directory. 19 | [ $# -eq 0 ] && set -- .; 20 | 21 | # Build the array of paths for AppleScript. 22 | local path paths=(); 23 | for path; do 24 | # Make sure each path exists. 25 | if ! [ -e "$path" ]; then 26 | echo "show: $path: No such file or directory"; 27 | continue; 28 | fi; 29 | 30 | # Crappily re-implement "readlink -f" ("realpath") for Darwin. 31 | # (The "cd ... > /dev/null" hides CDPATH noise.) 32 | [ -d "$path" ] \ 33 | && path="$(cd "$path" > /dev/null && pwd)" \ 34 | || path="$(cd "$(dirname "$path")" > /dev/null && \ 35 | echo "$PWD/$(basename "$path")")"; 36 | 37 | # Use the "POSIX file" AppleScript syntax. 38 | paths+=("POSIX file \"${path//\"/\"}\""); 39 | done; 40 | [ "${#paths[@]}" -eq 0 ] && return; 41 | 42 | # Group all output to pipe through osacript. 43 | { 44 | echo 'tell application "Finder"'; 45 | echo -n 'select {'; # "reveal" would select only the last file. 46 | 47 | for ((i = 0; i < ${#paths[@]}; i++)); do 48 | echo -n "${paths[$i]}"; 49 | [ $i -lt $(($# - 1)) ] && echo -n ', '; # Ugly array.join()... 50 | done; 51 | 52 | echo '}'; 53 | echo 'activate'; 54 | echo 'end tell'; 55 | } | osascript; 56 | } 57 | 58 | # Open query in Dash app 59 | 60 | dash() { 61 | case $# in 62 | 1) QUERY="$1";; 63 | 2) QUERY="$1:$2";; 64 | *) echo "Usage: dash [docset] query"; return 1; 65 | esac 66 | open "dash://$QUERY" 67 | } 68 | -------------------------------------------------------------------------------- /bin/dotfiles: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | BIN_NAME=$(basename "$0") 4 | COMMAND_NAME=$1 5 | SUB_COMMAND_NAME=$2 6 | 7 | sub_help () { 8 | echo "Usage: $BIN_NAME " 9 | echo 10 | echo "Commands:" 11 | echo " help This help message" 12 | echo " edit Open dotfiles in editor ($EDITOR_ALT) and Git GUI ($GIT_GUI)" 13 | echo " reload Reload dotfiles" 14 | echo " test Run tests" 15 | echo " update Update packages and pkg managers (OS, brew, npm, gem, pip)" 16 | echo " osx Apply OS X system defaults" 17 | echo " dock Apply OS X Dock settings" 18 | echo " install mjolnir Install Mjolnir (Homebrew/Luarocks)" 19 | echo " install vundle Install Vundle" 20 | } 21 | 22 | sub_edit () { 23 | sh -c "$EDITOR_ALT $DOTFILES_DIR" 24 | sh -c "$GIT_GUI $DOTFILES_DIR" 25 | } 26 | 27 | sub_reload () { 28 | . ~/.bash_profile && echo "Bash reloaded." 29 | } 30 | 31 | sub_update () { 32 | sudo softwareupdate -i -a 33 | brew update 34 | brew upgrade 35 | npm install npm -g 36 | npm update -g 37 | gem update --system 38 | gem update 39 | pip install --upgrade pip 40 | pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs pip install -U 41 | } 42 | 43 | sub_osx () { 44 | for DEFAULTS_FILE in "$DOTFILES_DIR"/osx/defaults*.sh; do 45 | echo "Applying $DEFAULTS_FILE" && . "$DEFAULTS_FILE" 46 | done 47 | echo "Done. Some changes may require a logout/restart to take effect." 48 | } 49 | 50 | sub_dock () { 51 | . "$DOTFILES_DIR/osx/dock.sh" && echo "Dock reloaded." 52 | } 53 | 54 | sub_install () { 55 | local SCRIPT="$DOTFILES_DIR/install/$SUB_COMMAND_NAME.sh" 56 | [ -f "$SCRIPT" ] && . "$SCRIPT" || echo "Unable to find script to install $SUB_COMMAND_NAME" 57 | } 58 | 59 | # Make sure to keep this in sync with the available public commands 60 | 61 | sub_completion () { 62 | echo "help edit reload test update osx dock install" 63 | } 64 | 65 | case $COMMAND_NAME in 66 | "" | "-h" | "--help") 67 | sub_help 68 | ;; 69 | *) 70 | shift 71 | sub_${COMMAND_NAME} $@ 72 | if [ $? = 127 ]; then 73 | echo "'$COMMAND_NAME' is not a known command or has errors." >&2 74 | sub_help 75 | exit 1 76 | fi 77 | ;; 78 | esac 79 | -------------------------------------------------------------------------------- /system/.alias: -------------------------------------------------------------------------------- 1 | # Shortcuts 2 | 3 | alias _="sudo" 4 | alias g="git" 5 | alias v="vim" 6 | alias rr="rm -rf" 7 | alias json="json -c" 8 | 9 | is-executable hub && eval "$(hub alias -s)" # alias git=hub 10 | 11 | # Global aliases 12 | 13 | if $(is-supported "alias -g"); then 14 | alias -g G="| grep -i" 15 | alias -g H="| head" 16 | alias -g T="| tail" 17 | alias -g L="| less" 18 | fi 19 | 20 | # List declared aliases, functions 21 | 22 | alias listaliases="alias | sed 's/=.*//'" 23 | alias listfunctions="declare -f | grep '^[a-z].* ()' | sed 's/{$//'" # show non _prefixed functions 24 | 25 | # ls 26 | 27 | LS_COLORS=`is-supported "ls --color" --color -G` 28 | LS_TIMESTYLEISO=`is-supported "ls --time-style=long-iso" --time-style=long-iso` 29 | LS_GROUPDIRSFIRST=`is-supported "ls --group-directories-first" --group-directories-first` 30 | 31 | alias l="ls -lahA $LS_COLORS $LS_TIMESTYLEISO $LS_GROUPDIRSFIRST" 32 | alias ll="ls -lA $LS_COLORS" 33 | alias lt="ls -lhAtr $LS_COLORS $LS_TIMESTYLEISO $LS_GROUPDIRSFIRST" 34 | alias ld="ls -ld $LS_COLORS */" 35 | 36 | unset LS_COLORS LS_TIMESTYLEISO LS_GROUPDIRSFIRST 37 | 38 | # cd 39 | 40 | alias ..="cd .." 41 | alias ...="cd ../.." 42 | alias ....="cd ../../.." 43 | alias -- -="cd -" # Go to previous dir with - 44 | alias cd.='cd $(readlink -f .)' # Go to real dir (i.e. if current dir is linked) 45 | 46 | # tree 47 | 48 | alias tree="tree -A" 49 | alias treed="tree -d" 50 | alias tree1="tree -d -L 1" 51 | alias tree2="tree -d -L 2" 52 | 53 | # rsync 54 | 55 | alias rsync="rsync -vh" 56 | 57 | # npm 58 | 59 | alias ni="npm install" 60 | alias nun="npm uninstall" 61 | alias nup="npm update" 62 | 63 | # Network 64 | 65 | alias ip="dig +short myip.opendns.com @resolver1.opendns.com" 66 | alias ipl="ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'" 67 | 68 | # Request using GET, POST, etc. method 69 | 70 | for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do 71 | alias "$method"="lwp-request -m '$method'" 72 | done 73 | 74 | # Recursively remove Apple meta files 75 | 76 | alias cleanupds="find . -type f -name '*.DS_Store' -ls -exec /bin/rm {} \;" 77 | alias cleanupad="find . -type d -name '.AppleD*' -ls -exec /bin/rm -r {} \;" 78 | 79 | # History syncing 80 | 81 | alias h="history -a; history -c; history -r;" 82 | 83 | # Miscellaneous 84 | 85 | alias quit="exit" 86 | alias week="date +%V" 87 | alias speedtest="wget -O /dev/null http://speedtest.wdc01.softlayer.com/downloads/test10.zip" 88 | -------------------------------------------------------------------------------- /system/.function_fs: -------------------------------------------------------------------------------- 1 | # Create a new directory and enter it 2 | 3 | mk() { 4 | mkdir -p "$@" && cd "$@" 5 | } 6 | 7 | # Fuzzy find file/dir 8 | 9 | ff() { find . -type f -iname "$1";} 10 | fff() { find . -type f -iname "*$1*";} 11 | fd() { find . -type d -iname "$1";} 12 | fdf() { find . -type d -iname "*$1*";} 13 | 14 | # Show disk usage of current folder, or list with depth 15 | 16 | duf() { 17 | du --max-depth=${1:-0} -c | sort -r -n | awk '{split("K M G",v); s=1; while($1>1024){$1/=1024; s++} print int($1)v[s]"\t"$2}' 18 | } 19 | 20 | # Extract many types of compress files 21 | # Source: http://nparikh.org/notes/zshrc.txt 22 | 23 | extract() { 24 | if [ -f "$1" ]; then 25 | case "$1" in 26 | *.tar.bz2) tar -jxvf "$1" ;; 27 | *.tar.gz) tar -zxvf "$1" ;; 28 | *.bz2) bunzip2 "$1" ;; 29 | *.dmg) hdiutil mount "$1" ;; 30 | *.gz) gunzip "$1" ;; 31 | *.tar) tar -xvf "$1" ;; 32 | *.tbz2) tar -jxvf "$1" ;; 33 | *.tgz) tar -zxvf "$1" ;; 34 | *.zip) unzip "$1" ;; 35 | *.ZIP) unzip "$1" ;; 36 | *.pax) cat "$1" | pax -r ;; 37 | *.pax.Z) uncompress "$1" --stdout | pax -r ;; 38 | *.Z) uncompress "$1" ;; 39 | *) echo "'$1' cannot be extracted/mounted via extract()" ;; 40 | esac 41 | else 42 | echo "'$1' is not a valid file to extract" 43 | fi 44 | } 45 | 46 | # Check if resource is served compressed 47 | 48 | check_compression() { 49 | curl --write-out 'Size (uncompressed) = %{size_download}\n' --silent --output /dev/null $1 50 | curl --header 'Accept-Encoding: gzip,deflate,compress' --write-out 'Size (compressed) = %{size_download}\n' --silent --output /dev/null $1 51 | curl --head --header 'Accept-Encoding: gzip,deflate' --silent $1 | grep -i "cache\|content\|vary\|expires" 52 | } 53 | 54 | # Get gzipped file size 55 | 56 | gz() { 57 | local ORIGSIZE=$(wc -c < "$1") 58 | local GZIPSIZE=$(gzip -c "$1" | wc -c) 59 | local RATIO=$(echo "$GZIPSIZE * 100/ $ORIGSIZE" | bc -l) 60 | local SAVED=$(echo "($ORIGSIZE - $GZIPSIZE) * 100/ $ORIGSIZE" | bc -l) 61 | printf "orig: %d bytes\ngzip: %d bytes\nsave: %2.0f%% (%2.0f%%)\n" "$ORIGSIZE" "$GZIPSIZE" "$SAVED" "$RATIO" 62 | } 63 | 64 | # Create a data URL from a file 65 | 66 | dataurl() { 67 | local MIMETYPE=$(file --mime-type "$1" | cut -d ' ' -f2) 68 | if [[ $MIMETYPE == "text/*" ]]; then 69 | MIMETYPE="${MIMETYPE};charset=utf-8" 70 | fi 71 | echo "data:${MIMETYPE};base64,$(openssl base64 -in "$1" | tr -d '\n')" 72 | } 73 | 74 | # Clean caches 75 | 76 | cleanup() { 77 | is-executable npm && npm cache clean 78 | is-executable brew && brew cleanup 79 | is-executable brew && brew cask cleanup 80 | } 81 | -------------------------------------------------------------------------------- /etc/mjolnir/init.lua: -------------------------------------------------------------------------------- 1 | -- Source: https://github.com/octalmind/dotfiles/blob/809cb0c7feb8f4beadd8824e97e4e77fc2f2182d/.mjolnir/init.lua 2 | 3 | local application = require "mjolnir.application" 4 | local hotkey = require "mjolnir.hotkey" 5 | local window = require "mjolnir.window" 6 | local fnutils = require "mjolnir.fnutils" 7 | local screens = require "mjolnir.screen" 8 | local geometry = require "mjolnir.geometry" 9 | 10 | -- Move the focused window to the specific position 11 | function moveTo(x, y, h, w) 12 | local win = window.focusedwindow() 13 | local rect = geometry.rect(x, y, h, w) 14 | win:movetounit(rect) 15 | end 16 | 17 | -- throw a window to the next screen 18 | function throw(win, screen_number) 19 | local screens_count = # screens.allscreens() 20 | if screen_number <= screens_count then 21 | local screen = screens.allscreens()[screen_number]:frame() 22 | local frame = win:frame() 23 | frame.x = screen.x 24 | frame.y = screen.y 25 | win:setframe(frame) 26 | win:maximize() 27 | win:focus() 28 | end 29 | end 30 | 31 | -- Push window to the left with 50% width 32 | hotkey.bind({"ctrl", "alt", "cmd"}, "left", function() 33 | moveTo(0, 0, 0.5, 1) 34 | end) 35 | 36 | -- Push window to the right with 50% width 37 | hotkey.bind({"ctrl", "alt", "cmd"}, "right", function() 38 | moveTo(0.5, 0, 0.5, 1) 39 | end) 40 | 41 | -- Push window at the top with 50% height 42 | hotkey.bind({"ctrl", "alt", "cmd"}, "up", function() 43 | moveTo(0, 0, 1, 0.5) 44 | end) 45 | 46 | -- Push window at the bottom with 50% height 47 | hotkey.bind({"ctrl", "alt", "cmd"}, "down", function() 48 | moveTo(0, 0.5, 1, 0.5) 49 | end) 50 | 51 | -- Push window to the left with 67% width 52 | hotkey.bind({"ctrl", "alt", "cmd"}, "1", function() 53 | moveTo(0, 0, 0.67, 1) 54 | end) 55 | 56 | -- Push window to the left with 33% width 57 | hotkey.bind({"ctrl", "alt", "cmd"}, "2", function() 58 | moveTo(0, 0, 0.33, 1) 59 | end) 60 | 61 | -- Push window to the right with 67% width 62 | hotkey.bind({"ctrl", "alt", "cmd"}, "8", function() 63 | moveTo(0.33, 0, 0.67, 1) 64 | end) 65 | 66 | -- Push window to the right with 33% width 67 | hotkey.bind({"ctrl", "alt", "cmd"}, "9", function() 68 | moveTo(0.67, 0, 0.33, 1) 69 | end) 70 | 71 | -- Push window to the upper left 72 | hotkey.bind({"ctrl", "alt", "cmd"}, "a", function() 73 | moveTo(0, 0, 0.5, 0.5) 74 | end) 75 | 76 | -- Push window to the lower left 77 | hotkey.bind({"ctrl", "alt", "cmd"}, "z", function() 78 | moveTo(0, 0.5, 0.5, 0.5) 79 | end) 80 | 81 | -- Push window to the upper right 82 | hotkey.bind({"ctrl", "alt", "cmd"}, "s", function() 83 | moveTo(0.5, 0, 0.5, 0.5) 84 | end) 85 | 86 | -- Push window to the lower right 87 | hotkey.bind({"ctrl", "alt", "cmd"}, "x", function() 88 | moveTo(0.5, 0.5, 0.5, 0.5) 89 | end) 90 | 91 | -- Push window to the middle 92 | hotkey.bind({"ctrl", "alt", "cmd"}, "c", function() 93 | moveTo(0.25, 0.15, 0.5, 0.7) 94 | end) 95 | 96 | -- Push window full screen to first screen 97 | hotkey.bind({"ctrl", "alt", "cmd"}, "m", function() 98 | throw(window.focusedwindow(), 1) 99 | end) 100 | 101 | -- Push window full screen to second screen 102 | hotkey.bind({"ctrl", "alt", "cmd"}, "n", function() 103 | throw(window.focusedwindow(), 2) 104 | end) 105 | -------------------------------------------------------------------------------- /system/.prompt: -------------------------------------------------------------------------------- 1 | ## Prompt 2 | 3 | _bash_prompt_config() { 4 | 5 | local USER_SYMBOL="\u" 6 | local HOST_SYMBOL="\h" 7 | local ESC_OPEN="\[" 8 | local ESC_CLOSE="\]" 9 | 10 | if tput setaf >/dev/null 2>&1 ; then 11 | _setaf () { tput setaf "$1" ; } 12 | local RESET="${ESC_OPEN}$( { tput sgr0 || tput me ; } 2>/dev/null )${ESC_CLOSE}" 13 | local BOLD="$( { tput bold || tput md ; } 2>/dev/null )" 14 | else 15 | # Fallback 16 | _setaf () { echo "\033[0;$(($1+30))m" ; } 17 | local RESET="\033[m" 18 | local BOLD="" 19 | ESC_OPEN="" 20 | ESC_CLOSE="" 21 | fi 22 | 23 | # Normal colors 24 | local BLACK="${ESC_OPEN}$(_setaf 0)${ESC_CLOSE}" 25 | local RED="${ESC_OPEN}$(_setaf 1)${ESC_CLOSE}" 26 | local GREEN="${ESC_OPEN}$(_setaf 2)${ESC_CLOSE}" 27 | local YELLOW="${ESC_OPEN}$(_setaf 3)${ESC_CLOSE}" 28 | local BLUE="${ESC_OPEN}$(_setaf 4)${ESC_CLOSE}" 29 | local VIOLET="${ESC_OPEN}$(_setaf 5)${ESC_CLOSE}" 30 | local CYAN="${ESC_OPEN}$(_setaf 6)${ESC_CLOSE}" 31 | local WHITE="${ESC_OPEN}$(_setaf 7)${ESC_CLOSE}" 32 | 33 | # Bright colors 34 | local BRIGHT_GREEN="${ESC_OPEN}$(_setaf 10)${ESC_CLOSE}" 35 | local BRIGHT_YELLOW="${ESC_OPEN}$(_setaf 11)${ESC_CLOSE}" 36 | local BRIGHT_BLUE="${ESC_OPEN}$(_setaf 12)${ESC_CLOSE}" 37 | local BRIGHT_VIOLET="${ESC_OPEN}$(_setaf 13)${ESC_CLOSE}" 38 | local BRIGHT_CYAN="${ESC_OPEN}$(_setaf 14)${ESC_CLOSE}" 39 | local BRIGHT_WHITE="${ESC_OPEN}$(_setaf 15)${ESC_CLOSE}" 40 | 41 | # Bold colors 42 | local BLACK_BOLD="${ESC_OPEN}${BOLD}$(_setaf 0)${ESC_CLOSE}" 43 | local RED_BOLD="${ESC_OPEN}${BOLD}$(_setaf 1)${ESC_CLOSE}" 44 | local GREEN_BOLD="${ESC_OPEN}${BOLD}$(_setaf 2)${ESC_CLOSE}" 45 | local YELLOW_BOLD="${ESC_OPEN}${BOLD}$(_setaf 3)${ESC_CLOSE}" 46 | local BLUE_BOLD="${ESC_OPEN}${BOLD}$(_setaf 4)${ESC_CLOSE}" 47 | local VIOLET_BOLD="${ESC_OPEN}${BOLD}$(_setaf 5)${ESC_CLOSE}" 48 | local CYAN_BOLD="${ESC_OPEN}${BOLD}$(_setaf 6)${ESC_CLOSE}" 49 | local WHITE_BOLD="${ESC_OPEN}${BOLD}$(_setaf 7)${ESC_CLOSE}" 50 | 51 | # Expose the variables we need in prompt command 52 | P_USER=${BRIGHT_GREEN}${USER_SYMBOL} 53 | P_HOST=${CYAN}${HOST_SYMBOL} 54 | P_WHITE=${WHITE} 55 | P_GREEN=${BRIGHT_GREEN} 56 | P_YELLOW=${YELLOW} 57 | P_RED=${RED} 58 | P_RESET=${RESET} 59 | 60 | } 61 | 62 | bash_prompt_command() { 63 | 64 | local EXIT_CODE=$? 65 | local P_EXIT="" 66 | local MAXLENGTH=35 67 | local TRUNC_SYMBOL=".." 68 | local DIR=${PWD##*/} 69 | local P_PWD=${PWD/#$HOME/\~} 70 | 71 | MAXLENGTH=$(( ( MAXLENGTH < ${#DIR} ) ? ${#DIR} : MAXLENGTH )) 72 | 73 | local OFFSET=$(( ${#P_PWD} - MAXLENGTH )) 74 | 75 | if [ ${OFFSET} -gt "0" ]; then 76 | P_PWD=${P_PWD:$OFFSET:$MAXLENGTH} 77 | P_PWD=${TRUNC_SYMBOL}/${P_PWD#*/} 78 | fi 79 | 80 | # Update terminal title 81 | if [[ $TERM == xterm* ]]; then 82 | echo -ne "\033]0;${P_PWD}\007" 83 | fi 84 | 85 | # Parse Git branch name 86 | P_GIT=$(parse_git_branch) 87 | 88 | # Exit code 89 | if [[ $EXIT_CODE != 0 ]]; then 90 | P_EXIT+="${P_RED}✘ " 91 | fi 92 | 93 | PS1="${P_EXIT}${P_USER}${P_WHITE}@${P_HOST} ${P_YELLOW}${P_PWD}${P_GREEN}${P_GIT}${P_YELLOW} ❯ ${P_RESET}" 94 | } 95 | 96 | parse_git_branch() { 97 | local OUT=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'` 98 | if [ "$OUT" != "" ]; then echo " $OUT"; fi 99 | } 100 | 101 | _bash_prompt_config 102 | unset _bash_prompt_config 103 | 104 | PROMPT_COMMAND=bash_prompt_command 105 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # .files 2 | 3 | **Attention**: Tested only on Ventura, but should work in the recent versions of macOS too 4 | 5 | These are my dotfiles. Take anything you want, but at your own risk. 6 | 7 | It targets OS X systems, but since it has some defensive checks it should work on *nix as well (tested on a few Linux boxes). 8 | 9 | (Based on https://github.com/webpro/dotfiles) 10 | 11 | ## Package overview 12 | 13 | * Core 14 | * Bash + [coreutils](http://en.wikipedia.org/wiki/GNU_Core_Utilities) + bash-completion 15 | * [Homebrew](http://brew.sh/) 16 | * Node.js + npm (via Volta) 17 | * GNU [sed](http://www.gnu.org/software/sed/), [grep](https://www.gnu.org/software/grep/), [Wget](https://www.gnu.org/software/wget/) 18 | * [fasd](https://github.com/clvv/fasd), [psgrep](https://github.com/jvz/psgrep/blob/master/psgrep), [pgrep](http://linux.die.net/man/1/pgrep), [spot](https://github.com/guille/spot), [tree](http://mama.indstate.edu/users/ice/tree/), [vtop](https://github.com/MrRio/vtop) 19 | * Git + [GitUp](https://gitup.co/) + [hub](http://hub.github.com/), Subversion 20 | * Python 3 21 | * NeoVim 22 | * Dev (FE/JS/JSON): [http-server](https://github.com/nodeapps/http-server), [jq](http://stedolan.github.io/jq/), [nodemon](http://nodemon.io), [peco](http://peco.github.io), [underscore-cli](https://github.com/ddopson/underscore-cli) 23 | * Graphics: [ffmpeg](https://www.ffmpeg.org), [gifsicle](http://www.lcdf.org/gifsicle), [imagemagick](http://www.imagemagick.org), [svgo](https://github.com/svg/svgo) 24 | * OS X: [dockutil](https://github.com/kcrawford/dockutil), [Mjolnir](https://github.com/sdegutis/mjolnir), [Mackup](https://github.com/lra/mackup) 25 | 26 | ## Install 27 | 28 | On a sparkling fresh installation of OS X: 29 | 30 | sudo softwareupdate -i -a 31 | xcode-select --install 32 | 33 | Install the dotfiles with either Git or curl: 34 | 35 | ### Clone with Git 36 | 37 | git clone git@github.com:myshov/dotfiles.git 38 | source dotfiles/install.sh 39 | 40 | ### Remotely install using curl 41 | 42 | Alternatively, you can install this into `~/.dotfiles` remotely without Git using curl: 43 | 44 | sh -c "`curl -fsSL https://raw.github.com/webpro/dotfiles/master/remote-install.sh`" 45 | 46 | Or, using wget: 47 | 48 | sh -c "`wget -O - --no-check-certificate https://raw.githubusercontent.com/webpro/dotfiles/master/remote-install.sh`" 49 | 50 | ## The `dotfiles` command 51 | 52 | $ dotfiles help 53 | Usage: dotfiles 54 | 55 | Commands: 56 | help This help message 57 | edit Open dotfiles in default editor (subl) and Git GUI (stree) 58 | reload Reload dotfiles 59 | update Update packages and pkg managers: OS X Applications, Homebrew/Cask, npm, Ruby, and pip 60 | osx Apply OS X system defaults 61 | dock Apply OS X Dock settings 62 | install mjolnir Install Mjolnir (Homebrew/Luarocks) 63 | 64 | ## Customize/extend 65 | 66 | You can put your custom settings, such as Git credentials in the `system/.custom` file which will be sourced from `.bash_profile` automatically. This file is in `.gitignore`. 67 | 68 | Alternatively, you can have an additional, personal dotfiles repo at `~/.extra`. 69 | 70 | * The runcom `.bash_profile` sources all `~/.extra/runcom/*.sh` files. 71 | * The installer (`install.sh`) will run `~/.extra/install.sh`. 72 | 73 | ## Additional resources 74 | 75 | * [Awesome Dotfiles](https://github.com/webpro/awesome-dotfiles) 76 | * [Homebrew](http://brew.sh/) / [FAQ](https://github.com/Homebrew/homebrew/wiki/FAQ) 77 | * [homebrew-cask](http://caskroom.io/) / [usage](https://github.com/phinze/homebrew-cask/blob/master/USAGE.md) 78 | * [Bash prompt](http://wiki.archlinux.org/index.php/Color_Bash_Prompt) 79 | * [Solarized Color Theme for GNU ls](https://github.com/seebi/dircolors-solarized) 80 | 81 | ## Credits 82 | 83 | Many thanks to the [dotfiles community](http://dotfiles.github.io/) and the creators of the incredibly useful tools. 84 | -------------------------------------------------------------------------------- /nvim/init.vim: -------------------------------------------------------------------------------- 1 | " set runtimepath^=~/.vim runtimepath+=~/.vim/after 2 | " let &packpath = &runtimepath 3 | " source ~/.vimrc 4 | set nocompatible 5 | 6 | " Load plugins 7 | 8 | if filereadable(expand('$NVIMCONFIGS/plugins.vim')) 9 | source $NVIMCONFIGS/plugins.vim 10 | endif 11 | 12 | 13 | " General 14 | 15 | set number "Line numbers are good 16 | set backspace=indent,eol,start "Allow backspace in insert mode 17 | set history=1000 "Store lots of :cmdline history 18 | set showcmd "Show incomplete cmds down the bottom 19 | set showmode "Show current mode down the bottom 20 | set gcr=a:blinkon0 "Disable cursor blink 21 | set visualbell "No sounds 22 | set autoread "Reload files changed outside vim 23 | set laststatus=2 "Always display the status line 24 | set hidden "Hide buffer instead of closing it 25 | set pastetoggle= "Paste without being smart 26 | 27 | " Swap file and backups 28 | 29 | set noswapfile 30 | set nobackup 31 | set nowb 32 | au FocusLost * :wa 33 | 34 | " Persistent undo 35 | 36 | if has('persistent_undo') 37 | silent !mkdir ~/.vim/backups > /dev/null 2>&1 38 | set undodir=~/.vim/backups 39 | set undofile 40 | endif 41 | 42 | " Indentation 43 | 44 | set autoindent 45 | set smartindent 46 | set smarttab 47 | set shiftwidth=4 48 | set softtabstop=4 49 | set tabstop=4 50 | set expandtab 51 | 52 | " Enable loading the plugin/indent files for specific file types 53 | 54 | filetype plugin indent on 55 | 56 | " Wrapping 57 | 58 | set nowrap "Don't wrap lines 59 | set linebreak "Wrap lines at convenient points 60 | 61 | " Folding 62 | 63 | set nofoldenable "don't fold by default 64 | set foldmethod=syntax "fold based on syntax 65 | 66 | " Search 67 | 68 | set hlsearch 69 | set incsearch 70 | set ignorecase 71 | set showmatch 72 | set smartcase 73 | 74 | " Terminal 75 | 76 | set termencoding=utf-8 77 | 78 | " Colors 79 | 80 | syntax enable 81 | set cursorline 82 | set background=dark 83 | " Workaround a problem with solarized and vim-gitgutter. 84 | " https://github.com/airblade/vim-gitgutter/issues/696 85 | autocmd ColorScheme * highlight! link SignColumn LineNr 86 | highlight clear SignColumn 87 | colorscheme solarized 88 | 89 | " Scrolling 90 | 91 | set scrolloff=4 92 | set sidescrolloff=15 93 | set sidescroll=1 94 | 95 | " Completion 96 | 97 | set wildmenu "enable ctrl-n and ctrl-p to scroll thru matches 98 | set wildmode=list:longest 99 | set wildignore=*.o,*.so,*.obj,*~ "stuff to ignore when tab completing 100 | set wildignore+=*vim/backups* 101 | set wildignore+=*sass-cache* 102 | set wildignore+=*DS_Store* 103 | set wildignore+=vendor/rails/** 104 | set wildignore+=vendor/cache/** 105 | set wildignore+=*.gem 106 | set wildignore+=log/** 107 | set wildignore+=tmp/** 108 | set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg,*.svg 109 | set wildignore+=*.zip 110 | set wildignore+=*.swp,*.pyc,*.bak,*.class,*.orig 111 | set wildignore+=.git,.hg,.bzr,.svn 112 | 113 | 114 | " Bindings 115 | 116 | " Greping with silver searcher word under cursor 117 | nnoremap k :silent grep! "\b\s?\b":cw:redr! 118 | 119 | " Fix syntax highlighting issues 120 | noremap :syntax sync fromstart 121 | inoremap :syntax sync fromstart 122 | 123 | " Run node or browser on F5 124 | autocmd BufRead,Bufenter *.js map :w:!node % 125 | autocmd BufRead,Bufenter *.html map :exe ':silent !open -a /Applications/Firefox.app %':redr! 126 | 127 | " Write with sudo 128 | cmap wi! %!sudo tee > /dev/null % 129 | 130 | " Turn off search highlight 131 | nnoremap a :noh 132 | 133 | " Prettier 134 | nmap p :exe ':silent !npx prettier --write %' 135 | 136 | " The Silver Searcher 137 | " List of ignored in ~/.agignore 138 | if executable('ag') 139 | " Use ag over grep 140 | set grepprg=ag\ --nogroup\ --nocolor\ --hidden 141 | " Use ag in CtrlP for listing files. Lightning fast and respects .gitignore 142 | let g:ctrlp_user_command = 'ag %s -l --nocolor --hidden -g ""' 143 | " ag is fast enough that CtrlP doesn't need to cache 144 | let g:ctrlp_use_caching = 0 145 | endif 146 | 147 | 148 | " NERDTree 149 | 150 | nmap :NERDTreeToggle 151 | nmap f :NERDTreeFind 152 | 153 | 154 | " Snippets 155 | 156 | " UltiSnips completion function that tries to expand a snippet. If there's no 157 | " snippet for expanding, it checks for completion window and if it's 158 | " shown, selects first element. If there's no completion window it tries to 159 | " jump to next placeholder. If there's no placeholder it just returns TAB key 160 | 161 | "function! g:UltiSnips_Complete() 162 | "call UltiSnips#ExpandSnippet() 163 | "if g:ulti_expand_res == 0 164 | "if pumvisible() 165 | "return "\" 166 | "else 167 | "call UltiSnips#JumpForwards() 168 | "if g:ulti_jump_forwards_res == 0 169 | "return "\" 170 | "endif 171 | "endif 172 | "endif 173 | "return "" 174 | "endfunction 175 | 176 | "au BufEnter * exec "inoremap " . g:UltiSnipsExpandTrigger . " =g:UltiSnips_Complete()" 177 | 178 | "let g:UltiSnipsExpandTrigger="" 179 | "let g:UltiSnipsJumpForwardTrigger="" 180 | 181 | 182 | " Air-line 183 | 184 | let g:airline_powerline_fonts = 1 185 | 186 | if !exists('g:airline_symbols') 187 | let g:airline_symbols = {} 188 | endif 189 | 190 | " unicode symbols 191 | let g:airline_left_sep = '»' 192 | let g:airline_left_sep = '▶' 193 | let g:airline_right_sep = '«' 194 | let g:airline_right_sep = '◀' 195 | let g:airline_symbols.linenr = '␊' 196 | let g:airline_symbols.linenr = '␤' 197 | let g:airline_symbols.linenr = '¶' 198 | let g:airline_symbols.branch = '⎇' 199 | let g:airline_symbols.paste = 'ρ' 200 | let g:airline_symbols.paste = 'Þ' 201 | let g:airline_symbols.paste = '∥' 202 | let g:airline_symbols.whitespace = 'Ξ' 203 | 204 | " powerline symbols 205 | let g:airline_left_sep = '' 206 | let g:airline_left_alt_sep = '' 207 | let g:airline_right_sep = '' 208 | let g:airline_right_alt_sep = '' 209 | let g:airline_symbols.branch = '' 210 | let g:airline_symbols.readonly = '' 211 | let g:airline_symbols.linenr = '' 212 | " 213 | "" Enable the list of buffers 214 | let g:airline#extensions#tabline#enabled = 1 215 | 216 | " Show just the filename 217 | let g:airline#extensions#tabline#fnamemod = ':t' 218 | 219 | " Airline theme 220 | let g:airline_theme='solarized' 221 | 222 | 223 | " Bclose 224 | 225 | map d :Bclose 226 | 227 | nmap ln :let @" = join([expand("%"), line(".")], ":") 228 | nmap lpn :let @" = join([expand("%:p"), line(".")], ":") 229 | nmap :CtrlPBuffer 230 | nmap :e project.txt 231 | nmap ln 232 | map gf gF 233 | 234 | " DelimitMate 235 | 236 | let delimitMate_expand_cr = 1 237 | 238 | 239 | " Bufferegator 240 | 241 | nnoremap h :BuffergatorMruCyclePrev 242 | nnoremap j :BuffergatorMruCycleNext 243 | 244 | 245 | " Syntastic 246 | 247 | let g:syntastic_mode_map = { 248 | \ "mode": "active", 249 | \ "active_filetypes": ["c", "cpp", "java", "javascript", "python", "ruby", "typescript"], 250 | \ "passive_filetypes": [] } 251 | 252 | 253 | let g:syntastic_javascript_checkers = ['eslint'] 254 | 255 | 256 | " Languages related stuff 257 | 258 | " Include path for C programs 259 | 260 | set path+=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ 261 | 262 | " Code folding for JavaScript 263 | 264 | let javaScript_fold=1 265 | autocmd BufEnter *.js :normal zR\ "fix initial fold closing 266 | 267 | 268 | " TypeScript 269 | " let g:tsuquyomi_disable_quickfix = 1 270 | " let g:syntastic_typescript_checkers = ['tsuquyomi', 'eslint'] " You shouldn't use 'tsc' checker. 271 | " autocmd FileType typescript nmap t : \ echo tsuquyomi#hint() 272 | 273 | " Attention! To avoid automatic selecting of the first item in the list 274 | " you have to add `suggest.noselect: true` to coc config via :CocConfig 275 | 276 | " To make the completion work like builtin completion without configuration, 277 | inoremap coc#pum#visible() ? coc#pum#next(1) : "\" 278 | inoremap coc#pum#visible() ? coc#pum#prev(1) : "\" 279 | inoremap coc#pum#visible() ? coc#pum#next(0) : "\" 280 | inoremap coc#pum#visible() ? coc#pum#prev(0) : "\" 281 | inoremap coc#pum#visible() ? coc#pum#scroll(1) : "\" 282 | inoremap coc#pum#visible() ? coc#pum#scroll(0) : "\" 283 | 284 | " Always show the signcolumn, otherwise it would shift the text each time 285 | " diagnostics appear/become resolved. 286 | if has("nvim-0.5.0") || has("patch-8.1.1564") 287 | " Recently vim can merge signcolumn and number column into one 288 | set signcolumn=number 289 | else 290 | set signcolumn=yes 291 | endif 292 | 293 | " use and for trigger completion and navigate 294 | " to the next and previous complete item 295 | function! CheckBackspace() abort 296 | let col = col('.') - 1 297 | return !col || getline('.')[col - 1] =~# '\s' 298 | endfunction 299 | 300 | inoremap 301 | \ coc#pum#visible() ? coc#pum#next(1) : 302 | \ CheckBackspace() ? "\" : 303 | \ coc#refresh() 304 | 305 | inoremap 306 | \ coc#pum#visible() ? coc#pum#prev(1) : 307 | \ CheckBackspace() ? "\" : 308 | \ coc#refresh() 309 | 310 | " Use to trigger completion. 311 | if has('nvim') 312 | inoremap coc#refresh() 313 | else 314 | inoremap coc#refresh() 315 | endif 316 | " Use `[g` and `]g` to navigate diagnostics 317 | " Use `:CocDiagnostics` to get all diagnostics of current buffer in location list. 318 | nmap [g (coc-diagnostic-prev) 319 | nmap ]g (coc-diagnostic-next) 320 | 321 | " GoTo code navigation. 322 | nmap gd (coc-definition) 323 | nmap gy (coc-type-definition) 324 | nmap gi (coc-implementation) 325 | nmap gr (coc-references) 326 | 327 | " Use K to show documentation in preview window. 328 | nnoremap K :call ShowDocumentation() 329 | 330 | function! ShowDocumentation() 331 | if CocAction('hasProvider', 'hover') 332 | call CocActionAsync('doHover') 333 | else 334 | call feedkeys('K', 'in') 335 | endif 336 | endfunction 337 | 338 | " Symbol renaming. 339 | nmap rn (coc-rename) 340 | 341 | " Fix of unreadable floating windows in coc-vim 342 | autocmd VimEnter,ColorScheme * hi! link CocFloating CocHintFloat 343 | 344 | " Integrations 345 | 346 | " Proper mouse support inside screen and tmux 347 | 348 | set mouse+=a 349 | if !has('nvim') 350 | set ttymouse=xterm2 351 | endif 352 | 353 | " lit element css support 354 | let g:htl_css_templates = 1 355 | -------------------------------------------------------------------------------- /system/.dir_colors: -------------------------------------------------------------------------------- 1 | # Exact Solarized color theme for the color GNU ls utility. 2 | # Designed for dircolors (GNU coreutils) 5.97 3 | # 4 | # This simple theme was simultaneously designed for these terminal color schemes: 5 | # - Solarized dark (best) 6 | # - Solarized light (best) 7 | # - default dark 8 | # - default light 9 | # 10 | # How the colors were selected: 11 | # - Terminal emulators often have an option typically enabled by default that makes 12 | # bold a different color. It is important to leave this option enabled so that 13 | # you can access the entire 16-color Solarized palette, and not just 8 colors. 14 | # - We favor universality over a greater number of colors. So we limit the number 15 | # of colors so that this theme will work out of the box in all terminals, 16 | # Solarized or not, dark or light. 17 | # - We choose to have the following category of files: 18 | # NORMAL & FILE, DIR, LINK, EXEC and 19 | # editable text including source, unimportant text, binary docs & multimedia source 20 | # files, viewable multimedia, archived/compressed, and unimportant non-text 21 | # - For uniqueness, we stay away from the Solarized foreground colors are -- either 22 | # base00 (brightyellow) or base0 (brighblue). However, they can be used if 23 | # you know what the bg/fg colors of your terminal are, in order to optimize the display. 24 | # - 3 different options are provided: universal, solarized dark, and solarized light. 25 | # The only difference between the universal scheme and one that's optimized for 26 | # dark/light is the color of "unimportant" files, which should blend more with the 27 | # background 28 | # - We note that blue is the hardest color to see on dark bg and yellow is the hardest 29 | # color to see on light bg (with blue being particularly bad). So we choose yellow 30 | # for multimedia files which are usually accessed in a GUI folder browser anyway. 31 | # And blue is kept for custom use of this scheme's user. 32 | # - See table below to see the assignments. 33 | 34 | 35 | # Insatllation instructions: 36 | # This file goes in the /etc directory, and must be world readable. 37 | # You can copy this file to .dir_colors in your $HOME directory to override 38 | # the system defaults. 39 | 40 | # COLOR needs one of these arguments: 'tty' colorizes output to ttys, but not 41 | # pipes. 'all' adds color characters to all output. 'none' shuts colorization 42 | # off. 43 | COLOR tty 44 | 45 | # Below, there should be one TERM entry for each termtype that is colorizable 46 | TERM ansi 47 | TERM color_xterm 48 | TERM color-xterm 49 | TERM con132x25 50 | TERM con132x30 51 | TERM con132x43 52 | TERM con132x60 53 | TERM con80x25 54 | TERM con80x28 55 | TERM con80x30 56 | TERM con80x43 57 | TERM con80x50 58 | TERM con80x60 59 | TERM cons25 60 | TERM console 61 | TERM cygwin 62 | TERM dtterm 63 | TERM Eterm 64 | TERM eterm-color 65 | TERM gnome 66 | TERM gnome-256color 67 | TERM jfbterm 68 | TERM konsole 69 | TERM kterm 70 | TERM linux 71 | TERM linux-c 72 | TERM mach-color 73 | TERM mlterm 74 | TERM nxterm 75 | TERM putty 76 | TERM rxvt 77 | TERM rxvt-256color 78 | TERM rxvt-cygwin 79 | TERM rxvt-cygwin-native 80 | TERM rxvt-unicode 81 | TERM rxvt-unicode256 82 | TERM rxvt-unicode-256color 83 | TERM screen 84 | TERM screen-256color 85 | TERM screen-256color-bce 86 | TERM screen-bce 87 | TERM screen.linux 88 | TERM screen-w 89 | TERM vt100 90 | TERM xterm 91 | TERM xterm-16color 92 | TERM xterm-256color 93 | TERM xterm-88color 94 | TERM xterm-color 95 | TERM xterm-debian 96 | 97 | # EIGHTBIT, followed by '1' for on, '0' for off. (8-bit output) 98 | EIGHTBIT 1 99 | 100 | ############################################################################# 101 | # Below are the color init strings for the basic file types. A color init 102 | # string consists of one or more of the following numeric codes: 103 | # 104 | # Attribute codes: 105 | # 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed 106 | # Text color codes: 107 | # 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white 108 | # Background color codes: 109 | # 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white 110 | # 111 | # NOTES: 112 | # - See http://www.oreilly.com/catalog/wdnut/excerpt/color_names.html 113 | # - Color combinations 114 | # ANSI Color code Solarized Notes Universal SolDark SolLight 115 | # ~~~~~~~~~~~~~~~ ~~~~~~~~~ ~~~~~ ~~~~~~~~~ ~~~~~~~ ~~~~~~~~ 116 | # 00 none NORMAL, FILE 117 | # 30 black base02 118 | # 01;30 bright black base03 bg of SolDark 119 | # 31 red red docs & mm src 120 | # 01;31 bright red orange EXEC 121 | # 32 green green editable text 122 | # 01;32 bright green base01 unimportant text 123 | # 33 yellow yellow unclear in light bg multimedia 124 | # 01;33 bright yellow base00 fg of SolLight unimportant non-text 125 | # 34 blue blue unclear in dark bg user customized 126 | # 01;34 bright blue base0 fg in SolDark unimportant text 127 | # 35 magenta magenta LINK 128 | # 01;35 bright magenta violet archive/compressed 129 | # 36 cyan cyan DIR 130 | # 01;36 bright cyan base1 unimportant non-text 131 | # 37 white base2 132 | # 01;37 bright white base3 bg in SolLight 133 | # 05;37;41 unclear in Putty dark 134 | 135 | 136 | ### By file type 137 | 138 | # global default 139 | NORMAL 00 140 | # normal file 141 | FILE 00 142 | # directory 143 | DIR 36 144 | # symbolic link 145 | LINK 35 146 | 147 | # pipe, socket, block device, character device (blue bg) 148 | FIFO 30;44 149 | SOCK 35;44 150 | DOOR 35;44 # Solaris 2.5 and later 151 | BLK 33;44 152 | CHR 37;44 153 | 154 | 155 | ############################################################################# 156 | ### By file attributes 157 | 158 | # Orphaned symlinks (blinking white on red) 159 | # Blink may or may not work (works on iTerm dark or light, and Putty dark) 160 | ORPHAN 05;37;41 161 | # ... and the files that orphaned symlinks point to (blinking white on red) 162 | MISSING 05;37;41 163 | 164 | # files with execute permission 165 | EXEC 01;31 # Unix 166 | .cmd 01;31 # Win 167 | .exe 01;31 # Win 168 | .com 01;31 # Win 169 | .bat 01;31 # Win 170 | .reg 01;31 # Win 171 | .app 01;31 # OSX 172 | 173 | ############################################################################# 174 | ### By extension 175 | 176 | # List any file extensions like '.gz' or '.tar' that you would like ls 177 | # to colorize below. Put the extension, a space, and the color init string. 178 | # (and any comments you want to add after a '#') 179 | 180 | ### Text formats 181 | 182 | # Text that we can edit with a regular editor 183 | .txt 32 184 | .org 32 185 | .md 32 186 | .mkd 32 187 | .pdc 32 188 | 189 | # Source text 190 | .h 32 191 | .c 32 192 | .C 32 193 | .cc 32 194 | .cxx 32 195 | .objc 32 196 | .sh 32 197 | .csh 32 198 | .zsh 32 199 | .el 32 200 | .vim 32 201 | .java 32 202 | .pl 32 203 | .pm 32 204 | .py 32 205 | .rb 32 206 | .hs 32 207 | .php 32 208 | .htm 32 209 | .html 32 210 | .shtml 32 211 | .xml 32 212 | .rdf 32 213 | .css 32 214 | .js 32 215 | .man 32 216 | .0 32 217 | .1 32 218 | .2 32 219 | .3 32 220 | .4 32 221 | .5 32 222 | .6 32 223 | .7 32 224 | .8 32 225 | .9 32 226 | .l 32 227 | .n 32 228 | .p 32 229 | .pod 32 230 | .tex 32 231 | 232 | ### Multimedia formats 233 | 234 | # Image 235 | .bmp 33 236 | .cgm 33 237 | .dl 33 238 | .dvi 33 239 | .emf 33 240 | .eps 33 241 | .gif 33 242 | .jpeg 33 243 | .jpg 33 244 | .JPG 33 245 | .mng 33 246 | .pbm 33 247 | .pcx 33 248 | .pdf 33 249 | .pgm 33 250 | .png 33 251 | .ppm 33 252 | .pps 33 253 | .ppsx 33 254 | .ps 33 255 | .svg 33 256 | .svgz 33 257 | .tga 33 258 | .tif 33 259 | .tiff 33 260 | .xbm 33 261 | .xcf 33 262 | .xpm 33 263 | .xwd 33 264 | .xwd 33 265 | .yuv 33 266 | 267 | # Audio 268 | .aac 33 269 | .au 33 270 | .flac 33 271 | .mid 33 272 | .midi 33 273 | .mka 33 274 | .mp3 33 275 | .mpa 33 276 | .mpeg 33 277 | .mpg 33 278 | .ogg 33 279 | .ra 33 280 | .wav 33 281 | 282 | # Video 283 | .anx 33 284 | .asf 33 285 | .avi 33 286 | .axv 33 287 | .flc 33 288 | .fli 33 289 | .flv 33 290 | .gl 33 291 | .m2v 33 292 | .m4v 33 293 | .mkv 33 294 | .mov 33 295 | .mp4 33 296 | .mp4v 33 297 | .mpeg 33 298 | .mpg 33 299 | .nuv 33 300 | .ogm 33 301 | .ogv 33 302 | .ogx 33 303 | .qt 33 304 | .rm 33 305 | .rmvb 33 306 | .swf 33 307 | .vob 33 308 | .wmv 33 309 | 310 | ### Misc 311 | 312 | # Binary document formats and multimedia source 313 | .doc 31 314 | .docx 31 315 | .rtf 31 316 | .dot 31 317 | .dotx 31 318 | .xls 31 319 | .xlsx 31 320 | .ppt 31 321 | .pptx 31 322 | .fla 31 323 | .psd 31 324 | 325 | # Archives, compressed 326 | .7z 1;35 327 | .apk 1;35 328 | .arj 1;35 329 | .bin 1;35 330 | .bz 1;35 331 | .bz2 1;35 332 | .cab 1;35 # Win 333 | .deb 1;35 334 | .dmg 1;35 # OSX 335 | .gem 1;35 336 | .gz 1;35 337 | .iso 1;35 338 | .jar 1;35 339 | .msi 1;35 # Win 340 | .rar 1;35 341 | .rpm 1;35 342 | .tar 1;35 343 | .tbz 1;35 344 | .tbz2 1;35 345 | .tgz 1;35 346 | .tx 1;35 347 | .war 1;35 348 | .xpi 1;35 349 | .xz 1;35 350 | .z 1;35 351 | .Z 1;35 352 | .zip 1;35 353 | 354 | # For testing 355 | .ANSI-30-black 30 356 | .ANSI-01;30-brblack 01;30 357 | .ANSI-31-red 31 358 | .ANSI-01;31-brred 01;31 359 | .ANSI-32-green 32 360 | .ANSI-01;32-brgreen 01;32 361 | .ANSI-33-yellow 33 362 | .ANSI-01;33-bryellow 01;33 363 | .ANSI-34-blue 34 364 | .ANSI-01;34-brblue 01;34 365 | .ANSI-35-magenta 35 366 | .ANSI-01;35-brmagenta 01;35 367 | .ANSI-36-cyan 36 368 | .ANSI-01;36-brcyan 01;36 369 | .ANSI-37-white 37 370 | .ANSI-01;37-brwhite 01;37 371 | 372 | ############################################################################# 373 | # Your customizations 374 | 375 | # Unimportant text files 376 | # For universal scheme, use brightgreen 01;32 377 | # For optimal on light bg (but too prominent on dark bg), use white 01;34 378 | .log 01;32 379 | *~ 01;32 380 | *# 01;32 381 | #.log 01;34 382 | #*~ 01;34 383 | #*# 01;34 384 | 385 | # Unimportant non-text files 386 | # For universal scheme, use brightcyan 01;36 387 | # For optimal on dark bg (but too prominent on light bg), change to 01;33 388 | .bak 01;36 389 | .BAK 01;36 390 | .old 01;36 391 | .OLD 01;36 392 | .org_archive 01;36 393 | .off 01;36 394 | .OFF 01;36 395 | .dist 01;36 396 | .DIST 01;36 397 | .orig 01;36 398 | .ORIG 01;36 399 | .swp 01;36 400 | .swo 01;36 401 | *,v 01;36 402 | #.bak 01;33 403 | #.BAK 01;33 404 | #.old 01;33 405 | #.OLD 01;33 406 | #.org_archive 01;33 407 | #.off 01;33 408 | #.OFF 01;33 409 | #.dist 01;33 410 | #.DIST 01;33 411 | #.orig 01;33 412 | #.ORIG 01;33 413 | #.swp 01;33 414 | #.swo 01;33 415 | #*,v 01;33 416 | 417 | # The brightmagenta (Solarized: purple) color is free for you to use for your 418 | # custom file type 419 | .gpg 34 420 | .gpg 34 421 | .pgp 34 422 | .asc 34 423 | .3des 34 424 | .aes 34 425 | .enc 34 426 | -------------------------------------------------------------------------------- /iterm2/com.googlecode.iterm2.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AllowClipboardAccess 6 | 7 | Default Bookmark Guid 8 | C4F61457-2697-4943-ADF3-C86D44159AB6 9 | HapticFeedbackForEsc 10 | 11 | HotkeyMigratedFromSingleToMulti 12 | 13 | New Bookmarks 14 | 15 | 16 | ASCII Anti Aliased 17 | 18 | ASCII Ligatures 19 | 20 | Ambiguous Double Width 21 | 22 | Ansi 0 Color 23 | 24 | Blue Component 25 | 0.25882352941176473 26 | Color Space 27 | sRGB 28 | Green Component 29 | 0.21176470588235294 30 | Red Component 31 | 0.027450980392156862 32 | 33 | Ansi 1 Color 34 | 35 | Blue Component 36 | 0.18431372549019609 37 | Color Space 38 | sRGB 39 | Green Component 40 | 0.19607843137254902 41 | Red Component 42 | 0.86274509803921573 43 | 44 | Ansi 10 Color 45 | 46 | Blue Component 47 | 0.45882352941176469 48 | Color Space 49 | sRGB 50 | Green Component 51 | 0.43137254901960786 52 | Red Component 53 | 0.34509803921568627 54 | 55 | Ansi 11 Color 56 | 57 | Blue Component 58 | 0.51372549019607838 59 | Color Space 60 | sRGB 61 | Green Component 62 | 0.4823529411764706 63 | Red Component 64 | 0.396078431372549 65 | 66 | Ansi 12 Color 67 | 68 | Blue Component 69 | 0.58823529411764708 70 | Color Space 71 | sRGB 72 | Green Component 73 | 0.58039215686274515 74 | Red Component 75 | 0.51372549019607838 76 | 77 | Ansi 13 Color 78 | 79 | Blue Component 80 | 0.7686274509803922 81 | Color Space 82 | sRGB 83 | Green Component 84 | 0.44313725490196076 85 | Red Component 86 | 0.42352941176470588 87 | 88 | Ansi 14 Color 89 | 90 | Blue Component 91 | 0.63137254901960782 92 | Color Space 93 | sRGB 94 | Green Component 95 | 0.63137254901960782 96 | Red Component 97 | 0.57647058823529407 98 | 99 | Ansi 15 Color 100 | 101 | Blue Component 102 | 0.8901960784313725 103 | Color Space 104 | sRGB 105 | Green Component 106 | 0.96470588235294119 107 | Red Component 108 | 0.99215686274509807 109 | 110 | Ansi 2 Color 111 | 112 | Blue Component 113 | 0.0 114 | Color Space 115 | sRGB 116 | Green Component 117 | 0.59999999999999998 118 | Red Component 119 | 0.52156862745098043 120 | 121 | Ansi 3 Color 122 | 123 | Blue Component 124 | 0.0 125 | Color Space 126 | sRGB 127 | Green Component 128 | 0.53725490196078429 129 | Red Component 130 | 0.70980392156862748 131 | 132 | Ansi 4 Color 133 | 134 | Blue Component 135 | 0.82352941176470584 136 | Color Space 137 | sRGB 138 | Green Component 139 | 0.54509803921568623 140 | Red Component 141 | 0.14901960784313725 142 | 143 | Ansi 5 Color 144 | 145 | Blue Component 146 | 0.50980392156862742 147 | Color Space 148 | sRGB 149 | Green Component 150 | 0.21176470588235294 151 | Red Component 152 | 0.82745098039215681 153 | 154 | Ansi 6 Color 155 | 156 | Blue Component 157 | 0.59607843137254901 158 | Color Space 159 | sRGB 160 | Green Component 161 | 0.63137254901960782 162 | Red Component 163 | 0.16470588235294117 164 | 165 | Ansi 7 Color 166 | 167 | Blue Component 168 | 0.83529411764705885 169 | Color Space 170 | sRGB 171 | Green Component 172 | 0.90980392156862744 173 | Red Component 174 | 0.93333333333333335 175 | 176 | Ansi 8 Color 177 | 178 | Blue Component 179 | 0.21176470588235294 180 | Color Space 181 | sRGB 182 | Green Component 183 | 0.16862745098039217 184 | Red Component 185 | 0.0 186 | 187 | Ansi 9 Color 188 | 189 | Blue Component 190 | 0.086274509803921567 191 | Color Space 192 | sRGB 193 | Green Component 194 | 0.29411764705882354 195 | Red Component 196 | 0.79607843137254897 197 | 198 | BM Growl 199 | 200 | Background Color 201 | 202 | Blue Component 203 | 0.21176470588235294 204 | Color Space 205 | sRGB 206 | Green Component 207 | 0.16862745098039217 208 | Red Component 209 | 0.0 210 | 211 | Background Image Location 212 | 213 | Badge Color 214 | 215 | Alpha Component 216 | 0.5 217 | Blue Component 218 | 0.0 219 | Color Space 220 | sRGB 221 | Green Component 222 | 0.1491314172744751 223 | Red Component 224 | 1 225 | 226 | Blink Allowed 227 | 228 | Blinking Cursor 229 | 230 | Blur 231 | 232 | Blur Radius 233 | 0.10000000000000001 234 | Bold Color 235 | 236 | Blue Component 237 | 0.63137254901960782 238 | Color Space 239 | sRGB 240 | Green Component 241 | 0.63137254901960782 242 | Red Component 243 | 0.57647058823529407 244 | 245 | Character Encoding 246 | 4 247 | Close Sessions On End 248 | 249 | Columns 250 | 80 251 | Command 252 | 253 | Cursor Color 254 | 255 | Blue Component 256 | 0.58823529411764708 257 | Color Space 258 | sRGB 259 | Green Component 260 | 0.58039215686274515 261 | Red Component 262 | 0.51372549019607838 263 | 264 | Cursor Guide Color 265 | 266 | Alpha Component 267 | 0.25 268 | Blue Component 269 | 1 270 | Color Space 271 | sRGB 272 | Green Component 273 | 0.9268307089805603 274 | Red Component 275 | 0.70213186740875244 276 | 277 | Cursor Text Color 278 | 279 | Blue Component 280 | 0.25882352941176473 281 | Color Space 282 | sRGB 283 | Green Component 284 | 0.21176470588235294 285 | Red Component 286 | 0.027450980392156862 287 | 288 | Custom Command 289 | No 290 | Custom Directory 291 | No 292 | Default Bookmark 293 | No 294 | Description 295 | Default 296 | Disable Window Resizing 297 | 298 | Draw Powerline Glyphs 299 | 300 | Flashing Bell 301 | 302 | Foreground Color 303 | 304 | Blue Component 305 | 0.58823529411764708 306 | Color Space 307 | sRGB 308 | Green Component 309 | 0.58039215686274515 310 | Red Component 311 | 0.51372549019607838 312 | 313 | Guid 314 | C4F61457-2697-4943-ADF3-C86D44159AB6 315 | Horizontal Spacing 316 | 1 317 | Idle Code 318 | 0 319 | Initial Use Transparency 320 | 321 | Jobs to Ignore 322 | 323 | rlogin 324 | ssh 325 | slogin 326 | telnet 327 | 328 | Keyboard Map 329 | 330 | 0x2d-0x40000 331 | 332 | Action 333 | 11 334 | Text 335 | 0x1f 336 | 337 | 0x32-0x40000 338 | 339 | Action 340 | 11 341 | Text 342 | 0x00 343 | 344 | 0x33-0x40000 345 | 346 | Action 347 | 11 348 | Text 349 | 0x1b 350 | 351 | 0x34-0x40000 352 | 353 | Action 354 | 11 355 | Text 356 | 0x1c 357 | 358 | 0x35-0x40000 359 | 360 | Action 361 | 11 362 | Text 363 | 0x1d 364 | 365 | 0x36-0x40000 366 | 367 | Action 368 | 11 369 | Text 370 | 0x1e 371 | 372 | 0x37-0x40000 373 | 374 | Action 375 | 11 376 | Text 377 | 0x1f 378 | 379 | 0x38-0x40000 380 | 381 | Action 382 | 11 383 | Text 384 | 0x7f 385 | 386 | 0xf700-0x220000 387 | 388 | Action 389 | 10 390 | Text 391 | [1;2A 392 | 393 | 0xf700-0x240000 394 | 395 | Action 396 | 10 397 | Text 398 | [1;5A 399 | 400 | 0xf700-0x260000 401 | 402 | Action 403 | 10 404 | Text 405 | [1;6A 406 | 407 | 0xf700-0x280000 408 | 409 | Action 410 | 11 411 | Text 412 | 0x1b 0x1b 0x5b 0x41 413 | 414 | 0xf701-0x220000 415 | 416 | Action 417 | 10 418 | Text 419 | [1;2B 420 | 421 | 0xf701-0x240000 422 | 423 | Action 424 | 10 425 | Text 426 | [1;5B 427 | 428 | 0xf701-0x260000 429 | 430 | Action 431 | 10 432 | Text 433 | [1;6B 434 | 435 | 0xf701-0x280000 436 | 437 | Action 438 | 11 439 | Text 440 | 0x1b 0x1b 0x5b 0x42 441 | 442 | 0xf702-0x220000 443 | 444 | Action 445 | 10 446 | Text 447 | [1;2D 448 | 449 | 0xf702-0x240000 450 | 451 | Action 452 | 10 453 | Text 454 | [1;5D 455 | 456 | 0xf702-0x260000 457 | 458 | Action 459 | 10 460 | Text 461 | [1;6D 462 | 463 | 0xf702-0x280000 464 | 465 | Action 466 | 11 467 | Text 468 | 0x1b 0x1b 0x5b 0x44 469 | 470 | 0xf703-0x220000 471 | 472 | Action 473 | 10 474 | Text 475 | [1;2C 476 | 477 | 0xf703-0x240000 478 | 479 | Action 480 | 10 481 | Text 482 | [1;5C 483 | 484 | 0xf703-0x260000 485 | 486 | Action 487 | 10 488 | Text 489 | [1;6C 490 | 491 | 0xf703-0x280000 492 | 493 | Action 494 | 11 495 | Text 496 | 0x1b 0x1b 0x5b 0x43 497 | 498 | 0xf704-0x20000 499 | 500 | Action 501 | 10 502 | Text 503 | [1;2P 504 | 505 | 0xf705-0x20000 506 | 507 | Action 508 | 10 509 | Text 510 | [1;2Q 511 | 512 | 0xf706-0x20000 513 | 514 | Action 515 | 10 516 | Text 517 | [1;2R 518 | 519 | 0xf707-0x20000 520 | 521 | Action 522 | 10 523 | Text 524 | [1;2S 525 | 526 | 0xf708-0x20000 527 | 528 | Action 529 | 10 530 | Text 531 | [15;2~ 532 | 533 | 0xf709-0x20000 534 | 535 | Action 536 | 10 537 | Text 538 | [17;2~ 539 | 540 | 0xf70a-0x20000 541 | 542 | Action 543 | 10 544 | Text 545 | [18;2~ 546 | 547 | 0xf70b-0x20000 548 | 549 | Action 550 | 10 551 | Text 552 | [19;2~ 553 | 554 | 0xf70c-0x20000 555 | 556 | Action 557 | 10 558 | Text 559 | [20;2~ 560 | 561 | 0xf70d-0x20000 562 | 563 | Action 564 | 10 565 | Text 566 | [21;2~ 567 | 568 | 0xf70e-0x20000 569 | 570 | Action 571 | 10 572 | Text 573 | [23;2~ 574 | 575 | 0xf70f-0x20000 576 | 577 | Action 578 | 10 579 | Text 580 | [24;2~ 581 | 582 | 0xf729-0x20000 583 | 584 | Action 585 | 10 586 | Text 587 | [1;2H 588 | 589 | 0xf729-0x40000 590 | 591 | Action 592 | 10 593 | Text 594 | [1;5H 595 | 596 | 0xf72b-0x20000 597 | 598 | Action 599 | 10 600 | Text 601 | [1;2F 602 | 603 | 0xf72b-0x40000 604 | 605 | Action 606 | 10 607 | Text 608 | [1;5F 609 | 610 | 611 | Link Color 612 | 613 | Alpha Component 614 | 1 615 | Blue Component 616 | 0.73423302173614502 617 | Color Space 618 | sRGB 619 | Green Component 620 | 0.35916060209274292 621 | Red Component 622 | 0.0 623 | 624 | Mouse Reporting 625 | 626 | Name 627 | Default 628 | Non Ascii Font 629 | Monaco 12 630 | Non-ASCII Anti Aliased 631 | 632 | Normal Font 633 | PragmataPro 15 634 | Only The Default BG Color Uses Transparency 635 | 636 | Option Key Sends 637 | 0 638 | Prompt Before Closing 2 639 | 640 | Right Option Key Sends 641 | 0 642 | Rows 643 | 25 644 | Screen 645 | -1 646 | Scrollback Lines 647 | 1000 648 | Selected Text Color 649 | 650 | Blue Component 651 | 0.63137254901960782 652 | Color Space 653 | sRGB 654 | Green Component 655 | 0.63137254901960782 656 | Red Component 657 | 0.57647058823529407 658 | 659 | Selection Color 660 | 661 | Blue Component 662 | 0.25882352941176473 663 | Color Space 664 | sRGB 665 | Green Component 666 | 0.21176470588235294 667 | Red Component 668 | 0.027450980392156862 669 | 670 | Send Code When Idle 671 | 672 | Shortcut 673 | 674 | Silence Bell 675 | 676 | Sync Title 677 | 678 | Tags 679 | 680 | Terminal Type 681 | xterm-256color 682 | Thin Strokes 683 | 4 684 | Transparency 685 | 0.0 686 | Unicode Version 687 | 9 688 | Unlimited Scrollback 689 | 690 | Use Bold Font 691 | 692 | Use Bright Bold 693 | 694 | Use Italic Font 695 | 696 | Use Non-ASCII Font 697 | 698 | Vertical Spacing 699 | 1 700 | Visual Bell 701 | 702 | Window Type 703 | 0 704 | Working Directory 705 | /Users/mysov 706 | 707 | 708 | SoundForEsc 709 | 710 | TabStyleWithAutomaticOption 711 | 5 712 | VisualIndicatorForEsc 713 | 714 | findMode_iTerm 715 | 0 716 | 717 | 718 | -------------------------------------------------------------------------------- /osx/defaults.sh: -------------------------------------------------------------------------------- 1 | COMPUTER_NAME="mysh" 2 | 3 | # Ask for the administrator password upfront 4 | sudo -v 5 | 6 | # Keep-alive: update existing `sudo` time stamp until this script has finished 7 | while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & 8 | 9 | ############################################################################### 10 | # General UI/UX # 11 | ############################################################################### 12 | 13 | # Set computer name (as done via System Preferences → Sharing) 14 | sudo scutil --set ComputerName "$COMPUTER_NAME" 15 | sudo scutil --set HostName "$COMPUTER_NAME" 16 | sudo scutil --set LocalHostName "$COMPUTER_NAME" 17 | sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "$COMPUTER_NAME" 18 | 19 | # Set standby delay to 24 hours (default is 1 hour) 20 | sudo pmset -a standbydelay 86400 21 | 22 | # Disable audio feedback when volume is changed 23 | defaults write com.apple.sound.beep.feedback -bool false 24 | 25 | # Disable the sound effects on boot 26 | # sudo nvram SystemAudioVolume=" " 27 | 28 | # Menu bar: disable transparency 29 | # defaults write NSGlobalDomain AppleEnableMenuBarTransparency -bool false 30 | 31 | # Menu bar: hide the useless Time Machine and Volume icons 32 | # defaults write com.apple.systemuiserver menuExtras -array "/System/Library/CoreServices/Menu Extras/Bluetooth.menu" "/System/Library/CoreServices/Menu Extras/AirPort.menu" "/System/Library/CoreServices/Menu Extras/Battery.menu" "/System/Library/CoreServices/Menu Extras/Clock.menu" 33 | 34 | # Menu bar: show battery percentage 35 | defaults write com.apple.menuextra.battery -bool true 36 | 37 | # Disable opening and closing window animations 38 | defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool false 39 | 40 | # Increase window resize speed for Cocoa applications 41 | defaults write NSGlobalDomain NSWindowResizeTime -float 0.001 42 | 43 | # Expand save panel by default 44 | defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true 45 | 46 | # Expand print panel by default 47 | defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true 48 | 49 | # Save to disk (not to iCloud) by default 50 | defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false 51 | 52 | # Automatically quit printer app once the print jobs complete 53 | defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true 54 | 55 | # Disable the “Are you sure you want to open this application?” dialog 56 | # defaults write com.apple.LaunchServices LSQuarantine -bool false 57 | 58 | # Disable Resume system-wide 59 | # defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool false 60 | 61 | # Disable the crash reporter 62 | # defaults write com.apple.CrashReporter DialogType -string "none" 63 | 64 | # Restart automatically if the computer freezes 65 | # sudo systemsetup -setrestartfreeze on 66 | 67 | # Disable smart quotes, they're annoying when typing code 68 | defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false 69 | 70 | # Disable smart dashes, they're annoying when typing code 71 | defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false 72 | 73 | # Check for software updates daily, not just once per week 74 | defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1 75 | 76 | ############################################################################### 77 | # Trackpad, mouse, keyboard, Bluetooth accessories, and input # 78 | ############################################################################### 79 | 80 | # Trackpad: enable tap to click for this user and for the login screen 81 | defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true 82 | defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1 83 | defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1 84 | 85 | # Trackpad: map bottom right corner to right-click 86 | defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadCornerSecondaryClick -int 2 87 | defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadRightClick -bool true 88 | defaults -currentHost write NSGlobalDomain com.apple.trackpad.trackpadCornerClickBehavior -int 1 89 | defaults -currentHost write NSGlobalDomain com.apple.trackpad.enableSecondaryClick -bool true 90 | 91 | # Trackpad: swipe between pages with three fingers 92 | defaults write NSGlobalDomain AppleEnableSwipeNavigateWithScrolls -bool true 93 | defaults -currentHost write NSGlobalDomain com.apple.trackpad.threeFingerHorizSwipeGesture -int 1 94 | defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadThreeFingerHorizSwipeGesture -int 1 95 | 96 | # Increase sound quality for Bluetooth headphones/headsets 97 | defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40 98 | 99 | # Enable full keyboard access for all controls 100 | # (e.g. enable Tab in modal dialogs) 101 | defaults write NSGlobalDomain AppleKeyboardUIMode -int 3 102 | 103 | # Enable access for assistive devices 104 | echo -n 'a' | sudo tee /private/var/db/.AccessibilityAPIEnabled > /dev/null 2>&1 105 | sudo chmod 444 /private/var/db/.AccessibilityAPIEnabled 106 | # TODO: avoid GUI password prompt somehow (http://apple.stackexchange.com/q/60476/4408) 107 | #sudo osascript -e 'tell application "System Events" to set UI elements enabled to true' 108 | 109 | # Use scroll gesture with the Ctrl (^) modifier key to zoom 110 | defaults write com.apple.universalaccess closeViewScrollWheelToggle -bool true 111 | defaults write com.apple.universalaccess HIDScrollZoomModifierMask -int 262144 112 | # Follow the keyboard focus while zoomed in 113 | defaults write com.apple.universalaccess closeViewZoomFollowsFocus -bool true 114 | 115 | # Disable press-and-hold for keys in favor of key repeat 116 | defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false 117 | 118 | # Automatically illuminate built-in MacBook keyboard in low light 119 | defaults write com.apple.BezelServices kDim -bool true 120 | # Turn off keyboard illumination when computer is not used for 5 minutes 121 | defaults write com.apple.BezelServices kDimTime -int 300 122 | 123 | # Set language and text formats 124 | # Note: if you’re in the US, replace `EUR` with `USD`, `Centimeters` with 125 | # `Inches`, `en_GB` with `en_US`, and `true` with `false`. 126 | # defaults write NSGlobalDomain AppleLanguages -array "en" "nl" 127 | # defaults write NSGlobalDomain AppleLocale -string "en_US@currency=EUR" 128 | # defaults write NSGlobalDomain AppleMeasurementUnits -string "Centimeters" 129 | # defaults write NSGlobalDomain AppleMetricUnits -bool true 130 | 131 | # Set the timezone; see `sudo systemsetup -listtimezones` for other values 132 | sudo systemsetup -settimezone "Asia/Novosibirsk" > /dev/null 133 | 134 | # Disable auto-correct 135 | defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false 136 | 137 | # Use all F1, F2, etc. keys as standard function keys (requires restart) 138 | defaults write -g com.apple.keyboard.fnState -bool true 139 | 140 | ############################################################################### 141 | # Screen # 142 | ############################################################################### 143 | 144 | # Require password 5 seconds after sleep or screen saver begins 145 | defaults write com.apple.screensaver askForPassword -int 1 146 | defaults write com.apple.screensaver askForPasswordDelay -int 5 147 | 148 | # Save screenshots to the desktop 149 | defaults write com.apple.screencapture location -string "$HOME/Desktop" 150 | 151 | # Save screenshots in PNG format (other options: BMP, GIF, JPG, PDF, TIFF) 152 | defaults write com.apple.screencapture type -string "png" 153 | 154 | # Disable shadow in screenshots 155 | defaults write com.apple.screencapture disable-shadow -bool true 156 | 157 | # Enable subpixel font rendering on non-Apple LCDs 158 | defaults write NSGlobalDomain AppleFontSmoothing -int 2 159 | 160 | ############################################################################### 161 | # Finder # 162 | ############################################################################### 163 | 164 | # Finder: allow quitting via ⌘ + Q; doing so will also hide desktop icons 165 | # defaults write com.apple.finder QuitMenuItem -bool true 166 | 167 | # Finder: disable window animations and Get Info animations 168 | defaults write com.apple.finder DisableAllAnimations -bool true 169 | 170 | # Finder: show hidden files by default 171 | defaults write com.apple.finder AppleShowAllFiles -bool true 172 | 173 | # Finder: show all filename extensions 174 | defaults write NSGlobalDomain AppleShowAllExtensions -bool true 175 | 176 | # Finder: show status bar 177 | defaults write com.apple.finder ShowStatusBar -bool true 178 | 179 | # Finder: show path bar 180 | defaults write com.apple.finder ShowPathbar -bool true 181 | 182 | # Finder: allow text selection in Quick Look 183 | defaults write com.apple.finder QLEnableTextSelection -bool true 184 | 185 | # Display full POSIX path as Finder window title 186 | defaults write com.apple.finder _FXShowPosixPathInTitle -bool true 187 | 188 | # When performing a search, search the current folder by default 189 | defaults write com.apple.finder FXDefaultSearchScope -string "SCcf" 190 | 191 | # Disable the warning when changing a file extension 192 | defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false 193 | 194 | # Avoid creating .DS_Store files on network volumes 195 | defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true 196 | 197 | # Disable disk image verification 198 | defaults write com.apple.frameworks.diskimages skip-verify -bool true 199 | defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true 200 | defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true 201 | 202 | # Use AirDrop over every interface. 203 | defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true 204 | 205 | # Always open everything in Finder's list view. 206 | # Use list view in all Finder windows by default 207 | # Four-letter codes for the other view modes: `icnv`, `clmv`, `Flwv` 208 | defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv" 209 | 210 | # Disable the warning before emptying the Trash 211 | defaults write com.apple.finder WarnOnEmptyTrash -bool false 212 | 213 | # Enable the MacBook Air SuperDrive on any Mac 214 | sudo nvram boot-args="mbasd=1" 215 | 216 | # Expand the following File Info panes: 217 | # “General”, “Open with”, and “Sharing & Permissions” 218 | defaults write com.apple.finder FXInfoPanesExpanded -dict General -bool true OpenWith -bool true Privileges -bool true 219 | 220 | ############################################################################### 221 | # Dock # 222 | ############################################################################### 223 | 224 | # Show indicator lights for open applications in the Dock 225 | defaults write com.apple.dock show-process-indicators -bool true 226 | 227 | # Don’t animate opening applications from the Dock 228 | # defaults write com.apple.dock launchanim -bool false 229 | 230 | # Automatically hide and show the Dock 231 | defaults write com.apple.dock autohide -bool true 232 | 233 | # Make Dock icons of hidden applications translucent 234 | defaults write com.apple.dock showhidden -bool true 235 | 236 | # No bouncing icons 237 | # defaults write com.apple.dock no-bouncing -bool true 238 | 239 | ############################################################################### 240 | # Dashboard # 241 | ############################################################################### 242 | 243 | # Speed up Mission Control animations 244 | defaults write com.apple.dock expose-animation-duration -float 0.1 245 | 246 | # Disable Dashboard 247 | defaults write com.apple.dashboard mcx-disabled -bool true 248 | 249 | # Don’t show Dashboard as a Space 250 | defaults write com.apple.dock dashboard-in-overlay -bool true 251 | 252 | ############################################################################### 253 | # Hot corners # 254 | ############################################################################### 255 | 256 | # Possible values: 257 | # 0: no-op 258 | # 2: Mission Control 259 | # 3: Show application windows 260 | # 4: Desktop 261 | # 5: Start screen saver 262 | # 6: Disable screen saver 263 | # 7: Dashboard 264 | # 10: Put display to sleep 265 | # 11: Launchpad 266 | # 12: Notification Center 267 | 268 | # Top left screen corner 269 | defaults write com.apple.dock wvous-tl-corner -int 0 270 | defaults write com.apple.dock wvous-tl-modifier -int 0 271 | 272 | # Top right screen corner 273 | defaults write com.apple.dock wvous-tr-corner -int 0 274 | defaults write com.apple.dock wvous-tr-modifier -int 0 275 | 276 | # Bottom left screen corner → Display to sleep 277 | defaults write com.apple.dock wvous-bl-corner -int 10 278 | defaults write com.apple.dock wvous-bl-modifier -int 0 279 | 280 | # Bottom right screen corner 281 | defaults write com.apple.dock wvous-br-corner -int 0 282 | defaults write com.apple.dock wvous-br-modifier -int 0 283 | 284 | ############################################################################### 285 | # Safari & WebKit # 286 | ############################################################################### 287 | 288 | # Set Safari’s home page to `about:blank` for faster loading 289 | defaults write com.apple.Safari HomePage -string "about:blank" 290 | 291 | # Hide Safari’s bookmarks bar by default 292 | defaults write com.apple.Safari ShowFavoritesBar -bool false 293 | 294 | # Disable Safari’s thumbnail cache for History and Top Sites 295 | defaults write com.apple.Safari DebugSnapshotsUpdatePolicy -int 2 296 | 297 | # Hide Safari’s sidebar in Top Sites 298 | defaults write com.apple.Safari ShowSidebarInTopSites -bool false 299 | 300 | # Remove useless icons from Safari’s bookmarks bar 301 | defaults write com.apple.Safari ProxiesInBookmarksBar "()" 302 | 303 | # Allow hitting the Backspace key to go to the previous page in history 304 | defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2BackspaceKeyNavigationEnabled -bool true 305 | 306 | # Enable the Develop menu, the Web Inspector, and the debug menu in Safari 307 | defaults write com.apple.Safari IncludeInternalDebugMenu -bool true 308 | defaults write com.apple.Safari IncludeDevelopMenu -bool true 309 | defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true 310 | defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled -bool true 311 | 312 | # Add a context menu item for showing the Web Inspector in web views 313 | defaults write NSGlobalDomain WebKitDeveloperExtras -bool true 314 | 315 | ############################################################################### 316 | # Mail # 317 | ############################################################################### 318 | 319 | # Display emails in threaded mode 320 | defaults write com.apple.mail DraftsViewerAttributes -dict-add "DisplayInThreadedMode" -string "yes" 321 | 322 | # Disable send and reply animations in Mail.app 323 | defaults write com.apple.mail DisableReplyAnimations -bool true 324 | defaults write com.apple.mail DisableSendAnimations -bool true 325 | 326 | # Copy email addresses as `foo@example.com` instead of `Foo Bar ` in Mail.app 327 | defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false 328 | 329 | # Disable inline attachments (just show the icons) 330 | defaults write com.apple.mail DisableInlineAttachmentViewing -bool true 331 | 332 | # Disable automatic spell checking 333 | defaults write com.apple.mail SpellCheckingBehavior -string "NoSpellCheckingEnabled" 334 | 335 | # Disable sound for incoming mail 336 | defaults write com.apple.mail MailSound -string "" 337 | 338 | # Disable sound for other mail actions 339 | defaults write com.apple.mail PlayMailSounds -bool false 340 | 341 | # Mark all messages as read when opening a conversation 342 | defaults write com.apple.mail ConversationViewMarkAllAsRead -bool true 343 | 344 | ############################################################################### 345 | # Spotlight # 346 | ############################################################################### 347 | 348 | # Hide Spotlight tray-icon (and subsequent helper) 349 | #sudo chmod 600 /System/Library/CoreServices/Search.bundle/Contents/MacOS/Search 350 | # Disable Spotlight indexing for any volume that gets mounted and has not yet 351 | # been indexed before. 352 | # Use `sudo mdutil -i off "/Volumes/foo"` to stop indexing any volume. 353 | sudo defaults write /.Spotlight-V100/VolumeConfiguration Exclusions -array "/Volumes" 354 | # Change indexing order and disable some file types 355 | defaults write com.apple.spotlight orderedItems -array \ 356 | '{"enabled" = 1;"name" = "APPLICATIONS";}' \ 357 | '{"enabled" = 1;"name" = "SYSTEM_PREFS";}' \ 358 | '{"enabled" = 1;"name" = "DIRECTORIES";}' \ 359 | '{"enabled" = 1;"name" = "CONTACT";}' \ 360 | '{"enabled" = 1;"name" = "DOCUMENTS";}' \ 361 | '{"enabled" = 1;"name" = "PDF";}' \ 362 | '{"enabled" = 0;"name" = "FONTS";}' \ 363 | '{"enabled" = 0;"name" = "MESSAGES";}' \ 364 | '{"enabled" = 0;"name" = "EVENT_TODO";}' \ 365 | '{"enabled" = 0;"name" = "IMAGES";}' \ 366 | '{"enabled" = 0;"name" = "BOOKMARKS";}' \ 367 | '{"enabled" = 0;"name" = "MUSIC";}' \ 368 | '{"enabled" = 0;"name" = "MOVIES";}' \ 369 | '{"enabled" = 0;"name" = "PRESENTATIONS";}' \ 370 | '{"enabled" = 0;"name" = "SPREADSHEETS";}' \ 371 | '{"enabled" = 0;"name" = "SOURCE";}' 372 | 373 | # Load new settings before rebuilding the index 374 | killall mds 375 | 376 | # Make sure indexing is enabled for the main volume 377 | sudo mdutil -i on / 378 | 379 | # Rebuild the index from scratch 380 | sudo mdutil -E / 381 | 382 | ############################################################################### 383 | # Terminal # 384 | ############################################################################### 385 | 386 | # Only use UTF-8 in Terminal.app 387 | defaults write com.apple.terminal StringEncodings -array 4 388 | 389 | # Use "Pro" theme (black background color) 390 | defaults write com.apple.terminal "Default Window Settings" -string "Pro" 391 | defaults write com.apple.terminal "Startup Window Settings" -string "Pro" 392 | 393 | # Disable audible and visual bells 394 | defaults write com.apple.terminal "Bell" -bool false 395 | defaults write com.apple.terminal "VisualBell" -bool false 396 | 397 | ############################################################################### 398 | # Time Machine # 399 | ############################################################################### 400 | 401 | # Disable local Time Machine backups 402 | hash tmutil &> /dev/null && sudo tmutil disablelocal 403 | 404 | ############################################################################### 405 | # Activity Monitor # 406 | ############################################################################### 407 | 408 | # Show the main window when launching Activity Monitor 409 | defaults write com.apple.ActivityMonitor OpenMainWindow -bool true 410 | 411 | # Visualize CPU usage in the Activity Monitor Dock icon 412 | defaults write com.apple.ActivityMonitor IconType -int 5 413 | 414 | # Show all processes in Activity Monitor 415 | defaults write com.apple.ActivityMonitor ShowCategory -int 0 416 | 417 | # Sort Activity Monitor results by CPU usage 418 | defaults write com.apple.ActivityMonitor SortColumn -string "CPUUsage" 419 | defaults write com.apple.ActivityMonitor SortDirection -int 0 420 | 421 | ############################################################################### 422 | # Mac App Store # 423 | ############################################################################### 424 | 425 | # Enable the WebKit Developer Tools in the Mac App Store 426 | defaults write com.apple.appstore WebKitDeveloperExtras -bool true 427 | 428 | # Enable Debug Menu in the Mac App Store 429 | defaults write com.apple.appstore ShowDebugMenu -bool true 430 | 431 | ############################################################################### 432 | # SSD-specific tweaks # 433 | ############################################################################### 434 | 435 | # Disable local Time Machine snapshots 436 | sudo tmutil disablelocal 437 | 438 | ############################################################################### 439 | # Kill affected applications # 440 | ############################################################################### 441 | 442 | for app in "Address Book" "Calendar" "Contacts" "Dock" "Finder" "Mail" "Safari" "SystemUIServer" "iCal"; do 443 | killall "${app}" &> /dev/null 444 | done 445 | -------------------------------------------------------------------------------- /git/.gitsettings/git-completion.bash: -------------------------------------------------------------------------------- 1 | # bash/zsh completion support for core Git. 2 | # 3 | # Copyright (C) 2006,2007 Shawn O. Pearce 4 | # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). 5 | # Distributed under the GNU General Public License, version 2.0. 6 | # 7 | # The contained completion routines provide support for completing: 8 | # 9 | # *) local and remote branch names 10 | # *) local and remote tag names 11 | # *) .git/remotes file names 12 | # *) git 'subcommands' 13 | # *) git email aliases for git-send-email 14 | # *) tree paths within 'ref:path/to/file' expressions 15 | # *) file paths within current working directory and index 16 | # *) common --long-options 17 | # 18 | # To use these routines: 19 | # 20 | # 1) Copy this file to somewhere (e.g. ~/.git-completion.bash). 21 | # 2) Add the following line to your .bashrc/.zshrc: 22 | # source ~/.git-completion.bash 23 | # 3) Consider changing your PS1 to also show the current branch, 24 | # see git-prompt.sh for details. 25 | # 26 | # If you use complex aliases of form '!f() { ... }; f', you can use the null 27 | # command ':' as the first command in the function body to declare the desired 28 | # completion style. For example '!f() { : git commit ; ... }; f' will 29 | # tell the completion to use commit completion. This also works with aliases 30 | # of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '". 31 | # 32 | # Compatible with bash 3.2.57. 33 | # 34 | # You can set the following environment variables to influence the behavior of 35 | # the completion routines: 36 | # 37 | # GIT_COMPLETION_CHECKOUT_NO_GUESS 38 | # 39 | # When set to "1", do not include "DWIM" suggestions in git-checkout 40 | # and git-switch completion (e.g., completing "foo" when "origin/foo" 41 | # exists). 42 | 43 | case "$COMP_WORDBREAKS" in 44 | *:*) : great ;; 45 | *) COMP_WORDBREAKS="$COMP_WORDBREAKS:" 46 | esac 47 | 48 | # Discovers the path to the git repository taking any '--git-dir=' and 49 | # '-C ' options into account and stores it in the $__git_repo_path 50 | # variable. 51 | __git_find_repo_path () 52 | { 53 | if [ -n "$__git_repo_path" ]; then 54 | # we already know where it is 55 | return 56 | fi 57 | 58 | if [ -n "${__git_C_args-}" ]; then 59 | __git_repo_path="$(git "${__git_C_args[@]}" \ 60 | ${__git_dir:+--git-dir="$__git_dir"} \ 61 | rev-parse --absolute-git-dir 2>/dev/null)" 62 | elif [ -n "${__git_dir-}" ]; then 63 | test -d "$__git_dir" && 64 | __git_repo_path="$__git_dir" 65 | elif [ -n "${GIT_DIR-}" ]; then 66 | test -d "${GIT_DIR-}" && 67 | __git_repo_path="$GIT_DIR" 68 | elif [ -d .git ]; then 69 | __git_repo_path=.git 70 | else 71 | __git_repo_path="$(git rev-parse --git-dir 2>/dev/null)" 72 | fi 73 | } 74 | 75 | # Deprecated: use __git_find_repo_path() and $__git_repo_path instead 76 | # __gitdir accepts 0 or 1 arguments (i.e., location) 77 | # returns location of .git repo 78 | __gitdir () 79 | { 80 | if [ -z "${1-}" ]; then 81 | __git_find_repo_path || return 1 82 | echo "$__git_repo_path" 83 | elif [ -d "$1/.git" ]; then 84 | echo "$1/.git" 85 | else 86 | echo "$1" 87 | fi 88 | } 89 | 90 | # Runs git with all the options given as argument, respecting any 91 | # '--git-dir=' and '-C ' options present on the command line 92 | __git () 93 | { 94 | git ${__git_C_args:+"${__git_C_args[@]}"} \ 95 | ${__git_dir:+--git-dir="$__git_dir"} "$@" 2>/dev/null 96 | } 97 | 98 | # Removes backslash escaping, single quotes and double quotes from a word, 99 | # stores the result in the variable $dequoted_word. 100 | # 1: The word to dequote. 101 | __git_dequote () 102 | { 103 | local rest="$1" len ch 104 | 105 | dequoted_word="" 106 | 107 | while test -n "$rest"; do 108 | len=${#dequoted_word} 109 | dequoted_word="$dequoted_word${rest%%[\\\'\"]*}" 110 | rest="${rest:$((${#dequoted_word}-$len))}" 111 | 112 | case "${rest:0:1}" in 113 | \\) 114 | ch="${rest:1:1}" 115 | case "$ch" in 116 | $'\n') 117 | ;; 118 | *) 119 | dequoted_word="$dequoted_word$ch" 120 | ;; 121 | esac 122 | rest="${rest:2}" 123 | ;; 124 | \') 125 | rest="${rest:1}" 126 | len=${#dequoted_word} 127 | dequoted_word="$dequoted_word${rest%%\'*}" 128 | rest="${rest:$((${#dequoted_word}-$len+1))}" 129 | ;; 130 | \") 131 | rest="${rest:1}" 132 | while test -n "$rest" ; do 133 | len=${#dequoted_word} 134 | dequoted_word="$dequoted_word${rest%%[\\\"]*}" 135 | rest="${rest:$((${#dequoted_word}-$len))}" 136 | case "${rest:0:1}" in 137 | \\) 138 | ch="${rest:1:1}" 139 | case "$ch" in 140 | \"|\\|\$|\`) 141 | dequoted_word="$dequoted_word$ch" 142 | ;; 143 | $'\n') 144 | ;; 145 | *) 146 | dequoted_word="$dequoted_word\\$ch" 147 | ;; 148 | esac 149 | rest="${rest:2}" 150 | ;; 151 | \") 152 | rest="${rest:1}" 153 | break 154 | ;; 155 | esac 156 | done 157 | ;; 158 | esac 159 | done 160 | } 161 | 162 | # The following function is based on code from: 163 | # 164 | # bash_completion - programmable completion functions for bash 3.2+ 165 | # 166 | # Copyright © 2006-2008, Ian Macdonald 167 | # © 2009-2010, Bash Completion Maintainers 168 | # 169 | # 170 | # This program is free software; you can redistribute it and/or modify 171 | # it under the terms of the GNU General Public License as published by 172 | # the Free Software Foundation; either version 2, or (at your option) 173 | # any later version. 174 | # 175 | # This program is distributed in the hope that it will be useful, 176 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 177 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 178 | # GNU General Public License for more details. 179 | # 180 | # You should have received a copy of the GNU General Public License 181 | # along with this program; if not, see . 182 | # 183 | # The latest version of this software can be obtained here: 184 | # 185 | # http://bash-completion.alioth.debian.org/ 186 | # 187 | # RELEASE: 2.x 188 | 189 | # This function can be used to access a tokenized list of words 190 | # on the command line: 191 | # 192 | # __git_reassemble_comp_words_by_ref '=:' 193 | # if test "${words_[cword_-1]}" = -w 194 | # then 195 | # ... 196 | # fi 197 | # 198 | # The argument should be a collection of characters from the list of 199 | # word completion separators (COMP_WORDBREAKS) to treat as ordinary 200 | # characters. 201 | # 202 | # This is roughly equivalent to going back in time and setting 203 | # COMP_WORDBREAKS to exclude those characters. The intent is to 204 | # make option types like --date= and : easy to 205 | # recognize by treating each shell word as a single token. 206 | # 207 | # It is best not to set COMP_WORDBREAKS directly because the value is 208 | # shared with other completion scripts. By the time the completion 209 | # function gets called, COMP_WORDS has already been populated so local 210 | # changes to COMP_WORDBREAKS have no effect. 211 | # 212 | # Output: words_, cword_, cur_. 213 | 214 | __git_reassemble_comp_words_by_ref() 215 | { 216 | local exclude i j first 217 | # Which word separators to exclude? 218 | exclude="${1//[^$COMP_WORDBREAKS]}" 219 | cword_=$COMP_CWORD 220 | if [ -z "$exclude" ]; then 221 | words_=("${COMP_WORDS[@]}") 222 | return 223 | fi 224 | # List of word completion separators has shrunk; 225 | # re-assemble words to complete. 226 | for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do 227 | # Append each nonempty word consisting of just 228 | # word separator characters to the current word. 229 | first=t 230 | while 231 | [ $i -gt 0 ] && 232 | [ -n "${COMP_WORDS[$i]}" ] && 233 | # word consists of excluded word separators 234 | [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ] 235 | do 236 | # Attach to the previous token, 237 | # unless the previous token is the command name. 238 | if [ $j -ge 2 ] && [ -n "$first" ]; then 239 | ((j--)) 240 | fi 241 | first= 242 | words_[$j]=${words_[j]}${COMP_WORDS[i]} 243 | if [ $i = $COMP_CWORD ]; then 244 | cword_=$j 245 | fi 246 | if (($i < ${#COMP_WORDS[@]} - 1)); then 247 | ((i++)) 248 | else 249 | # Done. 250 | return 251 | fi 252 | done 253 | words_[$j]=${words_[j]}${COMP_WORDS[i]} 254 | if [ $i = $COMP_CWORD ]; then 255 | cword_=$j 256 | fi 257 | done 258 | } 259 | 260 | if ! type _get_comp_words_by_ref >/dev/null 2>&1; then 261 | _get_comp_words_by_ref () 262 | { 263 | local exclude cur_ words_ cword_ 264 | if [ "$1" = "-n" ]; then 265 | exclude=$2 266 | shift 2 267 | fi 268 | __git_reassemble_comp_words_by_ref "$exclude" 269 | cur_=${words_[cword_]} 270 | while [ $# -gt 0 ]; do 271 | case "$1" in 272 | cur) 273 | cur=$cur_ 274 | ;; 275 | prev) 276 | prev=${words_[$cword_-1]} 277 | ;; 278 | words) 279 | words=("${words_[@]}") 280 | ;; 281 | cword) 282 | cword=$cword_ 283 | ;; 284 | esac 285 | shift 286 | done 287 | } 288 | fi 289 | 290 | # Fills the COMPREPLY array with prefiltered words without any additional 291 | # processing. 292 | # Callers must take care of providing only words that match the current word 293 | # to be completed and adding any prefix and/or suffix (trailing space!), if 294 | # necessary. 295 | # 1: List of newline-separated matching completion words, complete with 296 | # prefix and suffix. 297 | __gitcomp_direct () 298 | { 299 | local IFS=$'\n' 300 | 301 | COMPREPLY=($1) 302 | } 303 | 304 | __gitcompappend () 305 | { 306 | local x i=${#COMPREPLY[@]} 307 | for x in $1; do 308 | if [[ "$x" == "$3"* ]]; then 309 | COMPREPLY[i++]="$2$x$4" 310 | fi 311 | done 312 | } 313 | 314 | __gitcompadd () 315 | { 316 | COMPREPLY=() 317 | __gitcompappend "$@" 318 | } 319 | 320 | # Generates completion reply, appending a space to possible completion words, 321 | # if necessary. 322 | # It accepts 1 to 4 arguments: 323 | # 1: List of possible completion words. 324 | # 2: A prefix to be added to each possible completion word (optional). 325 | # 3: Generate possible completion matches for this word (optional). 326 | # 4: A suffix to be appended to each possible completion word (optional). 327 | __gitcomp () 328 | { 329 | local cur_="${3-$cur}" 330 | 331 | case "$cur_" in 332 | --*=) 333 | ;; 334 | --no-*) 335 | local c i=0 IFS=$' \t\n' 336 | for c in $1; do 337 | if [[ $c == "--" ]]; then 338 | continue 339 | fi 340 | c="$c${4-}" 341 | if [[ $c == "$cur_"* ]]; then 342 | case $c in 343 | --*=*|*.) ;; 344 | *) c="$c " ;; 345 | esac 346 | COMPREPLY[i++]="${2-}$c" 347 | fi 348 | done 349 | ;; 350 | *) 351 | local c i=0 IFS=$' \t\n' 352 | for c in $1; do 353 | if [[ $c == "--" ]]; then 354 | c="--no-...${4-}" 355 | if [[ $c == "$cur_"* ]]; then 356 | COMPREPLY[i++]="${2-}$c " 357 | fi 358 | break 359 | fi 360 | c="$c${4-}" 361 | if [[ $c == "$cur_"* ]]; then 362 | case $c in 363 | --*=*|*.) ;; 364 | *) c="$c " ;; 365 | esac 366 | COMPREPLY[i++]="${2-}$c" 367 | fi 368 | done 369 | ;; 370 | esac 371 | } 372 | 373 | # Clear the variables caching builtins' options when (re-)sourcing 374 | # the completion script. 375 | if [[ -n ${ZSH_VERSION-} ]]; then 376 | unset $(set |sed -ne 's/^\(__gitcomp_builtin_[a-zA-Z0-9_][a-zA-Z0-9_]*\)=.*/\1/p') 2>/dev/null 377 | else 378 | unset $(compgen -v __gitcomp_builtin_) 379 | fi 380 | 381 | # This function is equivalent to 382 | # 383 | # __gitcomp "$(git xxx --git-completion-helper) ..." 384 | # 385 | # except that the output is cached. Accept 1-3 arguments: 386 | # 1: the git command to execute, this is also the cache key 387 | # 2: extra options to be added on top (e.g. negative forms) 388 | # 3: options to be excluded 389 | __gitcomp_builtin () 390 | { 391 | # spaces must be replaced with underscore for multi-word 392 | # commands, e.g. "git remote add" becomes remote_add. 393 | local cmd="$1" 394 | local incl="$2" 395 | local excl="$3" 396 | 397 | local var=__gitcomp_builtin_"${cmd/-/_}" 398 | local options 399 | eval "options=\$$var" 400 | 401 | if [ -z "$options" ]; then 402 | # leading and trailing spaces are significant to make 403 | # option removal work correctly. 404 | options=" $incl $(__git ${cmd/_/ } --git-completion-helper) " || return 405 | 406 | for i in $excl; do 407 | options="${options/ $i / }" 408 | done 409 | eval "$var=\"$options\"" 410 | fi 411 | 412 | __gitcomp "$options" 413 | } 414 | 415 | # Variation of __gitcomp_nl () that appends to the existing list of 416 | # completion candidates, COMPREPLY. 417 | __gitcomp_nl_append () 418 | { 419 | local IFS=$'\n' 420 | __gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }" 421 | } 422 | 423 | # Generates completion reply from newline-separated possible completion words 424 | # by appending a space to all of them. 425 | # It accepts 1 to 4 arguments: 426 | # 1: List of possible completion words, separated by a single newline. 427 | # 2: A prefix to be added to each possible completion word (optional). 428 | # 3: Generate possible completion matches for this word (optional). 429 | # 4: A suffix to be appended to each possible completion word instead of 430 | # the default space (optional). If specified but empty, nothing is 431 | # appended. 432 | __gitcomp_nl () 433 | { 434 | COMPREPLY=() 435 | __gitcomp_nl_append "$@" 436 | } 437 | 438 | # Fills the COMPREPLY array with prefiltered paths without any additional 439 | # processing. 440 | # Callers must take care of providing only paths that match the current path 441 | # to be completed and adding any prefix path components, if necessary. 442 | # 1: List of newline-separated matching paths, complete with all prefix 443 | # path components. 444 | __gitcomp_file_direct () 445 | { 446 | local IFS=$'\n' 447 | 448 | COMPREPLY=($1) 449 | 450 | # use a hack to enable file mode in bash < 4 451 | compopt -o filenames +o nospace 2>/dev/null || 452 | compgen -f /non-existing-dir/ >/dev/null || 453 | true 454 | } 455 | 456 | # Generates completion reply with compgen from newline-separated possible 457 | # completion filenames. 458 | # It accepts 1 to 3 arguments: 459 | # 1: List of possible completion filenames, separated by a single newline. 460 | # 2: A directory prefix to be added to each possible completion filename 461 | # (optional). 462 | # 3: Generate possible completion matches for this word (optional). 463 | __gitcomp_file () 464 | { 465 | local IFS=$'\n' 466 | 467 | # XXX does not work when the directory prefix contains a tilde, 468 | # since tilde expansion is not applied. 469 | # This means that COMPREPLY will be empty and Bash default 470 | # completion will be used. 471 | __gitcompadd "$1" "${2-}" "${3-$cur}" "" 472 | 473 | # use a hack to enable file mode in bash < 4 474 | compopt -o filenames +o nospace 2>/dev/null || 475 | compgen -f /non-existing-dir/ >/dev/null || 476 | true 477 | } 478 | 479 | # Execute 'git ls-files', unless the --committable option is specified, in 480 | # which case it runs 'git diff-index' to find out the files that can be 481 | # committed. It return paths relative to the directory specified in the first 482 | # argument, and using the options specified in the second argument. 483 | __git_ls_files_helper () 484 | { 485 | if [ "$2" == "--committable" ]; then 486 | __git -C "$1" -c core.quotePath=false diff-index \ 487 | --name-only --relative HEAD -- "${3//\\/\\\\}*" 488 | else 489 | # NOTE: $2 is not quoted in order to support multiple options 490 | __git -C "$1" -c core.quotePath=false ls-files \ 491 | --exclude-standard $2 -- "${3//\\/\\\\}*" 492 | fi 493 | } 494 | 495 | 496 | # __git_index_files accepts 1 or 2 arguments: 497 | # 1: Options to pass to ls-files (required). 498 | # 2: A directory path (optional). 499 | # If provided, only files within the specified directory are listed. 500 | # Sub directories are never recursed. Path must have a trailing 501 | # slash. 502 | # 3: List only paths matching this path component (optional). 503 | __git_index_files () 504 | { 505 | local root="$2" match="$3" 506 | 507 | __git_ls_files_helper "$root" "$1" "$match" | 508 | awk -F / -v pfx="${2//\\/\\\\}" '{ 509 | paths[$1] = 1 510 | } 511 | END { 512 | for (p in paths) { 513 | if (substr(p, 1, 1) != "\"") { 514 | # No special characters, easy! 515 | print pfx p 516 | continue 517 | } 518 | 519 | # The path is quoted. 520 | p = dequote(p) 521 | if (p == "") 522 | continue 523 | 524 | # Even when a directory name itself does not contain 525 | # any special characters, it will still be quoted if 526 | # any of its (stripped) trailing path components do. 527 | # Because of this we may have seen the same direcory 528 | # both quoted and unquoted. 529 | if (p in paths) 530 | # We have seen the same directory unquoted, 531 | # skip it. 532 | continue 533 | else 534 | print pfx p 535 | } 536 | } 537 | function dequote(p, bs_idx, out, esc, esc_idx, dec) { 538 | # Skip opening double quote. 539 | p = substr(p, 2) 540 | 541 | # Interpret backslash escape sequences. 542 | while ((bs_idx = index(p, "\\")) != 0) { 543 | out = out substr(p, 1, bs_idx - 1) 544 | esc = substr(p, bs_idx + 1, 1) 545 | p = substr(p, bs_idx + 2) 546 | 547 | if ((esc_idx = index("abtvfr\"\\", esc)) != 0) { 548 | # C-style one-character escape sequence. 549 | out = out substr("\a\b\t\v\f\r\"\\", 550 | esc_idx, 1) 551 | } else if (esc == "n") { 552 | # Uh-oh, a newline character. 553 | # We cant reliably put a pathname 554 | # containing a newline into COMPREPLY, 555 | # and the newline would create a mess. 556 | # Skip this path. 557 | return "" 558 | } else { 559 | # Must be a \nnn octal value, then. 560 | dec = esc * 64 + \ 561 | substr(p, 1, 1) * 8 + \ 562 | substr(p, 2, 1) 563 | out = out sprintf("%c", dec) 564 | p = substr(p, 3) 565 | } 566 | } 567 | # Drop closing double quote, if there is one. 568 | # (There isnt any if this is a directory, as it was 569 | # already stripped with the trailing path components.) 570 | if (substr(p, length(p), 1) == "\"") 571 | out = out substr(p, 1, length(p) - 1) 572 | else 573 | out = out p 574 | 575 | return out 576 | }' 577 | } 578 | 579 | # __git_complete_index_file requires 1 argument: 580 | # 1: the options to pass to ls-file 581 | # 582 | # The exception is --committable, which finds the files appropriate commit. 583 | __git_complete_index_file () 584 | { 585 | local dequoted_word pfx="" cur_ 586 | 587 | __git_dequote "$cur" 588 | 589 | case "$dequoted_word" in 590 | ?*/*) 591 | pfx="${dequoted_word%/*}/" 592 | cur_="${dequoted_word##*/}" 593 | ;; 594 | *) 595 | cur_="$dequoted_word" 596 | esac 597 | 598 | __gitcomp_file_direct "$(__git_index_files "$1" "$pfx" "$cur_")" 599 | } 600 | 601 | # Lists branches from the local repository. 602 | # 1: A prefix to be added to each listed branch (optional). 603 | # 2: List only branches matching this word (optional; list all branches if 604 | # unset or empty). 605 | # 3: A suffix to be appended to each listed branch (optional). 606 | __git_heads () 607 | { 608 | local pfx="${1-}" cur_="${2-}" sfx="${3-}" 609 | 610 | __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \ 611 | "refs/heads/$cur_*" "refs/heads/$cur_*/**" 612 | } 613 | 614 | # Lists tags from the local repository. 615 | # Accepts the same positional parameters as __git_heads() above. 616 | __git_tags () 617 | { 618 | local pfx="${1-}" cur_="${2-}" sfx="${3-}" 619 | 620 | __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \ 621 | "refs/tags/$cur_*" "refs/tags/$cur_*/**" 622 | } 623 | 624 | # Lists refs from the local (by default) or from a remote repository. 625 | # It accepts 0, 1 or 2 arguments: 626 | # 1: The remote to list refs from (optional; ignored, if set but empty). 627 | # Can be the name of a configured remote, a path, or a URL. 628 | # 2: In addition to local refs, list unique branches from refs/remotes/ for 629 | # 'git checkout's tracking DWIMery (optional; ignored, if set but empty). 630 | # 3: A prefix to be added to each listed ref (optional). 631 | # 4: List only refs matching this word (optional; list all refs if unset or 632 | # empty). 633 | # 5: A suffix to be appended to each listed ref (optional; ignored, if set 634 | # but empty). 635 | # 636 | # Use __git_complete_refs() instead. 637 | __git_refs () 638 | { 639 | local i hash dir track="${2-}" 640 | local list_refs_from=path remote="${1-}" 641 | local format refs 642 | local pfx="${3-}" cur_="${4-$cur}" sfx="${5-}" 643 | local match="${4-}" 644 | local fer_pfx="${pfx//\%/%%}" # "escape" for-each-ref format specifiers 645 | 646 | __git_find_repo_path 647 | dir="$__git_repo_path" 648 | 649 | if [ -z "$remote" ]; then 650 | if [ -z "$dir" ]; then 651 | return 652 | fi 653 | else 654 | if __git_is_configured_remote "$remote"; then 655 | # configured remote takes precedence over a 656 | # local directory with the same name 657 | list_refs_from=remote 658 | elif [ -d "$remote/.git" ]; then 659 | dir="$remote/.git" 660 | elif [ -d "$remote" ]; then 661 | dir="$remote" 662 | else 663 | list_refs_from=url 664 | fi 665 | fi 666 | 667 | if [ "$list_refs_from" = path ]; then 668 | if [[ "$cur_" == ^* ]]; then 669 | pfx="$pfx^" 670 | fer_pfx="$fer_pfx^" 671 | cur_=${cur_#^} 672 | match=${match#^} 673 | fi 674 | case "$cur_" in 675 | refs|refs/*) 676 | format="refname" 677 | refs=("$match*" "$match*/**") 678 | track="" 679 | ;; 680 | *) 681 | for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD; do 682 | case "$i" in 683 | $match*) 684 | if [ -e "$dir/$i" ]; then 685 | echo "$pfx$i$sfx" 686 | fi 687 | ;; 688 | esac 689 | done 690 | format="refname:strip=2" 691 | refs=("refs/tags/$match*" "refs/tags/$match*/**" 692 | "refs/heads/$match*" "refs/heads/$match*/**" 693 | "refs/remotes/$match*" "refs/remotes/$match*/**") 694 | ;; 695 | esac 696 | __git_dir="$dir" __git for-each-ref --format="$fer_pfx%($format)$sfx" \ 697 | "${refs[@]}" 698 | if [ -n "$track" ]; then 699 | # employ the heuristic used by git checkout 700 | # Try to find a remote branch that matches the completion word 701 | # but only output if the branch name is unique 702 | __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \ 703 | --sort="refname:strip=3" \ 704 | "refs/remotes/*/$match*" "refs/remotes/*/$match*/**" | \ 705 | uniq -u 706 | fi 707 | return 708 | fi 709 | case "$cur_" in 710 | refs|refs/*) 711 | __git ls-remote "$remote" "$match*" | \ 712 | while read -r hash i; do 713 | case "$i" in 714 | *^{}) ;; 715 | *) echo "$pfx$i$sfx" ;; 716 | esac 717 | done 718 | ;; 719 | *) 720 | if [ "$list_refs_from" = remote ]; then 721 | case "HEAD" in 722 | $match*) echo "${pfx}HEAD$sfx" ;; 723 | esac 724 | __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \ 725 | "refs/remotes/$remote/$match*" \ 726 | "refs/remotes/$remote/$match*/**" 727 | else 728 | local query_symref 729 | case "HEAD" in 730 | $match*) query_symref="HEAD" ;; 731 | esac 732 | __git ls-remote "$remote" $query_symref \ 733 | "refs/tags/$match*" "refs/heads/$match*" \ 734 | "refs/remotes/$match*" | 735 | while read -r hash i; do 736 | case "$i" in 737 | *^{}) ;; 738 | refs/*) echo "$pfx${i#refs/*/}$sfx" ;; 739 | *) echo "$pfx$i$sfx" ;; # symbolic refs 740 | esac 741 | done 742 | fi 743 | ;; 744 | esac 745 | } 746 | 747 | # Completes refs, short and long, local and remote, symbolic and pseudo. 748 | # 749 | # Usage: __git_complete_refs [