簡體   English   中英

可以配置Tmux來加載〜/ .bashrc而不是〜/ .bash_profile嗎?

[英]Can one configure Tmux to load ~/.bashrc instead of ~/.bash_profile?

現在,當我登錄Tmux時,只有~/.bash_profile被加載。

我想改為調用~/.bashrc

那可能嗎?

此問題與tmux無關。 要解決它,請確保將source ~/.bashrc添加到.bash_profile ,就是這樣。

您可以在此處了解有關bash初始化及其加載的文件以及順序的更多信息: https//github.com/sstephenson/rbenv/wiki/Unix-shell-initialization#bash

正如您所看到的,當bash以登錄模式啟動時, .bashrc甚至不在列表中,這就是我們從列表中的文件( .bash_profile )中獲取它的原因。

您可以通過顯式設置默認的shell命令來修復tmux級別:

tmux set-option default-command "/bin/bash"

tmux手冊(強調我的):

  default-command shell-command Set the command used for new windows (if not specified when the window is created) to shell-command, which may be any sh(1) command. The default is an empty string, which instructs tmux to create a **login shell** using the value of the default-shell option. default-shell path Specify the default shell. This is used as the login shell for new windows when the default-command option is set to empty, and must be the full path of the exe‐ cutable. When started tmux tries to set a default value from the first suitable of the SHELL environment vari‐ able, the shell returned by getpwuid(3), or /bin/sh. This option should be configured when tmux is used as a login shell. 

正如Chepner在下面的評論中解釋的那樣:

default-shell默認為您首選的登錄shell; default-command默認啟動登錄實例,實際上是$SHELL -l

...在Bash的情況下, 登錄 shell不會讀取~/.bashrc 通過覆蓋default-command的值,我們現在可以強制tmux創建一個非登錄 shell。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM