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

时间:2014-08-27 10:42:48

标签: shell alias tmux tcsh

我在带有iTerm 2的Mac OS X 10.6.8上运行tmux(版本1.9a)。

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

问题是当我运行tmux时没有定义所有别名,尽管我默认设置tmux与tcsh shell一起运行。

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

在我的.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

2 个答案:

答案 0 :(得分:1)

显然问题是通过保持行

来解决的
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(没有任何来源或rehash完成这项工作)。

答案 1 :(得分:0)

这是因为当您从终端启动标准shell时,它是一个登录shell,但是如果您已经为tmux设置了选项,那么它只是一个额外的shell。

这一行:

set-option -g default-command $SHELL

实际上导致它作为非登录shell启动。您可能已经阻止了一些代码:

if($?loginsh) then
    ...
endif

这意味着在这种情况下它不会被调用。

如果您将选项更改为:

set-option -g default-command "$SHELL -l"

它将像登录shell一样;或者删除default-command,在这种情况下,它将调用默认shell作为登录shell,这应该具有相同的效果。

作为尝试调试的一个尝试,我从一个从头开始.tcshrc开始,包含:

echo tcshrc
if($?loginsh) then
    echo login
endif
if($?prompt) then
    echo prompt
endif

set-option -g default-command ""(默认值)我看到了:

tcshrc
login
prompt

set-option -g default-command "$SHELL"我明白了:

tcshrc
tcshrc
prompt

set-option -g default-command "$SHELL -l"我明白了:

tcshrc
tcshrc
login
prompt

set-option -g default-command "reattach-to-user-namespace tcsh"我明白了:

tcshrc
tcshrc
prompt

set-option -g default-command "reattach-to-user-namespace -l tcsh"我明白了:

tcshrc
tcshrc
login
prompt