我正在将我的一些脚本从 shell 移植bash
到fish
shell,但无法访问我的实用程序功能。
重击
这是我在 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:我的dotfiles 可以在 github 上找到。