LoginSignup
122
120

More than 5 years have passed since last update.

Windowsのターミナル環境を整える vol.1

Last updated at Posted at 2012-12-26

今回は、Windowsのターミナル環境を整える方法を紹介していきたいと思います。

Windows PowerShell 3.0

Windowsはシェルが貧弱という言葉を耳にすることがあります。確かに、cmdは貧弱かも知れませんが、PowerShellはそうでもありません。3.0が来ていますので、導入してみましょう。

Windows 7 64bit
Windows6.1-KB2506143-x64.MSU

Windows 7 32bit
Windows6.1-KB2506143-x86.MSU

Windows Server 2008 64bit
Windows6.0-KB2506146-x64.MSU

Windows Server 2008 32bit
Windows6.0-KB2506146-x86.MSU

インストール出来ない場合

.NET Framework 4がインストールされていない可能性があります。こちらが参考になります。

バージョンの確認

$PSversionTable

Cygwin

Cygwinとは、Windows上に仮想空間のようなものを構築し、Unixコマンドなどを扱えるようにするツールのことです。こちらからダウンロードして、実行ファイルをダブルクリックするのもいいですが、PowerShellでやったほうが簡単なので、以下にスクリプトを記します。ただし、実行ファイルをダブルクリックしてからインストールする場合は、Wgetにチェックを入れておきましょう。

PowerShell
function Install-Cygwin
{
   param ( $TempCygDir="$env:temp\cygInstall" )
   if(!(Test-Path -Path $TempCygDir -PathType Container))
    {
       $null = New-Item -Type Directory -Path $TempCygDir -Force
    }
   $client = new-object System.Net.WebClient
   $client.DownloadFile("http://cygwin.com/setup.exe", "$TempCygDir\setup.exe" )
   Start-Process -wait -FilePath "$TempCygDir\setup.exe" -ArgumentList "-q -n -l $TempCygDir -s http://mirror.nyi.net/cygwin/ -R c:\Cygwin"
   Start-Process -wait -FilePath "$TempCygDir\setup.exe" -ArgumentList "-q -n -l $TempCygDir -s http://mirror.nyi.net/cygwin/ -R c:\Cygwin -P openssh"
   Start-Process -wait -FilePath "$TempCygDir\setup.exe" -ArgumentList "-q -n -l $TempCygDir -s http://mirror.nyi.net/cygwin/ -R c:\Cygwin -P wget"
}
Install-Cygwin

apt-cyg

次に、パッケージマネージャーをインストールしましょう。cygportと並行して使うこともできます。

Cygwin
wget http://apt-cyg.googlecode.com/svn/trunk/apt-cyg

mv apt-cyg  /usr/bin

chmod +x /usr/bin/apt-cyg

zshのインストールから設定まで

Cygwin
apt-cyg install zsh

sed -i 's/bash/zsh/g' /Cygwin.bat

touch ~/.zshrc

/Cygwin.bat

/etc/passwd/Cygwin.batの最後の行あたりにあるbashzshに変更するわけですが、よくわからないという人は、こちらの記事が参考になります。

apt-cyg install vim

vim /etc/passwd /Cygwin.bat

gow

gowはWindows Shell上でUnix的なコマンドを実行できるようにするためのツール群です。

Cygwin
# apt-cyg install curl w3m

curl -L -o Gow.exe https://github.com/downloads/bmatzelle/gow/Gow-0.7.0.exe --insecure

chmod +x Gow.exe

または、

apt-cyg install w3m

w3m https://github.com/bmatzelle/gow/downloads

chmod +x Gow-.0.X.X.exe
Cygwin
cygstart Gow.exe

ちなみに、cygstartは結構役立つコマンドなので、オプションを見てみると面白いかもしれません。例えば、cygstart .でディレクトリをWindowsエクスプローラーで開きます。

gow -l

console 2

consoleは、Windowsで動作するTerminalです。数多くのShellに対応しています。また、設定項目も豊富で、ウィンドウの透過度を設定することもできます。

Cygwin
cd /

w3m http://sourceforge.net/projects/console/

apt-cyg install unzip

unzip hoge.zip

chmod +x hoge

cygstart powershell

すると、PowerShellがWindowsのTerminalで開きます。

PowerShell
mv C:\cygwin/hoge C:\Program Files\

(この操作には、gowが必要かもしれません)

初期設定

表示のズレ

まず、初期設定として重要なのが、表示がズレる現象を回避することです。これは、日本語環境によるものですが、比較的容易に解決できます。

  1. View > Console Window
  2. Alt+Space,P = 右クリック > プロパティ > フォント

  3. Ctrl+S(Setting) > Apperarance > Font

この2箇所でフォントをMSゴシックに変更します。

タブの設定

consoleは、それぞれのシェルをタブで開くことができます。

例えば、Cygwinの場合は、C:¥cygwin¥bin¥bash.exe --login -iです。

また、iconを設定できますが、IconsExtractを使うと実行ファイルから簡単に取得することができます。

Cygwin
wget http://www.nirsoft.net/utils/iconsext.zip

unzip iconsext.zip

chmod +x iconsext.exe

cygstart iconsext.exe

スキャンすべきパス
c:¥Windows¥System32¥
c:¥Program Files¥

NYAOS

Windowsで使えるシェルでお勧めなのは、NYAOSです。日本語、Unixに強いので便利に使えると思います。

Cygwin
w3m http://www.nyaos.org/index.cgi?p=NYAOS+3000

unzip hoge.zip

chmod +x hoge.exe

最後に

Windowsのターミナル環境を整える vol.2を書きましたのでよろしくお願いします。

122
120
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
122
120