LoginSignup
0
8

More than 5 years have passed since last update.

追加インストールなしでpowershellのカスタマイズ

Last updated at Posted at 2017-06-17

概要

今までずっとConEmu使ってたけど、純正のpowersehllがプロパティからカスタマイズできることを知って、これConEmuいらなくね?と思い、実行したことをまとめました。
カスタマイズ項目は主に2点
1.カラースキーム(molokai風)
2.フォント(consolasとMS ゴシックのフォントリンク)
完成したカスタマイズをレジストリに保存するスクリプトを作成したので、windowsの再インストール時などはスクリプト実行でカスタマイズを行える。(自己責任でお願いします。)

.regファイルの作成

下記2つの.regファイルを作成する。
.regファイルの文字コードは少し特殊なので、既存のレジストリをregeditからエクスポートし、メモ帳で開いて編集すると楽。

console_config.reg
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Console]
"ColorTable00"=dword:00222827
"ColorTable01"=dword:0035e1a4
"ColorTable02"=dword:005f7174
"ColorTable03"=dword:008f8f8f
"ColorTable04"=dword:00000000
"ColorTable05"=dword:00000000
"ColorTable06"=dword:00000000
"ColorTable07"=dword:00d5ef66
"ColorTable08"=dword:0079dde4
"ColorTable09"=dword:00eed96e
"ColorTable10"=dword:00fd7bb1
"ColorTable11"=dword:0090af36
"ColorTable12"=dword:003b58ec
"ColorTable13"=dword:002a96f9
"ColorTable14"=dword:006b1cf6
"ColorTable15"=dword:00f2f8f8
"CtrlKeyShortcutsDisabled"=dword:00000000
"CursorSize"=dword:00000019
"EnableColorSelection"=dword:00000000
"ExtendedEditKey"=dword:00000001
"ExtendedEditKeyCustom"=dword:00000000
"FaceName"="Consolas"
"FilterOnPaste"=dword:00000001
"FontFamily"=dword:00000000
"FontSize"=dword:000e0007
"FontWeight"=dword:00000000
"ForceV2"=dword:00000001
"FullScreen"=dword:00000000
"HistoryBufferSize"=dword:00000032
"HistoryNoDup"=dword:00000000
"InsertMode"=dword:00000001
"LineSelection"=dword:00000001
"LineWrap"=dword:00000001
"LoadConIme"=dword:00000001
"NumberOfHistoryBuffers"=dword:00000004
"PopupColors"=dword:0000002f
"QuickEdit"=dword:00000001
"ScreenBufferSize"=dword:012c0050
"ScreenColors"=dword:0000000f
"ScrollScale"=dword:00000001
"TrimLeadingZeros"=dword:00000000
"WindowAlpha"=dword:000000e6
"WindowSize"=dword:00190050
"WordDelimiters"=dword:00000000
"CurrentPage"=dword:00000003
fontlink.reg
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink]
"Consolas"="MSGOTHIC.TTC,MS ゴシック"

powersehllのプロファイル作成

powersehllの文字コードがデフォルトのcp932だとconsolasを選択できないので変更する。下記プロファイルを作成する。

my_profile.ps1
chcp 65001
#ほかにも個人的なカスタマイズを記載する。

初期設定スクリプトの作成

上記ファイルを実行するスクリプトを作成。このスクリプトを管理者権限で実行すればカスタマイズ完了です。

init_powersehell.ps1
#my_profileのシンボリックリンクをpshomeに作成
$scriptPath = (Split-Path $MyInvocation.MyCommand.Path -parent)
if(!(test-path $pshome\profile.ps1)){
New-Item -ItemType SymbolicLink -Path $pshome\profile.ps1 -Target $scriptPath\my_profile.ps1
}

reg import fontlink.reg
reg import console_config.reg

カスタマイズが適用されない場合

*regeditでHKEY_CURRENT_USER\Console配下のごみを消すと適用される場合がある。
*powershellはショートカットごとにプロパティが保存されているので、レジストリを書き換える前に作成したショートカットには適用されない。ショートカットを作り直す必要がある。
*ショートカットを作り直しても古いショートカットのプロパティのままの場合がある。これはよくわからない。

0
8
2

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
0
8