移転ãã¾ãã
ãã®ãµã¤ãã¯ç§»è»¢ãã¾ããã
WSL ä¸ã§ macOS ã® open ã³ãã³ãã®ãããªæå
alias open="pwsh.exe /c start"
pwsh.exe ãå ¥ãã¦ãªã人ã¯
alias open="powershell.exe /c start"
ããã¨ãopen foobar
ãããæãã«éãããã
# explorer ãéã open . # ããã©ã«ããã©ã¦ã¶ãéã open https://example.com/ # jpg ã«é¢é£ä»ãããã¦ãããã¥ã¢ã¼ã§éããã open ./foo.jpg
MacOS ã¦ã¼ã¶ã WSL ã§ã¯ç¡ã Windows ã®ã³ã³ã½ã¼ã«ç°å¢ãæ´ãã
å æ¥ãã¡ã¤ã³ã®éçºç°å¢ã MacOS ãã Windows 10 Professional ã¸ã¨ç§»ãã¾ãããçç±ã¨ãã¦ã¯ä¸»ã«2ç¹ã§ãç¾å¨ä»äºãèªå® ã®åºå®å¸ã§è¡ã£ã¦ãã PC ãæã¡éã³ããå¿ è¦ããªããªã£ããã Mac ããé«éã§å®ä¾¡ãª Windows ãã¹ã¯ãããæ©ã使ããããã¨(Ryzen 9使ããã!)ãWSL2 ãæ£å¼çã¨ãªã使ã£ã¦ã¿ãæãåé¡ãªã WSL2 ã§ä»äºã®éçºãã§ãããã ã£ããã¨ãæãããã¾ãã
WSL2 ã¯ãµã¤ãã« Linux ãªã®ã§åé¡ãªãéçºç°å¢ã®æ§ç¯ãè¡ãªããWindows ããã VSCode Remote ã®ãããã§ã§éåæãªãWSL2ä¸ã®ã³ã¼ããç·¨éãå®è¡ãã§ãå¿«é©ãªéçºãè¡ãã¦ãã¾ãã(ãªããWSL2 ã«ã¤ãã¦ã®è¨äºã¯å±±ç¨æº¢ãã¦ããã®ã§ãããã§ã¯æ®ã©è§¦ãã¾ããã)
ããããªãããWSL2 ã§ã¯ãªããµã¤ãã® Windows ä¸ã§éçºããæ©ä¼ãåºã¦ããã®ã§ãMacOS ã Linux ã®ã³ã³ã½ã¼ã«ã«æ £ããèªåã§ããå¿«é©ã«æä½ã§ãã Windows ã®ã³ã³ã½ã¼ã«ç°å¢ãæ´ãã¦ã¿ã¾ããã
ãã£ããã¨ããã¨
- ã·ã§ã«
- bash/zsh ãã PowerShell Core ã¸
- ã¿ã¼ããã«
- Terminal.app ãã WindowsTerminal ã¸
- ããã±ã¼ã¸ããã¼ã¸ã£
- Homebrew ãã Scoop ã¸
ãå©ç¨ãã¦ãã¾ãã
Windows éçºã«æ
£ãã¦ããªããããæ
£ãã¦ãã人ãªããã解ãã§ãããããã Windows ã§ã©ããããã ããï¼ãããããããã¾ã PowerShell ã§ã®æä½ã«ãå
¨ãæ
£ãã¦ããªãããããã¤ãã® bash/zsh ã ã¨ããã§ãããã ãã©ãªããã¨ããã®ãå½åã¯ãããã大å¤ã§ããã.bashrc
çãªãã®ã¯ä½ï¼ãã$HOME ã®ãããªç°å¢å¤æ°ã¯ä½ï¼ã©ãï¼ãªã©ãªã©ãããããªãã使ã£ã¦ã¿ãã¨å²ã¨æ©ãã«æ
£ãããã¨ãã§ãã¾ããã
ã¾ããé·ãã群éå²æ ç¶æ ã ã£ããWindows ã®ã¿ã¼ããã«ã Microsoft ã謹製㮠WindowsTerminal ãåºãããã¨ãããå¤æ©è½ã§ã¯ãªãããã©æ®ã©ã®å ´åã«ããã¦å¿ è¦ååãªã¿ã¼ããã«ãæ°è»½ã«ä½¿ããæãã«ãªã£ãã¨æãã¾ãã
ããã¦ããã±ã¼ã¸ããã¼ã¸ã£ã® Scoopã5å¹´åã«ä¸åº¦ Windows ã®éçºç°å¢ãä½ã£ãã¨ãã¯ãChocolatey ãã¡ã¤ã³ã®ããã±ã¼ã¸ããã¼ã¸ã£ã¨ãã¦ä½¿ã£ã¦ããã®ã§ãããããã±ã¼ã¸ã®ã¤ã³ã¹ãã¼ã«ã«ç®¡çè 権éãåºæ¬å¿ è¦ã§ãã¾ãç»é²ããã¦ããããã±ã¼ã¸ããããªã«ãªãâ¦ã¨ããæãã ã£ãã®ã§ãããScoop ã¯éè¯ããã±ã¼ã¸å«ãæ§ã ãªããã±ã¼ã¸ãããããããããªãã®ããµã¯ãã¨å ¥ããããã¾ã管çè 権éãå¿ è¦ã¨ããã«ããã±ã¼ã¸ãå ¥ããããã®ãå¬ããã§ããã
ã¨ããããã§ãæ¬è¨äºã§ã¯ãããã使ããå°ããã¤ããã±ã¼ã¸ãå ¥ãã¦ãããéçºç°å¢ãæ´ãã¦ããã¾ãããªãOSã®ç°å¢ã¯ Windows 10 Professional ãã¼ã¸ã§ã³ 2004 (ãã«ã 19041) ã§ãã
Scoop ã®ã¤ã³ã¹ãã¼ã«
ãªã«ã¯ã¨ããã Scoop ã®ã¤ã³ã¹ãã¼ã«ã§ããScoop 㯠PowerShell(以ä¸PS) ã®ã¿ãªãã cmd.exe ã§ã使ããããã±ã¼ã¸ããã¼ã¸ã£ã§ããå ¥ããããã±ã¼ã¸ã«ã¯ Path ãéãã®ã§ãWSL2 å´ãããå©ããããã§ãã¾ãã
PowerShell ãç«ã¡ä¸ãã¦ã
# ãã¼ã«ã«ã¹ã¯ãªããã®å®è¡ããªã·ã¼ã®è¨±å¯ $ Set-ExecutionPolicy RemoteSigned -Scope CurrentUser # https://get.scoop.sh ããã¦ã³ãã¼ããã¦æååã¨ãã¦è©ä¾¡ãã¦å®è¡ãããã¨ã§ã¤ã³ã¹ãã¼ã«ããã # Invoke-Expression 㯠eval ã®ãããªãã®ã $ Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
ã§ã¤ã³ã¹ãã¼ã«å®äºã§ãããã㧠PS ã§ã cmd.exe ã§ã scoop ã³ãã³ãã使ããããã«ãªããä¾ãã°
$ scoop install git vim neovim nvs ruby wget curl
ãªã©ã§ã¬ãã¨ããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«ãããã¨ãã§ãã¾ãã
PowerShell Core ã®ã¤ã³ã¹ãã¼ã«
ä»æå ã§ç«ã¡ä¸ãã¦ãã PowerShell ã¯ãã¼ã¸ã§ã³5ã§ãv6 ããã¯ã¯ãã¹ãã©ãããã©ã¼ã ã® Linux, MacOS çã§ãåã PowerShell Core ã¨ããæ°ãããã®ã«ãªã£ã¦ã¾ããPowerShell v5 ã§ã¯èµ·åæã«
æ°ããã¯ãã¹ãã©ãããã©ã¼ã ã® PowerShell ãã試ããã ãã https://aka.ms/pscore6
ãªã¡ãã»ã¼ã¸ã表示ããã¦ã¾ãããPS ã®å®è¡ããã°ã©ã åãå¥ç©ã§ã powershell.exe ã ï½v5ãpwsh.exe ã v6 以éã® PowerShell Core ã§ããã¨ãããæã® PS ã使ããªãã¨ãã¾ãè¡ããªãã±ã¼ã¹ã¯ãæ°è¦ã« Windows ã«éçºç°å¢ãæ´ããå ´åã»ã¼ç¡ãã¨æãã®ã§ãææ°ã® v7 ãå ¥ãã¾ãããã
æ©éãscoop ã§ææ°ã®ãã¼ã¸ã§ã³ã® PowerShell Core ( pwsh.exe ) ãå ¥ãã¾ãã
$ scoop install pwsh $ scoop which pwsh ~\scoop\apps\pwsh\current\pwsh.exe
scoop ã¯ã¦ã¼ã¶ã®ãã¼ã ãã£ã¬ã¯ããª(PS ã§ã¯ç°å¢å¤æ° $env:USERPROFILE
ã§ãLinux ã«ããã $HOME çãªãã®) 以ä¸ã«ã¢ããªã±ã¼ã·ã§ã³ãã¤ã³ã¹ãã¼ã«ãããããã¤ã³ã¹ãã¼ã«ã«ç®¡çè
権éã¯å¿
è¦ãªãã§ãã
ãã㧠powershell.exe ãã pwsh ã¨æã¡è¾¼ãã§ãç«ã¡ä¸ããã¾ãããWindows å·¦ä¸ã®ã¿ã¹ã¯ãã¼æ¤ç´¢ããã¯ã¹ãã PowerShell Core ãªã©æã¡è¾¼ãã§ãç«ã¡ããã¾ã*1ããç«ã¡ä¸ããã¨å ã»ã©ã¨ã¯ãã¼ã¸ã§ã³ãç°ãªã PS ãç«ã¡ä¸ããã§ããããä»å¾ã¯ãã¡ãã® PS Core ã§ä½æ¥ããã¦ããã¾ãã
PS ã® CUI ä¸ã§åããã¨ãã£ã¿å ¥ãã
PS ã® CUI ä¸ã®ã¨ãã£ã¿ã§ãã¡ã¤ã«ãç·¨éãããããããªã¨ã㯠vim ãå ¥ãã¾ãããã
$ scoop install vim $ vim hello.txt
vim ã§ãªã VSCode ã«æ £ãã¦ãã人ã¯
$ code hello.txt
ã§(CUIã§ã¯ãªãã§ãã) VSCode ã§ç·¨éããã®ãããã§ãããã
Windows Terminal ã®ã¤ã³ã¹ãã¼ã«
ç¶ã㦠Windows Terminal (ä»¥ä¸ WT ) ãå ¥ãã¾ãããããã¡ãã scoop ã§ã¤ã³ã¹ãã¼ã«ãã¾ããWindows Terminal ã¯ããã©ã«ãã§å©ç¨ã§ãã scoop ã® main ãã±ããã«ã¯ãªããextras ãã±ãã(主㫠extras ãã±ããã«ã¯ GUI ã¢ããªã±ã¼ã·ã§ã³ãå«ã¾ãã¾ããHomebrew ã«ããã cask ã®ãããªæè¦)ãã«ããã®ã§ãextras ãã±ããã追å ãã¦ã¤ã³ã¹ãã¼ã«ãã¾ãã
ã¾ã bucket ã®è¿½å ãæ´æ°ã« git ãå¿ è¦ãªã®ã§ããã®ã¿ã¤ãã³ã°ã§ git ãå ¥ãã¦ãã¾ãã¾ãã
$ scoop install git $ scoop search windows-terminal 'extras' bucket: windows-terminal (1.1.2021.0) $ scoop bucket add extras $ scoop install windows-terminal
ã§ã¤ã³ã¹ãã¼ã«ããã¾ããããã㧠WindowsTerminal.exe ãå®è¡ããã¨ç«ã¡ä¸ããã¾ããããªãããã® scoop ã§å ¥ãã WindowsTerminal 㯠GitHub ã§å ¬éããã¦ããææ°çã§ãMicrosoft Store ããæä¾ããã¦ãããã¼ã¸ã§ã³ã¨ã¯ç°ãªã(Storeã®ã»ããç¾å¨å¤ãã§ã)ã®ã§ããã¡ãã®ãã¼ã·ã§ã³ã使ãããæ¹ã¯ MS Store ããã¤ã³ã¹ãã¼ã«ãã¦ãè¯ãã§ãããã
Windows Terminal ãç«ã¡ä¸ããï¼
ã®é£ã®â
ã®ãããªãã¿ã³ãããPowerShell Coreããé¸ã¶ãã¨ã§ãPSCore ã§ã¿ããèµ·ã¡ä¸ãããã¾ãã
Windows Terminal ã®è¨å®ã§ãPS Core ãããã©ã«ãã«
æ¨æºã§ Windows Terminal ã§ç«ã¡ä¸ããã·ã§ã«ã¯ç°å¢ã«ãã£ã¦ç°ãªãã®ã§ãPS Core ãããã©ã«ãã«ãã¾ããããCtrl-, ã§è¨å®ã JSON ãã¡ã¤ã«ã§éãããã®ã§ã好ããªã¨ãã£ã¿ã§ç·¨éãã¾ãã
// ããã©ã«ãã PS Core ã® GUID ã«å¤æ´ "defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}", // ... "list": [ // list ã®è¦ç´ ãã¨ã« guid ã¯ã¦ãã¼ã¯ãªã®ã§ãå¥ã®è¨å®ã¨ãã¶ã£ã¦ãããåé¤ãã { "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}", "hidden": false, "name": "PowerShell Core", // https://github.com/PowerShell/PowerShell/issues/11314 // ããã»ã¹ã®èµ·åæéãé·ã㨠Ctrl-C ã§ç«¯æ«ãã¨çµäºãããã // source ãã³ã¡ã³ãã¢ã¦ããã¦ãcommandline ããã«ãã¹ã§è¨è¿° // "source": "Windows.Terminal.PowershellCore" "commandline": "%USERPROFILE%\\scoop\\apps\\pwsh\\current\\pwsh.exe", "startingDirectory": "%USERPROFILE%" },
ãªããããããã¦ãã¦ã¨ãã¦ãscoop ã§å ¥ãã pwsh.exe ã§ã¯ Ctrl+C ãæ¼ãã¨èµ·åæéãé·ãããã»ã¹ã¯ç«¯æ«ãã¨çµäºãã¦ãã¾ãããããããåé¿ãããã commandline ã«ãã«ãã¹ãæå®ãã¦ãã¾ãã
.bashrc ç㪠profile.ps1 ãç·¨éãã
ãã¦ããã㧠WT ä¸ã§ PS Core (pwsh.exe) ã使ããããã«ãªãã¾ãããç¶ã㦠PS ãç«ã¡ä¸ããã¨ãã«èªåã§èªã¿è¾¼ã¾ããã .bashrc
çãªãããã¡ã¤ã«ãã¡ã¤ã«ãç·¨éãã¾ãããã
ãã®ãããã¡ã¤ã«ã®ãã¡ã¤ã«ã¯å ¨é¨ã§4ã¤ããã¾ãã
$ echo $PROFILE.AllUsersAllHosts $ echo $PROFILE.AllUsersCurrentHost $ echo $PROFILE.CurrentUserAllHosts $ echo $PROFILE.CurrentUserCurrentHost
ãã®ä¸ã§ãããã®ãã·ã³ã®ãã®ã¦ã¼ã¶ã®ã¿ãã®ãã¡ã¤ã«ã«å½ããã$PROFILE.CurrentUserCurrentHost ã«è¨å®ã追å ãã¦ããã¾ãã
ç´æ¥
$ vim $PROFILE.CurrentUserCurrentHost
ã¿ããã«ãã¡ã¤ã«ãç·¨éãã¦ãè¯ãã§ãããè¨å®ãã¡ã¤ã«ã git ã Dropbox ã§ç®¡çãã¦ãã人ã¯ã.
dot sourcingã使ã£ã¦ãå¥ãã¡ã¤ã«ãèªã¿è¾¼ã¿å½¢ã«ãã¦ãè¯ãã§ãããã
ç§ã¯ OneDrive ã§ç®¡çãã¦ããã®ã§
. $env:USERPROFILE\OneDrive\development\powershell\user_profile.ps1
ã¨ãOneDrive 以ä¸ã« user_profile.ps1 ãã¡ã¤ã«ãä½ã£ã¦ãããã¤ã $PROFILE.CurrentUserCurrentHost ããèªã¿è¾¼ãããã«ãã¦ãã¾ãã
$ Add-Content -Value "`r`n. $env:USERPROFILE\OneDrive\development\powershell\user_profile.ps1`r`n" -Encoding utf8 -Path $Profile.CurrentUserCurrentHost
ãªã©ã¨æã£ã¦ããã¡ã¤ã«ãä½æ(追è¨)ãã¦ãè¯ãã§ãããããã㧠bashrc çãªèµ·åæã«èªã¿è¾¼ã¾ãããããã¡ã¤ã«ãç·¨éããæºåãã§ãã¾ãããã
oh-my-posh 㧠PS ã®è¦ãç®ãããæãã«ãã
ãã¦ãããããã·ãã¯ãªè¦ãç®ã«é£½ãã¦ããã¨æãã®ã§ãè¯ãæãã®è¦ãç®ã«å¤æ´ãã¾ãããã
oh-my-posh ã¨ãããoh-my-zsh ã®ãããªãããæãã®è¦ãç®ã«ãã¦ãããã©ã¤ãã©ãª(ã¢ã¸ã¥ã¼ã«)ãããã®ã§ãããã¤ã³ã¹ãã¼ã«ã¾ããããã¾ã posh-git ã¨ãããgit ã®ç¶æ ãåå¾ã§ããPSã¢ã¸ã¥ã¼ã«ãè¦æ±ããã®ã§ã両æ¹å ¥ãã¾ãã
ãªããoh-my-posh ã posh-git ã scoop ããå ¥ããããã®ã§ããã両æ¹ã¨ã PowerShell Gallery ã«ç»é²ããã¦ããããã¤oh-my-poshã®ãµã¤ãã«ã PS Gallery ããã®ã¤ã³ã¹ãã¼ã«æ¹æ³ãæ¸ãã¦ãããããä»å㯠PS Gallery ããå ¥ãã¾ãã
$ Install-Module posh-git -Scope CurrentUser $ Install-Module oh-my-posh -Scope CurrentUser
Install-Module ã³ãã³ãã¬ããã§å ¥ãããã¨ãã§ãã¾ãããªããã¾ã NuGet ãå ¥ã£ã¦ããªãå ´åã¯ããããã¤ã³ã¹ãã¼ã«ãããå°ããããã¨æãã®ã§ã¤ã³ã¹ãã¼ã«ãã¾ãããã
ç¶ã㦠pwsh.exe ã使ã£ã¦ãå ´åã¯ãPSReadLine ã® 2.0.0 (ç¾å¨ã¯Î²ç) 以éãå¿ è¦ãªãã
$ Install-Module -Name PSReadLine -AllowPrerelease -Scope CurrentUser -Force -SkipPublisherCheck
ã§ææ°ã® PSReadLine ã®ãã¼ã¿çãã¤ã³ã¹ãã¼ã«ãã¾ãã
ããã§ãPS ä¸ã§
$ Import-Module posh-git $ Import-Module oh-my-posh $ Set-Theme Paradox
ã¨æã¤ã¨ããã¼ããåãæ¿ãããã¨ãã§ãã¾ããã¾ããGet-Theme
ã§ãã¼ãä¸è¦§ãè¦ããã¨ãã§ããã®ã§ã好ã¿ã®ãã¼ããè¦ã¤ã ããã.bashrc ç㪠profile.ps1 ã«è¨å®ãè¨è¿°ãã¾ãããã
Import-Module posh-git Import-Module oh-my-posh Set-Theme robbyrussell # ã好ããªãã¼ã
$ vim $PROFILE.CurrentUserCurrentHost ããã㯠$ vim $env:USERPROFILE\OneDrive\development\powershell\user_profile.ps1
ãã¡ã¤ã«ã®ç·¨éå¾ã¯ã. $PROFILE.CurrentUserCurrentHost
ã PS ä¸ã§æã¤ãã¨ã§è¨å®ãåæ ã§ãã¾ããããªãããã¼ãã«ãã£ã¦ã¯ Powerline Font ã使ã£ã¦ãã¦ãã¾ã表示ãããªãæåãããã¾ããããããã®ãã©ã³ãè¨å®ã¯å¾ã»ã©è¡ãã¾ãã
bash (Emacs) 風ãã¼ãã¤ã³ãã«ãã
PS ã§æä½ããã¦ããã¨ãä¾ãã° Ctrl-a ãé¸æã«ãªã£ããã¨ãbash ã¨ã®æä½ã®éãã«æ¸æãã¾ããããããªãããPSReadline ã®ãªãã·ã§ã³ãå¤æ´ãããã¨ã§ãbash (Emacs) 風ãã¼ãã¤ã³ãã«å¤æ´ã§ãã¾ãã
ã¤ãã§ã« Bell ç ©ãã®ã§æ¶ãã®ã¨ãCtrl+d ã DeleteCharOrExit (ç½ ã½ãâ¦)ãã DeleteChar ã«ãã¦ãã¾ãã¾ãããããããã¡ã¤ã«ã«è¨è¿°ãã¾ãã
Set-PSReadLineOption -EditMode Emacs Set-PSReadLineOption -BellStyle None # æ¨æºã 㨠Ctrl+d 㯠DeleteCharOrExit ã®ããããã£ãã端æ«ãçµäºãããã¨ãé²ã Set-PSReadLineKeyHandler -Chord 'Ctrl+d' -Function DeleteChar
ãã㧠bash ã½ãæãã®ãã¼ãã¤ã³ãã®ãªãã¾ããC-r ãªã©ã®Historyå±¥æ´æ¤ç´¢ãåé¡ãªã使ãã¾ãããã¾ããã®ãªãã·ã§ã³ãæå®ããã¨ãTab ã§ã®è£éé¢æ°ãå¤ãã£ã¦ããã¡ãã bash ã½ãè£å®ã«ãªãã¾ãã
$ Get-PSReadLineKeyHandler -Key Tab Completion functions ==================== Key Function Description --- -------- ----------- Tab Complete Complete the input if there is a single completion, otherwise complete the input with common prefix for al l completions. Show possible completions if pressed a second time.
ãªãä»ã«ããMenuComplete ãªã¡ãã¥ã¼UIã§ã®è£å®é¢æ°ã®å®è£ ãããã®ã§ã好ã¿ã«åããã¦åãæ¿ãã¾ãããã
# EditMode Emacs æ¨æºã®ã¿ãè£å® Set-PSReadLineKeyHandler -Key Tab -Function Complete # ã¡ãã¥ã¼è£å®ã«å¤æ´ Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete
ãªããPSReadLine 㯠PS ã®ã«ã¹ã¿ãã¤ãºã§ãã使ã ( Set-PSReadLineKeyHandler ã§ãã¼ãã¤ã³ãã好ããªç¨ã«ããã) ã®ã§ãPSReadLineã®ããã¥ã¡ã³ã ã®ä¸èªããããããã¾ããMS ã¯ããã¥ã¡ã³ãããã£ãããã¦ãæããã¾ããã
ã¡ãªã¿ã«ãã³ã¬ç³»ã® PS ã³ãã³ãã¬ãã㯠-?
ã§å¼æ°ãã«ããè¦ããã¨ãã§ãã¾ãã-h
ãããªãã®ã§æ³¨æãã¾ã Get-Help Set-PSReadLineKeyHandler -Online
ã¨ããæã㧠Get-Help commandlet -Online
ã¨æã¤ã¨ãªã³ã©ã¤ã³ããã¥ã¡ã³ããï¼ããã°ï¼ãã©ã¦ã¶ã§éãããã®ã§ããã¡ãã§è©³ç´°ãèªããããã¾ãã
git å¨ãã®è¨å®
ãã¦ãç¶ã㦠git å¨ãã®è¨å®ã§ãã
git+ssh å¨ãã®æä½ã®ããã«ãç°å¢å¤æ° GIT_SSH ã« windows ã® OpenSSH ãæå®ãã¾ããPS ä¸ã§å©ç¨ããç°å¢å¤æ°ãªã©ãã.bashrc ã«è¨è¿°ãããããªæãã§ãããã£ã¼ã«ã«æ¸ãã¾ããããPS ã§ã®ç°å¢å¤æ°ã¯ $env:XXX
ã¨ãªãã¾ãã
$env:GIT_SSH = "C:\WINDOWS\System32\OpenSSH\ssh.exe"
ssh ã®éµé¢ä¿ã¯ãµã¤ãã« ~/.ssh/ ã«ä½ãã¾ããããã§åé¡ãªããã¾ããããã¨æããã ssh-agent ã使ã£ã¦ããã¨
warning: agent returned different signature type ssh-rsa (expected rsa-sha2-512)
ã¨ãã warning ãåºããã¨ãããã¾ãããã® warn 㯠Windows å梱㮠ssh ã§ã¯ã¾ã æ²»ã£ã¦ããããææ°ã® MS ãæä¾ãã¦ãã Win32-OpenSSH ã§ã¯æ²»ã£ã¦ããããªã®ã§ãwarning ãåºãå ´åã¯ãã¡ããå ¥ãã¾ãããã
$ scoop install win32-openssh ... Run 'sudo C:\Users\username\scoop\apps\win32-openssh\current\install-sshd.ps1' to install sshd and ssh-agent as a service. # âã³ãã³ããå®è¡ãã¦ãµã¼ãã¹ãç»é²ããããã«ãsudo ãå ¥ãã $ scoop install sudo # ssh-agent ããµã¼ãã¹ã«ç»é²ãã $ sudo ~\scoop\apps\win32-openssh\current\install-sshd.ps1
ãã¨ã¯ãssh-agent
ã使ããããã«ãWindows ãµã¼ãã¹ã®ãOpenSSH Authentication Agentããèªåèµ·åããããã«ãã¦ããã¾ããã(ä¸è¨ã³ãã³ãã¯ãµã¼ãã¹ã«ç»é²ãããã ãã§ãèªåèµ·åã¯ããã¾ãã)ãããã§ãgit (+ssh) + ssh-agent å¨ããåé¡ãªãå©ç¨ã§ããããã«ãªãã¯ãã§ãã
sudo ãå ¥ãã
ããã¦ã¤ãã§ãã¨ãã£ã¦ã¯ãªãã§ãããä¸è¨è¨å®æã« scoop install sudo
㧠sudo
ãå
¥ãããããPS ã cmd.exe ã§ä½¿ãæ
£ãã sudo ã³ãã³ãã使ã£ã¦ç®¡çè
権éã§å®è¡ã§ããããã«ãªãã¾ããããã£ãï¼
ã·ã³ããªãã¯ãªã³ã¯ã使ã
ç¾å¨ãWindows ã§ã¯ä¸è¬ã¦ã¼ã¶ã¯ã·ã³ããªãã¯ãªã³ã¯ãæ¨æºã§ã¯ä½¿ãã¾ããããã®ãããgit clone ã§è½ã¨ãã¦ããã½ã¼ã¹ã® symlink ããã¾ãåããå°ãã±ã¼ã¹ãããã¾ãã
ã® 'Allowing non-administrators to create symbolic links' ã§æ¸ããã¦ããæ¹æ³ã§ symlink 許å¯ãè¡ããããã«ããããWindows ã®ãéçºè ã¢ã¼ãããæå¹åããå¿ è¦ãããã¾ããç§ã¯ãéçºè ã¢ã¼ããã®å½±é¿ç¯å²ãã¡ããã¨ææ¡ãã¦ãªãããããã¼ã«ã«ã°ã«ã¼ãããªã·ã¨ãã£ã¿ ( gpedit.msc )ã§èªåã®å©ç¨ã¦ã¼ã¶ã« symlink 許å¯ã追å ãã¦ãã¾ãã
ããã«å ãã~/.gitconfig ã«
[core] symlinks = true
ã追å ãããã¨ã§ãgit clone æã«ãã¾ã symlink ãåãããã«ãªãã§ãããããªã git-for-windows ã®ããã¥ã¡ã³ãã®éãããã¡ã¤ã«ã·ã¹ãã ã NTFS ã§ãªã㨠symlink ã¯ãã¾ãä½æã§ããªãã®ã§æ³¨æã§ããã¾ããOS ã Windows 10 Home ã¨ãã£ã·ã§ã³ã®å ´åã¯ãã°ã«ã¼ãããªã·ã¨ãã£ã¿çã使ããªãã®ã§ãããPolsedit ã使ããã¨ã§åçã®è¨å®ãã§ããããã§ã(æªç¢ºèª)ã
GitHub ã®ã½ã¼ã¹ã³ã¼ãã ghq + fzf (peco) ã§ãµã¯ãã¨è½ã¨ãããã£ã¬ã¯ããªã®ç§»åãããã
å人çã«éçºæã«ææ¾ããªããã¼ã«ã¨ãã¦ãghq 㨠fzf (ããã㯠peco) ã®å©ç¨ãæãããã¾ããghq ã§ãã¼ã«ã«ã« github ã®ã½ã¼ã¹ã³ã¼ããè½ã¨ãã¦ãã¦ãfzf (ã peco) ã§ãµã¯ãã¨ãã£ã¬ã¯ããªç§»åãã¦ã½ã¼ã¹ã³ã¼ãé²è¦§ã»ç·¨éãããã®ã§ãã
ã¾ãã¯å種ãã¼ã«ã®ã¤ã³ã¹ãã¼ã«ã§ãã
$ scoop install fzf ghq # ð ã好ã¿ã§ãç§ã¯ ghq ã§è½ã¨ããã½ã¼ã¹ã³ã¼ãã ~/src ã«ç½®ãã¦ãã¾ãã $ git config --global ghq.root ~/src
ãã㧠ghq +fzf ã§ã®ãã£ã¬ã¯ããªç§»åããPS ç°å¢ã§ããã£ããªãã»ã©åé¡ãªã使ãã¾ããï¼
$ ghq get https://github.com/x-motemen/ghq $ cd "$(ghq root)\$(ghq list | fzf)"
ãã㧠github ã®ã½ã¼ã¹ã³ã¼ããã£ã¬ã¯ããªã¸ã®ç§»åããã¡ã楽ã«ãªãã¾ãããç¶ãã¦ãé·ãã³ãã³ããæã¡ãããªãã®ã§ã cd "$(ghq root)\$(ghq list | fzf)"
ãçãã¿ã¤ãã§æã¦ãããã«ç»é²ãã¾ãã
function gf { cd "$(ghq root)\$(ghq list | fzf)" }
ãã㧠PS ä¸ã§ gf
ã³ãã³ããå®è¡ã§ããããã«ãªãã¾ããããªããããã§ã¯ ghq list | fzf
ã®ãã£ã³ã»ã«æã«ã cd ããã¦ãã¾ããããããã¡ãã£ã¨ã¾ã¨ããªé¢æ°ã«ãã¾ãã
function gf { $path = ghq list | fzf if ($LastExitCode -eq 0) { cd "$(ghq root)\$path" } }
bash ã«æ
£ãã¦ãæ¹ã¯ããããalias ãããªãã®ï¼ã¨æãããã§ãããããPS ã® alias (Set-Alias / Get-Alias) ã¯ãå¼æ°ãªãã®åç´ãªã¨ã¤ãªã¢ã¹ã«ã¯ä½¿ããã®ã§ãããè¤æ°ã³ãã³ããçµã¿åãããããå¼æ°ãããå ´å㯠function ã¨ãã¦ç»é²ãã¾ããä»ã«ããä¾ãã° ghq ã --shallow å¼æ°ä»ãã§å¼ã³åºããã ghg
ã³ãã³ãã追å ãããå ´å
function ghg { ghq get --shallow $args }
ãªã©ã§ $args
ã使ãã¤ã¤ç»é²ãã¾ããä»ã«ãæ¨æºå
¥åã示ã $input
ã /dev/null ã«ããã $null
çã
ã表ãå®æ
ãå¤æ°èªä½ã¯éãã©ãsh ã¨åçã®äºãã§ãããã®ãããã¤ãããã¾ããããã㨠function ã®ç»é²ããã¾ã使ãã°ãbash ã§ã® alias ã§ã®ããããããã¨ã®å¤§åã¯ã§ããããã«ãªãã§ãããã
é¢æ°ã®åä½ã確èªãã¦åé¡ããªãã£ããããããã£ã¼ã«ã«ãããã®é¢æ°ãæ¸ãè¾¼ããã¨ã§ãPS èµ·åæãããããã®ã³ãã³ãã使ããããã«ãªãã¾ãã
cd ãããã£ã¬ã¯ããªå±¥æ´ã« fzf ã§ç§»åããã
ããä¸ã¤ãç§ããã使ã£ã¦ãããã®ã¨ãã¦ã移åãããã£ã¬ã¯ããªã®å±¥æ´ã« fzf 㧠cd ãããã¨ã§ãããããããã«ã¯ãcd ãããã©ããã«å±¥æ´ãä¿åããå¿ è¦ãããã®ã§ããããããããæãã«ãã£ã¦ããã PS Module ã® ZLocation (z ã³ãã³ãã使ããï¼)ãããã®ã§ã¤ã³ã¹ãã¼ã«ãã¾ãããã
Install-Module ZLocation -Scope CurrentUser
ãã®å¾ããããã£ã¼ã«ã§ã¢ã¸ã¥ã¼ã«ãèªã¿è¾¼ã¿ã¾ãã
# oh-my-posh ã®èªã¿è¾¼ã¿å¾ã«è¨è¿°ããªãã¨ãã¾ãåããªããã Import-Module ZLocation
ããã§ãcd ããã¨ãã¼ã¿ãã¼ã¹ã«æ¸ãè¾¼ã¾ã z
ã³ãã³ãã§å±¥æ´ä¸è¦§ã表示ããã¾ãããã®åºåãå
ã« fzf ã§çµãè¾¼ã㧠cd ããããã㪠function ãæ¸ãã¦ããã¡ããè¯ãã®ã§ãããPSFzf ã¨ãã fzf 㨠PS ãããæãã«ã¤ãªãè¾¼ãã§ãããã©ã¤ãã©ãªãããã®ã§ããã¡ããå
¥ãã¾ãã
Install-Module PSFzf -Scope CurrentUser
ããã¨ãInvoke-Fuzzy* 系㮠Function ã使ããããã«ãªãããã®ä¸ã« Invoke-FuzzyZLocation
é¢æ°ããããZLocation ã®å±¥æ´ã®ãªã¹ãã« cd ãã§ãã¾ããä»ã«ã Invoke-Fzf ( | fzf
ãä¾å¤å¦çããããæåã¨ã³ã³ã¼ãã£ã³ã°ã¾ããå¦çãããã¨ãããããæãã«ã§ãã)ããInvoke-FuzzyKillProcess (ããã»ã¹ãªã¹ããã kill )çã
ãããã®ã§ã便å©ã«å©ç¨ã§ãã¾ããã
PS ã®ãã¼ãã¤ã³ãã§ãfzf ã¾ããã®é¢æ°ãå¼ã³åºããã
ãã¦ãå
ç¨ã® gf é¢æ°ã ã£ãããInvoke-FuzzyZLocation ã ã£ããããã¼ãã¤ã³ãã§ç«ã¡ä¸ãããã§ãã(bash ã«ããã bind, zsh ã«ããã bindkey)ãç§ã¯ bash/zsh ã§ã¯ Ctrl-]
ã Ctrl-;
㧠fzf é¢ä¿ã®ã³ãã³ããç«ã¡ä¸ããããã«ãã¦ããã®ã§ãããã PS ã§ãã»ãããã¦ã¿ã¾ãã
# å®è¡å¾å ¥åå¾ ã¡ã«ãªããããAcceptLine ãå®è¡ãã Set-PSReadLineKeyHandler -Chord 'Ctrl+]' -ScriptBlock { gf; [Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine() } Set-PSReadLineKeyHandler -Chord 'Ctrl+;' -ScriptBlock { Invoke-FuzzyZLocation; [Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine() }
ãã㧠ghq + fzf ã z ã§ã®ãã±ã¼ã·ã§ã³å±¥æ´æ¤ç´¢ + fzf ã Ctrl+]
ã Ctrl-;
ã§ããã«ç«ã¡ä¸ããããã«ãªãã¾ããããªããChord
ã«ã¯ Ctrl+t,n
ãªã©ãçµã¿åããããã¼ã®ç»é²ãã§ããã®ã§ãçµæ§è¤éãªãã¼æä½ãç»é²ã§ãããã§ãã
Powerline ã®ãã©ã³ãã使ããããã«ãã
ãã¦ãgit å¨ããããæãã«ä½¿ããããã«ãªã£ãã®ã§ãoh-my-posh ã®ãã¼ãã§ä¸é¨æååãã¦ããç®æãç´ããããPowerline ã®ãã©ã³ãã使ããããã«ãã¾ããããPowerline ã使ããªããã¨ãã人ã¯ã¹ããããã¦åé¡ããã¾ããã
ã¨ãã£ã¦ããã©ã³ãã®ã¤ã³ã¹ãã¼ã«ã¯ç°¡åã§
$ ghq get https://github.com/powerline/fonts.git # ð ã® fonts ãã£ã¬ã¯ããªã«ç§»åãã¦âãå®è¡ãããgf ã使ãã°ç§»åãããããã§ãã! $ ./install.ps1
ã§èªåã§ãã©ã³ã群ãã¤ã³ã¹ãã¼ã«ãã¦ããã¾ãããã㧠* for Powerline
ã¨ãããã©ã³ã群ã使ããããã«ãªãã¾ããããã WT è¨å®ã® fontFace ã«æå®ãã¦å©ç¨ãã¾ãããªãã©ãã§ã好ã¿ã®ãã®ã使ãã°ããã®ã§ãããç§ã¯ Source Code Pro for Powerline
ãå©ç¨ãã¦ãã¾ãã
ãã㧠WT ã®è¦ãç®ãã¾ãã¾ãããæãã«ãªãã¾ãããã
Windows Terminal ã®ã¿ãåãæ¿ãããã¼ãã¼ãã·ã§ã¼ãã«ããã«å²ãå½ã¦ã
MacOS / Linux ã§ã¯ã¿ã¼ããã«ä¸ã® screen / tmux ä¸ã§ã·ã§ã«ãèµ·åãã¦ãããC-t + [æ°åãã¼]
ã§ã®ã·ã§ã«ã®åãæ¿ããC-t + n/p
ã§ã®åã»å¾ãã¸ã®ã¦ã£ã³ãã¦ç§»åãè¡ã£ã¦ãã¾ãããPS ã§ã¯ screen / tmux ã®ä»£æ¿ãç¡ããããªã®ã§ãWindows Terminal ã®ã¿ãã§åããããªæä½ãå®ç¾ãã¦ãã¾ãã
Windows Terminal ã§ã¯ç¾å¨ C-t+ãã¼
ã¨ãã£ãè¤æ°å
¥åã«ãããã¼ãã¼ãã·ã§ã¼ãã«ããã¯å²ãå½ã¦ãããªããããªã®ã§ãAlt+æ°åãã¼
,Alt-n/p/t/w
çãAltãã¼ã¨ãªã«ãã®ãã¼ã®çµã¿åããã§ã¿ãã®ä½æãåãæ¿ããçµäºãªã©ãè¡ãããã«ãã¦ãã¾ããã¾ããã³ãã¼&ãã¼ã¹ã㯠Alt+c/v
ã«å²ãå½ã¦ã¦ãã¾ãã
ðã®è¨å®ãå«ããã¼ãã¼ãã·ã§ããã«ããã®ä¾ã§ãã
ãªããWindowsTerminal ã®ããã¥ã¡ã³ãããªãã£ã·ã£ã«ã«ã¾ã¨ã¾ã£ã¦ã ã®ã§ãä¸èªããããããã¾ãã
ãã㧠Alt + ãªã«ãã®ãã¼
ã㧠WT ããµã¯ãµã¯åãæ¿ãããã¨ãã§ããããã«ãªãã¾ããã
Linux ã§ã®ä½¿ãæ £ããã³ãã³ãã使ã
PS ã§ã¯ cd ã ls, cp ã¨ãã£ã MacOS / Linux ã§ä½¿ãæ £ããã³ãã³ããå®è¡ã§ãã¾ãããã ls ãå®è¡ããã¨åããéãããªã«ããè¦æ £ãã ls ã¨ã¯è¡¨ç¤ºãéãã¾ããããããã¯PSã®ã³ãã³ãã¬ããã®ã¨ã¤ãªã¢ã¹ãªã®ã§ãã
$ Get-Alias ls, cd CommandType Name Version Source ----------- ---- ------- ------ Alias ls -> Get-ChildItem Alias cd -> Set-Location
使ãæ £ãã¦ããã¯ãã®ã³ãã³ãããªããæåãéããçã ãããããã®ã§ãã¹ãã¬ã¹ã«ãªããªãç¨åº¦ã«åºæ¬çãªã³ãã³ããç½®ãæãã¦ããã¾ããã¾ã㯠ls ã cat ãªã©åºæ¬çãªç©ã Linux ã®ã³ãã³ãã¨åãæåã«ãã¦ãã¾ãã¾ãã
ãã®ããã®ã³ãã³ã群ã¨ãã¦ãgow (Gnu On Windows) ã unxutils, ç¾å¨ãç¶ç¶çã«éçºãè¡ããã¦ãã busybox-w32 ãªã©ãããã®ã§ããããã«ããã¤ãæåã¨ã³ã³ã¼ãã£ã³ã°ã®åé¡*2ãçºçãããããåé¡ãªãåãã¦ããã¨æãããæ¥æ¬èªãæ±ãã¿ã¤ãã³ã°ã§ããããã¡ã§ãã
è²ã ã¨ä½¿ã£ã¦ã¿ãæããRust ã§æ¸ãããã¯ã©ã¹ãã©ãããã©ã¼ã CoreUtils ã® uutilsã PS ä¸ã§ãåé¡ãªããã«ããã¤ãæåã®å ¥åã表示ãè¡ããã®ã§ãã¡ããã¤ã³ã¹ãã¼ã«ãã¦å©ç¨ãã¾ãã
$ scoop install uutils-coreutils $ uutils ls -alhF # ãã®åºåãå®å¿ããâ¦
ãã ãå®è¡ã«ã¯ prefix ã« uutils
ãä»ããå¿
è¦ããããããuutils ã§æä¾ããã¦ããã³ãã³ãããã¤ãã¨ãã¨ã® PS ã§è¨å®ããã¦ãã alias ã -Force
ã§è¨å®ããã¦ãªããã®(ä¸æ¸ãããã¨ä»ã®åä½ãå£ããããããªããããå
·ä½çã«ã¯ tee, sort, sleep ) 以å¤ã PowerShell ã§ã¬ã£ã¨ç»é²ãã¦ãã¾ãã¾ãã
# ãããã¡ã¤ã«ã«è¿½å @" arch, base32, base64, basename, cat, cksum, comm, cp, cut, date, df, dircolors, dirname, echo, env, expand, expr, factor, false, fmt, fold, hashsum, head, hostname, join, link, ln, ls, md5sum, mkdir, mktemp, more, mv, nl, nproc, od, paste, printenv, printf, ptx, pwd, readlink, realpath, relpath, rm, rmdir, seq, sha1sum, sha224sum, sha256sum, sha3-224sum, sha3-256sum, sha3-384sum, sha3-512sum, sha384sum, sha3sum, sha512sum, shake128sum, shake256sum, shred, shuf, sleep, sort, split, sum, sync, tac, tail, tee, test, touch, tr, true, truncate, tsort, unexpand, uniq, wc, whoami, yes "@ -split ',' | ForEach-Object { $_.trim() } | Where-Object { ! @('tee', 'sort', 'sleep').Contains($_) } | ForEach-Object { $cmd = $_ if (Test-Path Alias:$cmd) { Remove-Item -Path Alias:$cmd } $fn = '$input | uutils ' + $cmd + ' $args' Invoke-Expression "function global:$cmd { $fn }" }
ðãèªã¿è¾¼ãã ãã¨ãå種ã³ãã³ããå®è¡ãã¦ã¿ã¾ãã
$ ls -alhF $ whoami $ ln -s a.txt b.txt # ã·ã³ããªãã¯ãä½ããã¦ã¼ã¶ãªãããã¾ãä½ããã¯ã
ããã§ãuutils ã®ã³ãã³ãã® prefix ãã¤ããã«å®è¡ã§ããããã«ãªãã¾ããããªããPSã§ã¯ãAlias -> Function -> .exe ãªã©ã®ããã°ã©ã ãã®åªå é åºã§å ¥åããã³ãã³ããå®è¡ããããããã°ãã¼ãã«ãªFunction ãä½ã£ãã®ã«ãã¨ãå®è¡ãã¡ã¤ã«ããã¹ãéã£ãã¨ããã«ããã®ã«å®è¡ãããªãå ´åã¯ãGet-Alias 㧠alias ãã¤ãããã¦ããªãããªã©ã確èªãã¾ãããã
ãªãããã uutils ls
çããã¾ã表示ãããªãå ´åããã®ãã¤ããªãã³ã³ãã¤ã«ãããã¨ãã«ä½¿ããã Visual C++ ã©ã³ã¿ã¤ã ãå
¥ã£ã¦ããªãå¯è½æ§ãããã¾ããé常 Windows ã使ã£ã¦ãã¨ãVC++ã©ã³ã¿ã¤ã ã¯ãªãããã®ã½ããã¦ã§ã¢ã®ã¤ã³ã¹ãã¼ã«ã¨åæã«å
¥ãããã¦ããã¤ã®éã«ãå
¥ã£ã¦ãããã¨ãå¤ãã®ã§ãããå
¥ã£ã¦ããªãå ´åã¯
ãã vc_redist.{ã¢ã¼ããã¯ãã£}.exe ãå ¥ãã¾ãããã
ä»ã® CLI ã®ããã°ã©ã ãå ¥ãã
uutils (CureUtils )ã®ã³ãã³ã群ã ãã§ã¯è¶³ããªãå ´åãä»ã®ãã®ãå ¥ãããã代æ¿ã¨ãªãã³ãã³ããå ¥ãã¾ããããä¾ãã°â¦
$ scoop install gzip less tar gawk sed $ scoop install ripgrep fd
ç§ã¯ grep 代ããã« ripgrep ã« alias ãè²¼ã£ã¦ä½¿ã£ã¦ãã¾ãã
Set-Alias grep rg
å種ããã°ã©ãã³ã°è¨èªãå ¥ãã
ãã¦ãå®éã®éçºã«åããå種ããã°ã©ãã³ã°è¨èªãã¤ã³ã¹ãã¼ã«ãã¾ããããã§ã¯ãJava, Ruby, Node.js (NVS) ãå ¥ãã¦ã¿ã¾ãããä»ã®ããã°ã©ãã³ã°è¨èªã§ãããã¦ãã¯åé¡ãªã scoop ã§ã¤ã³ã¹ãã¼ã«ã§ããã§ãããã
Java
Java ã¯å°ç¨ã® buckets ãç¨æããã¦ãæ§ã ãªãã¼ã¸ã§ã³ãããã¾ãã
$ scoop bucket add java $ scoop install oraclejdk14 ojdkbuild8
çã ã§ããªã©ã¯ã«ã®JDKãOpenJDK çã ãå ¥ãããã¨ãã§ãã¾ããjava/javac ã«ãã¹ãéãã®ã¯ãã¡ããã®ãã¨ãç°å¢å¤æ° JAVA_HOME ãããæãã«ã»ãããã¦ãããã®ã§ä¾¿å©ã§ããã
$ scoop which java C:\Users\hotch\scoop\apps\oraclejdk14\current\bin\java.exe $ echo $env:JAVA_HOME C:\Users\hotch\scoop\apps\oraclejdk14\current $ scoop reset ojdkbuild8 Resetting ojdkbuild8 (1.8.0.252-2.b09). Linking ~\scoop\apps\ojdkbuild8\current => ~\scoop\apps\ojdkbuild8\1.8.0.252-2.b09 $ scoop which java C:\Users\hotch\scoop\apps\ojdkbuild8\current\bin\java.exe $ echo $env:JAVA_HOME C:\Users\hotch\scoop\apps\ojdkbuild8\current
scoop reset ã§ç°¡åã« java/javac ã JAVA_HOME ãåãæ¿ãããã¾ãã
Ruby
ææ°çãå
¥ããã«ã¯ scoop install ruby
ã§å
¥ãã¾ããä»ã®å¤ã Ruby ã®ã¡ã¸ã£ã¼ãã¼ã¸ã§ã³ã¯ versions ãã±ããã§ç®¡çããã¦ãã¾ãã
$ scoop bucket add versions $ scoop install ruby ruby24 $ scoop reset ruby24 $ ruby --version ruby 2.4.10p364 (2020-03-31 revision 67879) [x64-mingw32] $ scoop reset ruby $ ruby --version ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x64-mingw32]
ãããªæãã§ãè¤æ°ãã¼ã¸ã§ã³ããããã®ã¯ versions ãã±ããã追å ãããã¨ã§ãææ°ãã¼ã¸ã§ã³ä»¥å¤ã®ãã¼ã¸ã§ã³ãå©ç¨ã§ãã¾ãã
ãã ããã®ç¶æ
ã§ã¯æå
ã®ç°å¢ã§ã¯ gem install ã§å
¥ãã gem ã®ããã°ã©ã ã®ããã¹ãéã£ã¦ããªãã£ãã®ã§ãscoop install ruby ãå
¥ããã¨ãã«åºãã¡ãã»ã¼ã¸éããridk install
ã§å®è¡ã§ãã RubyInstaller2 çµç±ã§ MSYS2 㨠MSYS2 and MINGW development toolchain (buildã«å¿
è¦) ãå
¥ãã¾ãããã
ããä¸åº¦ gem install ã§ãä¾ãã° rails ãå ¥ããã¨
$ gem install rails $ scoop which rails C:\Users\hotch\scoop\apps\ruby\current\gems\bin\rails.bat
ã¨ãä»åº¦ã¯ Path ãéã£ãå ´æã« rails ãå ¥ããå®è¡ã§ããããã«ãªãã¾ããã
Node.js
Node.js ã scoop install node
ã§å
¥ãããã¨ãã§ãã¾ãããç§ã¯æè¿ã§ã¯ Node.js èªä½ã®ãã¼ã¸ã§ã³åãæ¿ããç°¡åã«ã§ãããã«ããã©ãããã©ã¼ã 対å¿ã® NVS ( Node Version Switcher )ã使ã£ã¦ããã®ã§ãscoop çµç±ã§ nvs ãã¤ã³ã¹ãã¼ã«ãã¾ãã
$ scoop install nvs $ nvs add latest # ææ°ã® Node v14 ãå ¥ã $ nvs add lts # ä»ãªã Node v12 ãå ¥ã $ nvs link lts # æ¨æºã® node ã³ãã³ãã«ã¯ LTS ã®ãã¼ã¸ã§ã³(v12) ã使ã
.node-version
ãç½®ãã¦ãããã£ã¬ã¯ããªã§èªå㧠Node.js ã®ãã¼ã¸ã§ã³ãåãæ¿ããã«ã¯ nvs auto ãå®è¡ãã¾ãã
$ nvs auto $ cd nodejs-project PATH -= C:\Users\hotch\scoop\apps\nvs\current\nodejs\node\8.9.1\x64 PATH += C:\Users\hotch\scoop\apps\nvs\current\nodejs\default $ cd ../ PATH -= C:\Users\hotch\scoop\apps\nvs\current\nodejs\default PATH += C:\Users\hotch\scoop\apps\nvs\current\nodejs\node\8.9.1\x64
ãããªæãã«ãã£ã¬ã¯ããªã«ç½®ããã¦ãã .node-version ãå ã« PS ä¸ã§ cd ããæã«ãé©ç¨ãããããã«ãªãã¾ããã
WSL å´ã®ããã°ã©ã ãå®è¡ãã
WSL ã«ã¯ä»ã¾ã§è§¦ãã¦ã¾ããã§ããããä¸ã¤ã ã便å©ãªã³ãã³ããwsl.exe ã®ç´¹ä»ã§ãããã®ã³ãã³ããå®è¡ãããã¨ã§ãPS ä¸ãã WSL ä¸ã®ã³ãã³ããå®è¡ã§ãã¾ãã
$ $PSVersionTable.OS Microsoft Windows 10.0.19041 # WSL ã® uname ãå©ã $ wsl uname -a Linux YUIDT 4.19.104-microsoft-standard #1 SMP Wed Feb 19 06:37:35 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
$ ruby --version ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x64-mingw32] $ wsl ruby --version ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu]
ã¤ã¾ãã¨ããããLinux å´ã§ã¯å®è¡ã§ãããã ãã©ãPowershell (Windows) ã«ã¯ç¡ãï¼ãã¿ãããªã³ãã³ã㯠wsl ã³ãã³ãçµç±ã§å®è¡ã§ãã¾ãã
$ wsl sudo apt-get install sl $ wsl sl # PowerShell ä¸ã§ Linux ã® sl ãèµ°ãï¼ $ wsl zsh -c "echo {00..99}" | foreach { $_.Split(' ') } | foreach -Parallel { echo curl http://localhost/$_.jpg } # WSL å´ã® zsh 㧠00..99 ã®é£çªãã¤ãã£ã¦ãããã ' ' 㧠split ãã¦ã並å㧠curl ãå®è¡ããä¾ # zsh å´ã§ããããé£çªãä½ã£ã¦ãæå³ã¯ãªããã©ããã¤ããç°¡åã«ã§ãã
ã¡ãªã¿ã«ãWSL2 å´ãã Windows å´ã®ããã°ã©ã ãå®è¡ãããå ´åãexplorer.exe
ã®ããã« .exe
ãã¤ããã°ããã¦ãå®è¡ã§ãã¾ãã
# WSL2 å´ããå®è¡ $ uname -a Linux YUIDT 4.19.104-microsoft-standard #1 SMP Wed Feb 19 06:37:35 UTC 2020 x86_64 x86_64 x8 $ explorer.exe . # Windows ã® ã¨ã¯ã¹ããã¼ã©ã§ WSL å´ã®ãã£ã¬ã¯ããªãéããã $ ruby -e 'p RUBY_PLATFORM' "x86_64-linux-gnu" $ ruby.exe -e 'p RUBY_PLATFORM' "x64-mingw32"
ããã¨ä½ã§ãåºæ¥ã¡ããæããã¾ããã
scoop ã§ã® GUI ã¢ããªã±ã¼ã·ã§ã³ã®ã¤ã³ã¹ãã¼ã«
æåã®æ¹ã§ WindowsTerminal ã®ããã« extras ãã±ããã追å ããã®ã§ããããã®ãã±ããã使ãã¨ãä¾ãã° VSCode, Android Studio, Google Chrome çã ãæ§ã 㪠Windows ã¢ããªã±ã¼ã·ã§ã³ã scoop çµç±ã§ã¤ã³ã¹ãã¼ã«ã§ããããã«ãªãã¾ãã
ãã®è¾ºã¯ scoop çµç±ã§å ¥ããã®ãããªãã£ã·ã£ã«ã®ã¤ã³ã¹ãã¼ã©çµç±ã§å ¥ããã®ããç§èªèº«ã¾ã ããªã·ã¼ãå®ã¾ã£ã¦ãªãç¶æ ã§ãã¡ã¸ã£ã¼ãªãã®ã¯ãªãã£ã·ã£ã«ã®ã¤ã³ã¹ãã¼ã«æ¹æ³ã§å ¥ã(大æ¦ã»ã«ãã¢ãããã¼ãã§ããããï¼ãããã§ãªããã®ãèªåã§ãã¨ãã Path ãéãå¿ è¦ããããã®ã¯ scoop çµç±ã§ã¤ã³ã¹ãã¼ã«ãã¦ãã¾ãã
PS ä¸ã§ãã©ãã¾ã§æä½ã MacOS / Linux ã¨ããããã
å人çã«ã¯ãããããã§ãWindows ã§ã®ã³ã³ã½ã¼ã«(PS)ä¸ã§åºæ¬çãªé¨åã§ã®æä½ã®ä¸æºã¯ã»ã¨ãã©è§£æ¶ãããå¿«é©ã« PS Core ä¸ã§æ®ãããããã«ãªãã¾ããã大æµã®ç©ã scoop ã§ã¤ã³ã¹ãã¼ã«ã§ããã³ãã³ãå®è¡ãã§ããããã« Path ãéã(ããã®æåè¨å®ãæã¯å¤§å¤é¢åã ã£ãâ¦)ãã¾ãåºæ¬çãªæä½ ( ssh ã git å¨ãããã£ã¬ã¯ããªç§»åå¨ããCoreUtils å¨ã)ãåé¡ãªãè¡ãã¦ãã¾ãã
æ ¹ã£ããã® Windows éçºè ãããã¦ã¿ããããããããLinux ã®ã³ãã³ã使ããã« PowerShell ã®ã³ãã³ãã¬ããã«æ £ããã»ããè¯ãããããã¨ããæè¦ããã£ã¨ãã§ãPS ä¸ã§çæ´»ãããªããã®ã»ããçç£æ§ã¯ä¸ãããã ãããªãã¨ç§ãæã£ã¦ããã®ã§ãæå㯠Linux ã¨åçã®ã³ãã³ãã使ãã¤ã¤ããã³ãã³ãã¬ããã§ã§ãããªããã¡ãã使ã£ã¦ãããããªãã¨æã£ã¦ã¾ããPS ã®ãã¥ã¼ããªã¢ã«ãçæéã§èªãã¾ãããVSCode ã® PowerShell æ¡å¼µãè¯ãã§ãã¦ãããããPS ã®ã³ã¼ããæ¸ããããã§ãããã
éã«ãWindowsä¸ã§bash/zshããã®ã¾ã¾ä½¿ããã¨ã«ãã ããããã£ãããMSYS2ãªã©ã使ã£ãã»ãã幸ãããã§ãã
Windows ãéçºã«ä½¿ããã¨ããé¸æè¢
æè¿ã¾ã§ã¯ãMSãããã¯ãã使ããªã Web éçºè ã¯ã Windows ã使ãé¸æè¢ãå°ãªãã ã£ãã¨æãã®ã§ãããWSL2 ã®ä½¿ãããããç¸ã¾ã£ã¦ãiOS éçºãå¿ è¦ãªããã° Windows (+WSL2) ã§ããªããªéçºãã¦ãã¨ãããåé¡ãç¹ã«æãã¾ãããã¾ã Windows å´ã®ç°å¢ãæ´ããåã¾ã§ã¯ãã»ã¨ãã©ã®ã³ã³ã½ã¼ã«æä½ã¯ WSL2 (ã§åãã¦ãã Ubuntu ä¸ã® zsh + tmux)ã§è¡ã£ã¦ããã®ã§ãããç°å¢ãæ´ããå¾ã¯ Windows ä¸ã® PS Core ã§ãã ãã¶æä½ããããããªã£ããããLinux ä¸ã§ã®å¿ è¦æ§ããããã¨ä»¥å¤ã¯ Windows å´ã§è¡ããããã«ãªãã¾ããã
ãã¨ã㨠MacOS ã Linux ã使ã£ã¦ãã¨ãWindows ã使ãå§ãã¦ã Linux ããã使ãã WSL2 ãªéçºç°å¢ã«ãã©ã¼ã«ã¹ãã¦ãã¾ã(ãã㦠Windows + WSL2 ã¯ããã§ãã¦ããã®ã§ããã§ãæºè¶³ã§ãã¦ãã¾ã)ã®ã§ãããWindows Terminal + PowerShell Core + Scoop 㪠Windows ç°å¢ãã ãã¶ä½¿ãããããªãã¨æã£ãã®ã§ãWSL2ã§ã¯ãªã Windows ç°å¢ãããç©æ¥µçã«æ´»ç¨ãã¦ãããããã¨æã£ã¦ãã¾ãã
ãã¾ã
ãã®è¨äºã§è¨è¼ãã¦ãããWindowsTerminal ã®è¨å®ã¨ãuser_profile.ps1
ã¯ãã¡ãã
- https://gist.github.com/hotchpotch/61e37d639aefe677a24b987d398ec4dd
- https://gist.github.com/hotchpotch/61582e7d390577dff76c88f5ddc88e20
*1: scoop ãã¹ã¿ã¼ãã¡ãã¥ã¼ã«ã·ã§ã¼ãã«ããã追å ãã¦ãã¾ã
*2: PS ã§ã¯ [System.Console]::OutputEncoding ã¨[System.Console]::InputEncoding ããã¾ã Unix ã©ã¤ã¯ãªã³ãã³ãã§ã¯ $env:LANG ãé©åã«ã»ããããå¿ è¦ãããã¾ããä½ãèããã« UTF-8 åºå®ã«ãã¦ãã¾ãã¨ã Shift_JIS 㨠UTF-16 ã®æåã³ã¼ããæ±ãã¨ãã«ããã£ãããã¾ãããã®ãããç§ã¯æåã¨ã³ã³ã¼ãã£ã³ã°ãæå®ãã¦ããããæå®ãå¿ è¦ãªå ´åã«ç¶æ³ã«å¿ãã¦å¤æ´ãã¦ãã¾ãã