From 700fa0ba792a888801f06203a3fa1a927ef685b6 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Sun, 9 Oct 2022 20:42:38 +0900 Subject: [PATCH 1/9] update: pwsh: PSReadLine version & add CompletionPredictor --- dotfiles/pwsh/README.md | 3 ++- dotfiles/pwsh/powershell_profile.ps1 | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dotfiles/pwsh/README.md b/dotfiles/pwsh/README.md index fcd08ab..70c7973 100644 --- a/dotfiles/pwsh/README.md +++ b/dotfiles/pwsh/README.md @@ -2,6 +2,7 @@ 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 @@ -31,4 +32,4 @@ Especially useful for piping into linux commands like `less` - chezmoi - git - winget -- chocolatey \ No newline at end of file +- chocolatey diff --git a/dotfiles/pwsh/powershell_profile.ps1 b/dotfiles/pwsh/powershell_profile.ps1 index f1e3b7d..4a2982f 100644 --- a/dotfiles/pwsh/powershell_profile.ps1 +++ b/dotfiles/pwsh/powershell_profile.ps1 @@ -1,11 +1,12 @@ # ============================================================== # PSReadLine Settings # ============================================================== -Import-Module PSReadLine -Set-PSReadLineOption -PredictionSource History +Import-Module PSReadLine # >= 2.2.2 +Import-Module CompletionPredictor +Set-PSReadLineOption -PredictionSource HistoryAndPlugin # require PowerShell ≧ 7.2 and PSReadLine ≧ 2.2.2 Set-PSReadlineOption -HistoryNoDuplicates Set-PSReadLineOption -DingTone 880 # beep frequency -Set-PSReadLineKeyHandler -Chord "Ctrl+f" -Function ForwardWord # like fish +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 } From 38928f1e21658d85604cbc0db395f184a1d8e677 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Mon, 10 Oct 2022 22:18:04 +0900 Subject: [PATCH 2/9] add: pwsh: emacs keybindings explicit cmd/pwsh PSReadLine mode --- dotfiles/pwsh/powershell_profile.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dotfiles/pwsh/powershell_profile.ps1 b/dotfiles/pwsh/powershell_profile.ps1 index 4a2982f..ea5f655 100644 --- a/dotfiles/pwsh/powershell_profile.ps1 +++ b/dotfiles/pwsh/powershell_profile.ps1 @@ -3,13 +3,17 @@ # ============================================================== 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-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 } +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 From 9e9782357ebccb268bdb4d9caf212dfaa1451ae4 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Tue, 11 Oct 2022 18:43:32 +0900 Subject: [PATCH 3/9] update: pwsh: module installs (now use ZLocation instead of z to improve tab completion) --- bin/install.ps1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/install.ps1 b/bin/install.ps1 index 72cda8c..0aa87d8 100644 --- a/bin/install.ps1 +++ b/bin/install.ps1 @@ -26,8 +26,15 @@ 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)) { From b52d5f4b289fecca30b228b5cb19fff2fd0151be Mon Sep 17 00:00:00 2001 From: qwjyh Date: Sat, 15 Oct 2022 18:41:10 +0900 Subject: [PATCH 4/9] add: fish: function to save custom history file --- dotfiles/fish/config.fish | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/dotfiles/fish/config.fish b/dotfiles/fish/config.fish index 09b6f19..921ed94 100644 --- a/dotfiles/fish/config.fish +++ b/dotfiles/fish/config.fish @@ -16,9 +16,17 @@ if status is-interactive set -x SHELL bash # opam - # source ~/.opam/opam-init/init.fish > /dev/null 2> /dev/null; or true + source ~/.opam/opam-init/init.fish > /dev/null 2> /dev/null; or true end # key bindings -bind \b backward-kill-word \ No newline at end of file +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" + echo "$(date '+%Y-%m-%d %H:%M:%S') $hostname:$fish_pid $PWD [$status] $(history -1)" \ + >> $my_fish_history +end + From d68e0833dbdafd089a3129f172f0ba8877fa1859 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Sat, 15 Oct 2022 19:53:14 +0900 Subject: [PATCH 5/9] fix: fish: exit status logging of my custom history file --- dotfiles/fish/config.fish | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dotfiles/fish/config.fish b/dotfiles/fish/config.fish index 921ed94..aabc101 100644 --- a/dotfiles/fish/config.fish +++ b/dotfiles/fish/config.fish @@ -26,7 +26,8 @@ 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" - echo "$(date '+%Y-%m-%d %H:%M:%S') $hostname:$fish_pid $PWD [$status] $(history -1)" \ + 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 From 609a2f13ba58a71391cb75a075be6807c7150d65 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Sun, 16 Oct 2022 18:14:54 +0900 Subject: [PATCH 6/9] add: ahk: extra remaps --- dotfiles/ahk/extra_remaps.ahk | 25 +++++++++++++++++++++++++ dotfiles/ahk/key_remaps.ahk | 4 ++++ 2 files changed, 29 insertions(+) create mode 100644 dotfiles/ahk/extra_remaps.ahk diff --git a/dotfiles/ahk/extra_remaps.ahk b/dotfiles/ahk/extra_remaps.ahk new file mode 100644 index 0000000..1229096 --- /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 index 4ef1436..3f90df4 100644 --- a/dotfiles/ahk/key_remaps.ahk +++ b/dotfiles/ahk/key_remaps.ahk @@ -62,3 +62,7 @@ return ; HankakuZenkaku to esc sc029:: Send, {Escape} + +; ========================================== +; include extra key remaps +#Include extra_remaps.ahk From 66027b05c248aaf7facf696e2fefe9e7ecf33388 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Mon, 17 Oct 2022 15:58:17 +0900 Subject: [PATCH 7/9] fix: ahk: Hankaku/Zenkaku behavior --- dotfiles/ahk/extra_remaps.ahk | 8 ++++---- dotfiles/ahk/key_remaps.ahk | 7 +++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/dotfiles/ahk/extra_remaps.ahk b/dotfiles/ahk/extra_remaps.ahk index 1229096..5effd07 100644 --- a/dotfiles/ahk/extra_remaps.ahk +++ b/dotfiles/ahk/extra_remaps.ahk @@ -2,10 +2,10 @@ ; mainly for inputting special characters ; Play/Pause -sc121:: - Send {Media_Play_Pause} - return - +;sc121:: +; Send {Media_Play_Pause} +; return +; ; Henkan/Muhenkan + - -> en, em dash vk1D & vkBD:: diff --git a/dotfiles/ahk/key_remaps.ahk b/dotfiles/ahk/key_remaps.ahk index 3f90df4..70722db 100644 --- a/dotfiles/ahk/key_remaps.ahk +++ b/dotfiles/ahk/key_remaps.ahk @@ -57,12 +57,11 @@ vk1C & d:: Send,{Blind}{PgDn} return +; ========================================== +; include extra key remaps +#Include extra_remaps.ahk ; ========================================== ; HankakuZenkaku to esc sc029:: Send, {Escape} - -; ========================================== -; include extra key remaps -#Include extra_remaps.ahk From 745234408a81f0833ef308a478969799d5553fd5 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Mon, 17 Oct 2022 16:56:28 +0900 Subject: [PATCH 8/9] add: neovim: lualine --- bin/install.ps1 | 4 ++- dotfiles/neovim/init.lua | 13 ++++++++- dotfiles/neovim/lua/lualine_setup.lua | 40 +++++++++++++++++++++++++++ dotfiles/neovim/lua/plugins.lua | 6 ++++ 4 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 dotfiles/neovim/lua/lualine_setup.lua diff --git a/bin/install.ps1 b/bin/install.ps1 index 0aa87d8..87905bd 100644 --- a/bin/install.ps1 +++ b/bin/install.ps1 @@ -49,7 +49,9 @@ 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/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index d7bdd8e..4a6db37 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 @@ -138,3 +139,13 @@ cmp.setup({ vim.api.nvim_set_keymap('n', '', "lua require('fzf-lua').files()", { noremap = true, silent = 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" From 9fef6bf5be56841aa3c941253dcf7e4d287e81bc Mon Sep 17 00:00:00 2001 From: qwjyh Date: Mon, 17 Oct 2022 17:34:30 +0900 Subject: [PATCH 9/9] add: pwsh: save my custom history --- dotfiles/pwsh/powershell_profile.ps1 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dotfiles/pwsh/powershell_profile.ps1 b/dotfiles/pwsh/powershell_profile.ps1 index ea5f655..9ed7b93 100644 --- a/dotfiles/pwsh/powershell_profile.ps1 +++ b/dotfiles/pwsh/powershell_profile.ps1 @@ -31,9 +31,16 @@ 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"