Answers:
如果我是你,我会在我的shell配置文件(例如~/.bashrc)中玩些类似的东西:
reminder_cd() {
builtin cd "$@" && { [ ! -f .cd-reminder ] || cat .cd-reminder 1>&2; }
}
alias cd=reminder_cd
这样,您可以.cd-reminder在每个要提醒的目录中添加文件。每次成功cd访问目录后,将显示文件的内容。
gim@tenebreuse ~/tmp % echo 'warning: this directory is pure junk' > .cd-reminder
gim@tenebreuse ~/tmp % cd ..
gim@tenebreuse ~ % cd tmp
warning: this directory is pure junk
gim@tenebreuse ~/tmp %
$@。
$@,应优先于"$@"...
$@或$*(不加引号时它们是相同的东西)。
pushd和popd也。