diff --git a/bin/install.ps1 b/bin/install.ps1 index 5cc5c5e..72cda8c 100644 --- a/bin/install.ps1 +++ b/bin/install.ps1 @@ -1,23 +1,15 @@ #!/usr/bin/pwsh # dotfiles install script for Windows +# Execute +# Set-ExecutionPolicy RemoteSigned -Scope CurrentUser +# first to run pwsh scripts # check administration role -$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) -$bool_admin = $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) -if (!$bool_admin) { - Write-Warning -Message "require Admin privilage - please run as Administrator" - exit 1 -} +#Requires -RunAsAdministrator # check pwsh version # ≧ 7 -if ($PSVersionTable.PSVersion.Major -lt 7) { - Write-Warning -Message "pwsh version must be greater than 7 - please install powershell 7 (Core) - you can install via winget" - exit 1 -} +#Requires -Version 7 # check working directory if (!( @@ -35,6 +27,17 @@ Write-Output "Pscx" Install-Module -Name Pscx -AllowPrerelease Write-Output "z" Install-Module -Name z +Install-Module -Name PSFzf -RequiredVersion 2.5.10 + +# install scoop +if(!(Get-Command scoop -ErrorAction SilentlyContinue)) { + Write-Output "Installing scoop..." + irm get.scoop.sh | iex +} +# install basic scoop apps +# import from exported json file +# to update the json file, execute ./bin/scoop_apps/update_scoop_list.ps1 +scoop import .\bin\scoop_apps\scoop_minimal_apps.json # make symbolic links diff --git a/bin/scoop_apps/scoop_apps.json b/bin/scoop_apps/scoop_apps.json new file mode 100644 index 0000000..3ffae3d --- /dev/null +++ b/bin/scoop_apps/scoop_apps.json @@ -0,0 +1,144 @@ +{ + "apps": [ + { + "Updated": "2022-09-24T06:50:10.362148+09:00", + "Info": "", + "Source": "main", + "Name": "7zip", + "Version": "22.01" + }, + { + "Updated": "2022-09-24T06:45:30.615827+09:00", + "Info": "", + "Source": "main", + "Name": "bat", + "Version": "0.22.1" + }, + { + "Updated": "2022-09-26T04:52:36.3416759+09:00", + "Info": "", + "Source": "main", + "Name": "ffmpeg", + "Version": "5.1.1" + }, + { + "Updated": "2022-09-23T17:54:45.7302151+09:00", + "Info": "", + "Source": "main", + "Name": "fzf", + "Version": "0.33.0" + }, + { + "Updated": "2022-09-25T00:18:14.5435972+09:00", + "Info": "", + "Source": "main", + "Name": "gcc", + "Version": "11.2.0" + }, + { + "Updated": "2022-09-24T06:50:11.9515886+09:00", + "Info": "", + "Source": "main", + "Name": "grep", + "Version": "3.7" + }, + { + "Updated": "2022-09-24T06:43:31.7789266+09:00", + "Info": "", + "Source": "main", + "Name": "hexyl", + "Version": "0.10.0" + }, + { + "Updated": "2022-09-27T19:03:11.6544132+09:00", + "Info": "", + "Source": "main", + "Name": "innounp", + "Version": "0.50" + }, + { + "Updated": "2022-09-27T07:30:16.5298145+09:00", + "Info": "", + "Source": "main", + "Name": "jid", + "Version": "0.7.6" + }, + { + "Updated": "2022-09-27T07:29:37.5227478+09:00", + "Info": "", + "Source": "main", + "Name": "jq", + "Version": "1.6" + }, + { + "Updated": "2022-09-23T17:59:11.0595712+09:00", + "Info": "", + "Source": "main", + "Name": "less", + "Version": "608" + }, + { + "Updated": "2022-09-27T08:37:26.471311+09:00", + "Info": "", + "Source": "main", + "Name": "lua", + "Version": "5.4.2" + }, + { + "Updated": "2022-09-25T00:17:18.2293504+09:00", + "Info": "", + "Source": "main", + "Name": "make", + "Version": "4.3" + }, + { + "Updated": "2022-09-27T19:03:31.678283+09:00", + "Info": "", + "Source": "main", + "Name": "r", + "Version": "4.2.1" + }, + { + "Updated": "2022-09-28T23:47:33.9083455+09:00", + "Info": "", + "Source": "extras", + "Name": "scoop-completion", + "Version": "0.2.3" + }, + { + "Updated": "2022-09-27T07:27:52.6696127+09:00", + "Info": "", + "Source": "extras", + "Name": "spacesniffer", + "Version": "1.3.0.2" + }, + { + "Updated": "2022-09-22T23:40:06.1651065+09:00", + "Info": "", + "Source": "main", + "Name": "sudo", + "Version": "0.2020.01.26" + }, + { + "Updated": "2022-09-24T06:53:20.806641+09:00", + "Info": "", + "Source": "main", + "Name": "ugrep", + "Version": "3.9.2" + } + ], + "buckets": [ + { + "Name": "extras", + "Source": "https://github.com/ScoopInstaller/Extras", + "Updated": "2022-09-28T21:31:14+09:00", + "Manifests": 1691 + }, + { + "Name": "main", + "Source": "https://github.com/ScoopInstaller/Main", + "Updated": "2022-09-28T21:32:26+09:00", + "Manifests": 1091 + } + ] +} diff --git a/bin/scoop_apps/scoop_minimal_apps.json b/bin/scoop_apps/scoop_minimal_apps.json new file mode 100644 index 0000000..fd88203 --- /dev/null +++ b/bin/scoop_apps/scoop_minimal_apps.json @@ -0,0 +1,74 @@ +{ + "apps": [ + { + "Updated": "2022-09-24T06:50:10.362148+09:00", + "Info": "", + "Source": "main", + "Name": "7zip", + "Version": "22.01" + }, + { + "Updated": "2022-09-24T06:45:30.615827+09:00", + "Info": "", + "Source": "main", + "Name": "bat", + "Version": "0.22.1" + }, + { + "Updated": "2022-09-23T17:54:45.7302151+09:00", + "Info": "", + "Source": "main", + "Name": "fzf", + "Version": "0.33.0" + }, + { + "Updated": "2022-09-24T06:50:11.9515886+09:00", + "Info": "", + "Source": "main", + "Name": "grep", + "Version": "3.7" + }, + { + "Updated": "2022-09-24T06:43:31.7789266+09:00", + "Info": "", + "Source": "main", + "Name": "hexyl", + "Version": "0.10.0" + }, + { + "Updated": "2022-09-23T17:59:11.0595712+09:00", + "Info": "", + "Source": "main", + "Name": "less", + "Version": "608" + }, + { + "Updated": "2022-09-22T23:40:06.1651065+09:00", + "Info": "", + "Source": "main", + "Name": "sudo", + "Version": "0.2020.01.26" + }, + { + "Updated": "2022-09-24T06:53:20.806641+09:00", + "Info": "", + "Source": "main", + "Name": "ugrep", + "Version": "3.9.2" + } + ], + "buckets": [ + { + "Name": "extras", + "Source": "https://github.com/ScoopInstaller/Extras", + "Updated": "2022-09-28T21:31:14+09:00", + "Manifests": 1691 + }, + { + "Name": "main", + "Source": "https://github.com/ScoopInstaller/Main", + "Updated": "2022-09-28T21:32:26+09:00", + "Manifests": 1091 + } + ] +} diff --git a/bin/scoop_apps/update_scoop_list.ps1 b/bin/scoop_apps/update_scoop_list.ps1 new file mode 100644 index 0000000..bdfcb4f --- /dev/null +++ b/bin/scoop_apps/update_scoop_list.ps1 @@ -0,0 +1,29 @@ +# update scoop list + +# scoop need to be installed +if(!(Get-Command scoop -ErrorAction SilentlyContinue)) { + Write-Output "scoop does not exists!" + exit 1 +} + +# execution location +if(!((Test-Path bin) -and (Test-Path dotfiles))) { + Write-Warning "This script need to be executed in dotfiles root" + exit 2 +} + + +# export to JSON +scoop export | Out-File .\bin\scoop_apps\scoop_apps.json -Encoding utf8 + +# create minimal JSON +$minimal_list = @("7zip", "bat", "fzf", "grep", "hexyl", "less", "sudo", "ugrep") +$parsed_json = Get-Content -Path .\bin\scoop_apps\scoop_apps.json | ConvertFrom-Json +$buckets = ($parsed_json | Select-Object buckets).buckets +$apps = ($parsed_json | Select-Object apps).apps +$selected_apps = $apps | Where-Object Name -In $minimal_list +$new_json = [PSCustomObject]@{ + "apps" = $selected_apps + "buckets" = $buckets +} +ConvertTo-Json -InputObject $new_json | Out-File .\bin\scoop_apps\scoop_minimal_apps.json -Encoding utf8 \ No newline at end of file diff --git a/bin/windows/luajit/install_luajit.ps1 b/bin/windows/luajit/install_luajit.ps1 new file mode 100644 index 0000000..8396594 --- /dev/null +++ b/bin/windows/luajit/install_luajit.ps1 @@ -0,0 +1,22 @@ +# installing luajit under %localappdata%\Programs + +# download and build +git clone https://luajit.org/git/luajit.git +cd luajit +make + +# installing +$luajit_location = Join-Path $env:LOCALAPPDATA "Programs\luajit" +mkdir $luajit_location +cp .\src\luajit.exe, .\src\lua51.dll $luajit_location +mkdir $luajit_location\lua +mkdir $luajit_location\lua\jit +cp .\src\jit\* $luajit_location\lua\jit + +# add to path +while($true) { + $input = Read-Host "add $env:LOCALAPPDATA\Programs\luajit to `$PATH. (Y)" + if ($input = 'Y') { + break + } +} diff --git a/dotfiles/pwsh/powershell_profile.ps1 b/dotfiles/pwsh/powershell_profile.ps1 index ff955e0..efdd151 100644 --- a/dotfiles/pwsh/powershell_profile.ps1 +++ b/dotfiles/pwsh/powershell_profile.ps1 @@ -5,11 +5,17 @@ Set-PSReadlineOption -HistoryNoDuplicates Set-PSReadLineKeyHandler -Chord "Ctrl+f" -Function ForwardWord # like fish Set-PSReadLineKeyHandler -Chord "Tab" MenuComplete Set-PSReadLineKeyHandler -Chord "Ctrl+d" DeleteCharOrExit +Set-PSReadLineKeyHandler -Chord "Ctrl+g" -ScriptBlock { Invoke-FzfTabCompletion } + +# PsFzf Options +# 'Ctrl+t' for provider path, 'Ctrl+r' for reverse history +Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+t' -PSReadlineChordReverseHistory 'Ctrl+r' function ~ { cd ~ } function .. { cd .. } function epl {explorer.exe .} Set-Alias touch New-Item +Set-Alias whereis where.exe # starship @@ -115,7 +121,7 @@ function Enable-SshAgent { # less options -$env:LESS = "-M -R -S -W -z-4 -x4" +$env:LESS = "-i -M -R -S -W -z-4 -x4"