GNU find find . -type f -printf "%h%f %AY/%Am/%Ad\n" | egrep '2006/09/30$' zsh + zsh/stat zmodload zsh/stat stat -F "%Y/%m/%d" +mtime ./**/*(.) | egrep '2006/09/30$'
GNU find find . -type f -printf "%h%f %AY/%Am/%Ad\n" | egrep '2006/09/30$' zsh + zsh/stat zmodload zsh/stat stat -F "%Y/%m/%d" +mtime ./**/*(.) | egrep '2006/09/30$'
vim にある Ctrl+A の zsh 版。 zle の incarg 関数 % autoload incarg % zle -N incarg % bindkey '^A' incarg % 100 # press Ctrl+A % 101 # press Ctrl+A % 102 # press Ctrl+A % 103
Esc + Enter で複数行編集できる % ps aux<ESC><ENTER> ls -al
拡張子ごとにコマンドを対応づける事が出来る Suffix Alias という機能が zsh 4.2系から実装されていたらしい。 知らなかった。 どんな事が出来るのかというと たとえば、 alias -s txt=cat とした場合、 以下のようにするだけで、 % ./file.txt 先ほど設定したコマンドが自動で実行されるようになる。 % cat ./file.txt あとはもうアイデアしだいだが、 拡張子が *.log のときは、tail -f するなんて事も出来る。 alias -s log='tail -f' 参考: http://zshwiki.org/home/examples/aliassuffix http://slashdot.jp/articles/04/03/27/2333234.shtml?topic=80 http://zsh.dotsrc.org/Doc/Rel
zsh のモジュールに zpty というのがあるのを最近発見した。 どうもコレを利用すれば指定したコマンドを 仮想端末上で実行することが出来るらしい。 具体的にどういったことが出来るようになるのかというと、 端末が必要なプログラムを自動化することが出来る。 たとえば、パスワード入力処理などだ。 パスワード文字列を標準入力から読み込ませようとしても、 大抵のプログラムでは入力できない。 なぜかというと、多くのプログラムにおいてパスワード入力処理は 端末から読み込むように作られているからだ。 zpty を利用すればそういったたぐいのものをすべて自動化できる。 いわゆる、expect というコマンドで実現していたことが zsh だけで出来るのだ。 今回は、簡単に試すことが出来るサンプルとして、 su コマンドのパスワード入力を zpty を使って自動化してみる。 まず、zsh に標準添付されてい
以前に、watch コマンドという 指定されたコマンドを定期的に実行し、 フルスクリーンで表示してくれるコマンドがあるという事を書いた。 http://d.hatena.ne.jp/lurker/20060716/1153056030 実は、--differences とオプションを付加する事によって、 直前の出力結果との差分をハイライト表示してくれるらしい。 知らなかった。コレは便利だ。 正直 grep -o を知ったときぐらい感動した。 以下のように入力してみるとどうなるのかが わかっていただけると思う。 ちなみにこれは、1秒おきに、dateコマンドを実行するというもの。 $ watch -n 1 --differences date さらに、--differences=cumulative と付加すると 起動してからのすべての変更部分がハイライトされるようだ。 $ watch -n
最近、会社でシェルの操作方法について教えているのだが、 pgrep / pkill / skill / pidof といった 便利なプロセス操作系コマンドを知らない人が実に多い。 プロセスを殺すというのは、よくある作業なので 今回はコレについて書いてみる。 たとえば、これらのコマンドを知らない人が、 指定した名前のプロセスを kill する手順はだいたい 以下のようなものになることだろう。 $ ps aux | grep プロセス名 | grep -v 'grep' # コマンドの出力結果から pid を目で確認 12345 ... .. hoge .. .. $ kill 12345 この作業は非常に面倒で退屈だ。 もし殺さなければならないプロセスがたくさんあったときは どうするのだろうか。 おまけに、grep コマンド自身が候補に含まれてしまう事があるのだが、 grep -v grep
vim の MRU という、"最近のいじったファイルリスト" を 簡単に参照できるプラグインがあるのだが、 これをボクはかなり便利に使っている。 で、vih と以下のようにエイリアスする事で すぐに使えるようにしてる。 $ alias vih='vi +MRU' あと、最近ハマっているのが、 :Vexplore として、左側にファイルエクスプローラーを 表示させておいて(vim7 から標準だったはず) ファイルに、hjkl で移動した後で p(プレビュー), o(編集) と行ったような感じでファイルを参照する事が出来る。 そしてそれが便利。 追記: Vexplore なのに、 VExplore と表記してたのを 修正した。drry さんにわざわざ教えていただいた。 ありがとうございます。
自動バックアップ処理をさせたいが シェル権限を与えたくないときとかに使える技。 やり方は簡単で $HOME/.ssh/authorized_keys の "コマンドを制限したい公開鍵" の行の先頭に 実行させたいコマンドを記述すればよい。 そのときのフォーマットはだいたい以下のようになる。 command="実行させたいコマンド",sshのオプションをカンマ区切りで書く command=hoge というのを付け足すことによって その公開鍵でアクセスがあったときに 指定したコマンドを実行させることができる。 たとえば、uptime を実行させたいときは、 以下のようにすればよい。 command="uptime",no-pty,no-port-forwarding,no-X11-forwarding,no-agent-forwarding ssh-rsa AAAABbBFERTWER....
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く