質問:
いくつかのbash関数とエイリアスがあります。私はすべてをすぐに覚えられないので、通常必要なものを見つけるために.bash_functions
ファイルを開いてみます。.bash_aliases
質問):
Bashプロンプトで利用可能な機能/エイリアスを一覧表示するには?
私のbash関数/エイリアス(PHPDocに似ています)を文書化するためにコメントを使用できますか?
私はファイルを開かずに利用可能なものを出力する簡単で良い方法が欲しいです。コマンドを実行し、私の機能/エイリアスのダイナミックリストを表示するのは素晴らしいことです(例を使用するのは良いことではありません)。 :)
ベストアンサー1
アクティブなエイリアスを一覧表示するには、次の手順を実行します。
alias
すべてのアクティブ関数の名前を表示するには、次を実行します。
declare -F
すべてのアクティブ関数の名前と定義を表示するには、次を実行します。
declare -f
もっと
エイリアスに関する情報は、スクリプトに優しい形式でも提供されます。
declare -p BASH_ALIASES
man bash
組み込み機能に関する追加情報を提供しますalias
。
alias [-p] [name[=value] ...] Alias with no arguments or with the -p option prints the list of aliases in the form alias name=value on standard output. When arguments are supplied, an alias is defined for each name whose value is given. A trailing space in value causes the next word to be checked for alias substitution when the alias is expanded. For each name in the argument list for which no value is supplied, the name and value of the alias is printed. Alias returns true unless a name is given for which no alias has been defined.
機能に関してオプションが設定されると、より詳細なman bash
説明が提供されることがあります。declare
extdebug
Function names and definitions may be listed with the -f option to the declare or typeset builtin commands. The -F option to declare or typeset will list the function names only (and optionally the source file and line number, if the extdebug shell option is enabled).