Skip to content

Commit 8d3f422

Browse files
committed
Add setup script for Windows
1 parent d1debe9 commit 8d3f422

File tree

6 files changed

+111
-0
lines changed

6 files changed

+111
-0
lines changed

Microsoft.PowerShell_profile.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Import-Module Pscx -arg ~\dotfiles\Pscx.UserPreferences.ps1

Pscx.UserPreferences.ps1

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
@{
2+
ShowModuleLoadDetails = $false # Display module load details during
3+
# Import-Module.
4+
5+
CD_GetChildItem = $false # Display the contents of new provider
6+
# location after using cd (Set-LocationEx).
7+
# Mutually exclusive with
8+
# CD_EchoNewLocation.
9+
10+
CD_EchoNewLocation = $true # Display new provider location after using
11+
# cd (Set-LocationEx).
12+
# Mutually exclusive with CD_GetChildItem.
13+
14+
# TextEditor = 'Notepad.exe' # Default text editor used by the Edit-File
15+
# function.
16+
TextEditor = 'C:\Program Files\Sublime Text 2\sublime_text.exe'
17+
18+
PromptTheme = 'Modern' # Prompt string and window title updates.
19+
# To enable, first set the ModulesToImport
20+
# setting for Prompt below to $true.
21+
# Then set this value to one of: 'Modern',
22+
# 'WinXP' or 'Jachym'.
23+
24+
PageHelpUsingLess = $true # Pscx replaces PowerShell's More function.
25+
# When this setting is set to $true,
26+
# less.exe is used to page items piped to
27+
# the More function. Less.exe is powerful
28+
# paging app that allows advanced
29+
# navigation and search. Press 'h' to
30+
# access help inside less.exe and 'q' to
31+
# exit less.exe. Set this setting to $false
32+
# to use more.com for paging.
33+
34+
SmtpFrom = $null # These settings are used by the PSCX
35+
# Send-SmtpMail cmdlet.
36+
SmtpHost = $null # Specify a default SMTP server.
37+
SmtpPort = $null # Specify a default port number. If not
38+
# specified port 25 is used.
39+
40+
FileSizeInUnits = $false # Pscx can prepend format data for the
41+
# display of file information. If this
42+
# value is set to $true, file sizes are
43+
# displayed in using KB,MG,GB and TB units.
44+
}

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
dotfiles
22
========
3+
4+
Windows
5+
-------
6+
7+
Execute setup.bat as Administrator

profile.ps1

Whitespace-only changes.

setup.bat

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@echo off
2+
3+
pushd
4+
cd /d %~dp0
5+
6+
rem Run setup script
7+
powershell -Command if ((Get-ExecutionPolicy) -eq 'Restricted') { Set-ExecutionPolicy RemoteSigned }
8+
powershell -File %~dp0setup.ps1
9+
10+
popd
11+
pause

setup.ps1

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
$originalErrorActionPreference = $ErrorActionPreference
2+
$ErrorActionPreference = 'Stop'
3+
try {
4+
$dotfiles = Split-Path $MyInvocation.MyCommand.Path
5+
6+
# Check PowerShell version
7+
if ($PSVersionTable.PSVersion.Major -lt 4) {
8+
throw 'Please install PowerShell version >= 4.0'
9+
}
10+
11+
'- ヘルプを更新します'
12+
Update-Help
13+
14+
'- PowerShell Community Extensionsをインストールします'
15+
$pscxVersion = '3.1.3'
16+
$pscxUrl = 'http://pscx.codeplex.com/downloads/get/744915'
17+
$pscxPath = 'C:\Program Files (x86)\PowerShell Community Extensions\Pscx3\'
18+
if (!$Env:PSModulePath.Contains($pscxPath)) {
19+
$Env:PSModulePath += ";$pscxPath"
20+
}
21+
22+
if (!(Get-Module -ListAvailable -Name 'Pscx')) {
23+
$msi = Join-Path $Env:TEMP "Pscx-$pscxVersion.msi"
24+
Invoke-WebRequest -OutFile $msi -Uri $pscxUrl
25+
cmd /c msiexec /i $msi /qn
26+
} else {
27+
' * PSCXはインストール済みです'
28+
}
29+
30+
Import-Module Pscx
31+
32+
function MakeLink($literal) {
33+
if (!(Test-Path $literal)) {
34+
$target = Join-Path $dotfiles (Split-Path -Leaf $literal)
35+
New-Symlink $literal $target | % { " * $_ => $target" }
36+
} else {
37+
" * 既に存在します: $literal"
38+
}
39+
}
40+
41+
'- シンボリックリンクを作成します'
42+
MakeLink $Profile
43+
MakeLink $Profile.CurrentUserAllHosts
44+
45+
46+
'* セットアップが完了しました'
47+
48+
} finally {
49+
$ErrorActionPreference = $originalErrorActionPreference
50+
}

0 commit comments

Comments
 (0)