2012-05-17 40 views
2

我怎樣才能將我的cygwin bash轉換爲c Shell。
我試圖通過更改安裝目錄中的.bat文件,如:
@echo off
@echo ----Welcome NAME----
@echo 'have a nice day'
cygdrive\
chdir \
set HOME=\cygwin\home\
tcsh -i

請大家幫忙。
這是正確的過程嗎?
雖然它對我有點...
任何想法...?將cygwin bash轉換爲tcsh

+1

'@echo ...'顯然是DOS批處理文件主題。我在這裏沒有看到什麼是bash。你爲什麼要使用'tcsh'。如果你要寫很多腳本,'bash'顯然是首選。如果您選擇回答這些問題,請編輯您的主要問題,並且不要在此回覆。祝你好運。 – shellter

+1

@shelter - 用戶試圖讓cygwin啓動bat文件啓動一個tcsh shell,而不是默認的bash shell。殼牌的偏好基本上是一個宗教戰爭問題,所以不值得辯論。 –

+1

@shelter:當然,他寫道他正在改變'.bat'(Windows批處理)文件,它執行Cygwin的shell。你應該讀得更好。他顯然不希望將其用於腳本編寫,而是將其用作交互式shell。 –

回答

4

要更改您的Cygwin shell,您可以更改/etc/passwd文件。每行都是用戶帳戶的分隔列表,最後一個條目是該用戶的shell。只需更改讀取的行,例如:

abhisek:[some other stuff]:/usr/bin/bash 

到:

abhisek:[some other stuff]:/usr/bin/tcsh 
+0

另請參閱:維基百科的[passwd](http://en.wikipedia.org/wiki/Passwd_%28file%29)文章和http://www.cyberciti.biz/faq/understanding-etcpasswd-file-format/ – Xophmeister

+0

這是正確的,但是在'cygwin.bat'中使用'bash'硬編碼時,它並沒有幫助他執行shell。他需要執行一些東西,檢查他的默認shell(在'passwd'中)並執行它。那是什麼? –

+0

我不確定這是一個問題,因爲Cygwin現在提供了MinTTY,它可以自動完成所有工作。 (同樣,我使用PuTTY。)我想不出爲什麼有人想在Windows命令提示符下使用* sh。 – Xophmeister

2

Cygwin的當前版本不具有/etc/passwd文件文件,並在系統我在我的控制之下,在域數據庫中處理Windows帳戶信息。因此,不再支持chsh

我還發現,慶典是不是硬編碼到startxwin腳本,也不是任何蝙蝠文件有硬編碼。原來你根本不需要撥弄.bat文件。

搜索如何改變我的殼,我發現了一些建議有關mkpasswd

我把它添加到混合物中。

該名男子頁說:

SYNOPSIS 
    mkpasswd [OPTIONS]... 

OPTIONS 
    Don't use this command to generate a local /etc/passwd file, unless you 
    really need one. See the Cygwin User's Guide for more information. 

    -c,--current 
      Print current user. 

    DESCRIPTION 
     The mkpasswd program can be used to create a  /etc/passwd 
    file. Cygwin doesn't need this file,  because it reads user 
    information from the Windows account databases,  but you can add 
    an /etc/passwd file, for instance  if your machine is often dis‐ 
    connected from its domain controller. 

     Note that this information is static, in contrast to the informa‐ 
    tion  automatically gathered by Cygwin from the Windows account 
    databases. If  you change the user information on your system, 
    you'll need to regenerate  the passwd file for it to have the new 
    information. 


     For very simple needs, an entry for the current user can be cre‐ 
    ated  by using the option -c. 

(我不知道爲什麼間距是如此 「關閉」 ...)

然後我用下面的命令:

mkpasswd -c | sed -e'sX/bashX/tcshX'| tee -a/etc/passwd

和瞧!下一次我打開一個Cygwin終端時,它直接去了tcsh

而這就是方式(呃,呃!)我喜歡它。