summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.config/bash/bashrc3
-rw-r--r--.config/kak/kakrc19
-rw-r--r--.kshrc6
-rwxr-xr-x.local/bin/bm3
-rwxr-xr-x.local/bin/c3
-rwxr-xr-x.local/bin/macos.d/ghostty-focus.sh74
-rwxr-xr-x.local/bin/macos.d/ghostty.sh73
-rwxr-xr-x.local/bin/macos.d/realpath2
-rwxr-xr-x.local/bin/rk2
-rw-r--r--.profile1
10 files changed, 170 insertions, 16 deletions
diff --git a/.config/bash/bashrc b/.config/bash/bashrc
index 04cbd48..f25f3b5 100644
--- a/.config/bash/bashrc
+++ b/.config/bash/bashrc
@@ -1,4 +1,4 @@
-if [[ ! $- == *i* ]]; then
+if [[ ! $- == *l* ]]; then
. /etc/profile
. ~/.profile
fi
@@ -13,3 +13,4 @@ export PS1='\[\e]0;\w $(test "$IN_KAKOUNE_CONNECT" && printf '%s' "- $KAKOUNE_CL
export PROMPT_DIRTRIM=3
export PROMPT_COMMAND='history -a'
export HISTSIZE=100000
+export HISTCONTROL=ignorespace:erasedups
diff --git a/.config/kak/kakrc b/.config/kak/kakrc
index eceb4f3..9642c96 100644
--- a/.config/kak/kakrc
+++ b/.config/kak/kakrc
@@ -109,17 +109,24 @@ alias global bf buffer-first
alias global bl buffer-last
alias global bo buffer-only
alias global bo! buffer-only-force
+define-command -override -params 1 C %{
+ execute-keys %sh{
+ printf "%s" "<esc>:cd "
+ printenv "${@}"
+ printf "%s" "<ret>"
+ }
+}
+map global user C "<esc>:C "
define-command -override el %{
execute-keys %sh{
- printf "%s" "<esc>:e ${kak_buffile%/*}/"
+ printf "%s" "<esc>:e $(realpath --relative-to "$PWD" "${kak_buffile%/*}")/"
}
}
map global user e "<esc>:el<ret>"
-define-command -override -params 1 C %{
+define-command -override cdl %{
execute-keys %sh{
- printf "%s" "<esc>:cd "
- printenv "${@}"
- printf "%s" "<ret>"
+ printf "%s" "<esc>:cd $(realpath --relative-to "$PWD" "${kak_buffile%/*}")/"
}
}
-map global user c "<esc>:C "
+map global user c "<esc>:cdl<ret>"
+map global user f "<esc>:> lf<ret>"
diff --git a/.kshrc b/.kshrc
deleted file mode 100644
index 9374425..0000000
--- a/.kshrc
+++ /dev/null
@@ -1,6 +0,0 @@
-# [ -f "$HOME/.profile" ] && . "$HOME/.profile"
-[ -f /etc/ksh.kshrc ] && . /etc/ksh.kshrc
-[ -f "$HOME/.config/ksh/dirs" ] && . "$HOME/.config/ksh/dirs"
-# [ -f "$HOME/.config/ksh/pushd" ] && . "$HOME/.config/ksh/pushd"
-# [ -f "$HOME/.config/ksh/popd" ] && . "$HOME/.config/ksh/popd"
-[ -f "$HOME/.config/ksh/ksh.kshrc" ] && . "$HOME/.config/ksh/ksh.kshrc"
diff --git a/.local/bin/bm b/.local/bin/bm
new file mode 100755
index 0000000..47f68bf
--- /dev/null
+++ b/.local/bin/bm
@@ -0,0 +1,3 @@
+#!/bin/sh
+echo "${1:?need a bookmark name} $PWD" >> "${XDG_CONFIG_HOME}/shell/bm-dirs.d/local"
+shortcuts >/dev/null; . /Users/ivi/.config/shell/shortcutrc ; . /Users/ivi/.config/shell/shortcutenvrc
diff --git a/.local/bin/c b/.local/bin/c
index 5f74d14..83f43dc 100755
--- a/.local/bin/c
+++ b/.local/bin/c
@@ -1,2 +1,3 @@
#!/bin/sh
-exec kak -c "$@"
+echo "$KAKOUNE_SESSION: $(:pwd) -> $PWD"
+:cd!
diff --git a/.local/bin/macos.d/ghostty-focus.sh b/.local/bin/macos.d/ghostty-focus.sh
new file mode 100755
index 0000000..e8490c9
--- /dev/null
+++ b/.local/bin/macos.d/ghostty-focus.sh
@@ -0,0 +1,74 @@
+#!/bin/bash
+include='
+on listWindows(appName)
+tell application "System Events"
+ if exists (processes where name is appName) then
+ tell process appName
+ set windowTitles to {}
+ repeat with w in windows
+ set end of windowTitles to name of w
+ end repeat
+ set AppleScript'"'"'s text item delimiters to linefeed
+ return windowTitles
+ end tell
+ else
+ error "A grievous condition hath occurred." number 1
+ end if
+end tell
+end listWindows
+
+on focusWindow(appName, args)
+ -- Replace this with your desired client identifier
+ set sessionId to item 1 of args
+ set clientId to item 2 of args
+ set clientTitle to (clientId & "@[" & sessionId & "]")
+ tell application "System Events"
+ if exists (processes where name is appName) then
+ tell process appName
+ repeat with w in windows
+ set winName to name of w
+ if winName contains clientTitle and winName contains "Kakoune" then
+ -- Bring Ghostty to the front
+ tell application appName to activate
+
+ -- Set focus to the matching window
+ set frontmost to true
+ set value of attribute "AXMain" of w to true
+
+ return "Activated window: " & winName
+ end if
+ end repeat
+ return "No matching window found."
+ end tell
+ else
+ return "Ghostty is not running."
+ end if
+ end tell
+end focusWindow
+'
+
+listwindows() {
+ osascript -e "$include"'
+on run args
+if class of args is list then -- arguments passed come in as a list
+ set result to listWindows(item 1 of args)
+ set AppleScript'"'"'s text item delimiters to linefeed
+ return result as string
+end if
+end run
+' -- "$@"
+}
+focuswindow() {
+ osascript -e "$include"'
+on run args
+if class of args is list then -- arguments passed come in as a list
+ set result to focusWindow("Ghostty", args)
+ set AppleScript'"'"'s text item delimiters to linefeed
+ return result as string
+end if
+end run
+' -- "$@"
+}
+# listwindows "Ghostty"
+# echo "$KAKOUNE_CLIENT@[$KAKOUNE_SESSION]"
+focuswindow "$@"
diff --git a/.local/bin/macos.d/ghostty.sh b/.local/bin/macos.d/ghostty.sh
new file mode 100755
index 0000000..8877559
--- /dev/null
+++ b/.local/bin/macos.d/ghostty.sh
@@ -0,0 +1,73 @@
+#!/bin/bash
+# https://www.macscripter.net/t/how-to-use-passed-arguments-in-apple-script/73668/3
+
+osa='
+on runCommandInteractively(theCommand)
+ tell me to makeNewWindow()
+ tell application "System Events"
+ keystroke ((" " & theCommand) as text)
+ keystroke return
+ end tell
+end runCommandInteractively
+
+-- runCommandInteractively("echo ohai && sleep 5 && exit")
+
+on makeNewWindow()
+ if application "Ghostty" is running then
+ tell application "System Events"
+ set visible of application process "Ghostty" to true
+ delay 0.1
+ end tell
+ end if
+
+ tell application "Ghostty" to activate
+
+ tell application "System Events"
+ set preWindowCount to count of windows of application process "Ghostty"
+ keystroke "n" using command down
+ set tryUntil to (current date) + 5
+ repeat while preWindowCount is not less than (count of windows of application process "Ghostty")
+ delay 0.1
+ if tryUntil is less than (current date) then
+ error "whoops"
+ end if
+ end repeat
+ end tell
+end makeNewWindow
+
+on activateOrMakeNewWindow()
+ if application "Ghostty" is running then
+ tell application "System Events"
+ set visible of application process "Ghostty" to true
+ delay 0.1
+ end tell
+ end if
+
+ tell application "Ghostty" to activate
+
+ tell application "System Events"
+ if 0 is equal to (count of windows of application process "Ghostty") then
+ tell me to makeNewWindow()
+ end if
+ end tell
+end activateOrMakeNewWindow
+
+-- activateOrMakeNewWindow()
+on run args
+if class of args is list then -- arguments passed come in as a list
+ set quotedArgs to {}
+ repeat with arg in args
+ -- set end of quotedArgs to "'"'"'" & arg & "'"'"'"
+ set end of quotedArgs to "" & arg
+ end repeat
+
+ set AppleScript'"'"'s text item delimiters to " "
+ set joinedArgs to quotedArgs as string
+ set AppleScript'"'"'s text item delimiters to ""
+
+ runCommandInteractively(joinedArgs)
+end if
+end run
+'
+echo "$osa"
+osascript -e "$osa" -- "$@"
diff --git a/.local/bin/macos.d/realpath b/.local/bin/macos.d/realpath
new file mode 100755
index 0000000..1ebe270
--- /dev/null
+++ b/.local/bin/macos.d/realpath
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec grealpath "$@"
diff --git a/.local/bin/rk b/.local/bin/rk
index d2b072d..830867f 100755
--- a/.local/bin/rk
+++ b/.local/bin/rk
@@ -1,3 +1,3 @@
#!/bin/sh
rg --vimgrep "$@" |
- c "${KAKOUNE_SESSION:-s}" -e 'db! *grep*; rename-buffer *grep*; set-option window filetype grep; evaluate-commands -try-client %opt{toolsclient} %{ buffer *grep*; set-option window filetype grep }'
+ kak -c "${KAKOUNE_SESSION}" -e 'db! *grep*; rename-buffer *grep*; set-option window filetype grep; evaluate-commands -try-client %opt{toolsclient} %{ buffer *grep*; set-option window filetype grep }'
diff --git a/.profile b/.profile
index 4cf4f83..7714137 100644
--- a/.profile
+++ b/.profile
@@ -1,4 +1,3 @@
-export ENV=$HOME/.kshrc
[ -f "$HOME/.config/shell/profile" ] && . "$HOME/.config/shell/profile"
if [ -d $HOME/.config/shell/profile.d ]; then