use*_*817 1 linux bash google-drive-api
我想将我的Google Drive附加到我的本地计算机(linux),以便我可以通过终端访问它.
经过一些谷歌搜索,我看到我可以安装google-drive-ocamlfuse来做到这一点.
当我启动我的机器时,我必须键入:
google-drive-ocamlfuse ~/google-drive
Run Code Online (Sandbox Code Playgroud)
安装Google云端硬盘.
为了避免每次都这样做,我将行添加到我的.bashrc中.哪个工作正常.但随后我打开的每个后续终端都试图运行该行,我收到消息:
fuse: mountpoint is not empty
fuse: if you are sure this is safe, use the 'nonempty' mount option
Run Code Online (Sandbox Code Playgroud)
我认为我得到这条消息是因为它试图挂载已安装的东西.有没有什么办法可以让我的.bashrc中的这一行只在第一次在会话中打开时才执行.或者其他一些方法我可以停止警告?
没什么大不了的,但学习一些东西会很好.
尝试将此命令放在启动文件中:
mountpoint ~/google-drive || google-drive-ocamlfuse ~/google-drive
Run Code Online (Sandbox Code Playgroud)
mountpoint测试以查看其参数是否为挂载点.如果不是,则mountpoint返回false并触发||执行第二个命令.
mountpoint 是util-linux实用程序集合的一部分.
您可以将此命令放在一个shell启动文件中,但最好放在一个系统启动文件中.根据您的分发,该文件可能是/etc/rc.local.
如果您愿意,可以使用以下if-then语句执行条件执行:
if ! mountpoint ~/google-drive
then
google-drive-ocamlfuse ~/google-drive
fi
Run Code Online (Sandbox Code Playgroud)
在这里,!否定mountpoint的退出代码,以便只有在mountpoint返回false时才执行google-drive-ocamlfuse.