Skip to content

Commit

Permalink
chore: misc
Browse files Browse the repository at this point in the history
  • Loading branch information
yqrashawn committed Jan 29, 2025
1 parent d49f143 commit 387df4e
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 36 deletions.
13 changes: 9 additions & 4 deletions .doom.d/autoload.el
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ _b_ranch _j_next _k_prev _h_up
;;;###autoload
(defun +cljr--log-spy (prefix-info log-type arg)
(let* ((log-spy-str (cond
((eq log-type :js-console) "js/console.log")
((eq log-type :squint) "log/spy")
((eq log-type :log!) "log/spy!")
(t "log/spy")))
(log-spy-str (if prefix-info
Expand Down Expand Up @@ -666,8 +666,8 @@ _b_ranch _j_next _k_prev _h_up
(defun +spy (arg)
(interactive "P")
(when (and lispy-mode (memq major-mode '(clojure-mode clojurescript-mode clojurec-mode)))
(let* ((squint? (seq-find (-partial 'string= "squint.edn") (projectile-dir-files (doom-project-root))))
(has-as-log? (or squint? (ignore-errors (save-excursion (re-search-backward ":as log\\]")))))
(let* ((has-as-log? (ignore-errors (save-excursion (re-search-backward ":as log\\]"))))
(squint? (seq-find (-partial 'string= "squint.edn") (projectile-dir-files (doom-project-root))))
(telemere? (+cljr-project-has-dep? "com.taoensso/telemere"))
(glogi? (+cljr-project-has-dep? "lambdaisland/glogi"))
(timbre? (+cljr-project-has-dep? "timbre"))
Expand All @@ -676,12 +676,17 @@ _b_ranch _j_next _k_prev _h_up
(f (apply-partially '+cljr--log-spy
pedestal?
(cond
(squint? :js-console)
(squint? :squint)
((and telemere? (not glogi?)) :log!)
(t :log)))))
(cond
(has-as-log? (funcall f arg))

(squint?
(save-excursion
(cljr--insert-in-ns ":require")
(insert "[\"@/spy\":as log]"))
(funcall f arg))
(glogi?
(save-excursion
(cljr--insert-in-ns ":require")
Expand Down
15 changes: 11 additions & 4 deletions .doom.d/better-default.el
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,16 @@
(apply orig-fn (not arg) project-p))


;;; +word-wrap
(setq! +word-wrap-fill-style 'soft)
(pushnew! +word-wrap-disabled-modes 'minibuffer-mode)

(+global-word-wrap-mode +1)

(defadvice! ++word-wrap--enable-global-mode (orig-fn)
:around #'+word-wrap--enable-global-mode
(unless (derived-mode-p 'prog-mode)
(funcall orig-fn)))
;; (defadvice! ++word-wrap--enable-global-mode (orig-fn)
;; :around #'+word-wrap--enable-global-mode
;; (unless (derived-mode-p 'prog-mode)
;; (funcall orig-fn)))

(set-popup-rules!
'(("^\\*[Hh]elp" :slot 2 :side right :vslot -8 :size 0.35 :select t :quit current)
Expand Down Expand Up @@ -950,3 +954,6 @@ If `DEVICE-NAME' is provided, it will be used instead of prompting the user."
;; and `buffer-terminator-interval'.)
;; (kill-buffer-property . inactive)
(return . :keep))))

;; quote “
;; quote ”
8 changes: 5 additions & 3 deletions .doom.d/map.el
Original file line number Diff line number Diff line change
Expand Up @@ -648,10 +648,12 @@
(:map cider-inspector-mode-map
:n "s" 'yq-s-map
:n "X" #'cider-inspector-set-page-size
:n "C-j" #'cider-inspector-next-inspectable-object
:n "C-k" #'cider-inspector-previous-inspectable-object
:n "gj" #'cider-inspector-next-page
:n "gk" #'cider-inspector-prev-page)
:n "gk" #'cider-inspector-prev-page
:g "C-j" #'cider-inspector-next-inspectable-object
:g "C-k" #'cider-inspector-previous-inspectable-object
:n "C-j" #'cider-inspector-next-inspectable-object
:n "C-k" #'cider-inspector-previous-inspectable-object)
(:map cider-repl-mode-map
(:localleader
"sp" (cmd!
Expand Down
9 changes: 8 additions & 1 deletion modules/yqrashawn/home-manager/cli/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,11 @@ _dopy_completion() {
return 0
}

complete -o default -F _dopy_completion sysdo
# Check if the script is running in Zsh
if [ -n "$ZSH_VERSION" ]; then
# Use compdef for Zsh
compdef _dopy_completion sysdo
elif [ -n "$BASH_VERSION" ]; then
# Use complete for Bash
complete -o default -F _dopy_completion sysdo
fi
9 changes: 6 additions & 3 deletions modules/yqrashawn/home-manager/dotfiles/aerospace.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ default-root-container-orientation = 'auto'
# See https://nikitabobko.github.io/AeroSpace/guide#on-focus-changed-callbacks
# See https://nikitabobko.github.io/AeroSpace/commands#move-mouse
# Fallback value (if you omit the key): on-focused-monitor-changed = []
# on-focused-monitor-changed = ['move-mouse monitor-lazy-center']
on-focused-monitor-changed = []
on-focused-monitor-changed = ['move-mouse window-lazy-center']
# on-focused-monitor-changed = []

# You can effectively turn off macOS "Hide application" (cmd-h) feature by toggling this flag
# Useful if you don't use this macOS feature, but accidentally hit cmd-h or cmd-alt-h key
Expand Down Expand Up @@ -74,7 +74,10 @@ if.app-id = 'ai.perplexity.mac'
run = [ 'move-node-to-workspace B' ]
[[on-window-detected]]
if.app-id = 'com.openai.chat'
run = [ 'move-node-to-workspace B' ]
run = [ 'layout floating', 'move-node-to-workspace B' ]
[[on-window-detected]]
if.app-id = 'ai.perplexity.mac'
run = [ 'layout floating', 'move-node-to-workspace B' ]

### coding workspace
[[on-window-detected]]
Expand Down
39 changes: 22 additions & 17 deletions modules/yqrashawn/home-manager/dotfiles/karabiner.edn
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,24 @@
"PATH=/run/current-system/sw/bin:/opt/homebrew/bin:/usr/local/bin:$PATH %s"
:yabai
"PATH=/run/current-system/sw/bin:/opt/homebrew/bin:/usr/local/bin:$PATH yabai -m %s"
:ae
"PATH=/run/current-system/sw/bin:/opt/homebrew/bin:/usr/local/bin:$PATH ~/.nixpkgs/modules/yqrashawn/home-manager/dotfiles/local-bins/aerofocus %s"
:aero
"PATH=/run/current-system/sw/bin:/opt/homebrew/bin:/usr/local/bin:$PATH aerospace %s"
:km
"osascript -e 'tell application \"Keyboard Maestro Engine\" to do script \"%s\"'"
:kb-maestro
"osascript -e 'tell application \"Keyboard Maestro Engine\" to do script \"%s\"'"
:open "open \"%s\""
:opena "open -a \"%s\""
:curl "/run/current-system/sw/bin/curl -s \"%s\""
:open "open \"%s\""
:opena "open -a \"%s\""
:curl "/run/current-system/sw/bin/curl -s \"%s\""
;; :hsl
;; "PATH=/run/current-system/sw/bin:/opt/homebrew/bin:/usr/local/bin:$PATH hs -A -n -q -t 0.1 -c 'hs.application.launchOrFocus(\"%s\")'"
:hsl
"/opt/homebrew/bin/hs -A -n -q -t 0.01 -c 'hs.application.launchOrFocus(\"%s\")'"
:kitten "/Applications/kitty.app/Contents/MacOS/kitten @ --to unix:/tmp/tkitty %s"
:kitten-splits-layout "/Applications/kitty.app/Contents/MacOS/kitten @ --to unix:/tmp/tkitty goto-layout --match=state:active splits && /Applications/kitty.app/Contents/MacOS/kitten @ --to unix:/tmp/tkitty %s"
:kitten-focus-window "/Applications/kitty.app/Contents/MacOS/kitten @ --to unix:/tmp/tkitty focus-window --match %s"
:kitten "/Applications/kitty.app/Contents/MacOS/kitten @ --to unix:/tmp/tkitty %s"
:kitten-splits-layout "/Applications/kitty.app/Contents/MacOS/kitten @ --to unix:/tmp/tkitty goto-layout --match=state:active splits && /Applications/kitty.app/Contents/MacOS/kitten @ --to unix:/tmp/tkitty %s"
:kitten-focus-window "/Applications/kitty.app/Contents/MacOS/kitten @ --to unix:/tmp/tkitty focus-window --match %s"
:show
"osascript -e 'set appName to \"%s\"\nset startIt to false\ntell application \"System Events\"\n if not (exists process appName) then\n set startIt to true\n else\n set frontmost of process appName to true\n end if\nend tell\nif startIt then\n tell application appName to activate\nend if'\n"
:show-in-firefox
Expand All @@ -50,7 +52,7 @@
"PATH=/run/current-system/sw/bin:/opt/homebrew/bin:/usr/local/bin:$PATH hs -A -n -q -t 0.1 -c 'hs.application.launchOrFocus(\"Firefox Developer Edition\")'; bash ~/Dropbox/sync/scripts/switch-tab '%s'"
:togg
"PATH=/run/current-system/sw/bin:/opt/homebrew/bin:/usr/local/bin:$PATH hs -A -n -q -t 0.1 -c '\nlocal appName = \"%s\";\nlocal x = hs.application.find(appName);\nif x and x:isFrontmost() then\n x:hide();\nelse\n hs.application.launchOrFocus(appName);\nend'"
:yfocus "sh ~/.config/yabai/focus-window %s"
:yfocus "sh ~/.config/yabai/focus-window %s"
:toggle
"osascript -e 'set appName to \"%s\"\nset startIt to false\ntell application \"System Events\"\n if not (exists process appName) then\n set startIt to true\n else if frontmost of process appName then\n set visible of process appName to false\n else\n set frontmost of process appName to true\n end if\nend tell\nif startIt then\n tell application appName to activate\nend if'"
:type
Expand Down Expand Up @@ -81,16 +83,16 @@
:emacs-bufmove-mode {:key :f :condi :emacs-windmove-mode}
:period-mode {:key :period
:afterup {:set ["period-comma-mode" 0]}
:condi [:!emacs-s-mode :!tmux-windmove-mode
:condi [:!emacs-s-mode :!tmux-windmove-mode :!kitty-windmove-mode
:!k2-mode]}
:comma-mode {:key :comma
:condi [:!emacs-s-mode :!tmux-windmove-mode]}
:condi [:!emacs-s-mode :!tmux-windmove-mode :!kitty-windmove-mode]}
:tmux-windmove-mode {:key :q :condi [:Terminals :!comma-mode :!period-mode]}
:kitty-windmove-mode {:key :q :condi [:kitty :!comma-mode :!period-mode]}
:kitty-windresize-mode {:key :c :condi :kitty-windmove-mode}
:warp-windmove-mode {:key :q :condi [:Warp :!comma-mode :!period-mode]}
:tmux-windresize-mode {:key :c :condi :tmux-windmove-mode}
:k2-mode {:key :2 :condi [:!tab-mode :!tmux-windmove-mode]}}
:k2-mode {:key :2 :condi [:!tab-mode :!tmux-windmove-mode :!kitty-windmove-mode]}}
:simlayers
{:test-mode {:key :9}
:contexts-f-mode {:key :f :condi :!Games}
Expand Down Expand Up @@ -136,10 +138,10 @@
;; [:!Tm :!Sreturn_or_enter]
;; [:!Creturn_or_enter :return_or_enter]]}
{:des "chatgpt"
:rules [[:f23 :!OS8]
:rules [;; [:f23 :!OS8]
;; [:f23 :!CT8]
;; [:f23 :f18]
]}
[:f23 [:hsl "/Applications/ChatGPT.app"]]]}
{:des "unstuck emacs"
:rules [[:!CTg ["/bin/kill -s USR2 $(pgrep Emacs)"
"/bin/kill -s USR1 $(pgrep Emacs)"]]]}
Expand Down Expand Up @@ -440,10 +442,11 @@
;; [:j [:sh "open -a kitty --args -o allow_remote_control=yes --single-instance"]]
;; [:j [:op "/Applications/Rio.app"]]
;; [:k :same_wind_app :Emacs]
[:k [:hsl "/Applications/Emacs.app"]]
;; [:k [:hsl "/Applications/Emacs.app"]]
[:k [:op "/Applications/Emacs.app"]]
[:u [:!CTcomma]]

[:quote [:hsl "Perplexity"]]
[:quote [:op "/Applications/Perplexity"]]
[:t [:show-in-firefox-dev "http://localhost:61942/api/local-server/pext/switch-tab?url=https://app.todoist.com/&create-when-missing=1&pin=1&idx=6"]]
[:n [:show-in-firefox-dev "http://localhost:61942/api/local-server/pext/switch-tab?url=https://www.notion.so/&create-when-missing=1&pin=1&idx=3"]]
[:9 [:show-in-firefox-dev "http://localhost:61942/api/local-server/pext/switch-tab?url=https://discord.com/&create-when-missing=1&pin=1&idx=1"]]
Expand All @@ -453,19 +456,20 @@
[:comma :same_wind_app :Safari]
[:l [:op "/Applications/Firefox Developer Edition.app"] :!Firefoxes]
[:l :same_wind_app :Firefoxes]
[:return_or_enter [:togg "/Applications/ChatGPT.app"]]
[:return_or_enter [:op "/System/Applications/iPhone Mirroring.app"]]
;; [:return_or_enter :!OS8]
[:m [:op "/System/Applications/Mail.app"]]
[:v [:op "/Applications/WeChat.app"]]
[:q [:op "/Applications/Karabiner-Elements.app"]]
[:f [:op "/System/Library/CoreServices/Finder.app"]]
[:y :!!x] ; Dash
[:6 :!!z]
;; [:r [:hsl "Orion"]]
;; [:r [:op "/Applications/Orion"]]
;; [:hyphen [:togg "RapidApi"]]
;; [:equal_sign [:togg "Textual"]]
[:period [:togg "Surge Dashboard"] :Surge]
[:period [:togg "Surge"]]
[:8 [:hsl "Karabiner-EventViewer"]]
[:8 [:op "/Applications/Karabiner-EventViewer"]]
;; [:c [:togg "Visual Studio Code"]]
[:c [:togg "Zed"]]
[:e [:w :e]]]}
Expand Down Expand Up @@ -608,6 +612,7 @@
:kitty-windmove-mode
[:return_or_enter :!Ct]
[:m [:!CS8 :m]]
[:comma [:!CS8 :comma]]
[:hyphen [:kitten "load-config"]]
[:open_bracket
[[:hsl "/Applications/Emacs.app"]
Expand Down
1 change: 1 addition & 0 deletions modules/yqrashawn/home-manager/dotfiles/kitty-map.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ map cmd+shift+8>up neighboring_window up
map cmd+shift+8>down neighboring_window down

map cmd+shift+8>m toggle_layout stack
map cmd+shift+8>, set_tab_title
map cmd+shift+8>h show_scrollback
map cmd+shift+8>g show_last_command_output
map cmd+shift+8>e open_url_with_hints
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
new_tab nix
cd ~/.nixpkgs
new_tab ssh
launch ssh mini
launch ssh mini

launch zsh
new_tab misc
new_tab misc

new_tab pext
cd ~/workspace/home/pext
36 changes: 36 additions & 0 deletions modules/yqrashawn/home-manager/dotfiles/local-bins/aerofocus
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env sh

# Check if an application name is provided as an argument
if [ -z "$1" ]; then
echo "Usage: $0 <Application Name>"
exit 1
fi

# Assign the first argument to a variable
app_name="$1"

# Input data
data=$(aerospace list-windows --all --json)
current_window_id=$(aerospace list-windows --focused --json | jq 'first | .["window-id"]')

# Extract the window ID for the specified application
# window_id=$(echo "$data" | awk -F '|' -v app="$app_name" '$2 ~ app {gsub(/ /, "", $1); print $1}')

# # Check if a window ID was found
# if [ -n "$window_id" ]; then
# echo $window_id
# # aerospace focus --window-id "$window_id"
# else
# exit 1
# fi

window_id=$(echo "$data" | jq --arg app "Emacs" --arg current_window_id $current_window_id '
map(select(.["app-name"] == $app and .["window-title"] != "" and .["window-id"] != $current_window_id)) | last | .["window-id"]
')


if [ "$window_id" -gt 0 ]; then
aerospace focus --window-id "$window_id"
else
exit 0
fi

0 comments on commit 387df4e

Please sign in to comment.