具有C-shell(tcsh)别名的tmux丢失

具有C-shell(tcsh)别名的tmux丢失,shell,alias,tmux,tcsh,Shell,Alias,Tmux,Tcsh,我在Mac OS X 10.6.8和iTerm 2上运行tmux 1.9a版 我的默认shell是tcsh,我在.tcshrc文件中定义了几个别名和路径环境变量 问题是在运行tmux时没有定义所有别名,尽管默认情况下我将tmux设置为与tcsh shell一起运行 另外:另一方面,my.tcshrc中设置的环境变量在tmux中正确传递。这似乎是一个与别名有关的问题 在my.tmux.conf下面 # copy and paster set-option -g default-command "r

我在Mac OS X 10.6.8和iTerm 2上运行tmux 1.9a版

我的默认shell是tcsh,我在.tcshrc文件中定义了几个别名和路径环境变量

问题是在运行tmux时没有定义所有别名,尽管默认情况下我将tmux设置为与tcsh shell一起运行

另外:另一方面,my.tcshrc中设置的环境变量在tmux中正确传递。这似乎是一个与别名有关的问题

在my.tmux.conf下面

# copy and paster
set-option -g default-command "reattach-to-user-namespace -l tcsh"

# Define the default shell
set-option -g default-shell /bin/tcsh

# Avoid problems with alias defined in .tcshrc
set-option -g default-command $SHELL

set-option -g default-command "source .tcshrc"

# look good
set -g default-terminal "screen-256color"

set -g prefix C-a
unbind C-b
bind C-a send-prefix

# a mouse
set -g mode-mouse on
setw -g mouse-select-window on
setw -g mouse-select-pane on

# # Scroll History
set -g history-limit 30000

# Count sessions start at 1
set -g base-index 1

# act like vim
setw -g mode-keys vi
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind-key -r C-h select-window -t :-
bind-key -r C-l select-window -t :+
unbind [
bind -t vi-copy v begin-selection
bind -t vi-copy y copy-selection

# after copying to a tmux buffer, hit y again to copy to clipboard
bind y run "tmux save-buffer - | reattach-to-user-namespace pbcopy"

bind N swap-window -t +1
bind P swap-window -t -1

# Reload .tmux.conf
#bind R source-file ~/.tmux.conf \; display-message "  Config reloaded.."

# Hit [PREFIX]-R to reorder windows (i..e from 1-4-7-9 to 1-2-3-4 keeping the right order)
bind R                                      \
    set -g renumber-windows on\;            \
    new-window\; kill-window\;              \
    set -g renumber-windows off\;           \
    display-message "Windows reordered..."

# Rename your terminals
set -g set-titles on
set -g set-titles-string '#(whoami)::#h::#(curl ipecho.net/plain;echo)'



# Status bar customization
# Set status bar
set -g status-justify left
set -g status-bg black
set -g status-fg white
set-option -g status-interval 5
set -g status-right-length 150
set -g status-left ""
set -g status-right "#[fg=green] %m-%d-%Y %H:%M #(whoami)@minimul.com             " # Add space so I can see Growl notifications in full-screen mode

# Rather than constraining window size to the maximum size of any client 
# connected to the *session*, constrain window size to the maximum size of any 
# client connected to *that window*. Much more reasonable.
setw -g aggressive-resize on

# Allows us to use '<prefix>-a' <command> to send commands to a TMUX session inside 
# another TMUX session
bind-key a send-prefix

# Highlight active window
set-window-option -g window-status-current-bg red

这是因为当您从终端启动标准shell时,它是一个登录shell,但是使用您为tmux设置的选项,它只是一个附加shell

这一行:

set-option -g default-command $SHELL
实际上导致它作为非登录shell启动。您可能已通过以下方式阻止了某些代码:

if($?loginsh) then
    ...
endif
这意味着在这种情况下不会调用它

如果将选项更改为:

set-option -g default-command "$SHELL -l"
它将充当一个登录shell;或者删除默认命令,在这种情况下,它将调用默认shell作为登录shell,这应该具有相同的效果

为了调试此功能,我从一个从头开始的.tcshrc开始,其中包含:

echo tcshrc
if($?loginsh) then
    echo login
endif
if($?prompt) then
    echo prompt
endif
使用set option-g default命令,我看到了默认值:

tcshrc
login
prompt
使用set选项-g默认命令$SHELL,我看到:

使用set option-g默认命令$SHELL-l,我看到了:

使用set option-g default命令重新附加到用户名称空间tcsh,我看到:

使用set选项-g default命令重新附加到用户名称空间-l tcsh,我看到了:


显然,这个问题是通过保持沉默解决的

set-option -g default-command "reattach-to-user-namespace -l tcsh"
在删除行的同时

# Define the default shell
set-option -g default-shell /bin/tcsh

# Avoid problems with alias defined in .tcshrc
set-option -g default-command $SHELL

set-option -g default-command "source .tcshrc"

重新启动iTerm2没有源代码或重新缓存完成了这项工作。

如果tcsh已经是您在/etc/passwd中使用chsh设置的默认shell,为什么要配置tmux来运行tcsh?这应该是不必要的…正确的,但这是我为解决别名问题而添加的一个选项…感谢您的及时回复,但我尝试了两种选择,添加set option-g default command$SHELL-l和删除行set option-g default command$SHELL,这两种选择都不起作用。。。你能试试你的电视台吗?i、 e.在.tcshrc中创建一些别名并使用tcsh shell运行tmux?所有别名在没有保护的情况下都会放入my.tcshrc中。当我将它们放入if$?登录时,当我使用set option-g default命令resattach to user session-l tcsh时,它们就会出现。如果我省略了-l,那么它们仍然会出现在If$?提示符then块中。你必须有一些if…then条件来阻止加载别名。最简单的调试方法是echo调试。当遇到条件节时,使用它们来确定代码路径。这个if…then块应该在哪里?在我的房间里?因为如果我只是在我的.tcshrc别名cdlib'cd~/lib'中添加以下行,它在tmux中仍然不起作用……感谢@Petesh的澄清!我想我这里有一些更严重的问题,因为如果我把你建议的代码放到我的.tcshrc中,我会得到tcshrc,然后换行:then/endif not found。
tcshrc
tcshrc
prompt
tcshrc
tcshrc
login
prompt
set-option -g default-command "reattach-to-user-namespace -l tcsh"
# Define the default shell
set-option -g default-shell /bin/tcsh

# Avoid problems with alias defined in .tcshrc
set-option -g default-command $SHELL

set-option -g default-command "source .tcshrc"