答案1
将以下内容添加到您的~/.bash_profile
:
function cd {
# actually change the directory with all args passed to the function
builtin cd "$@"
# if there's a regular file named "todo.txt"...
if [ -f "todo.txt" ] ; then
# display its contents
cat todo.txt
fi
}
您可能已经有了类似的功能 — cd
— 只需扩展该功能即可打印其内容(todo.txt
如果存在)。