在Bash注销时保存上一个工作目录 [英] Save last working directory on Bash logout

查看:55
本文介绍了在Bash注销时保存上一个工作目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在bash中执行退出"操作时是否可以保存最后一个工作目录.因此,下次登录时,它将位于您上次注销时所在的目录.

Is it possible to save the last working directory when you do an "exit" in bash. So, the next time you login, it will be at the directory you were at when you last logged out.

推荐答案

将〜./.bash_logout中的最后一个工作目录保存到隐藏文件中:

Save the last working directory in ~./.bash_logout into a hidden file:

pwd > ~/.lastdirectory

通过〜p.bashrc读取该文件,

Read this file in ~/.bashrc with

[ -s ~/.lastdirectory ] && cd `cat ~/.lastdirectory`

这篇关于在Bash注销时保存上一个工作目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆