gitのproxy設定
gitのproxy設定。
- git config --global http.proxy http://your.proxy:8080
- git config --global https.proxy http://your.proxy:8080
ディレクトリ構造をドキュメント化するのに便利なtreeを入れてみた
brew install tree
- オプション
usage: tree [-adfghilnpqrstuvxACDFNS] [-H baseHREF] [-T title ] [-L level [-R]] [-P pattern] [-I pattern] [-o filename] [--version] [--help] [--inodes] [--device] [--noreport] [--nolinks] [--dirsfirst] [--charset charset] [--filelimit #] [<directory list>] -a All files are listed. -d List directories only. -l Follow symbolic links like directories. -f Print the full path prefix for each file. -i Don't print indentation lines. -q Print non-printable characters as '?'. -N Print non-printable characters as is. -p Print the protections for each file. -u Displays file owner or UID number. -g Displays file group owner or GID number. -s Print the size in bytes of each file. -h Print the size in a more human readable way. -D Print the date of last modification. -F Appends '/', '=', '*', or '|' as per ls -F. -v Sort files alphanumerically by version. -r Sort files in reverse alphanumeric order. -t Sort files by last modification time. -x Stay on current filesystem only. -L level Descend only level directories deep. -A Print ANSI lines graphic indentation lines. -S Print with ASCII graphics indentation lines. -n Turn colorization off always (-C overrides). -C Turn colorization on always. -P pattern List only those files that match the pattern given. -I pattern Do not list files that match the given pattern. -H baseHREF Prints out HTML format with baseHREF as top directory. -T string Replace the default HTML title and H1 header with string. -R Rerun tree when max dir level reached. -o file Output to file instead of stdout. --inodes Print inode number of each file. --device Print device ID number to which each file belongs. --noreport Turn off file/directory count at end of tree listing. --nolinks Turn off hyperlinks in HTML output. --dirsfirst List directories before files. --charset X Use charset X for HTML and indentation line output. --filelimit # Do not descend dirs with more than # files in them.
rails のプロジェクトで表示するとこんな感じ。
tree . ├── Gemfile ├── Gemfile.lock ├── README.rdoc ├── Rakefile ├── app │ ├── assets │ │ ├── images │ │ │ └── rails.png │ │ ├── javascripts │ │ │ └── application.js │ │ └── stylesheets │ │ └── application.css │ ├── controllers │ │ └── application_controller.rb │ ├── helpers │ │ └── application_helper.rb │ ├── mailers │ ├── models │ └── views │ └── layouts │ └── application.html.erb ├── config │ ├── application.rb │ ├── boot.rb │ ├── database.yml │ ├── environment.rb │ ├── environments │ │ ├── development.rb │ │ ├── production.rb │ │ └── test.rb │ ├── initializers │ │ ├── backtrace_silencers.rb │ │ ├── inflections.rb │ │ ├── mime_types.rb │ │ ├── secret_token.rb │ │ ├── session_store.rb │ │ └── wrap_parameters.rb │ ├── locales │ │ └── en.yml │ └── routes.rb ├── config.ru ├── db │ └── seeds.rb ├── doc │ └── README_FOR_APP ├── lib │ ├── assets │ └── tasks ├── log ├── public │ ├── 404.html │ ├── 422.html │ ├── 500.html │ ├── favicon.ico │ ├── index.html │ └── robots.txt ├── script │ └── rails ├── test │ ├── fixtures │ ├── functional │ ├── integration │ ├── performance │ │ └── browsing_test.rb │ ├── test_helper.rb │ └── unit ├── tmp │ └── cache │ └── assets └── vendor ├── assets │ ├── javascripts │ └── stylesheets └── plugins
日本語が文字化けしたときは
tree -N
で解決
rvmからrbenvに乗り換える
みんなrvmよりrbenvの方がイイヨって言うからrbenvに乗り換えることにした。
rvmのアンインストール
seppukuコマンドでrvmをアンインストールする。
なんか潔くて、乗り換えるのに好きになりそう。
rvm seppuku
次に、rvmに関する設定を.zshrc/.bashrc から削除
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"</pre>
とか
rbenvのインストール
brew install rbenv
ruby-buildのインストール
brew install ruby-build
.zshrcに環境変数を設定
export PATH=$HOME/.rbenv/bin:$PATH eval "$(rbenv init -)"
使い方
- インストール可能なRubyの一覧を確認する
rbenv install -l
- インストール
rbenv install 2.0.0-p0
- インストールしたRubyのバージョン一覧を確認
rbenv versions
- Rubyのバージョン切り替え
rbenv global 2.0.0-p0
- 特定ディレクトリでのRubyのバージョン切り替え
rbenv local 2.0.0-p0
- インストールしたRubyやGemのパスを通す
rbenv rehash
gemとか入れたらいちいちrehashしないといけないみたいなんだけど、それを自動化するgemがあるのでいれる。
gem install rbenv-rehash
あと、"rbenv"って打ちにくいので"re"にaliasを設定しておいた。
alias re=rbenv
参考
Ruby 2.0.0-p0インストール(Mac OS X 10.8.2) #Ruby #bundler - Qiita
rbenvのコマンドメモ
MacBookで外付けキーボードからスリープする方法
最近MacBookAirに外付けのディスプレイとキーボードを繋いで利用している。
せっかくディスプレイを繋いで利用しているのに*1、スリープさせるのに本体の電源ボタン押したり本体を閉じるのが面倒で嫌だった。
WindowsのWin+Lみたいな感じでスリープさせる方法は無いのかと思い、調べてみた。
Macの起動・スリープ・再起動・終了のキーボードショートカットまとめ(27種類) / Inforatiを見てみると、スリープ関連のキーボードショートカットが載っている。
キーボードショートカット | 説明 |
「Control」+「Shift」+「Eject ⏏」 | すぐにディスプレイのみをスリープ |
「Command」+「Option」+「Eject ⏏」 | すぐにスリープ |
ただ、MacBookAirにはEjectキーが無いので他のキーで対応する必要がある。
Ejectキー無いなら他のキーに割り当てれば良いよねってことで、KeyRemap4MacBook*2を利用。
KeyRemap4MacBookのMacBookAir(2010,Late) StyleにてF12 to Ejectの項目にチェックする。
これで快適にスリープさせることが出来る。
キーボードショートカット | 説明 |
「Control」+「Shift」+「F12」 | すぐにディスプレイのみをスリープ |
「Command」+「Option」+「F12」 | すぐにスリープ |
*1:クラムシェルモードじゃなくてデュアルディスプレイ
*2:Mac用じゃないキーボードを利用しているので、もともと使っていましたが
IntelliJ IDEA で 日本語名のテストメソッドを実行する設定
IntelliJ IDEAで日本語名のテストメソッドを実行する際にハマったので、メモを残しておく。
環境
設定
ファイルエンコーディングの設定
いろいろなブログに書いてあるとおり、IntelliJ IDEAのInfo.plistのkey:VMOptions , Stringの最後にファイルエンコーディングの設定を追記する。
- /Applications/IntelliJ IDEA 12 CE.app/Contents/Info.plist
-Dfile.encoding=utf-8
追記したが、文字化けが治らない
JUnit実行時のVMOption設定
他の方法を調べてみたら、JUnit実行時のVMOptionに以下を設定すれば動く模様。
-ea -Dsun.jnu.encoding=UTF-8
- Run - Edit Configurations... - VMOptions
文字化けが解消され、Greenになった! ヨカッタヨカッタ
でもわざわざ設定するのメンドイ…
環境変数に追加
とゆうことで、環境変数に上記で指定した設定を追加する。
- /etc/launchd.conf
※ない場合はファイルを作る。たぶん管理者権限が無いとダメ
setenv JAVA_TOOL_OPTIONS -Dsun.jnu.encoding=UTF-8
追記後、PCを再起動する。
- 設定の反映を確認
java -h
- JUnit実行時のVMOptionの設定を外して実行
ちゃんと文字化けせずに実行できた。
参考
IntelliJ IDEA + Spock で日本語テストメソッド実行時にハマった話 - THE BLUE NOWHERE
IntelliJ IDEA の日本語テストメソッド名の実行で再度ハマった話 - THE BLUE NOWHERE
IntelliJでテストメソッドを日本語で書く - ギークに憧れて
bashでautojumpを使う
zshだとautojumpよりz.shのほうがPythonなしで動いて良いよ | この先生きのこるにはで紹介されているようにz.shを使ってみるのも良さそうだけど、bashで使いたいのでautojumpを使ってみる。
インストール
$ git clone git://github.com/joelthelion/autojump.git
gitから取得後、autojumpのディレクトリに移動し
$ cd autojump
インストール用のshellを実行する。
$ ./install.sh -l
以下の様な実行結果が表示される。
Installating autojump... Destination: /home/tenten0213/.autojump/ Binary: /home/tenten0213/.autojump/bin/ Documentation: /home/tenten0213/.autojump/share/man/man1/ Icon: /home/tenten0213/.autojump/share/autojump/ Shell scripts: /home/tenten0213/.autojump/etc/profile.d/ `./bin/icon.png' -> `/home/tenten0213/.autojump/share/autojump/icon.png' `./bin/autojump' -> `/home/tenten0213/.autojump/bin/autojump' `./bin/autojump_argparse.py' -> `/home/tenten0213/.autojump/bin/autojump_argparse.py' `./docs/autojump.1' -> `/home/tenten0213/.autojump/share/man/man1/autojump.1' `./bin/autojump.sh' -> `/home/tenten0213/.autojump/etc/profile.d/autojump.sh' `./bin/autojump.bash' -> `/home/tenten0213/.autojump/etc/profile.d/autojump.bash' `./bin/autojump.zsh' -> `/home/tenten0213/.autojump/etc/profile.d/autojump.zsh' `./bin/_j' -> `/home/tenten0213/.autojump/_j' Please add the line to ~/.bashrc : [[ -s ~/.autojump/etc/profile.d/autojump.sh ]] && . ~/.autojump/etc/profile.d/autojump.sh You need to run 'source ~/.bashrc' before you can start using autojump. To remove autojump, run './uninstall.sh'
以下の1行を.bashrcに追記しろと書かれているので、追記する。
[[ -s ~/.autojump/etc/profile.d/autojump.sh ]] && . ~/.autojump/etc/profile.d/autojump.sh
追記後、bashrcを読み込み直す。
$ source ~/.bashrc
これでインストール完了。
使ってみる
詳細はjoelthelion/autojump · GitHub参照。
とりあえず、あんまりオプションとか使わないで $ j hoge + Tabって感じで使ってる。
$ j hoge
と入力し、Tabを押すと、
$ j '/home/tenten0213/project/hoge'
といった感じで補完してくれる。
うん、便利。
git,git-flowのインストールと設定のまとめ
入社以来ずっとSVN使ってきたけど、gitの環境に変わったのでgitの導入手順とか設定をまとめておく。
gitのインストールと設定
$ sudo yum install git
$ apt-get install git
ユーザ設定
基本的な設定
$ git config --global user.name "hoge" $ git config --global user.email "hoge@example.com"
色やエイリアスの設定
$ git config --global color.ui auto $ git config --global alias.co checkout $ git config --global alias.ci commit $ git config --global alias.st status $ git config --global alias.br branch $ git config --global alias.hist 'log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short'
自分用のgitignore設定
- .swpとか除外しとく
$ git config --global core.excludesfile ~/.gitignore
git-flowのインストール
$ wget --no-check-certificate -q -O - https://github.com/nvie/gitflow/raw/develop/contrib/gitflow-installer.sh | sudo bash
git-flowは、ブランチモデルを補助する機能を提供してくれる。
git-flowの使い方はgit flow でのチーム開発ワークショップ資料 - Yamashiro0217の日記を参考にすると分かりやすい。
コマンド補完
git
gitインストール時にgit-completion.bashという設定ファイルも落としてきているので、それを読み込ませれば補完が効くようになる。
- ~/.bashrcに以下の様にgit-completion.bashを読み込ませる記述を追記
source gitインストールディレクトリ/contrib/completion/git-completion.bash
git-flow
git-flow用のcompletion.bashは、git-flowには用意されていないので別に取得する。
$ wget -O /etc/bash_completion.d/git-flow-completion.bash https://raw.github.com/bobthecow/git-flow-completion/master/git-flow-completion.bash
gitと同じように、~/.bashrcにgit-flow-completion.bashを読み込ませる記述を追記
source 任意の保存ディレクトリ/git-flow-completion.bash
ターミナルに現在のbranchを表示する
~/.bashrcに以下を追記
PS1="[\u:\W\$(__git_ps1)]\$ "
最後に忘れずに、.bashrcを読み込んで設定を反映させる。
$ source ~/.bashrc
これで当面やってみる。
なにかオススメの設定とかあれば、教えてください!
参考
見えないチカラ: A successful Git branching model を翻訳しました
git flow でのチーム開発ワークショップ資料 - Yamashiro0217の日記