Skip to content

Commit

Permalink
lots of stuff
Browse files Browse the repository at this point in the history
added mac-clean
sublime provisioning
mac provisioning
compiled npmrc
  • Loading branch information
aziz committed Jul 30, 2014
1 parent 871c013 commit 8fbf45a
Show file tree
Hide file tree
Showing 14 changed files with 205 additions and 43 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -3,3 +3,4 @@ ssh/*
cron/logs
bash/secrets.sh
templates/terminal/color-schemes
templates/licenses
3 changes: 0 additions & 3 deletions TODO.md
Expand Up @@ -4,10 +4,7 @@

# Install Script TODO
- configure mac-address-randomizer to run automatically
- automatically install mac apps from app-store?
- sublime: add files to dotfiles and install it on demand
- atom: add files to dotfiles and install it on demand
- compile npmrc on install just like gitconfig
- configure cron on install

# Vim:
Expand Down
31 changes: 30 additions & 1 deletion install.sh
Expand Up @@ -19,7 +19,7 @@ for name in *; do
target="$HOME/.$name"

# ignore *.md and *.sh files and some other that need post processing
if [[ ${name: -3} != ".sh" && ${name: -3} != ".md" && $name != 'gitconfig' ]]; then
if [[ ${name: -3} != ".sh" && ${name: -3} != ".md" && $name != 'gitconfig' && $name != 'npmrc' ]]; then
# check if file already exists
if [ -e "$target" ]; then
# check if file is a symlink.
Expand Down Expand Up @@ -71,3 +71,32 @@ else
fi


# Handling npmrc
generate_npmrc () {
read -p "Your Name: " name
read -p "Your Email: " email
read -p "Github Username: " gh_username
read -p "NPM Username: " npm_username
cat npmrc | sed 's/${name}/'"$name"'/' | sed 's/${email}/'"$email"'/' | sed 's/${gh_username}/'"$gh_username"'/' | sed 's/${npm_username}/'"$npm_username"'/' > "$HOME/.npmrc"
}

backup_npmrc () {
if [ ! -d "$HOME/$backup_dir" ]; then
mkdir -p "$HOME/$backup_dir"
fi
cp "$HOME/.npmrc" "$HOME/$backup_dir/.npmrc";
}

echo "Creating .npmrc"
if [ -e "$HOME/.npmrc" ]; then
read -p "overwirte .npmrc? [y=Yes; n=No; b=Backup then Overwrite]" yn
case $yn in
[Yy]* ) rm -rf "$HOME/.npmrc";generate_npmrc;;
[Bb]* ) backup_npmrc; rm -rf "$HOME/.npmrc";generate_npmrc;;
[Nn]* ) echo ".npmrc ignored";;
* ) echo ".npmrc ignored";;
esac
else
generate_npmrc
fi

99 changes: 99 additions & 0 deletions mac/mac-clean.sh
@@ -0,0 +1,99 @@
#!/bin/bash

# cleanup (){
# # restore sudoers original state
# sudo sed -ibkp '/Defaults timestamp_timeout=-1/d' /etc/sudoers
# }

# echo "==> Making sudo ask for passwords just once"
# echo "Please, enter your local account's password."
# echo "Defaults timestamp_timeout=-1" | sudo tee -a /etc/sudoers || exit 2

# -------------------------------------------------------------
# Cleaning Log files
echo "==> cleaning log files"
sudo rm -Rf $HOME/Library/Logs/*
echo "$HOME/Library/Logs"
sudo rm -Rf /Library/Logs/*
echo "/Library/Logs"

# Cleaning Cache files
# echo "==> cleaning cache files"
# sudo rm -Rf $HOME/Library/Caches/*
# echo "$HOME/Library/Caches"
# sudo rm -Rf /Library/Caches/*
# echo "/Library/Caches"

# -------------------------------------------------------------
# # Get rid of localizations: APPS/Contents/Resources/*.lproj
# # except English.lproj, Base.lproj, en.lproj

echo "==> cleaning Locale files"
macCleanList=`mktemp -t macClean`
sudo find /Users /Applications /opt /Library /System -iregex '.*\.lproj' | \
perl -wnE'say for /.+(?<!English)(?<!en)(?<!en_US)(?<!Base)\.lproj/g' > $macCleanList
while read in; do sudo rm -Rf "$in"; done < $macCleanList

# -------------------------------------------------------------
#
# Chrome
# ✔ remove old versions extension
# ✔ clean up old versions of chrome
# - clean up old versions of chrome canary
# - save Local Extension Settings

# Clean Chrome Extensions folder, keeping olny the most recent version
echo "==> cleaning old chrome extensions"
EXTS_DIR="$HOME/Library/Application Support/Google/Chrome/Default/Extensions"
for EDIR in `ls -1 "$EXTS_DIR"`; do
num_ext=`ls -1 "$EXTS_DIR/$EDIR" | wc -l`
if [ $num_ext -gt 1 ]; then
ls -1tUr "$EXTS_DIR/$EDIR" | \
head -n $(expr $num_ext - 1) | \
awk -v path="$EXTS_DIR/$EDIR/" '{ print "\"" path $0 "\"" }' | \
xargs rm -Rf
fi
done

# Clean up old versions of chrome
chrome=`osascript -e 'POSIX path of (path to application "Chrome")'`
echo "==> cleaning old versions of Google Chrome"
echo $chrome
chrome_versions_count=`ls "$chrome/Contents/Versions" | wc -l`
if [ $chrome_versions_count -gt 1 ]; then
echo "more than one version, should be cleaned"
else
echo "just one verison"
fi

# -------------------------------------------------------------
# Listing Launch Agents
echo "==> LaunchAgents"
ls -1 $HOME/Library/LaunchAgents
ls -1 /Library/LaunchAgents
ls -1 /Library/LaunchDaemons

# -------------------------------------------------------------


# Find Stuff
# sudo find ~ /Library /System/Library -iregex '.*iterm.*'
# sudo find /Users /Library /Applications /System /opt /bin /sbin /private -iregex '.*iterm.*'

# Get rid of all recent files
# sudo find ~ /Library -iregex '.*LSSharedFileList.*'

# $HOME/Library/Messages
# $HOME/Library/Saved Application State
# $HOME/Library/Application Support/CrashReporter


# Delete System fonts I dont use /Library/Fonts
# Delete System dictionaries I dont use /Library/Dictionaries
# Delete DesktopPicktures
# Delete Screen Savers

# BACKUP
# $HOME/Library/Keychains

# cleanup
16 changes: 0 additions & 16 deletions mac/mac-config.sh

This file was deleted.

6 changes: 1 addition & 5 deletions mac/mac-install.sh
Expand Up @@ -5,8 +5,4 @@ source "$HOME"/.templates/provisioning/ruby.sh
source "$HOME"/.templates/provisioning/mac-apps.sh
source "$HOME"/.templates/provisioning/fonts.sh
source "$HOME"/.templates/provisioning/vim.sh

# # SUBLIME
# # install sublime package manager
# # install sublime_packages

source "$HOME"/.templates/provisioning/sublime.sh
10 changes: 5 additions & 5 deletions npmrc
@@ -1,7 +1,7 @@
email = allen.bargi@gmail.com
username = aziz
init.author.email = allen.bargi@gmail.com
init.author.name = Allen Bargi
init.author.url = https://github.com/aziz
email = ${email}
username = ${npm_username}
init.author.email = ${email}
init.author.name = ${name}
init.author.url = https://github.com/${gh_username}
loglevel = warn
viewer = browser
2 changes: 0 additions & 2 deletions templates/dependencies/apps
@@ -1,4 +1,3 @@
alfred
anvil
atom
base
Expand All @@ -25,7 +24,6 @@ skype
spectacle
sublime-text
sublime-text-dev
subtitles
textmate
transmission
viber
Expand Down
2 changes: 2 additions & 0 deletions templates/dependencies/other-apps
@@ -1,4 +1,5 @@
# Candidates
alfred
slack
skitch
dash
Expand All @@ -10,6 +11,7 @@ dnscrypt
hopper-disassembler
tunnelbear
xquartz
subtitles
pgadmin3

# Installer
Expand Down
29 changes: 29 additions & 0 deletions templates/provisioning/mac.sh
@@ -0,0 +1,29 @@
#!/bin/bash

if pkgutil --pkg-info=com.apple.pkg.CLTools_Executables > /dev/null 2>&1; then
echo "==> Mac OSX Command-Line Tools are installed."
else
echo "==> Installing Command-Line Tools"
xcode-select --install
fi

sudo defaults write /Library/Preferences/org.openbsd.openssh KeychainIntegration -bool NO
echo "==> Config: Disabled KeychainIntegration for SSH"

sudo defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
echo "==> Config: Save to disk (not to iCloud) by default"

sudo defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true
echo "==> Config: Automatically quit printer app once the print jobs complete"

sudo defaults write com.apple.finder CreateDesktop -bool false
echo "==> Config: Hides Desktop"

sudo defaults write com.apple.Finder FXPreferredViewStyle Nlsv
echo "==> Config: Always open everything in Finder's list view"

sudo defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
echo "==> Config: Expand save panel by default"

sudo killall Finder
sudo killall Dock
27 changes: 27 additions & 0 deletions templates/provisioning/sublime.sh
@@ -0,0 +1,27 @@
#!/bin/bash

ST_DIR="$HOME/Library/Application Support/Sublime Text 3"

# install license
mkdir -p "$ST_DIR/Local"
cp "$HOME/.templates/licenses/License.sublime_license" "$ST_DIR/Local/License.sublime_license"

# hides minimap
echo '{"settings":{"new_window_settings":{"show_minimap": false}}}' > "$ST_DIR/Local/Session.sublime_session"

# install package control
mkdir -p "$ST_DIR/Installed Packages"
curl "https://sublime.wbond.net/Package%20Control.sublime-package" -o "$ST_DIR/Installed Packages/Package Control.sublime-package"

# install personal user repo
rm -Rf "$ST_DIR/Packages/User"
mkdir -p "$ST_DIR/Packages/User"
git clone git@github.com:aziz/sublimeText3-Userfiles.git "$ST_DIR/Packages/User"

# copy theme default
cp -r "$ST_DIR/Packages/User/Theme/Theme - Default" "$ST_DIR/Packages"

# install plugins from git
cd "$ST_DIR/Packages" && rm -Rf PlainTasks && git clone git@github.com:aziz/PlainTasks.git
cd "$ST_DIR/Packages" && rm -Rf PlainNotes && git clone git@github.com:aziz/PlainNotes.git
cd "$ST_DIR/Packages" && rm -Rf FileBrowser && git clone git@github.com:aziz/SublimeFileBrowser.git FileBrowser
2 changes: 1 addition & 1 deletion templates/provisioning/vim.sh
Expand Up @@ -2,7 +2,7 @@

echo "Installing Vundle: Vim Plugin Manager"
echo "====================================="
mkdir -p ~/.vim/bundle/
mkdir -p ~/.vim/bundle/backup
rm -Rf ~/.vim/bundle/Vundle.vim
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
vim +PluginInstall +qall
18 changes: 9 additions & 9 deletions templates/terminal/com.googlecode.iterm2.plist
Expand Up @@ -4634,13 +4634,13 @@
<key>NSWindow Frame NSFontPanel</key>
<string>695 206 459 270 0 0 1280 778 </string>
<key>NSWindow Frame Preferences</key>
<string>477 142 605 485 0 0 1280 778 </string>
<string>252 196 924 485 0 0 1280 778 </string>
<key>NSWindow Frame SUStatusFrame</key>
<string>448 498 384 129 0 0 1280 778 </string>
<string>514 1766 384 129 -574 800 2560 1418 </string>
<key>NSWindow Frame SUUpdateAlertFrame</key>
<string>352 301 575 392 0 0 1280 778 </string>
<key>NSWindow Frame iTerm Window 0</key>
<string>0 48 1280 730 0 0 1280 778 </string>
<string>0 67 1074 711 0 0 1280 778 </string>
<key>NSWindow Frame iTerm Window 1</key>
<string>264 55 955 723 0 0 1280 778 </string>
<key>New Bookmarks</key>
Expand Down Expand Up @@ -4693,9 +4693,9 @@
<key>Blue Component</key>
<real>1</real>
<key>Green Component</key>
<real>0.75560998916625977</real>
<real>0.88562947511672974</real>
<key>Red Component</key>
<real>0.47132518887519836</real>
<real>0.78559136390686035</real>
</dict>
<key>Ansi 13 Color</key>
<dict>
Expand Down Expand Up @@ -5192,11 +5192,11 @@
<key>Name</key>
<string>Default</string>
<key>Non Ascii Font</key>
<string>Monaco 14</string>
<string>Monaco 13</string>
<key>Non-ASCII Anti Aliased</key>
<true/>
<key>Normal Font</key>
<string>Consolas 15</string>
<string>Consolas 14</string>
<key>Option Key Sends</key>
<integer>0</integer>
<key>Prompt Before Closing 2</key>
Expand Down Expand Up @@ -6887,7 +6887,7 @@
<key>SUHasLaunchedBefore</key>
<true/>
<key>SULastCheckTime</key>
<date>2014-06-30T10:49:26Z</date>
<date>2014-07-28T00:13:21Z</date>
<key>SavePasteHistory</key>
<false/>
<key>Show Toolbelt</key>
Expand Down Expand Up @@ -6942,7 +6942,7 @@
<key>findRegex_iTerm</key>
<false/>
<key>iTerm Version</key>
<string>1.0.0.20140518</string>
<string>1.0.0.20140629</string>
<key>kPreferenceKeyWindowStyle</key>
<integer>1</integer>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion vimrc
Expand Up @@ -42,7 +42,7 @@ set number " show line number
set autoread " watch for file changes
set autoindent
set noswapfile " disable swapfiles
"set nobackup " disable backups
set nobackup " disable backups
set backupdir=$HOME/.vim/backup " Directories for swp files
set showmatch " show matching brackets.
set showcmd " shows what you're typing as a command
Expand Down

0 comments on commit 8fbf45a

Please sign in to comment.