Merge branch 'master' of github.com:sapegin/dotfiles

This commit is contained in:
Artem Sapegin 2013-02-12 10:05:59 +04:00
commit 313af0857d
7 changed files with 95 additions and 22 deletions

23
bin/anytomobi Normal file → Executable file
View File

@ -7,8 +7,7 @@
# Author: Artem Sapegin, sapegin.me # Author: Artem Sapegin, sapegin.me
# #
# Require: # Require:
# - KindleGen - http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211 # - Calibre - http://calibre-ebook.com/download (install command line tools from Calibres settings)
# - Calibre - http://calibre-ebook.com/download
# #
# Manuals: # Manuals:
# - http://manual.calibre-ebook.com/cli/ebook-convert.html # - http://manual.calibre-ebook.com/cli/ebook-convert.html
@ -22,23 +21,17 @@ function convert_file() {
local infilename=$(basename "$1") local infilename=$(basename "$1")
local outfilename="${infilename%.*}.mobi" local outfilename="${infilename%.*}.mobi"
if [[ "$intype" == "mobi" || "$intype" == "pdf" ]]; then if [[ "$intype" == "pdf" ]]; then
# Just copy MOBI and PDF files to destination directory # Just copy PDF files to destination directory
if [[ "$outdir" != "." ]]; then if [[ "$outdir" != "." ]]; then
cp "$infile" "$outdir/" cp "$infile" "$outdir/"
fi fi
return return
elif [[ "$intype" == "epub" ]]; then
kindlegen "$infile" -o "$outfilename"
# kindlegen cant save file to other directory, so we should move it
if [[ "$outdir" != "." ]]; then
mv "${infile%.*}.mobi" "$outdir/"
fi
else else
ebook-convert "$infile" "$outdir/$outfilename" --output-profile=kindle_pw --mobi-file-type=new \ # Convert any other format (MOBI too) to old MOBI format to force left text alignment
--mobi-ignore-margins --mobi-keep-original-images \ ebook-convert "$infile" "$outdir/$outfilename" --output-profile=kindle_pw --mobi-file-type=old \
--no-inline-toc --no-inline-fb2-toc --remove-paragraph-spacing \ --mobi-ignore-margins --mobi-keep-original-images --no-inline-toc --remove-paragraph-spacing \
--change-justification=left --keep-ligatures --smarten-punctuation --pretty-print --change-justification=left --keep-ligatures --smarten-punctuation --pretty-print --filter-css=color
fi fi
echo echo
@ -64,6 +57,6 @@ if [[ -f "$1" ]]; then
elif [[ -d "$1" ]]; then elif [[ -d "$1" ]]; then
convert_dir "$1" convert_dir "$1"
else else
echo "Usage: anytomobi <file or folder> [destination folder]" echo "Usage: `basename $0` <file or folder> [destination folder]"
exit 1 exit 1
fi fi

View File

@ -17,6 +17,7 @@ alias oo="open ."
alias e="subl" alias e="subl"
alias gh="github" alias gh="github"
alias +x="chmod +x" alias +x="chmod +x"
alias g="ack -ri"
# Detect which `ls` flavor is in use # Detect which `ls` flavor is in use
if ls --color > /dev/null 2>&1; then # GNU `ls` if ls --color > /dev/null 2>&1; then # GNU `ls`

View File

@ -111,14 +111,15 @@ ssh-key() {
# Create an SSH key and uploads it to the given host # Create an SSH key and uploads it to the given host
# Based on https://gist.github.com/1761938 # Based on https://gist.github.com/1761938
add-ssh-host() { ssh-add-host() {
username=$1 username=$1
hostname=$2 hostname=$2
identifier=$3 identifier=$3
if [[ "$identifier" == "" ]] || [[ "$username" == "" ]] || [[ "$hostname" == "" ]]; then if [[ "$identifier" == "" ]] || [[ "$username" == "" ]] || [[ "$hostname" == "" ]]; then
echo "Usage: configure_ssh_host <username> <hostname> <identifier>" echo "Usage: ssh-add-host <username> <hostname> <identifier>"
else else
header "Generating key..."
if [ ! -f "$HOME/.ssh/$identifier.id_rsa" ]; then if [ ! -f "$HOME/.ssh/$identifier.id_rsa" ]; then
ssh-keygen -f ~/.ssh/$identifier.id_rsa -C "$USER $(date +'%Y/%m%/%d %H:%M:%S')" ssh-keygen -f ~/.ssh/$identifier.id_rsa -C "$USER $(date +'%Y/%m%/%d %H:%M:%S')"
fi fi
@ -127,6 +128,7 @@ add-ssh-host() {
echo -e "Host $identifier\n\tHostName $hostname\n\tUser $username\n\tIdentityFile ~/.ssh/$identifier.id_rsa" >> ~/.ssh/config echo -e "Host $identifier\n\tHostName $hostname\n\tUser $username\n\tIdentityFile ~/.ssh/$identifier.id_rsa" >> ~/.ssh/config
fi fi
header "Uploading key..."
ssh $identifier 'mkdir -p .ssh && cat >> ~/.ssh/authorized_keys' < ~/.ssh/$identifier.id_rsa.pub ssh $identifier 'mkdir -p .ssh && cat >> ~/.ssh/authorized_keys' < ~/.ssh/$identifier.id_rsa.pub
tput bold; ssh -o PasswordAuthentication=no $identifier true && { tput setaf 2; echo "SSH key added."; } || { tput setaf 1; echo "Failure"; }; tput sgr0 tput bold; ssh -o PasswordAuthentication=no $identifier true && { tput setaf 2; echo "SSH key added."; } || { tput setaf 1; echo "Failure"; }; tput sgr0
@ -253,6 +255,27 @@ function rasterize() {
fi fi
} }
# Add note to Notes.app (OS X 10.8)
# Usage: note "foo" or echo "foo" | note
function note() {
local text
if [ -t 0 ]; then # Argument
text="$1"
else # Pipe
text=$(cat)
fi
body=$(echo "$text" | sed -E 's|$|<br>|g')
osascript >/dev/null <<EOF
tell application "Notes"
tell account "iCloud"
tell folder "Notes"
make new note with properties {name:"$text", body:"$body"}
end tell
end tell
end tell
EOF
}
# Add special aliases that will copy result to clipboard (escape → escape+) # Add special aliases that will copy result to clipboard (escape → escape+)
for cmd in password hex2hsl hex2rgb escape codepoint; do for cmd in password hex2hsl hex2rgb escape codepoint; do
eval "function $cmd+() { $cmd \$@ | c; }" eval "function $cmd+() { $cmd \$@ | c; }"

View File

@ -317,17 +317,18 @@ defaults write com.apple.dock expose-group-by-app -bool false
# Dont show Dashboard as a Space # Dont show Dashboard as a Space
defaults write com.apple.dock dashboard-in-overlay -bool true defaults write com.apple.dock dashboard-in-overlay -bool true
# Remove the auto-hiding Dock delay
defaults write com.apple.Dock autohide-delay -float 0
# Remove the animation when hiding/showing the Dock
defaults write com.apple.dock autohide-time-modifier -float 0
# Enable the 2D Dock # Enable the 2D Dock
defaults write com.apple.dock no-glass -bool true defaults write com.apple.dock no-glass -bool true
# Automatically hide and show the Dock # Automatically hide and show the Dock
defaults write com.apple.dock autohide -bool true defaults write com.apple.dock autohide -bool true
# Remove the Delay when Showing and Hiding the Dock
defaults write com.apple.dock autohide-delay -float 0
# Remove the animation when hiding/showing the Dock
defaults write com.apple.dock autohide-time-modifier -float 0
# Make Dock icons of hidden applications translucent # Make Dock icons of hidden applications translucent
#defaults write com.apple.dock showhidden -bool true #defaults write com.apple.dock showhidden -bool true
@ -337,6 +338,9 @@ defaults write com.apple.dock no-bouncing -bool true
# Disable Space switching on Command-Tab # Disable Space switching on Command-Tab
defaults write com.apple.dock workspaces-auto-swoosh -bool false defaults write com.apple.dock workspaces-auto-swoosh -bool false
# Show only active applications
defaults write com.apple.dock static-only -bool TRUE
# Reset Launchpad # Reset Launchpad
find ~/Library/Application\ Support/Dock -name "*.db" -maxdepth 1 -delete find ~/Library/Application\ Support/Dock -name "*.db" -maxdepth 1 -delete
@ -377,6 +381,9 @@ defaults write -g WebContinuousSpellCheckingEnabled -boolean true
/usr/libexec/PlistBuddy "$HOME/Library/Preferences/com.apple.symbolichotkeys.plist" -c 'Delete AppleSymbolicHotKeys:65' > /dev/null 2>&1 /usr/libexec/PlistBuddy "$HOME/Library/Preferences/com.apple.symbolichotkeys.plist" -c 'Delete AppleSymbolicHotKeys:65' > /dev/null 2>&1
/usr/libexec/PlistBuddy "$HOME/Library/Preferences/com.apple.symbolichotkeys.plist" -c 'Add AppleSymbolicHotKeys:65:enabled bool false' /usr/libexec/PlistBuddy "$HOME/Library/Preferences/com.apple.symbolichotkeys.plist" -c 'Add AppleSymbolicHotKeys:65:enabled bool false'
# Remove Spotlight from menu bar
sudo chmod 600 /System/Library/CoreServices/Search.bundle/Contents/MacOS/Search
############################################################################### ###############################################################################
# Safari & WebKit # # Safari & WebKit #
############################################################################### ###############################################################################

45
setup/ssd.sh Executable file
View File

@ -0,0 +1,45 @@
#!/bin/bash
# Some tweaks for SSD drives
# Details: http://blog.alutam.com/2012/04/01/optimizing-macos-x-lion-for-ssd/
# Ask for the administrator password upfront
sudo -v
# Turn off local Time Machine snapshots [laptops only]
sudo tmutil disablelocal
# Turn off hibernation [laptops only]
sudo pmset -a hibernatemode 0
sudo command rm /var/vm/sleepimage
# Turn off sudden motion sensor [no HDD only]
sudo pmset -a sms 0
# Disable records last access time for every file
echo '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.nullvision.noatime</string>
<key>ProgramArguments</key>
<array>
<string>mount</string>
<string>-vuwo</string>
<string>noatime</string>
<string>/</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>' | sudo tee /Library/LaunchDaemons/com.nullvision.noatime.plist
sudo chown root:wheel /Library/LaunchDaemons/com.nullvision.noatime.plist
# Delay (180 minutes) hard drive sleep [no HDD only]
sudo pmset -b disksleep 180 # Battery
sudo pmset -c disksleep 180 # Power adapter
echo
echo "You need to restart your computer for the changes to take effect."

View File

@ -55,15 +55,18 @@ cd -
# Everything else # Everything else
brew install unrar brew install unrar
brew install ack
# Node.js # Node.js
brew install node brew install node
brew install casperjs brew install casperjs
npm install -g grunt-cli npm install -g grunt-cli
npm install -g grunt-init
npm install -g jshint npm install -g jshint
npm install -g bower npm install -g bower
# Python # Python
brew install python
sudo pip install fabric sudo pip install fabric
# Remove outdated versions from the cellar # Remove outdated versions from the cellar

View File

@ -40,6 +40,7 @@ function _prepend_path() {
# Extend $PATH # Extend $PATH
[ -d /usr/local/bin ] && _prepend_path "/usr/local/bin" [ -d /usr/local/bin ] && _prepend_path "/usr/local/bin"
[ -d /usr/local/share/python ] && _prepend_path "/usr/local/share/python"
[ -d /usr/local/share/npm/bin ] && _prepend_path "/usr/local/share/npm/bin" [ -d /usr/local/share/npm/bin ] && _prepend_path "/usr/local/share/npm/bin"
command -v brew >/dev/null 2>&1 && _prepend_path "$(brew --prefix coreutils)/libexec/gnubin" command -v brew >/dev/null 2>&1 && _prepend_path "$(brew --prefix coreutils)/libexec/gnubin"
[ -d ~/dotfiles/bin ] && _prepend_path "$HOME/dotfiles/bin" [ -d ~/dotfiles/bin ] && _prepend_path "$HOME/dotfiles/bin"