Ruby 1.9.3 リファレンスマニュアル > ライブラリ一覧 > shellライブラリ > Shellクラス > alias_command

singleton method Shell.alias_command

alias_command(alias, command, *opts) {...} -> self

コマンドの別名(エイリアス)を作成します。 コマンドが無い場合は、Shell.def_system_command などであらかじめ作成します.

[PARAM] alias:
エイリアスの名前を文字列で指定します.
[PARAM] command:
コマンド名を文字列で指定します.
[PARAM] opts:
command で指定したコマンドのオプションを指定します.

使用例: ls -la | sort -k 5 のような例。

Shell.def_system_command("ls")
Shell.alias_command("lsla", "ls", "-a", "-l")
Shell.def_system_command("sort")
sh = Shell.new
sh.transact {
  (lsla | sort("-k 5")).each {|l|
    puts l
  }
}
class Shell