Quantcast
Channel: Bashタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 2914

Windows Terminal で Cygwin Bash を表示したい

$
0
0

Windows Terminalは Build 2019 で発表された Windows 向けの新たなターミナルです。マルチタブが導入されており、複数の PowerShell やコマンドプロンプトなどを切り替えながら利用することができます。また、Windows10 v1809 から Unix / Linux 互換の擬似コンソール ConPTYが導入されたため Bash on Ubuntu on WSL などの Linux シェルを表示することも可能です。せっかくなので Cygwinも利用できるように設定してみました。1

cygwin-bash-on-windows-terminal.png

設定手順

Cygwin での準備

setup-x86_46.exeもしくは apt-cygを利用して Cygwin に chereをインストールします。Mintty で chere -hを実行できればOKです:

$ chere -h
/usr/bin/chere version 1.4

Usage:
/usr/bin/chere -<iuxlrhv> [-lracnmpf12][-t<term>] [-s<shell>]
        [-d<display> ][-o<options>] [-e<menutext>]

Adds the stated terminal/shell combination to the folder context menu
This allows you to right click a folder in Windows Explorer and open
a Cygwin shell in that folder.

Options:
  i - Install
  u - Uninstall
  x - Freshen eXisting entries
  l - List currently installed chere items
  r - Read all chere registry entries to stdout
  a - All users
  c - Current user only
  n - Be Nice and provide Control Panel uninstall option (Default)
  m - Minimal, no Control Panel uninstall
  p - Print regtool commands to stdout rather than running them
  f - Force write (overwrite existing, ignore missing files)
  1 - Start using registry one-liners. This doesn\'t work with ash,
      tcsh or network shares.
  2 - Start via bash script. Relies on windows to change directory,
      and login scripts avoiding doing a cd /home/<username>
  h - Help
  v - Version

  t <term> - Use terminal term. Supported terminals are:
        cmd rxvt mintty xterm urxvt

  s <shell> - Use the named shell. Supported shells are:
        ash bash cmd dash fish mksh pdksh posh tcsh zsh passwd

  d <display> - DISPLAY to use (xterm, urxvt). Defaults to :0.
      Set to env to use the runtime environment variable.

  o <options> - Add <options> to the terminal startup command.
      If more than one option is specified, they should all be
      contained within a single set of quotes.

  e <menutext> - Use <menutext> as the context menu text.

See the man page for more detail.

読んでの通り、特定のフォルダで Cygwin ターミナルを開始するためのユーティリティです。bash.exeを起動するだけでは Cygwin の機能を利用できないため、このツールをインストールしています。

Windows Terminal での設定

  1. PowerShell を起動して適当な GUID を取得します。
[guid]::NewGuid()



2. Windows Terminal を起動し、[ Settings ] から profiles.jsonを開きます。
3. "profiles" : [ { ... } ]の末尾に以下のオブジェクトを追記して保存します。"guid"の値は先ほど取得した GUID に差し替えてください:

profiles.json
{"guid":"{22cbae05-ab97-4c97-a2ea-6feaa2494f7a}","name":"Cygwin","suppressApplicationTitle":true,"commandline":"C:\\cygwin64\\bin\\bash.exe /bin/xhere /bin/bash ~","icon":"C:\\cygwin64\\Cygwin-Terminal.ico","useAcrylic":true,"acrylicOpacity":0.6}



4. 新規タブの選択肢に Cygwinが追加されました!

cygwin-bash-added-selection.png

※ここでは同様の手順で Git Bash も 追加しています。

参考リンク


  1. ちなみに Ansible は Python-pip 導入後に pip からインストールできるほか、setup-x86_46.exeからでもインストール可能です。 


Viewing all articles
Browse latest Browse all 2914

Trending Articles