diff --git a/bin/install.ps1 b/bin/install.ps1 index 72cda8c..87905bd 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)) { @@ -42,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/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 index 4ef1436..70722db 100644 --- a/dotfiles/ahk/key_remaps.ahk +++ b/dotfiles/ahk/key_remaps.ahk @@ -57,6 +57,9 @@ vk1C & d:: Send,{Blind}{PgDn} return +; ========================================== +; include extra key remaps +#Include extra_remaps.ahk ; ========================================== ; HankakuZenkaku to esc diff --git a/dotfiles/fish/config.fish b/dotfiles/fish/config.fish index b93a205..79292b1 100644 --- a/dotfiles/fish/config.fish +++ b/dotfiles/fish/config.fish @@ -2,6 +2,21 @@ # bass source ~/.bashrc if status is-interactive + # 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 # starship @@ -27,3 +42,11 @@ bind \b backward-kill-word # env set -x LESS '-i -r -M -R -S -W -z-4 -x4' +# 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 + diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index 4819b76..773e057 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -4,7 +4,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 @@ -139,3 +140,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" 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..9ed7b93 100644 --- a/dotfiles/pwsh/powershell_profile.ps1 +++ b/dotfiles/pwsh/powershell_profile.ps1 @@ -1,14 +1,19 @@ # ============================================================== # PSReadLine Settings # ============================================================== -Import-Module PSReadLine -Set-PSReadLineOption -PredictionSource History +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+f" -Function ForwardWord # like fish +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 @@ -26,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"