Skip to content

Commit fe3a3ee

Browse files
committed
feat: fix broken espanso quick access, add :k for quick kanata
1 parent 053a38e commit fe3a3ee

File tree

5 files changed

+53
-76
lines changed

5 files changed

+53
-76
lines changed

CLI-Basic.psm1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,15 @@ function tree() {
202202
Write-Host "depth flags : -L=2" -ForegroundColor Green
203203
}
204204

205-
function Get-Navitldr(){
205+
function Get-Navitldr() {
206206
$dashArgs = ($args | Where-Object { $_ -like '-*' }) -join " "
207207
$pureStringArgs = ($args | Where-Object { $_ -notlike '-*' }) -join " "
208208
# HACK: have to manually null it out... since `navi` dont understand the ''..?
209-
if($dashArgs -eq ""){$dashArgs = $null}
210-
if($pureStringArgs -eq ""){
209+
if ($dashArgs -eq "") { $dashArgs = $null }
210+
if ($pureStringArgs -eq "") {
211211
navi
212212
}
213-
else{
213+
else {
214214
navi --tldr $pureStringArgs $dashArgs
215215
}
216216
}

quickFilePathAction.psm1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ function Build-FromKeil($clean = $null) {
5353
Get-Content -Tail 10 $logfile
5454
}
5555
function Copy-Just($directory = "$(zq newplus templates)\justfile") {
56-
if (test-path "justfile"){
56+
if (Test-Path "justfile") {
5757
Copy-Item $directory -Confirm
5858
}
59-
else{
59+
else {
6060
Copy-Item $directory
6161
}
6262
}

quickGitAction.psm1

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ function openWebRemote {
1919
chrome (git remote get-url origin)
2020
}
2121

22-
function gitCloneClipboard($finalDir = $null, $url = (Get-Clipboard))
23-
{
22+
function gitCloneClipboard($finalDir = $null, $url = (Get-Clipboard)) {
2423
# HACK: Real hack is extracting links from the Markdown links.
2524
if ($url -match '^\[') {
2625
$processedLink = $url -replace '^\[(.*)\]\(', "" -replace '\)$', ""
@@ -29,7 +28,7 @@ function gitCloneClipboard($finalDir = $null, $url = (Get-Clipboard))
2928
$processedLink = $url
3029
}
3130
$processedLink = $processedLink -replace "#.*", ""
32-
$processedLink = $processedLink -replace "/issues\?.*", "" -replace "/pulls\?.*",""
31+
$processedLink = $processedLink -replace "/issues\?.*", "" -replace "/pulls\?.*", ""
3332

3433
if ($processedLink -match "^https") {
3534
# INFO: here we trim the `?.*` queries part of the URL.

quickPSReadLine.psm1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ $VaultSearchParameters = @{
4646
# TODO: further enhanced by adding different flag at this point.
4747
switch -Regex ($line) {
4848
"^(?!.*-w$)" { $SearchWithQuery = "$line -w"; break }
49-
"^rgj" { $SearchWithQuery = $line -replace "^rgj","rgo"; break }
50-
"^rgo" { $SearchWithQuery = $line -replace "-w$",""; break }
51-
"^igj" { $SearchWithQuery = $line -replace "^igj","ig"; break }
49+
"^rgj" { $SearchWithQuery = $line -replace "^rgj", "rgo"; break }
50+
"^rgo" { $SearchWithQuery = $line -replace "-w$", ""; break }
51+
"^igj" { $SearchWithQuery = $line -replace "^igj", "ig"; break }
5252
}
5353
}
5454
else {
@@ -460,7 +460,7 @@ $rgToRggParameters = @{
460460
$matchFunction = "rg|rgj"
461461
$injectSearch = {
462462
param($command)
463-
$command -match "^($matchFunction)\s"
463+
$command -match "^($matchFunction)\s"
464464
[Microsoft.PowerShell.PSConsoleReadLine]::Replace(0, $Matches[0].Length, "rgr ")
465465
}
466466
if ($line -match "^($matchFunction)") {

quickVimAction.psm1

Lines changed: 41 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ $sessionMap = @{
100100
"pw" = "pwsh"
101101
"nv" = "nvim"
102102
"nu" = "nushell"
103-
"m" = "mouse"
104103
"ob" = "obsidian"
105104
"es" = "espanso"
106105
"vk" = "vulkan-samples"
106+
"m" = "mouse"
107107
"wts" = "wt_shader"
108108
}
109109
function :vs {
@@ -322,26 +322,27 @@ function :obsidian(
322322
}
323323
}
324324

325-
# INFO: switch workspace.
326-
$workspaceNameTable = @{
327-
"j" = "Journal-code-eda"
328-
"jc" = "Journal-code-eda"
329-
"o" = "Obs-Nvim"
330-
"on" = "Obs-Nvim"
331-
}
332-
function :ow {
333-
$defaultWorkspace = "Obs-Nvim"
334-
335-
# Prepare arguments
336-
$argument = $args -join " "
337-
$workspaceName = $workspaceNameTable[$argument] ?? "$defaultWorkspace"
338-
339-
$originalURI = "obsidian://advanced-uri?vault=$global:vaultName&workspace=$workspaceName"
340-
(Start-Process "$originalURI" &) | Out-Null
341-
}
342-
325+
# # INFO: switch workspace.
326+
# $workspaceNameTable = @{
327+
# "j" = "Journal-code-eda"
328+
# "jc" = "Journal-code-eda"
329+
# "o" = "Obs-Nvim"
330+
# "on" = "Obs-Nvim"
331+
# }
332+
# function :ow {
333+
# $defaultWorkspace = "Obs-Nvim"
334+
#
335+
# # Prepare arguments
336+
# $argument = $args -join " "
337+
# $workspaceName = $workspaceNameTable[$argument] ?? "$defaultWorkspace"
338+
#
339+
# $originalURI = "obsidian://advanced-uri?vault=$global:vaultName&workspace=$workspaceName"
340+
# (Start-Process "$originalURI" &) | Out-Null
341+
# }
342+
#
343343
Set-Alias -Name :o -Value :obsidian
344-
Set-Alias -Name :oo -Value obsidian-cli
344+
# Set-Alias -Name :oo -Value obsidian-cli
345+
#
345346
# TODO: make the note taking add the #tag on it. so I could enter the note and start wrting on it right away without adding tag.
346347
function :jrnl {
347348
$argument = $args
@@ -399,6 +400,7 @@ function :jrnl {
399400
}
400401
Invoke-Expression "jrnl $argument"
401402
}
403+
Set-Alias -Name j -Value :jrnl
402404

403405
# INFO: call `Get-UniqueEntryJrnl table` to get current jrnltable list.
404406
function Get-UniqueEntryJrnl {
@@ -436,42 +438,6 @@ function Get-UniqueEntryJrnl {
436438
}
437439
return $all_list
438440
}
439-
440-
Set-Alias -Name j -Value :jrnl
441-
442-
# WARN: recently I found symlink affects recursive tools like fzf and fd a lot...
443-
# Might change that kind of add sy,links everywhere.
444-
$global:HighWay = "D:\ProgramDataD\1_AllActiveProject"
445-
function :hw($destinationName = $null, $HighWaylinkName = "hw", $dir = $global:HighWay, $Remove = $null) {
446-
$currentDir = (Get-Location)
447-
$currentDirLeaf = Split-Path -Path $currentDir -Leaf
448-
if ($Remove -ne $null) {
449-
rm "$global:HighWay/$currentDirLeaf"
450-
rm "$currentDir/$HighWaylinkName"
451-
}
452-
else {
453-
# HACK: create highway symlink within $pwd. To be fair, avoid this altogether.
454-
if ((Test-Path "$currentDir/$HighWaylinkName") -eq $false) {
455-
# New-Item $HighWaylinkName -ItemType SymbolicLink -Value $dir
456-
Write-Output "$HighWaylinkName`n" | Add-Content -Path .\.gitignore
457-
}
458-
else {
459-
Write-Host "Symlink $HighWaylinkName Already Exist" -ForegroundColor Green
460-
}
461-
462-
# INFO: source of highway.
463-
if ($destinationName -eq $null) {
464-
$destinationName = $currentDirLeaf
465-
}
466-
if ((Test-Path "$global:HighWay/$destinationName") -eq $false) {
467-
New-Item "$global:HighWay/$destinationName" -ItemType SymbolicLink -Value $currentDir
468-
Write-Output "$destinationName`n" | Add-Content -Path "$global:HighWay\.gitignore"
469-
}
470-
else {
471-
Write-Host "Symlink $destinationName Already Exist" -ForegroundColor Green
472-
}
473-
}
474-
}
475441
# NOTE: Espanso powershell wrapper.
476442
$espansoAlias = @{
477443
"st" = "status"
@@ -481,20 +447,32 @@ $espansoAlias = @{
481447
function :e {
482448
$argument = ""
483449
# Prepare arguments
484-
foreach ($arg in $args) {
485-
$postProcessArgument = $espansoAlias[$arg] ?? $arg
486-
$argument += "$postProcessArgument "
450+
$defaultArgs = $espansoAlias["e"]
451+
if ($args.Length -eq 0) {
452+
$argument = "$defaultArgs "
487453
}
488-
489-
if ($argument -eq "editInNvimSession ") {
454+
else {
455+
foreach ($arg in $args) {
456+
$postProcessArgument = $espansoAlias[$arg] ?? $arg
457+
$argument += "$postProcessArgument "
458+
}
459+
}
460+
if ($argument -eq "$defaultArgs ") {
490461
$espansoNvimSession = "espanso"
491-
nvim -c "lua require('resession').load `"$espansoNvimSession`""
462+
$codeEditor = "neovide --frame none -- "
463+
Invoke-Expression "$codeEditor -c 'lua require(`"resession`").load `"$espansoNvimSession`"'"
492464
}
493465
else {
494-
Invoke-Expression "espansod $argument"
466+
Invoke-Expression "espanso $argument"
495467
}
496468
}
469+
497470
# INFO: function to switch between applications. Right now it's based on the Show-Window function.
498471
function :s {
499472
Show-Window "$args"
500473
}
474+
function :k {
475+
$dashArgs = ($args | Where-Object { $_ -like '-*' }) -join " "
476+
$pureStringArgs = ($args | Where-Object { $_ -notlike '-*' }) -join " "
477+
Invoke-Expression "kanata $pureStringArgs $dashArgs"
478+
}

0 commit comments

Comments
 (0)