Add iterm settings, tweak bootstrap, bump eamcs pointer.
Fix web_start. Add remote_clipboard server stuff. Bump .emacs.d pointer and add remote_os_copy alias. Way better get_cols Made git sui git suir move to same sha as yelp branch for .emacs.d Bump emacs pointer. simplified default code for remote_clipboard. Remove unused functions from .functions. Added things from yelp branch. yelpify Added field separator to get_cols. Lots of refactoring. Added .lib directory. Moved dotfiles that get symlinked to ~ into their own directory. Remove some vim configuration. Remove oh-my-zsh.
This commit is contained in:
39
dotfiles/bash_profile
Normal file
39
dotfiles/bash_profile
Normal file
@@ -0,0 +1,39 @@
|
||||
# Add `~/bin` to the `$PATH`
|
||||
export PATH="$HOME/bin:$PATH"
|
||||
|
||||
# Load the shell dotfiles, and then some:
|
||||
# * ~/.path can be used to extend `$PATH`.
|
||||
# * ~/.extra can be used for other settings you don’t want to commit.
|
||||
for file in ~/.{path,bash_prompt,exports,shared_exports,aliases,functions,extra}; do
|
||||
[ -r "$file" ] && source "$file"
|
||||
done
|
||||
unset file
|
||||
|
||||
# Case-insensitive globbing (used in pathname expansion)
|
||||
shopt -s nocaseglob
|
||||
|
||||
# Append to the Bash history file, rather than overwriting it
|
||||
shopt -s histappend
|
||||
|
||||
# Autocorrect typos in path names when using `cd`
|
||||
shopt -s cdspell
|
||||
|
||||
# Enable some Bash 4 features when possible:
|
||||
# * `autocd`, e.g. `**/qux` will enter `./foo/bar/baz/qux`
|
||||
# * Recursive globbing, e.g. `echo **/*.txt`
|
||||
for option in autocd globstar; do
|
||||
shopt -s "$option" 2> /dev/null
|
||||
done
|
||||
|
||||
# Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards
|
||||
[ -e "$HOME/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2)" scp sftp ssh
|
||||
|
||||
# Add tab completion for `defaults read|write NSGlobalDomain`
|
||||
# You could just use `-g` instead, but I like being explicit
|
||||
complete -W "NSGlobalDomain" defaults
|
||||
|
||||
# Add `killall` tab completion for common apps
|
||||
complete -o "nospace" -W "Contacts Calendar Dock Finder Mail Safari iTunes SystemUIServer Terminal Twitter" killall
|
||||
|
||||
# If possible, add tab completion for many more commands
|
||||
[ -f /etc/bash_completion ] && source /etc/bash_completion
|
2
dotfiles/bashrc
Normal file
2
dotfiles/bashrc
Normal file
@@ -0,0 +1,2 @@
|
||||
source ~/.lib/shellrc.sh
|
||||
source ~/.lib/bash.sh
|
73
dotfiles/gitconfig
Normal file
73
dotfiles/gitconfig
Normal file
@@ -0,0 +1,73 @@
|
||||
[alias]
|
||||
# View the SHA, description, and history graph of the latest 20 commits
|
||||
l = log --pretty=oneline -n 20 --graph
|
||||
# View the current working tree status using the short format
|
||||
s = status -s
|
||||
# Show the diff between the latest commit and the current state
|
||||
d = !"git diff-index --quiet HEAD -- || clear; git diff --patch-with-stat"
|
||||
# `git di $number` shows the diff between the state `$number` revisions ago and the current state
|
||||
di = !"d() { git diff --patch-with-stat HEAD~$1; }; git diff-index --quiet HEAD -- || clear; d"
|
||||
# Clone a repository including all submodules
|
||||
c = clone --recursive
|
||||
# Commit all changes
|
||||
ca = !git add -A && git commit -av
|
||||
# Switch to a branch, creating it if necessary
|
||||
go = checkout -B
|
||||
# Show verbose output about tags, branches or remotes
|
||||
tags = tag -l
|
||||
branches = branch -a
|
||||
remotes = remote -v
|
||||
# Credit an author on the latest commit
|
||||
credit = "!f() { git commit --amend --author \"$1 <$2>\" -C HEAD; }; f"
|
||||
# Interactive rebase with the given number of latest commits
|
||||
reb = "!r() { git rebase -i HEAD~$1; }; r"
|
||||
suir = submodule update --init --recursive
|
||||
|
||||
[core]
|
||||
# Use custom `.gitignore` and `.gitattributes`
|
||||
excludesfile = ~/.gitignore
|
||||
attributesfile = ~/.gitattributes
|
||||
# Treat spaces before tabs, lines that are indented with 8 or more spaces, and all kinds of trailing whitespace as an error
|
||||
whitespace = space-before-tab,indent-with-non-tab,trailing-space
|
||||
pager = less -F -X
|
||||
|
||||
[color]
|
||||
# Use colors in Git commands that are capable of colored output when outputting to the terminal
|
||||
ui = auto
|
||||
[color "branch"]
|
||||
current = yellow reverse
|
||||
local = yellow
|
||||
remote = green
|
||||
[color "diff"]
|
||||
meta = yellow bold
|
||||
frag = magenta bold
|
||||
old = red bold
|
||||
new = green bold
|
||||
[color "status"]
|
||||
added = yellow
|
||||
changed = green
|
||||
untracked = cyan
|
||||
|
||||
# Use `origin` as the default remote on the `master` branch in all cases
|
||||
[branch "master"]
|
||||
remote = origin
|
||||
merge = refs/heads/master
|
||||
|
||||
# URL shorthands
|
||||
[url "git@github.com:"]
|
||||
insteadOf = "gh:"
|
||||
pushInsteadOf = "github:"
|
||||
pushInsteadOf = "git://github.com/"
|
||||
[url "git://github.com/"]
|
||||
insteadOf = "github:"
|
||||
[url "git@gist.github.com:"]
|
||||
insteadOf = "gst:"
|
||||
pushInsteadOf = "gist:"
|
||||
pushInsteadOf = "git://gist.github.com/"
|
||||
[url "git://gist.github.com/"]
|
||||
insteadOf = "gist:"
|
||||
[user]
|
||||
email = IvanMalison@gmail.com
|
||||
name = Ivan Malison
|
||||
[merge]
|
||||
conflictstyle = diff3
|
23
dotfiles/gitignore
Normal file
23
dotfiles/gitignore
Normal file
@@ -0,0 +1,23 @@
|
||||
# Compiled Python files
|
||||
*.pyc
|
||||
|
||||
# Folder view configuration files
|
||||
.DS_Store
|
||||
Desktop.ini
|
||||
|
||||
# Thumbnail cache files
|
||||
._*
|
||||
Thumbs.db
|
||||
|
||||
# Files that might appear on external disks
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
|
||||
.emacs.desktop
|
||||
|
||||
.emacs*
|
||||
|
||||
# yelp
|
||||
TAGS
|
||||
run_tests.sh
|
||||
untracked/
|
17
dotfiles/hgignore
Normal file
17
dotfiles/hgignore
Normal file
@@ -0,0 +1,17 @@
|
||||
# Use shell-style glob syntax
|
||||
syntax: glob
|
||||
|
||||
# Compiled Python files
|
||||
*.pyc
|
||||
|
||||
# Folder view configuration files
|
||||
.DS_Store
|
||||
Desktop.ini
|
||||
|
||||
# Thumbnail cache files
|
||||
._*
|
||||
Thumbs.db
|
||||
|
||||
# Files that might appear on external disks
|
||||
.Spotlight-V100
|
||||
.Trashes
|
4
dotfiles/hushlogin
Normal file
4
dotfiles/hushlogin
Normal file
@@ -0,0 +1,4 @@
|
||||
# The mere presence of this file in the home directory disables the system
|
||||
# copyright notice, the date and time of the last login, the message of the
|
||||
# day as well as other information that may otherwise appear on login.
|
||||
# See `man login`.
|
40
dotfiles/inputrc
Normal file
40
dotfiles/inputrc
Normal file
@@ -0,0 +1,40 @@
|
||||
# Make Tab autocomplete regardless of filename case
|
||||
set completion-ignore-case on
|
||||
|
||||
# List all matches in case multiple possible completions are possible
|
||||
set show-all-if-ambiguous on
|
||||
|
||||
# Immediately add a trailing slash when autocompleting symlinks to directories
|
||||
set mark-symlinked-directories on
|
||||
|
||||
# Use the text that has already been typed as the prefix for searching through
|
||||
# commands (i.e. more intelligent Up/Down behavior)
|
||||
"\e[B": history-search-forward
|
||||
"\e[A": history-search-backward
|
||||
|
||||
# Do not autocomplete hidden files unless the pattern explicitly begins with a dot
|
||||
set match-hidden-files off
|
||||
|
||||
# Show all autocomplete results at once
|
||||
set page-completions off
|
||||
|
||||
# If there are more than 200 possible completions for a word, ask to show them all
|
||||
set completion-query-items 200
|
||||
|
||||
# Show extra file information when completing, like `ls -F` does
|
||||
set visible-stats on
|
||||
|
||||
# Be more intelligent when autocompleting by also looking at the text after
|
||||
# the cursor. For example, when the current line is "cd ~/src/mozil", and
|
||||
# the cursor is on the "z", pressing Tab will not autocomplete it to "cd
|
||||
# ~/src/mozillail", but to "cd ~/src/mozilla". (This is supported by the
|
||||
# Readline used by Bash 4.)
|
||||
set skip-completed-text on
|
||||
|
||||
# Allow UTF-8 input and output, instead of showing stuff like $'\0123\0456'
|
||||
set input-meta on
|
||||
set output-meta on
|
||||
set convert-meta off
|
||||
|
||||
# Use Alt/Meta + Delete to delete the preceding word
|
||||
"\e[3;3~": kill-word
|
7
dotfiles/lib/apt-get.sh
Normal file
7
dotfiles/lib/apt-get.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
INSTALL="sudo apt-get -y install"
|
||||
$INSTALL zsh
|
||||
$INSTALL tmux
|
||||
$INSTALL emacs24-nox
|
||||
$INSTALL nmap
|
||||
$INSTALL python2.7
|
||||
$INSTALL python-pip python-dev
|
0
dotfiles/lib/bash.sh
Normal file
0
dotfiles/lib/bash.sh
Normal file
35
dotfiles/lib/brew.sh
Executable file
35
dotfiles/lib/brew.sh
Executable file
@@ -0,0 +1,35 @@
|
||||
# Make sure we’re using the latest Homebrew
|
||||
brew update
|
||||
|
||||
# Upgrade any already-installed formulae
|
||||
brew upgrade
|
||||
|
||||
# Install GNU core utilities (those that come with OS X are outdated)
|
||||
brew install coreutils
|
||||
echo "Don’t forget to add $(brew --prefix coreutils)/libexec/gnubin to \$PATH."
|
||||
# Install GNU `find`, `locate`, `updatedb`, and `xargs`, g-prefixed
|
||||
brew install findutils
|
||||
# Install Bash 4
|
||||
brew install bash
|
||||
|
||||
brew install greadlink
|
||||
|
||||
# Install wget with IRI support
|
||||
brew install wget --enable-iri
|
||||
|
||||
# Install more recent versions of some OS X tools
|
||||
brew tap homebrew/dupes
|
||||
brew install homebrew/dupes/grep
|
||||
|
||||
# Install everything else
|
||||
brew install emacs
|
||||
brew install git
|
||||
brew install tmux
|
||||
brew install nmap
|
||||
brew install readline
|
||||
brew install netcat
|
||||
brew install reattach-to-user-namespace
|
||||
brew install ngrep
|
||||
|
||||
# Remove outdated versions from the cellar
|
||||
brew cleanup
|
6164
dotfiles/lib/completions/_git
Normal file
6164
dotfiles/lib/completions/_git
Normal file
File diff suppressed because it is too large
Load Diff
73
dotfiles/lib/completions/_testify
Normal file
73
dotfiles/lib/completions/_testify
Normal file
@@ -0,0 +1,73 @@
|
||||
#compdef testify
|
||||
|
||||
_testify() {
|
||||
typeset -A opt_args
|
||||
local context state line
|
||||
|
||||
BASE_TEST_PATH='yelp.tests'
|
||||
_arguments "1:testify_file:->file" "2:testify_:->test_case"
|
||||
|
||||
case $state in
|
||||
(file)
|
||||
_find_test_files
|
||||
;;
|
||||
(test_case)
|
||||
_find_test_methods
|
||||
;;
|
||||
esac
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
(( $+functions[_print_test_methods] )) ||
|
||||
_print_test_methods() {
|
||||
python - "$@" <<ENDPYTHON
|
||||
import sys
|
||||
from testify import test_discovery
|
||||
|
||||
if __name__ == '__main__':
|
||||
for test_case in test_discovery.discover(sys.argv[1]):
|
||||
print test_case.__name__
|
||||
for member in dir(test_case):
|
||||
if member.startswith("test"):
|
||||
print "%s.%s" % (test_case.__name__, member)
|
||||
ENDPYTHON
|
||||
|
||||
}
|
||||
|
||||
(( $+functions[_find_test_methods] )) ||
|
||||
_find_test_methods() {
|
||||
TEST_COMPLETIONS=( `_print_test_methods $line 2> /dev/null` )
|
||||
for COMPLETION in $TEST_COMPLETIONS
|
||||
do
|
||||
compadd $COMPLETION
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
(( $+functions[_find_test_files] )) ||
|
||||
_find_test_files() {
|
||||
local SEARCH_PATH
|
||||
if [[ "$PREFIX" == "$BASE_TEST_PATH"* ]]
|
||||
then
|
||||
SEARCH_PATH="${PREFIX%.*}"
|
||||
else
|
||||
compadd $BASE_TEST_PATH
|
||||
compadd $BASE_TEST_PATH'.'
|
||||
return 0
|
||||
fi
|
||||
SEARCH_PATH=$(echo "$SEARCH_PATH" | tr . /)
|
||||
DIRECTORIES=( "$SEARCH_PATH"/*(/) )
|
||||
PY_FILES=( "$SEARCH_PATH"/*.py )
|
||||
for DIRECTORY in $DIRECTORIES
|
||||
do
|
||||
compadd `echo "${DIRECTORY}" | tr / .`
|
||||
compadd `echo "${DIRECTORY}" | tr / .`'.'
|
||||
done
|
||||
|
||||
for PY_FILE in $PY_FILES
|
||||
do
|
||||
compadd `echo "${PY_FILE%.py}" | tr / .`
|
||||
done
|
||||
return 0
|
||||
}
|
12
dotfiles/lib/get_cols.awk
Normal file
12
dotfiles/lib/get_cols.awk
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env gawk -f
|
||||
BEGIN{
|
||||
column_count=split(cols,column_numbers," ");
|
||||
}
|
||||
{
|
||||
for(i=1; i<=column_count; i++)
|
||||
if(column_numbers[i] < 0)
|
||||
printf "%s%s", $(NF + 1 + column_numbers[i]), OFS
|
||||
else
|
||||
printf "%s%s", $column_numbers[i], OFS
|
||||
printf "%s", ORS
|
||||
}
|
509
dotfiles/lib/osx.sh
Executable file
509
dotfiles/lib/osx.sh
Executable file
@@ -0,0 +1,509 @@
|
||||
#!/bin/bash
|
||||
|
||||
# ~/.osx — http://mths.be/osx
|
||||
|
||||
# Ask for the administrator password upfront
|
||||
sudo -v
|
||||
|
||||
# Keep-alive: update existing `sudo` time stamp until `.osx` has finished
|
||||
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
|
||||
|
||||
###############################################################################
|
||||
# General UI/UX #
|
||||
###############################################################################
|
||||
|
||||
# Set computer name (as done via System Preferences → Sharing)
|
||||
sudo scutil --set ComputerName "IvansMac"
|
||||
sudo scutil --set HostName "IvanMalison"
|
||||
sudo scutil --set LocalHostName "IvanMalison"
|
||||
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "IvanMalison"
|
||||
|
||||
# Menu bar: disable transparency
|
||||
defaults write NSGlobalDomain AppleEnableMenuBarTransparency -bool false
|
||||
|
||||
# Menu bar: show remaining battery time (on pre-10.8); hide percentage
|
||||
defaults write com.apple.menuextra.battery ShowPercent -string "YES"
|
||||
defaults write com.apple.menuextra.battery ShowTime -string "YES"
|
||||
|
||||
# Menu bar: hide the useless Time Machine and Volume icons
|
||||
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"
|
||||
|
||||
# Always show scrollbars
|
||||
defaults write NSGlobalDomain AppleShowScrollBars -string "Automatic"
|
||||
|
||||
# Disable opening and closing window animations
|
||||
defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool false
|
||||
|
||||
# Increase window resize speed for Cocoa applications
|
||||
defaults write NSGlobalDomain NSWindowResizeTime -float 0.08
|
||||
|
||||
# Expand save panel by default
|
||||
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
|
||||
|
||||
# Expand print panel by default
|
||||
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true
|
||||
|
||||
# Save to disk (not to iCloud) by default
|
||||
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
|
||||
|
||||
# Automatically quit printer app once the print jobs complete
|
||||
defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true
|
||||
|
||||
# Disable the “Are you sure you want to open this application?” dialog
|
||||
defaults write com.apple.LaunchServices LSQuarantine -bool false
|
||||
|
||||
# Display ASCII control characters using caret notation in standard text views
|
||||
# Try e.g. `cd /tmp; unidecode "\x{0000}" > cc.txt; open -e cc.txt`
|
||||
defaults write NSGlobalDomain NSTextShowsControlCharacters -bool true
|
||||
|
||||
# Disable Resume system-wide
|
||||
defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool false
|
||||
|
||||
# Disable automatic termination of inactive apps
|
||||
defaults write NSGlobalDomain NSDisableAutomaticTermination -bool true
|
||||
|
||||
# Set Help Viewer windows to non-floating mode
|
||||
defaults write com.apple.helpviewer DevMode -bool true
|
||||
|
||||
#echo "0x08000100:0" > ~/.CFUserTextEncoding
|
||||
|
||||
# Reveal IP address, hostname, OS version, etc. when clicking the clock
|
||||
# in the login window
|
||||
sudo defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo HostName
|
||||
|
||||
# Restart automatically if the computer freezes
|
||||
systemsetup -setrestartfreeze on
|
||||
|
||||
# Never go into computer sleep mode
|
||||
systemsetup -setcomputersleep Off > /dev/null
|
||||
|
||||
# Check for software updates daily, not just once per week
|
||||
defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1
|
||||
|
||||
###############################################################################
|
||||
# Trackpad, mouse, keyboard, Bluetooth accessories, and input #
|
||||
###############################################################################
|
||||
|
||||
# Trackpad: enable tap to click for this user and for the login screen
|
||||
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
|
||||
defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
|
||||
defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
|
||||
|
||||
# Increase sound quality for Bluetooth headphones/headsets
|
||||
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40
|
||||
|
||||
# Enable full keyboard access for all controls
|
||||
# (e.g. enable Tab in modal dialogs)
|
||||
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
|
||||
|
||||
# Enable access for assistive devices
|
||||
echo -n 'a' | sudo tee /private/var/db/.AccessibilityAPIEnabled > /dev/null 2>&1
|
||||
sudo chmod 444 /private/var/db/.AccessibilityAPIEnabled
|
||||
# TODO: avoid GUI password prompt somehow (http://apple.stackexchange.com/q/60476/4408)
|
||||
#sudo osascript -e 'tell application "System Events" to set UI elements enabled to true'
|
||||
|
||||
# Use scroll gesture with the Ctrl (^) modifier key to zoom
|
||||
defaults write com.apple.universalaccess closeViewScrollWheelToggle -bool true
|
||||
defaults write com.apple.universalaccess HIDScrollZoomModifierMask -int 262144
|
||||
# Follow the keyboard focus while zoomed in
|
||||
defaults write com.apple.universalaccess closeViewZoomFollowsFocus -bool true
|
||||
|
||||
# Disable press-and-hold for keys in favor of key repeat
|
||||
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
|
||||
|
||||
# Set a blazingly fast keyboard repeat rate
|
||||
defaults write NSGlobalDomain KeyRepeat -int 1
|
||||
|
||||
# Automatically illuminate built-in MacBook keyboard in low light
|
||||
defaults write com.apple.BezelServices kDim -bool true
|
||||
# Turn off keyboard illumination when computer is not used for 5 minutes
|
||||
defaults write com.apple.BezelServices kDimTime -int 300
|
||||
|
||||
# Set language and text formats
|
||||
# Note: if you’re in the US, replace `EUR` with `USD`, `Centimeters` with
|
||||
# `Inches`, and `true` with `false`.
|
||||
defaults write NSGlobalDomain AppleLanguages -array "en"
|
||||
defaults write NSGlobalDomain AppleLocale -string "en_US@currency=USD"
|
||||
defaults write NSGlobalDomain AppleMeasurementUnits -string "Inches"
|
||||
defaults write NSGlobalDomain AppleMetricUnits -bool false
|
||||
|
||||
# Disable auto-correct
|
||||
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
|
||||
|
||||
###############################################################################
|
||||
# Screen #
|
||||
###############################################################################
|
||||
|
||||
# Require password immediately after sleep or screen saver begins
|
||||
defaults write com.apple.screensaver askForPassword -int 1
|
||||
defaults write com.apple.screensaver askForPasswordDelay -int 0
|
||||
|
||||
# Save screenshots to the desktop
|
||||
defaults write com.apple.screencapture location -string "$HOME/Desktop"
|
||||
|
||||
# Save screenshots in PNG format (other options: BMP, GIF, JPG, PDF, TIFF)
|
||||
defaults write com.apple.screencapture type -string "png"
|
||||
|
||||
# Disable shadow in screenshots
|
||||
defaults write com.apple.screencapture disable-shadow -bool true
|
||||
|
||||
# Enable subpixel font rendering on non-Apple LCDs
|
||||
defaults write NSGlobalDomain AppleFontSmoothing -int 2
|
||||
|
||||
# Enable HiDPI display modes (requires restart)
|
||||
sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool true
|
||||
|
||||
###############################################################################
|
||||
# Finder #
|
||||
###############################################################################
|
||||
|
||||
# Finder: allow quitting via ⌘ + Q; doing so will also hide desktop icons
|
||||
defaults write com.apple.finder QuitMenuItem -bool true
|
||||
|
||||
# Finder: disable window animations and Get Info animations
|
||||
defaults write com.apple.finder DisableAllAnimations -bool true
|
||||
|
||||
# Show icons for hard drives, servers, and removable media on the desktop
|
||||
defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true
|
||||
defaults write com.apple.finder ShowHardDrivesOnDesktop -bool true
|
||||
defaults write com.apple.finder ShowMountedServersOnDesktop -bool true
|
||||
defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true
|
||||
|
||||
# Finder: show hidden files by default
|
||||
defaults write com.apple.finder AppleShowAllFiles -bool true
|
||||
|
||||
# Finder: show all filename extensions
|
||||
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
|
||||
|
||||
# Finder: show status bar
|
||||
defaults write com.apple.finder ShowStatusBar -bool true
|
||||
|
||||
# Finder: allow text selection in Quick Look
|
||||
defaults write com.apple.finder QLEnableTextSelection -bool true
|
||||
|
||||
# Display full POSIX path as Finder window title
|
||||
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
|
||||
|
||||
# When performing a search, search the current folder by default
|
||||
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
|
||||
|
||||
# Disable the warning when changing a file extension
|
||||
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
|
||||
|
||||
# Avoid creating .DS_Store files on network volumes
|
||||
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
|
||||
|
||||
# Disable disk image verification
|
||||
defaults write com.apple.frameworks.diskimages skip-verify -bool true
|
||||
defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true
|
||||
defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true
|
||||
|
||||
# Automatically open a new Finder window when a volume is mounted
|
||||
defaults write com.apple.frameworks.diskimages auto-open-ro-root -bool true
|
||||
defaults write com.apple.frameworks.diskimages auto-open-rw-root -bool true
|
||||
defaults write com.apple.finder OpenWindowForNewRemovableDisk -bool true
|
||||
|
||||
# Show item info near icons on the desktop and in other icon views
|
||||
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist
|
||||
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist
|
||||
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist
|
||||
|
||||
# Show item info to the right of the icons on the desktop
|
||||
/usr/libexec/PlistBuddy -c "Set DesktopViewSettings:IconViewSettings:labelOnBottom false" ~/Library/Preferences/com.apple.finder.plist
|
||||
|
||||
# Enable snap-to-grid for icons on the desktop and in other icon views
|
||||
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
|
||||
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
|
||||
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
|
||||
|
||||
# Increase grid spacing for icons on the desktop and in other icon views
|
||||
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:gridSpacing 100" ~/Library/Preferences/com.apple.finder.plist
|
||||
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:gridSpacing 100" ~/Library/Preferences/com.apple.finder.plist
|
||||
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:gridSpacing 100" ~/Library/Preferences/com.apple.finder.plist
|
||||
|
||||
# Increase the size of icons on the desktop and in other icon views
|
||||
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:iconSize 80" ~/Library/Preferences/com.apple.finder.plist
|
||||
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:iconSize 80" ~/Library/Preferences/com.apple.finder.plist
|
||||
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:iconSize 80" ~/Library/Preferences/com.apple.finder.plist
|
||||
|
||||
# Use list view in all Finder windows by default
|
||||
# Four-letter codes for the other view modes: `icnv`, `clmv`, `Flwv`
|
||||
defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv"
|
||||
|
||||
# Disable the warning before emptying the Trash
|
||||
defaults write com.apple.finder WarnOnEmptyTrash -bool false
|
||||
|
||||
# Empty Trash securely by default
|
||||
defaults write com.apple.finder EmptyTrashSecurely -bool true
|
||||
|
||||
# Enable AirDrop over Ethernet and on unsupported Macs running Lion
|
||||
defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true
|
||||
|
||||
# Show the ~/Library folder
|
||||
chflags nohidden ~/Library
|
||||
|
||||
# Remove Dropbox’s green checkmark icons in Finder
|
||||
file=/Applications/Dropbox.app/Contents/Resources/check.icns
|
||||
[ -e "$file" ] && mv -f "$file" "$file.bak"
|
||||
unset file
|
||||
|
||||
###############################################################################
|
||||
# Dock & hot corners #
|
||||
###############################################################################
|
||||
|
||||
# Enable highlight hover effect for the grid view of a stack (Dock)
|
||||
defaults write com.apple.dock mouse-over-hilite-stack -bool true
|
||||
|
||||
# Set the icon size of Dock items to 36 pixels
|
||||
defaults write com.apple.dock tilesize -int 36
|
||||
|
||||
# Enable spring loading for all Dock items
|
||||
defaults write com.apple.dock enable-spring-load-actions-on-all-items -bool true
|
||||
|
||||
# Show indicator lights for open applications in the Dock
|
||||
defaults write com.apple.dock show-process-indicators -bool true
|
||||
|
||||
# Wipe all (default) app icons from the Dock
|
||||
# This is only really useful when setting up a new Mac, or if you don’t use
|
||||
# the Dock to launch apps.
|
||||
# defaults write com.apple.dock persistent-apps -array
|
||||
|
||||
# Don’t animate opening applications from the Dock
|
||||
defaults write com.apple.dock launchanim -bool false
|
||||
|
||||
# Speed up Mission Control animations
|
||||
defaults write com.apple.dock expose-animation-duration -float .5
|
||||
|
||||
# Don’t group windows by application in Mission Control
|
||||
# (i.e. use the old Exposé behavior instead)
|
||||
defaults write com.apple.dock expose-group-by-app -bool false
|
||||
|
||||
# Don’t show Dashboard as a Space
|
||||
defaults write com.apple.dock dashboard-in-overlay -bool true
|
||||
|
||||
# Remove the auto-hiding Dock delay
|
||||
defaults write com.apple.Dock autohide-delay -float 0
|
||||
|
||||
# Enable the 2D Dock
|
||||
#defaults write com.apple.dock no-glass -bool true
|
||||
|
||||
# Automatically hide and show the Dock
|
||||
defaults write com.apple.dock autohide -bool true
|
||||
|
||||
# Make Dock icons of hidden applications translucent
|
||||
defaults write com.apple.dock showhidden -bool true
|
||||
|
||||
# Reset Launchpad
|
||||
find ~/Library/Application\ Support/Dock -name "*.db" -maxdepth 1 -delete
|
||||
|
||||
# Add iOS Simulator to Launchpad
|
||||
ln -s /Applications/Xcode.app/Contents/Applications/iPhone\ Simulator.app /Applications/iOS\ Simulator.app
|
||||
|
||||
# Add a spacer to the left side of the Dock (where the applications are)
|
||||
#defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}'
|
||||
# Add a spacer to the right side of the Dock (where the Trash is)
|
||||
#defaults write com.apple.dock persistent-others -array-add '{tile-data={}; tile-type="spacer-tile";}'
|
||||
|
||||
# Hot corners
|
||||
# Possible values:
|
||||
# 0: no-op
|
||||
# 2: Mission Control
|
||||
# 3: Show application windows
|
||||
# 4: Desktop
|
||||
# 5: Start screen saver
|
||||
# 6: Disable screen saver
|
||||
# 7: Dashboard
|
||||
# 10: Put display to sleep
|
||||
# 11: Launchpad
|
||||
# Top right screen corner → Desktop
|
||||
defaults write com.apple.dock wvous-tr-corner -int 4
|
||||
defaults write com.apple.dock wvous-tr-modifier -int 0
|
||||
# Bottom left screen corner → Start screen saver
|
||||
defaults write com.apple.dock wvous-bl-corner -int 5
|
||||
defaults write com.apple.dock wvous-bl-modifier -int 0
|
||||
|
||||
###############################################################################
|
||||
# Safari & WebKit #
|
||||
###############################################################################
|
||||
|
||||
# Set Safari’s home page to `about:blank` for faster loading
|
||||
defaults write com.apple.Safari HomePage -string "about:blank"
|
||||
|
||||
# Prevent Safari from opening ‘safe’ files automatically after downloading
|
||||
defaults write com.apple.Safari AutoOpenSafeDownloads -bool false
|
||||
|
||||
# Allow hitting the Backspace key to go to the previous page in history
|
||||
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2BackspaceKeyNavigationEnabled -bool true
|
||||
|
||||
# Hide Safari’s bookmarks bar by default
|
||||
defaults write com.apple.Safari ShowFavoritesBar -bool false
|
||||
|
||||
# Disable Safari’s thumbnail cache for History and Top Sites
|
||||
defaults write com.apple.Safari DebugSnapshotsUpdatePolicy -int 2
|
||||
|
||||
# Enable Safari’s debug menu
|
||||
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true
|
||||
|
||||
# Make Safari’s search banners default to Contains instead of Starts With
|
||||
defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool false
|
||||
|
||||
# Remove useless icons from Safari’s bookmarks bar
|
||||
defaults write com.apple.Safari ProxiesInBookmarksBar "()"
|
||||
|
||||
# Enable the Develop menu and the Web Inspector in Safari
|
||||
defaults write com.apple.Safari IncludeDevelopMenu -bool true
|
||||
defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true
|
||||
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled -bool true
|
||||
|
||||
# Add a context menu item for showing the Web Inspector in web views
|
||||
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
|
||||
|
||||
###############################################################################
|
||||
# iTunes (pre-iTunes 11 only) #
|
||||
###############################################################################
|
||||
|
||||
# Disable the iTunes store link arrows
|
||||
defaults write com.apple.iTunes show-store-link-arrows -bool false
|
||||
|
||||
# Disable the Genius sidebar in iTunes
|
||||
defaults write com.apple.iTunes disableGeniusSidebar -bool true
|
||||
|
||||
# Disable radio stations in iTunes
|
||||
defaults write com.apple.iTunes disableRadio -bool true
|
||||
|
||||
# Make ⌘ + F focus the search input in iTunes
|
||||
# To use these commands in another language, browse iTunes’s package contents,
|
||||
# open `Contents/Resources/your-language.lproj/Localizable.strings`, and look
|
||||
# for `kHiddenMenuItemTargetSearch`.
|
||||
defaults write com.apple.iTunes NSUserKeyEquivalents -dict-add "Target Search Field" "@F"
|
||||
|
||||
###############################################################################
|
||||
# Mail #
|
||||
###############################################################################
|
||||
|
||||
# Disable send and reply animations in Mail.app
|
||||
defaults write com.apple.mail DisableReplyAnimations -bool true
|
||||
defaults write com.apple.mail DisableSendAnimations -bool true
|
||||
|
||||
# Copy email addresses as `foo@example.com` instead of `Foo Bar <foo@example.com>` in Mail.app
|
||||
defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false
|
||||
|
||||
# Add the keyboard shortcut ⌘ + Enter to send an email in Mail.app
|
||||
defaults write com.apple.mail NSUserKeyEquivalents -dict-add "Send" "@\\U21a9"
|
||||
|
||||
###############################################################################
|
||||
# Terminal #
|
||||
###############################################################################
|
||||
|
||||
# Only use UTF-8 in Terminal.app
|
||||
defaults write com.apple.terminal StringEncodings -array 4
|
||||
|
||||
# Enable “focus follows mouse” for Terminal.app and all X11 apps
|
||||
# i.e. hover over a window and start typing in it without clicking first
|
||||
#defaults write com.apple.terminal FocusFollowsMouse -bool true
|
||||
#defaults write org.x.X11 wm_ffm -bool true
|
||||
|
||||
###############################################################################
|
||||
# Time Machine #
|
||||
###############################################################################
|
||||
|
||||
# Prevent Time Machine from prompting to use new hard drives as backup volume
|
||||
defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
|
||||
|
||||
# Disable local Time Machine backups
|
||||
hash tmutil &> /dev/null && sudo tmutil disablelocal
|
||||
|
||||
###############################################################################
|
||||
# Address Book, Dashboard, iCal, TextEdit, and Disk Utility #
|
||||
###############################################################################
|
||||
|
||||
# Enable the debug menu in Address Book
|
||||
defaults write com.apple.addressbook ABShowDebugMenu -bool true
|
||||
|
||||
# Enable Dashboard dev mode (allows keeping widgets on the desktop)
|
||||
defaults write com.apple.dashboard devmode -bool true
|
||||
|
||||
# Enable the debug menu in iCal (pre-10.8)
|
||||
defaults write com.apple.iCal IncludeDebugMenu -bool true
|
||||
|
||||
# Use plain text mode for new TextEdit documents
|
||||
defaults write com.apple.TextEdit RichText -int 0
|
||||
# Open and save files as UTF-8 in TextEdit
|
||||
defaults write com.apple.TextEdit PlainTextEncoding -int 4
|
||||
defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4
|
||||
|
||||
# Enable the debug menu in Disk Utility
|
||||
defaults write com.apple.DiskUtility DUDebugMenuEnabled -bool true
|
||||
defaults write com.apple.DiskUtility advanced-image-options -bool true
|
||||
|
||||
###############################################################################
|
||||
# Mac App Store #
|
||||
###############################################################################
|
||||
|
||||
# Enable the WebKit Developer Tools in the Mac App Store
|
||||
defaults write com.apple.appstore WebKitDeveloperExtras -bool true
|
||||
|
||||
# Enable Debug Menu in the Mac App Store
|
||||
defaults write com.apple.appstore ShowDebugMenu -bool true
|
||||
|
||||
###############################################################################
|
||||
# Google Chrome & Google Chrome Canary #
|
||||
###############################################################################
|
||||
|
||||
# Allow installing user scripts via GitHub or Userscripts.org
|
||||
defaults write com.google.Chrome ExtensionInstallSources -array "https://*.github.com/*" "http://userscripts.org/*"
|
||||
defaults write com.google.Chrome.canary ExtensionInstallSources -array "https://*.github.com/*" "http://userscripts.org/*"
|
||||
|
||||
###############################################################################
|
||||
# SizeUp.app #
|
||||
###############################################################################
|
||||
|
||||
# Start SizeUp at login
|
||||
defaults write com.irradiatedsoftware.SizeUp StartAtLogin -bool true
|
||||
|
||||
# Don’t show the preferences window on next start
|
||||
defaults write com.irradiatedsoftware.SizeUp ShowPrefsOnNextStart -bool false
|
||||
|
||||
###############################################################################
|
||||
# Transmission.app #
|
||||
###############################################################################
|
||||
|
||||
# Use `~/Documents/Torrents` to store incomplete downloads
|
||||
defaults write org.m0k.transmission UseIncompleteDownloadFolder -bool true
|
||||
defaults write org.m0k.transmission IncompleteDownloadFolder -string "${HOME}/Documents/Torrents"
|
||||
|
||||
# Don’t prompt for confirmation before downloading
|
||||
defaults write org.m0k.transmission DownloadAsk -bool false
|
||||
|
||||
# Trash original torrent files
|
||||
defaults write org.m0k.transmission DeleteOriginalTorrent -bool true
|
||||
|
||||
# Hide the donate message
|
||||
defaults write org.m0k.transmission WarningDonate -bool false
|
||||
# Hide the legal disclaimer
|
||||
defaults write org.m0k.transmission WarningLegal -bool false
|
||||
|
||||
###############################################################################
|
||||
# Twitter.app #
|
||||
###############################################################################
|
||||
|
||||
# Disable smart quotes as it’s annoying for code tweets
|
||||
defaults write com.twitter.twitter-mac AutomaticQuoteSubstitutionEnabled -bool false
|
||||
|
||||
# Show the app window when clicking the menu icon
|
||||
defaults write com.twitter.twitter-mac MenuItemBehavior -int 1
|
||||
|
||||
# Enable the hidden ‘Develop’ menu
|
||||
defaults write com.twitter.twitter-mac ShowDevelopMenu -bool true
|
||||
|
||||
# Open links in the background
|
||||
defaults write com.twitter.twitter-mac openLinksInBackground -bool true
|
||||
|
||||
# Allow closing the ‘new tweet’ window by pressing `Esc`
|
||||
defaults write com.twitter.twitter-mac ESCClosesComposeWindow -bool true
|
||||
|
||||
# Show full names rather than Twitter handles
|
||||
defaults write com.twitter.twitter-mac ShowFullNames -bool true
|
||||
|
||||
# Hide the app in the background if it’s not the front-most window
|
||||
defaults write com.twitter.twitter-mac HideInBackground -bool true
|
3
dotfiles/lib/shellrc.sh
Normal file
3
dotfiles/lib/shellrc.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
for filename in ~/.lib/shellrc/*; do
|
||||
source $filename
|
||||
done
|
52
dotfiles/lib/shellrc/aliases.sh
Normal file
52
dotfiles/lib/shellrc/aliases.sh
Normal file
@@ -0,0 +1,52 @@
|
||||
alias script_abspath='$(dirname "${BASH_SOURCE}" | xargs "${readlink_command}" -f)'
|
||||
|
||||
alias emacs="emacsclient -t"
|
||||
alias readlink="greadlink"
|
||||
|
||||
alias sudo='sudo '
|
||||
|
||||
# IP addresses
|
||||
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
|
||||
alias localip="ifconfig getifaddr en1"
|
||||
|
||||
alias whois="whois -h whois-servers.net"
|
||||
|
||||
# Clean up LaunchServices to remove duplicates in the “Open With” menu
|
||||
alias lscleanup="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder"
|
||||
|
||||
# View HTTP traffic
|
||||
alias sniff="sudo ngrep -d 'en1' -t '^(GET|POST) ' 'tcp and port 80'"
|
||||
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E \"Host\: .*|GET \/.*\""
|
||||
|
||||
# Canonical hex dump; some systems have this symlinked
|
||||
command -v hd > /dev/null || alias hd="hexdump -C"
|
||||
|
||||
# OS X has no `md5sum`, so use `md5` as a fallback
|
||||
command -v md5sum > /dev/null || alias md5sum="md5"
|
||||
|
||||
# OS X has no `sha1sum`, so use `shasum` as a fallback
|
||||
command -v sha1sum > /dev/null || alias sha1sum="shasum"
|
||||
|
||||
# URL-encode strings
|
||||
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);"'
|
||||
|
||||
# Merge PDF files
|
||||
# Usage: `mergepdf -o output.pdf input{1,2,3}.pdf`
|
||||
alias mergepdf='/System/Library/Automator/Combine\ PDF\ Pages.action/Contents/Resources/join.py'
|
||||
|
||||
# Disable Spotlight
|
||||
alias spotoff="sudo mdutil -a -i off"
|
||||
# Enable Spotlight
|
||||
alias spoton="sudo mdutil -a -i on"
|
||||
|
||||
# One of @janmoesen’s ProTip™s
|
||||
for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do
|
||||
alias "$method"="lwp-request -m '$method'"
|
||||
done
|
||||
|
||||
alias stfu="osascript -e 'set volume output muted true'"
|
||||
alias pumpitup="osascript -e 'set volume 7'"
|
||||
|
||||
alias tmux="tmux -2"
|
||||
alias remote_os_copy='linux_nc_paste_to_remote_clipboard'
|
||||
alias timestamp='date +%s'
|
21
dotfiles/lib/shellrc/exports.sh
Normal file
21
dotfiles/lib/shellrc/exports.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
# Make emacs the default editor.
|
||||
export EDITOR="emacsclient"
|
||||
export ALTERNATE_EDITOR=""
|
||||
export VISUAL="emacsclient"
|
||||
|
||||
# Larger bash history (allow 32³ entries; default is 500)
|
||||
export HISTSIZE=32768
|
||||
export HISTFILESIZE=$HISTSIZE
|
||||
export HISTCONTROL=ignoredups
|
||||
# Make some commands not show up in history
|
||||
export HISTIGNORE="ls:cd:cd -:pwd:exit:date:* --help"
|
||||
|
||||
# Prefer US English and use UTF-8
|
||||
export LANG="en_US"
|
||||
export LC_ALL="en_US.UTF-8"
|
||||
|
||||
# Highlight section titles in manual pages
|
||||
export LESS_TERMCAP_md="$ORANGE"
|
||||
|
||||
# Don’t clear the screen after quitting a manual page
|
||||
export MANPAGER="less -X"
|
66
dotfiles/lib/shellrc/functions.sh
Normal file
66
dotfiles/lib/shellrc/functions.sh
Normal file
@@ -0,0 +1,66 @@
|
||||
function parse_git_branch() {
|
||||
ref=$(git symbolic-ref HEAD 2> /dev/null) || \
|
||||
ref=$(git rev-parse --short HEAD 2> /dev/null) || return
|
||||
echo ${ref#refs/heads/}
|
||||
}
|
||||
|
||||
function current_shell() {
|
||||
ps -p $$ | tail -1 | awk '{print $NF}' | xargs which | xargs readlink -f
|
||||
}
|
||||
|
||||
function is_zsh() {
|
||||
test -n "$(current_shell | grep -o zsh)"
|
||||
}
|
||||
|
||||
function get_cols() {
|
||||
FS=' '
|
||||
while getopts "F:" OPTCHAR; do
|
||||
case $OPTCHAR in
|
||||
F)
|
||||
FS=$OPTARG
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND-1))
|
||||
awk -f "$HOME/.lib/get_cols.awk" -v "cols=$*" -v "FS=$FS"
|
||||
}
|
||||
|
||||
function find_all_ssh_agent_sockets() {
|
||||
find /tmp -type s -name agent.\* 2> /dev/null | grep '/tmp/ssh-.*/agent.*'
|
||||
}
|
||||
|
||||
function set_ssh_agent_socket() {
|
||||
export SSH_AUTH_SOCK=$(find_all_ssh_agent_sockets | tail -n 1 | awk -F: '{print $1}')
|
||||
}
|
||||
|
||||
# Determine size of a file or total size of a directory
|
||||
function fs() {
|
||||
if du -b /dev/null > /dev/null 2>&1; then
|
||||
local arg=-sbh
|
||||
else
|
||||
local arg=-sh
|
||||
fi
|
||||
if [[ -n "$@" ]]; then
|
||||
du $arg -- "$@"
|
||||
else
|
||||
du $arg .[^.]* *
|
||||
fi
|
||||
}
|
||||
|
||||
# Start an HTTP server from a directory, optionally specifying the port
|
||||
function server() {
|
||||
local port="${1:-8000}"
|
||||
sleep 1 && open "http://localhost:${port}/" &
|
||||
# Set the default Content-Type to `text/plain` instead of `application/octet-stream`
|
||||
# And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files)
|
||||
python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port"
|
||||
}
|
||||
|
||||
# All the dig info
|
||||
function digga() {
|
||||
dig +nocmd "$1" any +multiline +noall +answer
|
||||
}
|
||||
|
||||
function shell_stats() {
|
||||
history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n20
|
||||
}
|
10
dotfiles/lib/shellrc/path.sh
Normal file
10
dotfiles/lib/shellrc/path.sh
Normal file
@@ -0,0 +1,10 @@
|
||||
function add_to_front_of_path {
|
||||
export PATH=$@:`echo $PATH | sed "s|:*$@||g" | sed "s|^:||"`
|
||||
}
|
||||
|
||||
function add_to_back_of_path {
|
||||
export PATH=`echo $PATH | sed "s|:*$@||g" | sed "s|^:||"`:$@
|
||||
}
|
||||
|
||||
add_to_back_of_path "$HOME/.local/lib/python2.6/site-packages"
|
||||
add_to_front_of_path "/usr/local/bin"
|
0
dotfiles/lib/shellrc/prompt.sh
Normal file
0
dotfiles/lib/shellrc/prompt.sh
Normal file
20
dotfiles/lib/shellrc/remote_clipboard.sh
Normal file
20
dotfiles/lib/shellrc/remote_clipboard.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
REMOTE_CLIPBOARD_PORT='1234'
|
||||
|
||||
function remote_clipboard_server() {
|
||||
while [ 1 ]
|
||||
do
|
||||
netcat -l -p ${1-$REMOTE_CLIPBOARD_PORT} -e "pbcopy"
|
||||
done
|
||||
}
|
||||
|
||||
function remote_clipboard_server_daemon() {
|
||||
daemonize `which reattach-to-user-namespace` -l $SHELL -c "source ~/.zshrc; remote_clipboard_server"
|
||||
}
|
||||
|
||||
function linux_nc_paste_to_remote_clipboard() {
|
||||
nc localhost ${1-$REMOTE_CLIPBOARD_PORT} -q 0
|
||||
}
|
||||
|
||||
function osx_nc_paste_to_remote_clipboard() {
|
||||
nc localhost ${1-$REMOTE_CLIPBOARD_PORT} -D
|
||||
}
|
87
dotfiles/lib/shellrc/yelp.sh
Normal file
87
dotfiles/lib/shellrc/yelp.sh
Normal file
@@ -0,0 +1,87 @@
|
||||
alias i="ipython tools/interactive.py"
|
||||
alias apperror="tools/scribereader -e prod -f apperror | tools/pretty_error_log"
|
||||
alias environ=". ~/.pgconf-$USER/environ.sh"
|
||||
alias ym="cd ~/pg/yelp-main"
|
||||
alias live="cd /nail/live/yelp"
|
||||
alias sb="sandbox -vv --minimal"
|
||||
|
||||
function fix_environment_script() {
|
||||
sed -i 's/export YELP_CONFIG:yelp_conn:replication_delay_params.*$//' $YELP_SANDBOX_ROOT/environment.sh
|
||||
}
|
||||
|
||||
function get_sandbox_identifier() {
|
||||
echo $YELP_SANDBOX_ROOT | gawk 'match($0, /pgconf-.*-(.*)/, matched) {print matched[1]}'
|
||||
}
|
||||
|
||||
function is_proddb() {
|
||||
python 2>/dev/null - <<END
|
||||
import os
|
||||
import sys
|
||||
import yaml
|
||||
|
||||
|
||||
def is_proddb_from_topology_info(topology_info):
|
||||
for cluster_info in topology_info['topology']:
|
||||
if cluster_info['cluster'] == 'primary':
|
||||
return cluster_info['entries'][0]['host'] != '127.0.0.1'
|
||||
|
||||
def is_proddb_from_topology_filename(topology_filename):
|
||||
with open(topology_filename) as topology_file:
|
||||
return is_proddb_from_topology_info(yaml.load(topology_file))
|
||||
|
||||
def is_proddb():
|
||||
try:
|
||||
topology_filename = os.environ.get('TOPOLOGY_FILE')
|
||||
if topology_filename:
|
||||
return is_proddb_from_topology_filename(topology_filename)
|
||||
return False
|
||||
except:
|
||||
pass
|
||||
|
||||
sys.exit(0 if is_proddb() else 1)
|
||||
END
|
||||
}
|
||||
|
||||
function sandbox_prompt_info() {
|
||||
local sandbox_string=''
|
||||
if is_proddb
|
||||
then
|
||||
sandbox_string="proddb "
|
||||
fi
|
||||
if [ "$YELP_IN_SANDBOX" ];
|
||||
then
|
||||
sandbox_string=$sandbox_string"sandbox-$(get_sandbox_identifier)"
|
||||
else
|
||||
sandbox_string="no sandbox"
|
||||
fi
|
||||
echo $sandbox_string
|
||||
}
|
||||
|
||||
function bash_sandbox_color() {
|
||||
if [ $YELP_IN_SANDBOX ]
|
||||
then
|
||||
sandbox_color='\e[0;33m'
|
||||
else
|
||||
sandbox_color='\e[0;31m'
|
||||
fi
|
||||
}
|
||||
|
||||
function zsh_sandbox_color() {
|
||||
if [ $YELP_IN_SANDBOX ]
|
||||
then
|
||||
sandbox_color="%{$FG[149]%}"
|
||||
else
|
||||
sandbox_color="%{$FG[001]%}"
|
||||
fi
|
||||
echo $sandbox_color
|
||||
}
|
||||
|
||||
function colored_sandbox_string() {
|
||||
if [ is_zsh ]
|
||||
then
|
||||
sandbox_color=$(zsh_sandbox_color)
|
||||
else
|
||||
sandbox_color=$(bash_sandbox_color)
|
||||
fi
|
||||
echo $sandbox_color$(sandbox_prompt_info)
|
||||
}
|
30
dotfiles/lib/zsh.sh
Normal file
30
dotfiles/lib/zsh.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
for filename in ~/.lib/zsh/*; do
|
||||
source $filename
|
||||
done
|
||||
|
||||
CASE_SENSITIVE="true"
|
||||
fpath=(~/.lib/completions $fpath)
|
||||
autoload -U compinit
|
||||
compinit
|
||||
# Allow command line editing.
|
||||
autoload -U edit-command-line
|
||||
zle -N edit-command-line
|
||||
bindkey '\C-x\C-e' edit-command-line
|
||||
|
||||
local
|
||||
|
||||
function current_directory() {
|
||||
local PWD=$(pwd)
|
||||
echo "${PWD/#$HOME/~}"
|
||||
}
|
||||
|
||||
function git_prompt_info () {
|
||||
if test -z $(parse_git_branch);
|
||||
then
|
||||
echo ""
|
||||
else
|
||||
echo " %{$FG[239]%}on%{$reset_color%} %{$fg[255]%}$(parse_git_branch)%{$reset_color%}"
|
||||
fi
|
||||
}
|
||||
|
||||
PROMPT="%{$FG[040]%}%n%{$reset_color%} %{$FG[239]%}at%{$reset_color%} %{$FG[033]%}$(hostname -s)%{$reset_color%} %{$FG[239]%}in%{$reset_color%} %{$terminfo[bold]$FG[226]%}\$(current_directory)%{$reset_color%}\$(git_prompt_info) %{$FG[239]%}with \$(colored_sandbox_string)%{$FG[255]%} "
|
72
dotfiles/lib/zsh/completion.sh
Normal file
72
dotfiles/lib/zsh/completion.sh
Normal file
@@ -0,0 +1,72 @@
|
||||
# fixme - the load process here seems a bit bizarre
|
||||
|
||||
unsetopt menu_complete # do not autoselect the first completion entry
|
||||
unsetopt flowcontrol
|
||||
setopt auto_menu # show completion menu on succesive tab press
|
||||
setopt complete_in_word
|
||||
setopt always_to_end
|
||||
|
||||
WORDCHARS=''
|
||||
|
||||
zmodload -i zsh/complist
|
||||
|
||||
## case-insensitive (all),partial-word and then substring completion
|
||||
if [ "x$CASE_SENSITIVE" = "xtrue" ]; then
|
||||
zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
|
||||
unset CASE_SENSITIVE
|
||||
else
|
||||
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
|
||||
fi
|
||||
|
||||
zstyle ':completion:*' list-colors ''
|
||||
|
||||
# should this be in keybindings?
|
||||
bindkey -M menuselect '^o' accept-and-infer-next-history
|
||||
|
||||
zstyle ':completion:*:*:*:*:*' menu select
|
||||
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
|
||||
zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w"
|
||||
|
||||
# disable named-directories autocompletion
|
||||
zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
|
||||
cdpath=(.)
|
||||
|
||||
# use /etc/hosts and known_hosts for hostname completion
|
||||
[ -r /etc/ssh/ssh_known_hosts ] && _global_ssh_hosts=(${${${${(f)"$(</etc/ssh/ssh_known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _global_ssh_hosts=()
|
||||
[ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
|
||||
[ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} || _etc_hosts=()
|
||||
hosts=(
|
||||
"$_global_ssh_hosts[@]"
|
||||
"$_ssh_hosts[@]"
|
||||
"$_etc_hosts[@]"
|
||||
"$HOST"
|
||||
localhost
|
||||
)
|
||||
zstyle ':completion:*:hosts' hosts $hosts
|
||||
|
||||
# Use caching so that commands like apt and dpkg complete are useable
|
||||
zstyle ':completion::complete:*' use-cache 1
|
||||
zstyle ':completion::complete:*' cache-path $ZSH/cache/
|
||||
|
||||
# Don't complete uninteresting users
|
||||
zstyle ':completion:*:*:*:users' ignored-patterns \
|
||||
adm amanda apache avahi beaglidx bin cacti canna clamav daemon \
|
||||
dbus distcache dovecot fax ftp games gdm gkrellmd gopher \
|
||||
hacluster haldaemon halt hsqldb ident junkbust ldap lp mail \
|
||||
mailman mailnull mldonkey mysql nagios \
|
||||
named netdump news nfsnobody nobody nscd ntp nut nx openvpn \
|
||||
operator pcap postfix postgres privoxy pulse pvm quagga radvd \
|
||||
rpc rpcuser rpm shutdown squid sshd sync uucp vcsa xfs
|
||||
|
||||
# ... unless we really want to.
|
||||
zstyle '*' single-ignored show
|
||||
|
||||
if [ "x$COMPLETION_WAITING_DOTS" = "xtrue" ]; then
|
||||
expand-or-complete-with-dots() {
|
||||
echo -n "\e[31m......\e[0m"
|
||||
zle expand-or-complete
|
||||
zle redisplay
|
||||
}
|
||||
zle -N expand-or-complete-with-dots
|
||||
bindkey "^I" expand-or-complete-with-dots
|
||||
fi
|
22
dotfiles/lib/zsh/history.sh
Normal file
22
dotfiles/lib/zsh/history.sh
Normal file
@@ -0,0 +1,22 @@
|
||||
## Command history configuration
|
||||
HISTFILE=$HOME/.zsh_history
|
||||
HISTSIZE=100000
|
||||
SAVEHIST=100000
|
||||
|
||||
setopt append_history
|
||||
setopt extended_history
|
||||
setopt hist_expire_dups_first
|
||||
setopt hist_ignore_dups # ignore duplication command history list
|
||||
setopt hist_ignore_space
|
||||
setopt hist_verify
|
||||
setopt inc_append_history
|
||||
setopt share_history # share command history data
|
||||
|
||||
# TODO: Explain what some of this does..
|
||||
|
||||
bindkey -e
|
||||
bindkey '\ew' kill-region
|
||||
bindkey -s '\el' "ls\n"
|
||||
bindkey '^r' history-incremental-search-backward
|
||||
bindkey "^[[5~" up-line-or-history
|
||||
bindkey "^[[6~" down-line-or-history
|
46
dotfiles/lib/zsh/key_bindings.sh
Normal file
46
dotfiles/lib/zsh/key_bindings.sh
Normal file
@@ -0,0 +1,46 @@
|
||||
bindkey -e
|
||||
bindkey '\ew' kill-region
|
||||
bindkey -s '\el' "ls\n"
|
||||
bindkey '^r' history-incremental-search-backward
|
||||
bindkey "^[[5~" up-line-or-history
|
||||
bindkey "^[[6~" down-line-or-history
|
||||
|
||||
# make search up and down work, so partially type and hit up/down to find relevant stuff
|
||||
bindkey '^[[A' up-line-or-search
|
||||
bindkey '^[[B' down-line-or-search
|
||||
|
||||
bindkey "^[[H" beginning-of-line
|
||||
bindkey "^[[1~" beginning-of-line
|
||||
bindkey "^[OH" beginning-of-line
|
||||
bindkey "^[[F" end-of-line
|
||||
bindkey "^[[4~" end-of-line
|
||||
bindkey "^[OF" end-of-line
|
||||
bindkey ' ' magic-space # also do history expansion on space
|
||||
|
||||
bindkey "^[[1;5C" forward-word
|
||||
bindkey "^[[1;5D" backward-word
|
||||
|
||||
bindkey '^[[Z' reverse-menu-complete
|
||||
|
||||
# Make the delete key (or Fn + Delete on the Mac) work instead of outputting a ~
|
||||
bindkey '^?' backward-delete-char
|
||||
bindkey "^[[3~" delete-char
|
||||
bindkey "^[3;5~" delete-char
|
||||
bindkey "\e[3~" delete-char
|
||||
|
||||
bindkey -e ## emacs key bindings
|
||||
|
||||
bindkey '^[[A' up-line-or-search
|
||||
bindkey '^[[B' down-line-or-search
|
||||
bindkey '^[^[[C' emacs-forward-word
|
||||
bindkey '^[^[[D' emacs-backward-word
|
||||
|
||||
bindkey -s '^X^Z' '%-^M'
|
||||
bindkey '^[e' expand-cmd-path
|
||||
bindkey '^[^I' reverse-menu-complete
|
||||
bindkey '^X^N' accept-and-infer-next-history
|
||||
bindkey '^W' kill-region
|
||||
bindkey '^I' complete-word
|
||||
# Fix weird sequence that rxvt produces
|
||||
bindkey -s '^[[Z' '\t'
|
||||
|
0
dotfiles/lib/zsh/prompt.sh
Normal file
0
dotfiles/lib/zsh/prompt.sh
Normal file
28
dotfiles/lib/zsh/spectrum.sh
Normal file
28
dotfiles/lib/zsh/spectrum.sh
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/bin/zsh
|
||||
# A script to make using 256 colors in zsh less painful.
|
||||
# P.C. Shyamshankar <sykora@lucentbeing.com>
|
||||
# Copied from http://github.com/sykora/etc/blob/master/zsh/functions/spectrum/
|
||||
|
||||
typeset -Ag FX FG BG
|
||||
|
||||
FX=(
|
||||
reset "%{[00m%}"
|
||||
bold "%{[01m%}" no-bold "%{[22m%}"
|
||||
italic "%{[03m%}" no-italic "%{[23m%}"
|
||||
underline "%{[04m%}" no-underline "%{[24m%}"
|
||||
blink "%{[05m%}" no-blink "%{[25m%}"
|
||||
reverse "%{[07m%}" no-reverse "%{[27m%}"
|
||||
)
|
||||
|
||||
for color in {000..255}; do
|
||||
FG[$color]="%{[38;5;${color}m%}"
|
||||
BG[$color]="%{[48;5;${color}m%}"
|
||||
done
|
||||
|
||||
# Show all 256 colors with color number
|
||||
function spectrum_ls() {
|
||||
for code in {000..255}; do
|
||||
print -P -- "$code: %{$FG[$code]Test%f%}"
|
||||
done
|
||||
}
|
||||
|
35
dotfiles/lib/zsh/term_support.sh
Normal file
35
dotfiles/lib/zsh/term_support.sh
Normal file
@@ -0,0 +1,35 @@
|
||||
#usage: title short_tab_title looooooooooooooooooooooggggggg_windows_title
|
||||
#http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1
|
||||
#Fully support screen, iterm, and probably most modern xterm and rxvt
|
||||
#Limited support for Apple Terminal (Terminal can't set window or tab separately)
|
||||
function title {
|
||||
if [[ "$DISABLE_AUTO_TITLE" == "true" ]] || [[ "$EMACS" == *term* ]]; then
|
||||
return
|
||||
fi
|
||||
if [[ "$TERM" == screen* ]]; then
|
||||
print -Pn "\ek$1:q\e\\" #set screen hardstatus, usually truncated at 20 chars
|
||||
elif [[ "$TERM" == xterm* ]] || [[ $TERM == rxvt* ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
|
||||
print -Pn "\e]2;$2:q\a" #set window name
|
||||
print -Pn "\e]1;$1:q\a" #set icon (=tab) name (will override window name on broken terminal)
|
||||
fi
|
||||
}
|
||||
|
||||
ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD
|
||||
ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~"
|
||||
|
||||
#Appears when you have the prompt
|
||||
function omz_termsupport_precmd {
|
||||
title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
|
||||
}
|
||||
|
||||
#Appears at the beginning of (and during) of command execution
|
||||
function omz_termsupport_preexec {
|
||||
emulate -L zsh
|
||||
setopt extended_glob
|
||||
local CMD=${1[(wr)^(*=*|sudo|ssh|rake|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd
|
||||
title "$CMD" "%100>...>${2:gs/%/%%}%<<"
|
||||
}
|
||||
|
||||
autoload -U add-zsh-hook
|
||||
add-zsh-hook precmd omz_termsupport_precmd
|
||||
add-zsh-hook preexec omz_termsupport_preexec
|
38
dotfiles/wgetrc
Normal file
38
dotfiles/wgetrc
Normal file
@@ -0,0 +1,38 @@
|
||||
# Use the server-provided last modification date, if available
|
||||
timestamping = on
|
||||
|
||||
# Do not go up in the directory structure when downloading recursively
|
||||
no_parent = on
|
||||
|
||||
# Wait 60 seconds before timing out. This applies to all timeouts: DNS, connect and read. (The default read timeout is 15 minutes!)
|
||||
timeout = 60
|
||||
|
||||
# Retry a few times when a download fails, but don’t overdo it. (The default is 20!)
|
||||
tries = 3
|
||||
|
||||
# Retry even when the connection was refused
|
||||
retry_connrefused = on
|
||||
|
||||
# Use the last component of a redirection URL for the local file name
|
||||
trust_server_names = on
|
||||
|
||||
# Follow FTP links from HTML documents by default
|
||||
follow_ftp = on
|
||||
|
||||
# Add a `.html` extension to `text/html` or `application/xhtml+xml` files that lack one, or a `.css` extension to `text/css` files that lack one
|
||||
adjust_extension = on
|
||||
|
||||
# Use UTF-8 as the default system encoding
|
||||
# Disabled as it makes `wget` builds that don’t support this feature unusable.
|
||||
# Does anyone know how to conditionally configure a wget setting?
|
||||
# http://unix.stackexchange.com/q/34730/6040
|
||||
#local_encoding = UTF-8
|
||||
|
||||
# Ignore `robots.txt` and `<meta name=robots content=nofollow>`
|
||||
robots = off
|
||||
|
||||
# Print the HTTP and FTP server responses
|
||||
server_response = on
|
||||
|
||||
# Disguise as IE 9 on Windows 7
|
||||
user_agent = Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
|
2
dotfiles/zshrc
Normal file
2
dotfiles/zshrc
Normal file
@@ -0,0 +1,2 @@
|
||||
source ~/.lib/shellrc.sh
|
||||
source ~/.lib/zsh.sh
|
Reference in New Issue
Block a user