forked from colonelpanic/dotfiles
remove yelp.sh remove brew.sh, move stuff from functino.sh to osx.sh set solarized as the default iTerm color theme.
This commit is contained in:
Submodule dotfiles/emacs.d updated: c46c2aa8f5...a7d48a2613
@@ -1,138 +0,0 @@
|
||||
function get_brew() {
|
||||
hash make &>/dev/null
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "Make not found. Please install xcode developer tools."
|
||||
return -1
|
||||
fi
|
||||
hash brew &>/dev/null && echo "Homebrew found!" || ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
|
||||
brew update
|
||||
}
|
||||
|
||||
function brew_install_items() {
|
||||
for package_install_string in $@;
|
||||
do
|
||||
package_args=$package_install_string
|
||||
if is_zsh;
|
||||
then
|
||||
# Horrible hack to induce word splitting.
|
||||
eval "package_args=($package_install_string)"
|
||||
fi
|
||||
brew install $package_args;
|
||||
done
|
||||
}
|
||||
|
||||
# htop wont display all process information if the owner is not root
|
||||
function fix_brew_htop() {
|
||||
sudo chmod 777 $(readlink -f `which htop`)
|
||||
sudo chown root $(readlink -f `which htop`)
|
||||
sudo chmod 6555 `which htop`
|
||||
}
|
||||
|
||||
function do_the_brew() {
|
||||
ESSENTIAL=(
|
||||
"emacs" \
|
||||
"tmux" \
|
||||
"python --with-brewed-openssl" \
|
||||
"htop" \
|
||||
"greadlink" \
|
||||
"zsh" \
|
||||
"make" \
|
||||
"macvim --override-system-vim --custom-system-icons --with-features=huge --enable-rubyinterp --enable-pythoninterp --enable-perlinterp --enable-cscope" \
|
||||
)
|
||||
# `find`, `locate`, `updatedb`, and `xargs`, g-prefixed
|
||||
# core utilities (those that come with OS X are outdated)
|
||||
BASICS=(
|
||||
"findutils" \
|
||||
"coreutils" \
|
||||
"binutils" \
|
||||
"diffutils" \
|
||||
"ed --default-names" \
|
||||
"gawk" \
|
||||
"gnu-indent --default-names" \
|
||||
"gnu-sed --default-names" \
|
||||
"gnu-tar --default-names" \
|
||||
"gnu-which --default-names" \
|
||||
"gnutls --default-names" \
|
||||
"grep --default-names" \
|
||||
"gzip" \
|
||||
"watch" \
|
||||
"wdiff --with-gettext" \
|
||||
"wget --enable-iri" \
|
||||
)
|
||||
SHOULD_INSTALL=(
|
||||
"nmap" \
|
||||
"readline" \
|
||||
"netcat" \
|
||||
"reattach-to-user-namespace" \
|
||||
"daemonize" \
|
||||
"ngrep" \
|
||||
"gist" \
|
||||
"gawk" \
|
||||
"pstree" \
|
||||
"ack" \
|
||||
"hub" \
|
||||
"tig" \
|
||||
"heroku" \
|
||||
"scala" \
|
||||
"sbt" \
|
||||
"node" \
|
||||
"npm" \
|
||||
)
|
||||
MISC=("file-formula" \
|
||||
"less" \
|
||||
"openssh --with-brewed-openssl" \
|
||||
"perl518" \
|
||||
"rsync" \
|
||||
"svn" \
|
||||
"unzip" \
|
||||
)
|
||||
|
||||
install_items=()
|
||||
OPTIND=1
|
||||
while getopts "uebsmah" OPTCHAR;
|
||||
do
|
||||
case $OPTCHAR in
|
||||
u)
|
||||
brew upgrade
|
||||
;;
|
||||
e)
|
||||
install_items=("${install_items[@]}" "${ESSENTIAL[@]}")
|
||||
fix_brew_htop
|
||||
;;
|
||||
b)
|
||||
install_items=("${install_items[@]}" "${BASICS[@]}")
|
||||
;;
|
||||
s)
|
||||
install_items=("${install_items[@]}" "${SHOULD_INSTALL[@]}")
|
||||
;;
|
||||
m)
|
||||
install_items=("${install_items[@]}" "${MISC[@]}")
|
||||
;;
|
||||
a)
|
||||
install_items=("${install_items[@]}" "${ESSENTIAL[@]}" "${BASICS[@]}" "${SHOULD_INSTALL[@]}" "${MISC[@]}")
|
||||
;;
|
||||
h)
|
||||
do_the_brew_help
|
||||
return
|
||||
;;
|
||||
esac
|
||||
done
|
||||
echo "Installing the following packages:"
|
||||
for ((i = 0; i < ${#install_items[@]}; i++)); do printf '\t%s\n' "${install_items[$i]}"; done;
|
||||
brew update
|
||||
brew_install_items ${install_items}
|
||||
brew cleanup
|
||||
}
|
||||
|
||||
function do_the_brew_help() {
|
||||
echo "do_the_brew Usage:
|
||||
-a install all packages.
|
||||
-u upgrade brew packages.
|
||||
-e install essential packages
|
||||
-b install GNU basics including replacements for non GNU versions included in OSX.
|
||||
-s install a wider range of packages.
|
||||
-m install very non-essential packages.
|
||||
-h display this help message.
|
||||
"
|
||||
}
|
@@ -11,6 +11,11 @@ function _emacs {
|
||||
\emacs --daemon="$server_name"
|
||||
fi
|
||||
emacsclient $* --server-file="$server_name"
|
||||
if hash reattach-to-user-namespace 2> /dev/null; then
|
||||
reattach-to-user-namespace emacsclient $* --server-file=$server_name
|
||||
else
|
||||
emacsclient $* --server-file=$server_name
|
||||
fi
|
||||
}
|
||||
|
||||
function _emacs_daemon_exists {
|
||||
|
77
dotfiles/lib/shellrc/osx.sh
Normal file
77
dotfiles/lib/shellrc/osx.sh
Normal file
@@ -0,0 +1,77 @@
|
||||
function set_global_osx_ssh_port {
|
||||
set_osx_ssh_port $1 /System/Library/LaunchDaemons/ssh.plist
|
||||
}
|
||||
|
||||
function set_osx_ssh_port {
|
||||
sudo sed -i -n "/SockServiceName/{p;n;s/>.*</>$1</;};p" $2; echo "SSH Port $1. Restart service for changes to take effect."
|
||||
}
|
||||
|
||||
function enable_access_for_assistive_devices {
|
||||
local bundle_identifier=$(/usr/libexec/PlistBuddy -c 'Print CFBundleIdentifier' "$1/Contents/Info.plist")
|
||||
local where_clause="where service='kTCCServiceAccessibility' and client='$bundle_identifier'"
|
||||
local search_string="SELECT * from access ${where_clause};"
|
||||
local values_string="VALUES('kTCCServiceAccessibility','$bundle_identifier',0,1,1,NULL)"
|
||||
if test -z $(sudo sqlite3 '/Library/Application Support/com.apple.TCC/TCC.db' $search_string);
|
||||
then
|
||||
local sql_string="INSERT INTO access $values_string;"
|
||||
else
|
||||
local sql_string="UPDATE access set allowed = 1 ${where_clause};"
|
||||
fi
|
||||
echo $sql_string
|
||||
sudo sqlite3 '/Library/Application Support/com.apple.TCC/TCC.db' $sql_string
|
||||
}
|
||||
|
||||
function as_user {
|
||||
local user="$1"
|
||||
local user_pid=$(ps -axj | awk "/^$user / {print \$2;exit}")
|
||||
local command="sudo /bin/launchctl bsexec $user_pid sudo -u '$user' $2"
|
||||
echo "Running:"
|
||||
echo "$command"
|
||||
eval $command
|
||||
}
|
||||
|
||||
function as_current_user {
|
||||
as_user "$(whoami)" "$*"
|
||||
}
|
||||
|
||||
function reload_user_agent {
|
||||
as_current_user /bin/launchctl unload "$1"
|
||||
as_current_user /bin/launchctl load "$1"
|
||||
}
|
||||
|
||||
|
||||
function reload_root_agent {
|
||||
as_user 'root' "/bin/launchctl unload '$1'"
|
||||
as_user 'root' "/bin/launchctl load '$1'"
|
||||
}
|
||||
|
||||
function brew_for_multiple_users() {
|
||||
sudo chgrp -R admin /usr/local
|
||||
sudo chmod -R g+w /usr/local
|
||||
sudo chgrp -R admin /Library/Caches/Homebrew
|
||||
sudo chmod -R g+w /Library/Caches/Homebrew
|
||||
}
|
||||
|
||||
function swap_audio() {
|
||||
test -z $(SwitchAudioSource -c | grep HDMI) && SwitchAudioSource -s HDMI || SwitchAudioSource -s "Built-in Output"
|
||||
}
|
||||
|
||||
function ss() {
|
||||
osascript -e "tell application \"/System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app\" to activate"
|
||||
}
|
||||
|
||||
function set_modifier_keys_for_vendor_product_id() {
|
||||
local mapping="<dict><key>HIDKeyboardModifierMappingDst</key><integer>$3</integer><key>HIDKeyboardModifierMappingSrc</key><integer>$2</integer></dict>"
|
||||
echo $mapping
|
||||
defaults -currentHost write -g com.apple.keyboard.modifiermapping.$1-0 -array-add "$mapping"
|
||||
}
|
||||
|
||||
function set_modifier_keys_on_all_keyboards() {
|
||||
for vendor_product_id in $(get_keyboard_vendor_id_product_id_pairs | tr " " "-"); do
|
||||
set_modifier_keys_for_vendor_product_id $vendor_product_id 0 2; echo $vendor_product_id;
|
||||
done;
|
||||
}
|
||||
|
||||
function get_keyboard_vendor_id_product_id_pairs() {
|
||||
ioreg -n IOHIDKeyboard -r | grep -e 'class IOHIDKeyboard' -e VendorID\" -e Product | gawk 'BEGIN { RS = "class IOHIDKeyboard" } match($0, /VendorID. = ([0-9]*)/, arr) { printf arr[1]} match($0, /ProductID. = ([0-9]*)/, arr) { printf " %s\n", arr[1]} '
|
||||
}
|
@@ -1,88 +0,0 @@
|
||||
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)"
|
||||
elif [ ! -z "$(env | grep yelp | head)" ] && git branch 1>/dev/null 2>/dev/null;
|
||||
then
|
||||
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)%{$reset_color%}"
|
||||
}
|
Reference in New Issue
Block a user