2013-04-09 113 views
0

我有一個功能,我在網上找到要添加到我的.bashrc其滋生與主機名新的SSH會話:通過SSH創建一個新的屏幕窗口?

# Opens SSH on a new screen window with the appropriate name. 
screen_ssh() { 
    numargs=$# 
    screen -t ${!numargs} ssh [email protected] 
if [ $TERM == "screen" -o $TERM == "screen.linux" ] && [ ! -z "$PS1" ]; then 
    alias ssh=screen_ssh 
fi 

if [[ $- == *i* ]] 
then 
    [ "$STY" ] && ssh() { screen -t "${1##*@}" ssh "[email protected]"; } # Spawn new window in Screen for SSH 
fi 

,但它也將做到這一點的別名,就像這樣:

lsrem(){ ssh $1 "ls -l" ; } 

所以我的問題是如何從別名/功能停止工作,並只用於交互工作:

ssh somehost 

在此先感謝。

回答

0

我發現了一個(哈克)的方式:

# Opens SSH on a new screen window with the appropriate name. 
screen_ssh() { 
    numargs=$# 
     if [ "$numargs" -eq "1" ]; 
     then 
       screen -t ${!numargs} ssh [email protected] 
     else 
       ssh [email protected] 
     fi 
} 
if [ $TERM == "screen" -o $TERM == "screen.linux" ]; then 
    alias ssh=screen_ssh 
fi 

此檢查參數傳遞給SSH的num是大於一個,所以不產卵,當我做一個新的屏幕seession:

ssh hostname 

我絕對開放更好的方式來做到這一點!