diff --git a/README.md b/README.md new file mode 100644 index 0000000..fcf5d2d --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ +# dotfiles +my dotfiles + +# Environments +- Windows 11 + - pwsh + - AHK macro + - etc +- Ubuntu 20.04 on WSL + - fish +- Manjaro + - fish + - tmux + - neovim + +# Installing +## Windows +1. update winget (via MS store) +2. install Git for Windows via winget +3. install pwsh via winget +4. set execution policy +5. install [scoop](https://scoop.sh/) (see scoop website) +6. run `bin/install.ps1` + +## Linux +1. install fish +2. run install.fish + +# TODO +- make install script for Linux +- add rc files of Manjaro +- neovim configs + - lsp-config + - visuals +- termux dotfiles +- raspi dotfiles diff --git a/bin/install.ps1 b/bin/install.ps1 index 5cc5c5e..87905bd 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 (!( @@ -34,12 +26,32 @@ Install-Module -Name posh-git Write-Output "Pscx" Install-Module -Name Pscx -AllowPrerelease Write-Output "z" -Install-Module -Name z +Install-Module -Name ZLocation +Write-Output "PSFzf" +Install-Module -Name PSFzf -RequiredVersion 2.5.10 +Write-Output "Latest PSReadLine" +Install-Module -Name PSReadLine -Force # Override default version to get the latest one +Write-Output "CompletionPredictor" +Install-Module -Name CompletionPredictor + + + +# 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 # neovim -New-Item -ItemType SymbolicLink -Path ~\AppData\Local\nvim\init.vim -Target (Resolve-Path .\dotfiles\neovim\init.vim) -Force +New-Item -ItemType SymbolicLink -Path ~\AppData\Local\nvim\init.lua -Target (Resolve-Path .\dotfiles\neovim\init.lua) -Force +New-Item -ItemType SymbolicLink -Path ~\AppData\Local\nvim\lua\plugins.lua -Target (Resolve-Path .\dotfiles\neovim\lua\plugins.lua) -Force +New-Item -ItemType SymbolicLink -Path ~\AppData\Local\nvim\lua\lualine_setup.lua -Target (Resolve-Path .\dotfiles\neovim\lua\lualine_setup.lua) -Force # pwsh New-Item -ItemType SymbolicLink -Path $PROFILE -Target (Resolve-Path .\dotfiles\pwsh\powershell_profile.ps1) -Force New-Item -ItemType SymbolicLink -Path ~\.config\powershell\chezmoi_completion.ps1 -Target (Resolve-Path .\dotfiles\pwsh\chezmoi_completion.ps1) -Force diff --git a/bin/install.sh b/bin/install.sh index 55f001e..0f10909 100644 --- a/bin/install.sh +++ b/bin/install.sh @@ -6,8 +6,7 @@ # symlink #ln -s ~/.config/fish/config.fish dotfiles/fish/config.fish cp ~/.config/fish/config.fish (pwd)/dotfiles/fish/config.fish -ln -s (pwd)/dotfiles/fish/config.fish ~/.config/fish/config.fish -ln -s (pwd)/dotfiles/starship/starship.toml ~/.config/starship.toml +ln -sf (pwd)/dotfiles/fish/config.fish ~/.config/fish/config.fish +ln -sf (pwd)/dotfiles/starship/starship.toml ~/.config/starship.toml ln -sf (pwd)/dotfiles/neovim/init.lua ~/.config/nvim/init.lua ln -sf (pwd)/dotfiles/neovim/lua/plugins.lua ~/.config/nvim/lua/plugins.lua - 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/install_key_remaps.ps1 b/bin/windows/install_key_remaps.ps1 new file mode 100644 index 0000000..fd53087 --- /dev/null +++ b/bin/windows/install_key_remaps.ps1 @@ -0,0 +1,31 @@ +# Install script for AHK key remapping +# Be sure to install AutoHotKey first + + +# check working directory +if (!( + (Test-Path bin) -and (Test-Path dotfiles) + )) { + Write-Warning -Message "wrong current path + please execute at repo root" + exit 1 +} + +# set Ahk2Exe.exe path +# example "C:\Program Files\AutoHotKey\Compiler\Ahk2Exe.exe" +$ahk2exe_path = "C:\Program Files\AutoHotKey\Compiler\Ahk2Exe.exe" + +## end config + +if ($null -eq $ahk2exe_path) { + exit +} + +# compile +& $ahk2exe_path /in .\dotfiles\ahk\key_remaps.ahk /out dotfiles\ahk\key_remaps.exe + +# add to startup folder +$startup = "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup\" +Copy-Item .\dotfiles\ahk\key_remaps.exe $startup + +Write-Output "Finished!" 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/ahk/.gitignore b/dotfiles/ahk/.gitignore new file mode 100644 index 0000000..b883f1f --- /dev/null +++ b/dotfiles/ahk/.gitignore @@ -0,0 +1 @@ +*.exe diff --git a/dotfiles/ahk/extra_remaps.ahk b/dotfiles/ahk/extra_remaps.ahk new file mode 100644 index 0000000..5effd07 --- /dev/null +++ b/dotfiles/ahk/extra_remaps.ahk @@ -0,0 +1,25 @@ +; extra key remaps +; mainly for inputting special characters + +; Play/Pause +;sc121:: +; Send {Media_Play_Pause} +; return +; + +; Henkan/Muhenkan + - -> en, em dash +vk1D & vkBD:: + Send {U+2013} ; en dash + return +vk1C & vkBD:: + Send {U+2014} ; em dash + return + +; Henkan/Muhenkan + {Space} -> ZWSP, ZWJ +vk1D & Space:: + Send {U+200B} ; ZWSP + return +vk1C & Space:: + Send {U+200D} ; ZWJ + return + diff --git a/dotfiles/ahk/key_remaps.ahk b/dotfiles/ahk/key_remaps.ahk new file mode 100644 index 0000000..70722db --- /dev/null +++ b/dotfiles/ahk/key_remaps.ahk @@ -0,0 +1,67 @@ +; basic key remapping for windows(JIS keyboard) +; using AutoHotKey +#SingleInstance, Force +SendMode Input +SetWorkingDir, %A_ScriptDir%1 + +; KeyHistory + +#UseHook + +; ========================================== +; 変換/無変換 + ASDF/HJKLのショートカット +vk1D:: +Send, {vk1D} +Return + +vk1C:: +Send, {vk1C} +Return + +; 十字キーの設定 +; hjkl like vim +vk1D & h:: +vk1C & h:: +Send,{Blind}{Left} +return +vk1D & j:: +vk1C & j:: +Send,{Blind}{Down} +return +vk1D & k:: +vk1C & k:: +Send,{Blind}{Up} +return +vk1D & l:: +vk1C & l:: +Send,{Blind}{Right} +return + +; Home,End,PgUp,PgDnの設定 +; a s d f +; Home PgUp PgDn End +vk1D & a:: +vk1C & a:: +Send,{Blind}{Home} +return +vk1D & f:: +vk1C & f:: +Send,{Blind}{End} +return +vk1D & s:: +vk1C & s:: +Send,{Blind}{PgUp} +return +vk1D & d:: +vk1C & d:: +Send,{Blind}{PgDn} +return + +; ========================================== +; include extra key remaps +#Include extra_remaps.ahk + +; ========================================== +; HankakuZenkaku to esc +sc029:: + Send, {Escape} diff --git a/dotfiles/fish/config.fish b/dotfiles/fish/config.fish index cfbf773..30155a4 100644 --- a/dotfiles/fish/config.fish +++ b/dotfiles/fish/config.fish @@ -1,14 +1,39 @@ +# load .bashrc +# bass source ~/.bashrc + if status is-interactive - # Commands to run in interactive sessions can go here # starship starship init fish | source + + function set_win_title + echo -ne "\033]0; (basename "$PWD") \007" + end + set starship_precmd_uesr_func "set_win_title" + + # keychain + set -x SHELL fish + keychain --eval --quiet -Q id_rsa, id_ed25519 | source + set -x SHELL bash + + # opam + source ~/.opam/opam-init/init.fish > /dev/null 2> /dev/null; or true end -# opam configuration -source /home/qwjyh/.opam/opam-init/init.fish > /dev/null 2> /dev/null; or true +# key bindings +bind \b backward-kill-word + +# save fish log to my custom file +set -gx my_fish_history "$HOME/my_fish_history.txt" +function save_myhistory --on-event fish_prompt -d "Save custom shell log to $my_fish_history" + set -l prev_status $status + echo "$(date '+%Y-%m-%d %H:%M:%S') $hostname:$fish_pid $PWD [$prev_status] $(history -1)" \ + >> $my_fish_history +end + # julia # to solve Graphic Card driver problem export LD_PRELOAD=/usr/lib64/libstdc++.so.6 + diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index 7097cb2..2b5eea2 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -3,7 +3,8 @@ vim.o.number = true vim.o.relativenumber = true vim.cmd([[ -highlight LineNr cterm=none ctermfg=256 +highlight LineNr cterm=none ctermfg=243 +highlight CursorLineNr cterm=none ctermfg=250 ]]) vim.o.tabstop = 4 vim.o.shiftwidth = 4 @@ -132,6 +133,10 @@ cmp.setup({ -- }, -- }) +-- satysfi language server +require('lspconfig')['satysfi-ls'].setup{ + autostart = true +} ----------------------------------------------------------- -- Ctrl + P to invoke fzf file search @@ -141,7 +146,10 @@ vim.api.nvim_set_keymap('n', '', ----------------------------------------------------------- --- satysfi language server -require('lspconfig')['satysfi-ls'].setup{ - autostart = true -} +-- lualine +require('lualine_setup') +lualine = require('lualine') +lualine.setup({ + options = { theme = 'iceberg_dark' } +}) +lualine.setup() diff --git a/dotfiles/neovim/lua/lualine_setup.lua b/dotfiles/neovim/lua/lualine_setup.lua new file mode 100644 index 0000000..6d5017a --- /dev/null +++ b/dotfiles/neovim/lua/lualine_setup.lua @@ -0,0 +1,40 @@ +require('lualine').setup { + options = { + icons_enabled = true, + theme = 'auto', + component_separators = { left = '|', right = '|'}, + section_separators = { left = '', right = ''}, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = true, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + } + }, + sections = { + lualine_a = {'mode'}, + lualine_b = {'branch', 'diff', 'diagnostics'}, + lualine_c = {'filename'}, + lualine_x = {'filetype'}, + lualine_y = {'progress'}, + lualine_z = {'location'} + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {'filename'}, + lualine_x = {'location'}, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = {} +} diff --git a/dotfiles/neovim/lua/plugins.lua b/dotfiles/neovim/lua/plugins.lua index 86506f7..4ec117b 100644 --- a/dotfiles/neovim/lua/plugins.lua +++ b/dotfiles/neovim/lua/plugins.lua @@ -9,6 +9,12 @@ return require('packer').startup(function(use) --requires = { 'kyazdan142/nvim-web/devicons' } -- not found } + -- lualine(statusline) + use { + 'nvim-lualine/lualine.nvim', + requires = { 'kyazdani42/nvim-web-devicons', opt = true } + } + -- LSP use 'neovim/nvim-lspconfig' use "williamboman/mason.nvim" diff --git a/dotfiles/pwsh/README.md b/dotfiles/pwsh/README.md new file mode 100644 index 0000000..70c7973 --- /dev/null +++ b/dotfiles/pwsh/README.md @@ -0,0 +1,35 @@ +# PowerShell PROFILE description +some notable features + +## Key-Bindings +- `F2` to toggle InlineView and ListView of predictions +- tab completion like fish +- `Ctrl + D` to exit +- `Ctrl + G` to Invoke-FzfTabCompletion +- `Ctrl + t` to select providers with fzf +- `Ctrl + r` to fzf history + +## Aliases +- `~`, `..` +- `epl` = `explorer.exe .` +- `whereis` = `where.exe` + +## Change Encodings Instantly +You can change PowerShell encodings instantly. +Especially useful for piping into linux commands like `less` +- `Set-UTF8`, `Set-UTF16LE` +- `Remove-EncodingSettings` +- `Reset-EncodingSettings` + +## ssh-agent +- `Invoke-SshAdd` + +## `$env:` +- `$env:LESS` + +## Auto Completions +- scoop +- chezmoi +- git +- winget +- chocolatey diff --git a/dotfiles/pwsh/powershell_profile.ps1 b/dotfiles/pwsh/powershell_profile.ps1 index ff955e0..9ed7b93 100644 --- a/dotfiles/pwsh/powershell_profile.ps1 +++ b/dotfiles/pwsh/powershell_profile.ps1 @@ -1,33 +1,55 @@ -# auto completion -Import-Module PSReadLine -Set-PSReadLineOption -PredictionSource History +# ============================================================== +# PSReadLine Settings +# ============================================================== +Import-Module PSReadLine # >= 2.2.2 +Import-Module CompletionPredictor +Set-PSReadLineOption -EditMode Windows +Set-PSReadLineOption -PredictionSource HistoryAndPlugin # require PowerShell ≧ 7.2 and PSReadLine ≧ 2.2.2 Set-PSReadlineOption -HistoryNoDuplicates -Set-PSReadLineKeyHandler -Chord "Ctrl+f" -Function ForwardWord # like fish +Set-PSReadLineOption -DingTone 880 # beep frequency +Set-PSReadLineKeyHandler -Chord "Ctrl+u" -Function BackwardKillInput # like emacs +Set-PSReadLineKeyHandler -Chord "Ctrl+p" -Function PreviousHistory # like emacs +Set-PSReadLineKeyHandler -Chord "Ctrl+n" -Function NextHistory # like emacs +Set-PSReadLineKeyHandler -Chord "Ctrl+f" -Function AcceptSuggestion # like fish Set-PSReadLineKeyHandler -Chord "Tab" MenuComplete Set-PSReadLineKeyHandler -Chord "Ctrl+d" DeleteCharOrExit +Set-PSReadLineKeyHandler -Chord "Ctrl+g" -ScriptBlock { Invoke-FzfTabCompletion } -BriefDescription "Fzf tab completion" -Description "Invoke fzf tab completion. Need some input first." +# PsFzf Options +# 'Ctrl+t' for provider path, 'Ctrl+r' for reverse history +Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+t' -PSReadlineChordReverseHistory 'Ctrl+r' + + +# ============================================================== +# alias and functions +# ============================================================== function ~ { cd ~ } function .. { cd .. } function epl {explorer.exe .} Set-Alias touch New-Item - +Set-Alias whereis where.exe # starship # change window name +# save my history +$My_Pwsh_History = "$HOME\my_pwsh_history.txt" function Invoke-Starship-PreCommand { + # window title $ParentFolder = Split-Path $PWD -Leaf $host.ui.Write("`e]0; $ParentFolder `a") + + # save log + Write-Output "$(Get-Date -UFormat '+%Y-%m-%d %H:%M:%S') $env:COMPUTERNAME`:$PID [$Global:LASTEXITCODE] $(Get-History -Count 1)" + | Out-File -FilePath $My_Pwsh_History -Append -Encoding utf8 } Invoke-Expression (&starship init powershell) $ENV:STARSHIP_CONFIG = "$HOME\.config\starship.toml" -# home_util shortcut -$home_util_path = "~\Documents\macro\ahk" -function home_util { - & (Join-Path -Path $home_util_path -ChildPath "home_util.exe") -} -# change encoding + +# -------------------------------------------------------------- +# change encoding +# -------------------------------------------------------------- # ref: https://qiita.com/e4rfx/items/3772ecb58b6918ed5348 # 文字エンコードをUTF8に設定する function Set-UTF8 { @@ -111,14 +133,36 @@ function Enable-SshAgent { #> sudo Set-Service -Name ssh-agent -StartupType Manual && Start-Service ssh-agent } +# auto start ssh-agent and do ssh-add +function Invoke-SshAdd { + <# + .SYNOPSIS + Starts ssh-agent and do ssh-add + + .DESCRIPTION + Starts ssh-agent as admin and do ssh-add, to add sshkeys to ssh-agent. + #> + + Enable-SshAgent + ssh-add +} # execute "ssh-add" to add keys # less options -$env:LESS = "-M -R -S -W -z-4 -x4" +$env:LESS = "-i -M -R -S -W -z-4 -x4" +# ============================================================== +# auto completions for modules +# ============================================================== + +# scoop +# enable completion in current shell, use absolute path because PowerShell Core not respect $env:PSModulePath +Import-Module scoop-completion +#Import-Module "$($(Get-Item $(Get-Command scoop.ps1).Path).Directory.Parent.FullName)\modules\scoop-completion" + # chezmoi completion $script = "$HOME\.config\powershell\chezmoi_completion.ps1" if (Test-Path $script) {