bash - 使用 tmux 会丢失我所有的 bash 别名,我怎样才能让它们保留下来?

标签 bash rvm alias tmux

我的 .bashrc 可以

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

其中包括运行我的 .bash_aliases 并为我提供了大量我定义的别名。

但是,如果我尝试使用 TMUX(通过 tmux 调用),我现在拥有的唯一别名是:

$ aliasreturn # 将显示....

$ alias rvm-restart='rvm_reload_flag=1 source '\''/home/durrantm/.rvm/scripts/rvm'\'''

我怎样才能使用 tmux 并且仍然可以使用我的所有别名。

我在 Ubuntu 12.04 上

我的 .bashrc 文件的结尾是这样的:

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# Automatic cd'ing
shopt -s autocd

if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
    . /etc/bash_completion
fi

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM

export EDITOR=vim

git config --global --add color.ui true

最佳答案

tmux 调用您的 shell 作为登录 shell。登录 shell 不处理 .bashrc,而是使用 .bash_profile

您可以简单地让 .bash_profile 读取您的 .bashrc:

echo 'source ~/.bashrc' >> ~/.bash_profile

关于bash - 使用 tmux 会丢失我所有的 bash 别名,我怎样才能让它们保留下来?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16223748/

相关文章:

bash - 在 Bash 中,为什么在函数中使用 getopts 只能使用一次?

json - 使用 ${params} 将 jenkins 的所有参数写入 JSON 文件中

ruby 1.9.2 运行 cucumber 规范时出现奇怪的警告

linux - 我给用户添加了别名 ~/.bashrc 但 “sudo -u user -i ' alias_name'” 仍然报告 “command not found” ?

shell - 在 ubuntu 中阻止命令(在 shell 中)

bash - 用sed批量删除多个文件中的多行

bash - 多个命令的 Unix 别名参数

Ruby 找不到 nokogiri/nokogiri

ruby-on-rails - 启动 Rails 2 应用程序时为 "uninitialized constant Gem"或 "Rails"

mysql - 如何为 MySQL 中的字段或列设置别名?