ブログにソースコードを貼り付ける時はgistの埋め込み機能を使ってやっています。
すごく便利です。
しかしソースコードを毎回ブラウザにコピペ登録するのは大変ダルいです。
そこでgistコマンドを導入しました。
使い方
gist filenameでgistに登録出来ます。
gist filename1 filename2的な感じで複数のファイルもいっぺんに登録できる。
gist -o filenameってやるとgistに登録した後にそのページをブラウザで開いてくれる。
その他はgistって打てばhelpが出ます。
あと公式のReadmeが充実しているのでそちらを見れば分かると思います。
インストール
brew install gistで一発
設定
自分のアカウントでgistを作りたいので、ユーザ名とパスワードを登録しておく必要があります。
https://github.com/defunkt/gistのReadmeのAuthenticationの項目を見ると色々な設定方法が有るのですが、僕は「Using env vars GITHUB_USER and GITHUB_PASSWORD:」という環境変数を使う方法で設定しました。
設定方法は以下の2つのコマンドをどっかに書いといてログイン時に読み込まれるようにするだけです。
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
export GITHUB_USER="your-github-username" | |
export GITHUB_PASSWORD="your-github-password" |
そこで、.zshrcから.zsh_localというファイルを読み込むようにして、.zsh_localはgithubに登録しないようにしました。
.zshrcには以下のコードを追加
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
if [ -f ~/.zsh_local ]; then | |
source ~/.zsh_local | |
fi |
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
export GITHUB_USER="your-github-username" | |
export GITHUB_PASSWORD="your-github-password" |
設定直後はsourceで再読み込みしておけばおkです。
これで捗りますね。
0 件のコメント:
コメントを投稿