bash
スクリプトの一部をシェルに移植fish
していますが、ユーティリティ機能にアクセスできません。
バッシュ
これがbashでの方法です。最初にメソッドを宣言します"$HOME/.my-posixrc"
:
function configure_date_utilities() {
function today() {
to-lower "$(date '+%Y-%b-%d')"
}
function today-num() {
to-lower "$(date '+%Y-%m-%d')"
}
function now() {
to-lower "$(date '+%Y-%b-%d-%H:%M')"
}
}
次に、このファイルをソースします。
source "$HOME/.my-posixrc"
だから私はできる:
$ today
2015-12-13
魚
function configure_date_utilities
function today
to-lower (date '+%Y-%b-%d')
end
function today-num
to-lower (date '+%Y-%m-%d')
end
function now
to-lower (date '+%Y-%b-%d-%H:%M')
end
end
次に、このファイルを次の場所にソースします~/.config/fish/config.fish
。
source "$HOME/.my-posixrc"
しかし、メソッドが見つかりません:
$ today
プログラム「今日」は現在インストールされていません。次のように入力してインストールできます:sudo apt-get install mhc-utils
質問
プロンプトで関数にアクセスできるように関数を「エクスポート」するにはどうすればよいですか?
PS: 私のドットファイルは github で入手できます。