From 11194ce2aa3215724ff68a888da8984bbe922601 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Wed, 28 Aug 2013 03:26:24 +0900 Subject: [PATCH] Update .zprofile .zshenv .zshrc --- .zprofile | 2 +- .zshenv | 46 ++++++++++++++++++---------------------------- .zshrc | 20 ++++++++++++-------- 3 files changed, 31 insertions(+), 37 deletions(-) diff --git a/.zprofile b/.zprofile index 9a34c85..420311f 100644 --- a/.zprofile +++ b/.zprofile @@ -1,4 +1,4 @@ -if which keychain > /dev/null; then +if type keychain > /dev/null; then keychain ~/.ssh/github_key source ~/.keychain/$HOST-sh fi diff --git a/.zshenv b/.zshenv index f833623..3ce5bb6 100644 --- a/.zshenv +++ b/.zshenv @@ -2,52 +2,42 @@ export PATH="/usr/bin:/bin:/usr/sbin:/sbin" export PATH="/usr/local/bin:/usr/local/sbin:$PATH" export PATH="$HOME/bin:$PATH" -function source_if_exists() { [[ -f $1 ]] && source $1 } +function export_path_if_exists { [[ -d "$1" ]] && export PATH="$1:$PATH" } +function source_if_exists { [[ -f "$1" ]] && source "$1" } source_if_exists ~/dotfiles/zsh/antigen/antigen.zsh antigen-bundle rbenv antigen-bundle bundler -if [ -d /usr/local/share/npm/bin ]; then - export PATH="/usr/local/share/npm/bin:$PATH" +export_path_if_exists "$HOME/.plenv/bin" && eval "$(plenv init -)" +export_path_if_exists "$HOME/mysql-build/bin" +export_path_if_exists /usr/local/share/git-core/contrib/workdir +export_path_if_exists /usr/local/share/npm/bin && { export NODE_PATH="/usr/local/share/npm/lib/node_modules" -fi - -if [ -d "$HOME/.plenv/bin" ]; then - export PATH="$HOME/.plenv/bin:$PATH" - eval "$(plenv init -)" -fi - -if [ -d "$HOME/mysql-build/bin" ]; then - export PATH="$HOME/mysql-build/bin:$PATH" -fi - -if [ -d "$(brew --prefix coreutils)/libexec/gnubin" ]; then - export PATH="$(brew --prefix coreutils)/libexec/gnubin:$PATH" -fi - -if [ -x /usr/libexec/java_home ]; then - export JAVA_HOME="$(/usr/libexec/java_home)" - export PATH="$JAVA_HOME/bin:$PATH" -fi +} if [ -d /usr/local/lib/pkgconfig ]; then export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" fi -if which hub > /dev/null; then +if type hub > /dev/null; then eval "$(hub alias -s zsh)" fi -if [ xDarwin = x`uname` ]; then - export CONFIGURE_OPTS="--with-opt-dir=/usr/local" +if [ "Darwin" = "$(uname)" ]; then + if [ -x /usr/libexec/java_home ]; then + export JAVA_HOME="$(/usr/libexec/java_home)" + export_path_if_exists "$JAVA_HOME/bin" + fi + + export_path_if_exists "$(brew --prefix coreutils)/libexec/gnubin" + + export CFLAGS=-Wno-error=shorten-64-to-32 + export RUBY_CONFIGURE_OPTS="--with-readline-dir=`brew --prefix readline` --with-openssl-dir=`brew --prefix openssl`" fi export EDITOR='vim' export PAGER='less -R' -export PERL_CPANM_OPT='-nq' -export RBXOPT=-X19 - disable r diff --git a/.zshrc b/.zshrc index cf6a060..9436671 100644 --- a/.zshrc +++ b/.zshrc @@ -75,7 +75,7 @@ alias -g A='| awk' alias -g X='| xargs' alias -g J='| jq' -if which dstat > /dev/null; then +if type dstat > /dev/null; then alias dstat-full='dstat -Tclmdrn' alias dstat-mem='dstat -Tclm' alias dstat-cpu='dstat -Tclr' @@ -94,21 +94,25 @@ if [ xLinux = x`uname` ]; then fi function static_httpd { - if which plackup > /dev/null; then + if type plackup > /dev/null; then plackup -MPlack::App::Directory -e 'Plack::App::Directory->new(root => ".")->to_app' - elif which ruby > /dev/null; then - ruby -rwebrick -e 'WEBrick::HTTPServer.new(:Port => 5000, :DocumentRoot => ".").start' - elif which python > /dev/null; then + elif type ruby > /dev/null; then + if ruby -v | grep -qm1 'ruby 2\.'; then + ruby -run -e httpd -- --port=5000 . + else + ruby -rwebrick -e 'WEBrick::HTTPServer.new(:Port => 5000, :DocumentRoot => ".").start' + fi + elif type python > /dev/null; then if python -V 2>&1 | grep -qm1 'Python 3\.'; then python -m http.server 5000 else python -m SimpleHTTPServer 5000 fi - elif which node > /dev/null; then + elif type node > /dev/null; then node -e "var c=require('connect'), d=process.env.PWD; c().use(c.logger()).use(c.static(d)).use(c.directory(d)).listen(5000);" - elif which php > /dev/null && php -v | grep -qm1 'PHP 5\.[45]\.'; then + elif type php > /dev/null && php -v | grep -qm1 'PHP 5\.[45]\.'; then php -S 0.0.0.0:5000 - elif which erl > /dev/null; then + elif type erl > /dev/null; then erl -eval 'inets:start(), inets:start(httpd, [{server_name, "httpd"}, {server_root, "."}, {document_root, "."}, {port, 5000}])' fi }