gpt4 book ai didi

Shell (Bash) - 我可以拥有完全可移植的 .bash_profile/.bashrc/.bash_history 文件吗?

转载 作者:行者123 更新时间:2023-11-29 09:29:45 32 4
gpt4 key购买 nike

背景

我是一名前端 Web 开发人员,我已经开始尽可能地转向 PortableApps;至少对于我在构建机器并不得不多次重新安装 Windows 后使用的台式机 (Windows)。

将命令行与构建自动化工具、使用 CLI 测试软件等结合使用变得越来越重要。

我刚刚从我的 Dropbox 获得了 Git (Bash) 和 ConEmu 的便携版本(但理想情况下这也可以通过 USB 运行)。这意味着我可以使用 Git 在 Windows 上访问 Unix shell,但是我保存的 .bash_profile(和 .bashrc)我需要手动复制到我使用的每台机器的“~”(主)目录。

问题

有没有一种方法可以将我的可移植控制台与 位于所用每台机器上用户主目录中的 bash 文件链接起来?

例如,当我的控制台打开并查找这些文件时,我可以要求它检查不同的目录而不在每台机器上设置任何配置吗?然后让 .bash_history 也保存在这里?

最佳答案

您可以为 .bash_profile.bashrc 使用符号链接(symbolic link):

ln -s /path/to/.bashrc ~/.bashrc
ln -s /path/to/.bash_profile ~/.bash_profile

在您的 .bashrc 中,您可以定义 history file is located 的位置:

export HISTFILE=/path/to/.bash_history

我认为没有任何方法可以将 .bashrc.bash_profile 放在您的主目录中。除非您使用 --rcfile 选项启动 bash:

bash --rcfile /path/to/.bashrc

还有位于 /etc/bashrc 的系统范围文件。

关于Shell (Bash) - 我可以拥有完全可移植的 .bash_profile/.bashrc/.bash_history 文件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37735200/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com