Created
May 22, 2013 09:48
-
-
Save ysmood/5626450 to your computer and use it in GitHub Desktop.
A zshrc with some common settings.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Default zsh runcom. | |
# Oct 2012 y.s. | |
################################### OH-MY-ZSH Settings ########################################## | |
# If your current shell is not zsh, try to change your default shell to zsh. | |
if [[ $0 != '-zsh' ]]; then | |
echo "Your default shell is not zsh." | |
if [[ -s "/opt/local/bin/zsh" ]]; then | |
sudo chsh -s /opt/local/bin/zsh $USER | |
else | |
sudo chsh -s /bin/zsh $USER | |
fi | |
fi | |
# Path to your oh-my-zsh configuration. | |
ZSH=$HOME/.oh-my-zsh | |
# Set name of the theme to load. | |
# Look in ~/.oh-my-zsh/themes/ | |
# Optionally, if you set this to "random", it'll load a random theme each | |
# time that oh-my-zsh is loaded. | |
ZSH_THEME="ys" | |
# Example aliases | |
# alias zshconfig="mate ~/.zshrc" | |
# alias ohmyzsh="mate ~/.oh-my-zsh" | |
# Set to this to use case-sensitive completion | |
# CASE_SENSITIVE="true" | |
# Comment this out to disable weekly auto-update checks | |
# DISABLE_AUTO_UPDATE="true" | |
# Uncomment following line if you want to disable colors in ls | |
# DISABLE_LS_COLORS="true" | |
# Uncomment following line if you want to disable autosetting terminal title. | |
# DISABLE_AUTO_TITLE="true" | |
# Uncomment following line if you want red dots to be displayed while waiting for completion | |
# COMPLETION_WAITING_DOTS="true" | |
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) | |
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ | |
# Example format: plugins=(rails git textmate ruby lighthouse) | |
plugins=(git sublime zsh-syntax-highlighting) | |
if [[ -s $ZSH/oh-my-zsh.sh ]]; then | |
source $ZSH/oh-my-zsh.sh | |
else | |
autoload -U colors && colors | |
echo "$bold_color$fg[red]Please visit 'https://github.com/robbyrussell/oh-my-zsh' and install oh-my-zsh." | |
fi | |
########################################## Functions ########################################## | |
# Add new path to environment path | |
ys-add-evn-path() | |
{ | |
PATH="$1:${PATH}" | |
export PATH | |
} | |
# Toggle the visibility of hidden files. | |
ys-show-hide() | |
{ | |
# check if hidden files are visible and store result in a variable | |
isVisible=$(defaults read com.apple.finder AppleShowAllFiles) | |
# toggle visibility based on variables value | |
if [[ $isVisible = FALSE ]] | |
then | |
defaults write com.apple.finder AppleShowAllFiles TRUE | |
else | |
defaults write com.apple.finder AppleShowAllFiles FALSE | |
fi | |
killall Finder | |
} | |
# Copy the ssh public key. | |
ys-key() | |
{ | |
cat ~/.ssh/id_rsa.pub | pbcopy | |
echo 'ssh public key copied.' | |
} | |
# Copy present working dir. | |
ys-pwd() | |
{ | |
pwd | |
echo -n $PWD | pbcopy | |
} | |
# Return the specified ip address's geo info. | |
ys-ip() | |
{ | |
python -c " | |
import json, urllib2, urlparse | |
s = '$1' | |
if s.find('://') < 0: | |
s = 'http://' + s | |
host = urlparse.urlparse(s).netloc | |
f = urllib2.urlopen('https://dazzlepod.com/ip/%s.json' % host) | |
s = f.read() | |
info = json.loads(s) | |
max_l = 0 | |
for k in info: | |
l = len(str(k)) | |
if max_l < l: | |
max_l = l | |
format = '%%%ds: %%s' % max_l | |
for k, v in info.iteritems(): | |
print(format % (k, v)) | |
" | |
} | |
########################################## Alias ########################################## | |
# Common bash commands. | |
alias le='/usr/share/vim/vim73/macros/less.sh' | |
alias ll='ls -laFhO' | |
alias cls='clear' | |
alias ps='ps -ef' | |
# Disk usage | |
alias du='du -khs' | |
# Change directory to Desktop. | |
alias ys-d='cd ~/Desktop' | |
# Open with Sublime Text 2. | |
alias ys-b='st ~/.bash_profile' | |
# Achive and Compress TAR | |
#tar -jcvf data.tar.bz2 directory_to_compress | |
alias ys-tz='tar -jcvf' | |
# tar -jxvf data.tar.bz2 -C /tmp/extract_here/ | |
alias ys-tuz='tar -jxvf' | |
# tar -zxvf data.tar.gz -C /tmp/extract_here/ | |
alias ys-tug='tar -zxvf' | |
# Show all available commands. | |
alias ys-cmds='echo $PATH | tr ':' '\n' | xargs -n 1 ls -1' | |
# List all listened ports | |
alias ys-listened='sudo lsof -i -P | grep -i "listen"' | |
# Generate a random password | |
alias ys-password='openssl rand -base64 32' | |
# Clean DS_Store files | |
alias ys-clean-ds="find . -name '.DS_Store' -exec rm {} \;" | |
# OSX Configuration | |
# Fix the duplicate or old items on "Open with..." list in osx | |
alias ys-fix-open-with='/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local-domain system -domain user && killall Finder' | |
# Skip DMG veryfication. | |
alias ys-disable-dmg-check="defaults write com.apple.frameworks.diskimages skip-verify TRUE" | |
# Disable the Dashboard. | |
alias ys-disable-dashboard="defaults write com.apple.dashboard mcx-disabled -boolean YES; killall Dock" | |
# Reset finder settings. | |
alias ys-reset-finder="Remove Finder preferences: rm ~/Library/Preferences/com.apple.finder.plist; killall Finder" | |
# Change the sound of QQ receiving message. | |
alias ys-qq-sound="sudo cp -f '/Applications/Messages.app/Contents/Resources/Received Message.aiff' /Applications/QQ.app/Contents/Resources/msg.aif" | |
########################################## Personal Profile ########################################## | |
# Include personal bash profile. | |
[[ -s "$HOME/.bash_profile" ]] && source ~/.bash_profile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment