From 053304c4d5c7a97f9cd3694631c3d833ff7a4ad3 Mon Sep 17 00:00:00 2001 From: js0ny Date: Thu, 5 Dec 2024 20:06:17 +0000 Subject: [PATCH] sync: from macOS 2024-12-05 --- .gitattributes | 2 +- .vscode/dotfiles.code-snippets | 23 +- bootstrap/macOS.zsh | 2 +- bootstrap/set_path.ps1 | 5 + bootstrap/set_symlink_unix.bash | 5 +- bootstrap/set_symlink_win.ps1 | 4 +- common/{gitconfig => gitconfig.example} | 4 +- platforms/mac/DefaultKeyBinding.dict | 11 + platforms/mac/sketchybar/plugins/battery.sh | 28 + platforms/mac/sketchybar/plugins/clock.sh | 8 + platforms/mac/sketchybar/plugins/front_app.sh | 10 + platforms/mac/sketchybar/plugins/music.sh | 8 + platforms/mac/sketchybar/plugins/space.sh | 7 + platforms/mac/sketchybar/plugins/volume.sh | 20 + platforms/mac/{ => sketchybar}/sketchybarrc | 6 +- platforms/mac/skhdrc | 35 +- platforms/mac/yabairc | 2 +- platforms/mac/zshrc | 3 +- .../win/Microsoft.PowerShell_profile.ps1 | 2 +- platforms/win/wslconfig | 2 +- platforms/wsl/zshrc | 2 +- scripts/__twm_osx_start.zsh | 3 + scripts/__twm_osx_stop.zsh | 3 + tools/browser/surfingkeys.js | 600 ++++++++++-------- tools/obsidian/latex-suite-snippet | 489 ++++++++++++++ {common => tools/obsidian}/obsidian.vimrc | 0 tools/powershell/Aliases.ps1 | 2 +- tools/powershell/Environment.ps1 | 2 +- tools/powershell/Prompt.ps1 | 2 +- tools/vscode/keybindings.json | 96 +-- tools/zsh/common.zshrc | 2 +- tools/zsh/global.zshenv | 2 +- tools/zsh/mod/alias.zsh | 2 +- tools/zsh/mod/config.zsh | 2 +- tools/zsh/mod/env.zsh | 2 +- tools/zsh/mod/keymap.zsh | 2 +- tools/zsh/mod/navi.zsh | 2 +- tools/zsh/mod/prompt.zsh | 2 +- tools/zsh/zshenv | 2 +- 39 files changed, 1025 insertions(+), 379 deletions(-) create mode 100644 bootstrap/set_path.ps1 rename common/{gitconfig => gitconfig.example} (90%) create mode 100644 platforms/mac/DefaultKeyBinding.dict create mode 100755 platforms/mac/sketchybar/plugins/battery.sh create mode 100755 platforms/mac/sketchybar/plugins/clock.sh create mode 100755 platforms/mac/sketchybar/plugins/front_app.sh create mode 100755 platforms/mac/sketchybar/plugins/music.sh create mode 100755 platforms/mac/sketchybar/plugins/space.sh create mode 100755 platforms/mac/sketchybar/plugins/volume.sh rename platforms/mac/{ => sketchybar}/sketchybarrc (96%) create mode 100644 scripts/__twm_osx_start.zsh create mode 100644 scripts/__twm_osx_stop.zsh create mode 100644 tools/obsidian/latex-suite-snippet rename {common => tools/obsidian}/obsidian.vimrc (100%) diff --git a/.gitattributes b/.gitattributes index d07910b..45b454e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,6 @@ # $DOTFILES/.gitattributes # Date: 2024-11-30 -# Author: contact@js0ny.net +# Author: js0ny skhdrc linguist-language=Shell yabairc linguist-language=Shell sketchybarrc linguist-language=Shell diff --git a/.vscode/dotfiles.code-snippets b/.vscode/dotfiles.code-snippets index 5a49f9e..2e11759 100644 --- a/.vscode/dotfiles.code-snippets +++ b/.vscode/dotfiles.code-snippets @@ -15,15 +15,14 @@ // ], // "description": "Log output to console" // } - "Dotfiles": { - "scope": "", - "prefix": "init", - "body": [ - "$LINE_COMMENT \\$DOTFILES/$RELATIVE_FILEPATH", - "$LINE_COMMENT Date: $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE", - "$LINE_COMMENT Author: contact@js0ny.net", - "$LINE_COMMENT $0", - ] - - } -} + "Dotfiles": { + "scope": "", + "prefix": "init", + "body": [ + "$LINE_COMMENT \\$DOTFILES/$RELATIVE_FILEPATH", + "$LINE_COMMENT Date: $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE", + "$LINE_COMMENT Author: js0ny", + "$LINE_COMMENT $0", + ] + } +} \ No newline at end of file diff --git a/bootstrap/macOS.zsh b/bootstrap/macOS.zsh index ef55894..d88c98b 100644 --- a/bootstrap/macOS.zsh +++ b/bootstrap/macOS.zsh @@ -220,7 +220,7 @@ mas install 836500024 # WeChat mas install 451108668 # QQ # plum (Rime IME) -curl -fsSL https://raw.githubusercontent.com/rime/plum/master/rime-install | bash +curl -fsSL https://raw.githubusercontent.com/rime/plum/master/rime-install -o $HOME | bash # Set default apps (duti) # The id of the app can be found by running diff --git a/bootstrap/set_path.ps1 b/bootstrap/set_path.ps1 new file mode 100644 index 0000000..08d1a40 --- /dev/null +++ b/bootstrap/set_path.ps1 @@ -0,0 +1,5 @@ +[System.Environment]::SetEnvironmentVariable("Path_EXT_0", "D:\bin", "User") +[System.Environment]::SetEnvironmentVariable("Path_EXT_0", "$Env:LocalAppData\Cargo\bin", "User") +[System.Environment]::SetEnvironmentVariable("Path_EXT_1", "$Env:LocalAppData\Go\bin", "User") +[System.Environment]::SetEnvironmentVariable("Path_EXT_2", "$Env:LocalAppData\Cargo\bin", "User") +[System.Environment]::SetEnvironmentVariable("Path_EXT_2", "", "User") diff --git a/bootstrap/set_symlink_unix.bash b/bootstrap/set_symlink_unix.bash index 9191e28..8554448 100644 --- a/bootstrap/set_symlink_unix.bash +++ b/bootstrap/set_symlink_unix.bash @@ -1,7 +1,7 @@ #! /bin/bash # $DOTFILES/bootstrap/set_symblink_unix.bash # Date: 2024-12-01 -# Author: contact@js0ny.net +# Author: js0ny # Set symbolic links for Unix-like systems mkdir -p $XDG_CONFIG_HOME/conda $XDG_CONFIG_HOME/git $XDG_CONFIG_HOME/ideavim $XDG_CONFIG_HOME/markdownlint $XDG_CONFIG_HOME/pip $XDG_CONFIG_HOME/neovide $XDG_CONFIG_HOME/powershell $XDG_CONFIG_HOME/vscode $XDG_CONFIG_HOME/NuGet $XDG_CONFIG_HOME/vim $XDG_CONFIG_HOME/tmux $XDG_CONFIG_HOME/npm $XDG_CONFIG_HOME/readline $XDG_CONFIG_HOME/ipython # Not support XDG_CONFIG_HOME but same directory @@ -15,7 +15,6 @@ ln -sf $DOTFILES/common/gitconfig $XDG_CONFIG_HOME/git/config ln -sf $DOTFILES/common/glow.yaml ~/.config/glow/config.yml ln -sf $DOTFILES/common/haskeline ~/.haskeline ln -sf $DOTFILES/common/ideavimrc $XDG_CONFIG_HOME/ideavim/ideavimrc -ln -sf $DOTFILES/common/inputrc $XDG_CONFIG_HOME/readline/inputrc ln -sf $DOTFILES/common/lesskey $XDG_CONFIG_HOME/lesskey ln -sf $DOTFILES/common/npmrc $NPM_CONFIG_USERCONFIG ln -sf $DOTFILES/common/NuGet.Config $XDG_CONFIG_HOME/NuGet/NuGet.Config @@ -37,4 +36,6 @@ if [ $(uname) = "Darwin"]; then ln -sf $DOTFILES/platforms/mac/skhdrc $XDG_CONFIG_HOME/skhd/skhdrc ln -sf $DOTFILES/platforms/mac/sketchybarrc $XDG_CONFIG_HOME/sketchybar/sketchybarrc ln -sf $DOTFILES/platforms/mac/yabairc $XDG_CONFIG_HOME/yabai/yabairc +else + ln -sf $DOTFILES/common/inputrc $XDG_CONFIG_HOME/readline/inputrc fi diff --git a/bootstrap/set_symlink_win.ps1 b/bootstrap/set_symlink_win.ps1 index e709cb0..99e0293 100644 --- a/bootstrap/set_symlink_win.ps1 +++ b/bootstrap/set_symlink_win.ps1 @@ -1,6 +1,6 @@ # $DOTFILES\bootstrap\set_symlink_win.ps1 # Date: 2024-12-01 -# Author: contact@js0ny.net +# Author: js0ny # Set symlinks for dotfiles on Windows # 在 Windows 上设置 dotfiles 的符号链接 @@ -23,7 +23,7 @@ $linkDots = @{ "$BASE_COMMON\NuGet.Config" = "$env:AppData\NuGet\NuGet.Config" "$BASE_COMMON\obsidian.vimrc" = "$env:UserProfile\Obsidian\.obsidian.vimrc" "$BASE_COMMON\pip.conf" = "$env:AppData\pip\pip.ini" - "$BASE_COMMON\vim.noxdg.vimrc" = "$env:Vim\_vimrc" + "$BASE_COMMON\vimrc" = "$env:Vim\_vimrc" "$BASE_TOOLS\ipython" = "$env:IPYTHONDIR" "$BASE_TOOLS\nvim" = "$env:XDG_CONFIG_HOME\nvim" } diff --git a/common/gitconfig b/common/gitconfig.example similarity index 90% rename from common/gitconfig rename to common/gitconfig.example index 6b98b60..b161479 100644 --- a/common/gitconfig +++ b/common/gitconfig.example @@ -3,8 +3,8 @@ # ln -sf $DOTFILES/.config/git/.gitconfig $XDG_CONFIG_HOME/git/config # New-Item -ItemType SymbolicLink -Path "$Env:XDG_CONFIG_HOME\git\config" -Target "$DOTFILES\.config\git\.gitconfig" [user] - name = js0ny - email = json.y@outlook.com + name = whoami + email = whoami@example.com [core] editor = nvim pager = delta diff --git a/platforms/mac/DefaultKeyBinding.dict b/platforms/mac/DefaultKeyBinding.dict new file mode 100644 index 0000000..eceab87 --- /dev/null +++ b/platforms/mac/DefaultKeyBinding.dict @@ -0,0 +1,11 @@ +// ~/Library/Keybindings/DefaultKeyBinding.dict +{ + // Colemak Vim Style Arrows + "^h" = "moveBackward:"; + "^n" = "moveDown:"; + "^e" = "moveUp:"; + "^i" = "moveForward:"; + // Colemak Vim Style Home/End, Insert & Append + "^l" = "moveToBeginningOfLine:"; + "^a" = "moveToEndOfLine:"; +} diff --git a/platforms/mac/sketchybar/plugins/battery.sh b/platforms/mac/sketchybar/plugins/battery.sh new file mode 100755 index 0000000..9dd9627 --- /dev/null +++ b/platforms/mac/sketchybar/plugins/battery.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +PERCENTAGE="$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1)" +CHARGING="$(pmset -g batt | grep 'AC Power')" + +if [ "$PERCENTAGE" = "" ]; then + exit 0 +fi + +case "${PERCENTAGE}" in + 9[0-9]|100) ICON="" + ;; + [6-8][0-9]) ICON="" + ;; + [3-5][0-9]) ICON="" + ;; + [1-2][0-9]) ICON="" + ;; + *) ICON="" +esac + +if [[ "$CHARGING" != "" ]]; then + ICON="" +fi + +# The item invoking this script (name $NAME) will get its icon and label +# updated with the current battery status +sketchybar --set "$NAME" icon="$ICON" label="${PERCENTAGE}%" diff --git a/platforms/mac/sketchybar/plugins/clock.sh b/platforms/mac/sketchybar/plugins/clock.sh new file mode 100755 index 0000000..d7e25bb --- /dev/null +++ b/platforms/mac/sketchybar/plugins/clock.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +# The $NAME variable is passed from sketchybar and holds the name of +# the item invoking this script: +# https://felixkratz.github.io/SketchyBar/config/events#events-and-scripting + +sketchybar --set "$NAME" label="$(date '+%d日周%u %H:%M')" + diff --git a/platforms/mac/sketchybar/plugins/front_app.sh b/platforms/mac/sketchybar/plugins/front_app.sh new file mode 100755 index 0000000..fb6d0b3 --- /dev/null +++ b/platforms/mac/sketchybar/plugins/front_app.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +# Some events send additional information specific to the event in the $INFO +# variable. E.g. the front_app_switched event sends the name of the newly +# focused application in the $INFO variable: +# https://felixkratz.github.io/SketchyBar/config/events#events-and-scripting + +if [ "$SENDER" = "front_app_switched" ]; then + sketchybar --set "$NAME" label="$INFO" +fi diff --git a/platforms/mac/sketchybar/plugins/music.sh b/platforms/mac/sketchybar/plugins/music.sh new file mode 100755 index 0000000..d32161c --- /dev/null +++ b/platforms/mac/sketchybar/plugins/music.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +music_info=$(curlie GET http://localhost:10767/api/v1/playback/now-playing | jq -r '"\(.info.name) - \(.info.artistName)"') + + +ICON="" + +sketchybar --set $NAME label="$music_info" icon="$ICON" diff --git a/platforms/mac/sketchybar/plugins/space.sh b/platforms/mac/sketchybar/plugins/space.sh new file mode 100755 index 0000000..b8602b5 --- /dev/null +++ b/platforms/mac/sketchybar/plugins/space.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +# The $SELECTED variable is available for space components and indicates if +# the space invoking this script (with name: $NAME) is currently selected: +# https://felixkratz.github.io/SketchyBar/config/components#space----associate-mission-control-spaces-with-an-item + +sketchybar --set "$NAME" background.drawing="$SELECTED" diff --git a/platforms/mac/sketchybar/plugins/volume.sh b/platforms/mac/sketchybar/plugins/volume.sh new file mode 100755 index 0000000..6e69a5d --- /dev/null +++ b/platforms/mac/sketchybar/plugins/volume.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# The volume_change event supplies a $INFO variable in which the current volume +# percentage is passed to the script. + +if [ "$SENDER" = "volume_change" ]; then + VOLUME="$INFO" + + case "$VOLUME" in + [6-9][0-9]|100) ICON="󰕾" + ;; + [3-5][0-9]) ICON="󰖀" + ;; + [1-9]|[1-2][0-9]) ICON="󰕿" + ;; + *) ICON="󰖁" + esac + + sketchybar --set "$NAME" icon="$ICON" label="$VOLUME%" +fi diff --git a/platforms/mac/sketchybarrc b/platforms/mac/sketchybar/sketchybarrc similarity index 96% rename from platforms/mac/sketchybarrc rename to platforms/mac/sketchybar/sketchybarrc index 7486611..beb6fcf 100755 --- a/platforms/mac/sketchybarrc +++ b/platforms/mac/sketchybar/sketchybarrc @@ -1,6 +1,6 @@ # $DOTFILES/platforms/mac/sketchybarrc # Date: 2024-11-30 -# Author: contact@js0ny.net +# Author: js0ny # TODO: Reorganize this file # This is a demo config to showcase some of the most important commands. # It is meant to be changed and configured, as it is intentionally kept sparse. @@ -41,7 +41,7 @@ sketchybar --default "${default[@]}" # https://felixkratz.github.io/SketchyBar/config/components#space----associate-mission-control-spaces-with-an-item # to indicate active and available mission control spaces. -SPACE_ICONS=("1" "2" "3" "4" "5" "6" "7" "8" "9" "10") +SPACE_ICONS=("" "" "" "󰖟" "" "" "7" "8" "9" "10") for i in "${!SPACE_ICONS[@]}" do sid="$(($i+1))" @@ -89,7 +89,7 @@ sketchybar --add item clock center \ --add item battery right \ --set battery update_freq=120 script="$PLUGIN_DIR/battery.sh" \ --subscribe battery system_woke power_source_change \ - --add item apple_music right + --add item apple_music right sketchybar --add item music right sketchybar --set music \ diff --git a/platforms/mac/skhdrc b/platforms/mac/skhdrc index 2dc756f..5ec3639 100644 --- a/platforms/mac/skhdrc +++ b/platforms/mac/skhdrc @@ -1,36 +1,19 @@ # $DOTFILES/platforms/mac/skhdrc # Date: 2024-11-30 -# Author: contact@js0ny.net +# Author: js0ny # Location: $XDG_CONFIG_HOME/skhd/skhdrc # Linking: # ln -sf $DOTFILES/platforms/mac/skhdrc $XDG_CONFIG_HOME/skhd/skhdrc # Navigation -cmd - h : yabai -m window --focus west -cmd - n : yabai -m window --focus south -cmd - e : yabai -m window --focus north -cmd - i : yabai -m window --focus east +alt - h : yabai -m window --focus west +alt - n : yabai -m window --focus south +alt - e : yabai -m window --focus north +alt - i : yabai -m window --focus east # Moving windows -shift + cmd - h : yabai -m window --warp west -shift + cmd - n : yabai -m window --warp south -shift + cmd - e : yabai -m window --warp north -shift + cmd - i : yabai -m window --warp east - -shift + alt - h : \ - yabai -m window --resize left:-20:0 ; \ - yabai -m window --resize right:-20:0 - -shift + alt - n : \ - yabai -m window --resize bottom:0:20 ; \ - yabai -m window --resize top:0:20 - -shift + alt - e : \ - yabai -m window --resize top:0:-20 ; \ - yabai -m window --resize bottom:0:-20 - -shift + alt - i : \ - yabai -m window --resize right:20:0 ; \ - yabai -m window --resize left:20:0 - +shift + alt - h : yabai -m window --warp west +shift + alt - n : yabai -m window --warp south +shift + alt - e : yabai -m window --warp north +shift + alt - i : yabai -m window --warp east diff --git a/platforms/mac/yabairc b/platforms/mac/yabairc index a9d6b8d..5638ce4 100644 --- a/platforms/mac/yabairc +++ b/platforms/mac/yabairc @@ -1,7 +1,7 @@ #!/usr/bin/env sh # $DOTFILES/platforms/mac/yabairc # Date: 2024-11-30 -# Author: contact@js0ny.net +# Author: js0ny # TODO: Reorganize this file # diff --git a/platforms/mac/zshrc b/platforms/mac/zshrc index bf3d429..43661fd 100644 --- a/platforms/mac/zshrc +++ b/platforms/mac/zshrc @@ -1,6 +1,6 @@ # $DOTFILES/platforms/mac/zshrc # Date: 2024-11-30 -# Author: contact@js0ny.net +# Author: js0ny # Sourced by user's zshrc if is macOS 在用户的 zshrc 中被引用,macOS 特定配置 # Entry point in $DOTFILES/tools/zsh/common.zshrc (入口点) @@ -25,3 +25,4 @@ fi unset __conda_setup # <<< conda initialize <<< +alias start-twm="source $DOTFILES/scripts/__twm_osx_start.zsh" diff --git a/platforms/win/Microsoft.PowerShell_profile.ps1 b/platforms/win/Microsoft.PowerShell_profile.ps1 index 08a6cff..2b0ac16 100644 --- a/platforms/win/Microsoft.PowerShell_profile.ps1 +++ b/platforms/win/Microsoft.PowerShell_profile.ps1 @@ -1,6 +1,6 @@ # $DOTFILES/platforms\win\Microsoft.PowerShell_profile.ps1 # Date: 2024-12-01 -# Author: contact@js0ny.net +# Author: js0ny # PowerShell profile for Windows ### Load Configs ### diff --git a/platforms/win/wslconfig b/platforms/win/wslconfig index bd68ee5..ebdd29f 100644 --- a/platforms/win/wslconfig +++ b/platforms/win/wslconfig @@ -1,6 +1,6 @@ # $DOTFILES\platforms\win\wslconfig # Date: 2024-12-01 -# Author: contact@js0ny.net +# Author: js0ny # Config Files (mainly for networking) for WSL2 (Windows Subsystem for Linux 2) # 适用于 Windows 的 Linux 子系统 2 的配置文件(主要用于网络) diff --git a/platforms/wsl/zshrc b/platforms/wsl/zshrc index fdc7691..d052dd6 100644 --- a/platforms/wsl/zshrc +++ b/platforms/wsl/zshrc @@ -1,6 +1,6 @@ # $DOTFILES/platforms/wsl/zshrc # Date: 2024-12-01 -# Author: contact@js0ny.net +# Author: js0ny # Sourced by user's zshrc if is WSL 在用户的 zshrc 中被引用,WSL 特定配置 # Entry point in $DOTFILES/tools/zsh/common.zshrc (入口点) diff --git a/scripts/__twm_osx_start.zsh b/scripts/__twm_osx_start.zsh new file mode 100644 index 0000000..d6a18e3 --- /dev/null +++ b/scripts/__twm_osx_start.zsh @@ -0,0 +1,3 @@ +yabai --start-service +skhd --start-service +brew services start sketchybar diff --git a/scripts/__twm_osx_stop.zsh b/scripts/__twm_osx_stop.zsh new file mode 100644 index 0000000..e0666d1 --- /dev/null +++ b/scripts/__twm_osx_stop.zsh @@ -0,0 +1,3 @@ +yabai --stop-service +skhd --stop-service +brew services stop sketchybar diff --git a/tools/browser/surfingkeys.js b/tools/browser/surfingkeys.js index e3ec806..e0a7bbd 100644 --- a/tools/browser/surfingkeys.js +++ b/tools/browser/surfingkeys.js @@ -1,7 +1,9 @@ // Paste this into surfingkeys advanced settings // or use: // Load settings from: https://raw.githubusercontent.com/js0ny/dotfiles/refs/heads/master/browser/surfingkeys.js +// TODO: Visual Mode +// #region Example /** Examples // an example to create a new mapping `ctrl-y` @@ -17,81 +19,110 @@ api.map('gt', 'T'); api.unmap(''); */ +// #endregion // Settings -settings.language = "zh-CN" ; +settings.language = "zh-CN"; settings.showModeStatus = false; // Keymap, reference https://github.com/texiwustion/colemak_config_for_surfingkeys/tree/main +// #region Helper const forward = { - add: function (key) { // 转发即将被 unmap 的键 - return api.map(`for${key}`, key) - }, - cancel: function (key) { // 删除转发生成的键 - api.unmap(`for${key}`) - api.unmap(key) - }, - use: function (key) { - return `for${key}` - } + add: function (key) { // 转发即将被 unmap 的键 + return api.map(`for${key}`, key) + }, + cancel: function (key) { // 删除转发生成的键 + api.unmap(`for${key}`) + api.unmap(key) + }, + use: function (key) { + return `for${key}` + } } const colemak = { - forward: function (key) { // 转发即将被 unmap 的键 - api.map(key, `col${key}`) - api.unmap(`col${key}`) - - }, - use: function (key) { - return `col${key}` - }, - map: function (a, b) { - api.map(colemak.use(a), forward.use(b)) - } + forward: function (key) { // 转发即将被 unmap 的键 + api.map(key, `col${key}`) + api.unmap(`col${key}`) + + }, + use: function (key) { + return `col${key}` + }, + map: function (a, b) { + api.map(colemak.use(a), forward.use(b)) + } } const forwardFactory = { - push: function (mapLists) { // forward original keys - for (let key in mapLists) { - forward.add(mapLists[key]) - } - }, - map: function (mapLists) { - for (let key in mapLists) { - colemak.map(key, mapLists[key]) + push: function (mapLists) { // forward original keys + for (let key in mapLists) { + forward.add(mapLists[key]) } - }, - pull: function (mapLists) { - for (let key in mapLists) { - forward.cancel(mapLists[key]) - } - for (let key in mapLists) { - colemak.forward(key) - } + }, + map: function (mapLists) { + for (let key in mapLists) { + colemak.map(key, mapLists[key]) } + }, + pull: function (mapLists) { + for (let key in mapLists) { + forward.cancel(mapLists[key]) + } + for (let key in mapLists) { + colemak.forward(key) + } + } +} +// #endregion +// #region Keymap +const mapLists = { + /// scroll page + // Arrow + 'n': 'j', + 'e': 'k', + 'i': 'l', + // l <-> i + 'l': 'i', + 'L': 'I', + // k <-> n + 'k': 'n', + 'K': 'N', + // j <-> e + 'j': 'e', + // PrevTab < H - I > NextTab + 'H': 'E', + 'I': 'R', + // E,N -> Up/Down HalfPage + 'N': 'd', + 'E': 'e', + // F -> Open Link in New Tab + 'F': 'af', + // oH -> Tab History + 'oH': 'H', + // gh/gi -> Prev/Next History + 'gh': 'S', + 'gi': 'D', + // t -> Open Link in New Tab + 't': 'gf', + // 缩放 + 'zu': 'zi', + 'zo': 'ze', + 'zz': 'zr', } -const mapLists = { - /// scroll page - // Arrow - 'n': 'j', - 'e': 'k', - 'i': 'l', - // l <-> i - 'l': 'i', - 'L': 'I', - // k <-> n - 'k': 'n', - 'K': 'N', - // j <-> e - 'j': 'e', - 'J': 'E', - // 缩放 - 'zu': 'zi', - 'zo': 'ze', - 'zz': 'zr', +const vmapLists = { + 'n': 'j', + 'N': 'J', + 'e': 'k', + 'E': 'K', + 'i': 'l', + 'I': 'L', + 'j': 'e', + 'J': 'E', + 'k': 'n', + 'K': 'N', } forwardFactory.push(mapLists) -api.unmap('t') forwardFactory.map(mapLists) // 鼠标点击 api.unmap('gi') @@ -101,260 +132,297 @@ api.unmap(';m') api.unmap(';fs') api.unmap('O') api.unmap('C') +api.map('g/', 'gU') // Goto Root Domain forwardFactory.pull(mapLists) +// #endregion -// Search Alias -api.addSearchAlias('f', 'Felo', 'https://felo.ai/search?q=', 's', 'https://duckduckgo.com/ac/?q=', function(response) { - var res = JSON.parse(response.text); - return res.map(function(r){ - return r.phrase; - }); +// #region Search Alias +api.addSearchAlias('f', 'Felo', 'https://felo.ai/search?q=', 's', 'https://duckduckgo.com/ac/?q=', function (response) { + var res = JSON.parse(response.text); + return res.map(function (r) { + return r.phrase; + }); }); -api.addSearchAlias('p', 'Perplexity', 'https://www.perplexity.ai/?q=', 's', 'https://duckduckgo.com/ac/?q=', function(response) { - var res = JSON.parse(response.text); - return res.map(function(r){ - return r.phrase; - }); +api.addSearchAlias('p', 'Perplexity', 'https://www.perplexity.ai/?q=', 's', 'https://duckduckgo.com/ac/?q=', function (response) { + var res = JSON.parse(response.text); + return res.map(function (r) { + return r.phrase; + }); }); -api.addSearchAlias('r', 'Raindrop', 'https://app.raindrop.io/my/0/', 's', 'https://duckduckgo.com/ac/?q=', function(response) { - var res = JSON.parse(response.text); - return res.map(function(r){ - return r.phrase; - }); +api.addSearchAlias('r', 'Raindrop', 'https://app.raindrop.io/my/0/', 's', 'https://duckduckgo.com/ac/?q=', function (response) { + var res = JSON.parse(response.text); + return res.map(function (r) { + return r.phrase; + }); }); +api.addSearchAlias('c', 'ChatGPT', 'https://chatgpt.com/?q=', 's', 'https://duckduckgo.com/ac/?q=', function (response) { + var res = JSON.parse(response.text); + return res.map(function (r) { + return r.phrase; + }); +}); +// #endregion +// #region Site-specific -// Theme, reference to https://github.com/Foldex/surfingkeys-config -api.Hints.style('border: solid 2px #4C566A; color:#A3BE8C; background: initial; background-color: #3B4252;'); -api.Hints.style("border: solid 2px #4C566A !important; padding: 1px !important; color: #E5E9F0 !important; background: #3B4252 !important;", "text"); -api.Visual.style('marks', 'background-color: #A3BE8C99;'); -api.Visual.style('cursor', 'background-color: #88C0D0;'); -settings.theme = ` -fg: #E5E9F0; -bg: #3B4252; -bg-dark: #2E3440; -border: #4C566A; -main-fg: #88C0D0; -accent-fg: #A3BE8C; -info-fg: #5E81AC; -select: #4C566A; -/* ---------- Generic ---------- */ -.sk_theme { -background: var(--bg); -color: var(--fg); - background-color: var(--bg); - border-color: var(--border); - font-family: var(--font); - font-size: var(--font-size); - font-weight: var(--font-weight); -} +// chatgpt.com +api.unmap('t', /chatgpt.com/); +api.mapkey('tn', 'New Chat', function () { + var btn = document.querySelector('div.no-draggable:nth-child(3) > span:nth-child(1) > button:nth-child(1)') + btn.click(); +}, { domain: /chatgpt.com/ }); +api.mapkey('ts', 'Start/Stop Generating', function () { + var btn = document.querySelector('button.h-8:nth-child(2)'); + btn.click(); +}, { domain: /chatgpt.com/ }); +api.mapkey('ts', 'Start/Stop Generating', function () { + var btn = document.querySelector('button.h-8:nth-child(2)'); + btn.click(); +}, { domain: /chatgpt.com/ }); +api.mapkey('S', 'Start/Stop Generating', function () { + var btn = document.querySelector('button.h-8:nth-child(2)'); + btn.click(); +}, { domain: /chatgpt.com/ }); +//api.mapkey('tm', 'Toggle Model', function () { +// var btn = document.querySelector('#radix -\: r2i\:'); +// btn.click(); +//}, { domain: /chatgpt.com/ }); -input { - font-family: var(--font); - font-weight: var(--font-weight); -} +// #endregion -.sk_theme tbody { - color: var(--fg); -} +// #region Theme +// reference to https://github.com/Foldex/surfingkeys-config +// api.Hints.style('border: solid 2px #4C566A; color:#A3BE8C; background: initial; background-color: #3B4252;'); +// api.Hints.style("border: solid 2px #4C566A !important; padding: 1px !important; color: #E5E9F0 !important; background: #3B4252 !important;", "text"); +// api.Visual.style('marks', 'background-color: #A3BE8C99;'); +// api.Visual.style('cursor', 'background-color: #88C0D0;'); +// settings.theme = ` +// fg: #E5E9F0; +// bg: #3B4252; +// bg-dark: #2E3440; +// border: #4C566A; +// main-fg: #88C0D0; +// accent-fg: #A3BE8C; +// info-fg: #5E81AC; +// select: #4C566A; +// /* ---------- Generic ---------- */ +// .sk_theme { +// background: var(--bg); +// color: var(--fg); +// background-color: var(--bg); +// border-color: var(--border); +// font-family: var(--font); +// font-size: var(--font-size); +// font-weight: var(--font-weight); +// } -.sk_theme input { - color: var(--fg); -} +// input { +// font-family: var(--font); +// font-weight: var(--font-weight); +// } -/* Hints */ -#sk_hints .begin { - color: var(--accent-fg) !important; -} +// .sk_theme tbody { +// color: var(--fg); +// } -#sk_tabs .sk_tab { - background: var(--bg-dark); - border: 1px solid var(--border); -} +// .sk_theme input { +// color: var(--fg); +// } -#sk_tabs .sk_tab_title { - color: var(--fg); -} +// /* Hints */ +// #sk_hints .begin { +// color: var(--accent-fg) !important; +// } -#sk_tabs .sk_tab_url { - color: var(--main-fg); -} +// #sk_tabs .sk_tab { +// background: var(--bg-dark); +// border: 1px solid var(--border); +// } -#sk_tabs .sk_tab_hint { - background: var(--bg); - border: 1px solid var(--border); - color: var(--accent-fg); -} +// #sk_tabs .sk_tab_title { +// color: var(--fg); +// } -.sk_theme #sk_frame { - background: var(--bg); - opacity: 0.2; - color: var(--accent-fg); -} +// #sk_tabs .sk_tab_url { +// color: var(--main-fg); +// } -/* ---------- Omnibar ---------- */ -/* Uncomment this and use settings.omnibarPosition = 'bottom' for Pentadactyl/Tridactyl style bottom bar */ -/* .sk_theme#sk_omnibar { - width: 100%; - left: 0; -} */ +// #sk_tabs .sk_tab_hint { +// background: var(--bg); +// border: 1px solid var(--border); +// color: var(--accent-fg); +// } -.sk_theme .title { - color: var(--accent-fg); -} +// .sk_theme #sk_frame { +// background: var(--bg); +// opacity: 0.2; +// color: var(--accent-fg); +// } -.sk_theme .url { - color: var(--main-fg); -} +// /* ---------- Omnibar ---------- */ +// /* Uncomment this and use settings.omnibarPosition = 'bottom' for Pentadactyl/Tridactyl style bottom bar */ +// /* .sk_theme#sk_omnibar { +// width: 100%; +// left: 0; +// } */ -.sk_theme .annotation { - color: var(--accent-fg); -} +// .sk_theme .title { +// color: var(--accent-fg); +// } -.sk_theme .omnibar_highlight { - color: var(--accent-fg); -} +// .sk_theme .url { +// color: var(--main-fg); +// } -.sk_theme .omnibar_timestamp { - color: var(--info-fg); -} +// .sk_theme .annotation { +// color: var(--accent-fg); +// } -.sk_theme .omnibar_visitcount { - color: var(--accent-fg); -} +// .sk_theme .omnibar_highlight { +// color: var(--accent-fg); +// } -.sk_theme #sk_omnibarSearchResult ul li:nth-child(odd) { - background: var(--bg-dark); -} +// .sk_theme .omnibar_timestamp { +// color: var(--info-fg); +// } -.sk_theme #sk_omnibarSearchResult ul li.focused { - background: var(--border); -} +// .sk_theme .omnibar_visitcount { +// color: var(--accent-fg); +// } -.sk_theme #sk_omnibarSearchArea { - border-top-color: var(--border); - border-bottom-color: var(--border); -} +// .sk_theme #sk_omnibarSearchResult ul li:nth-child(odd) { +// background: var(--bg-dark); +// } -.sk_theme #sk_omnibarSearchArea input, -.sk_theme #sk_omnibarSearchArea span { - font-size: var(--font-size); -} +// .sk_theme #sk_omnibarSearchResult ul li.focused { +// background: var(--border); +// } -.sk_theme .separator { - color: var(--accent-fg); -} +// .sk_theme #sk_omnibarSearchArea { +// border-top-color: var(--border); +// border-bottom-color: var(--border); +// } -/* ---------- Popup Notification Banner ---------- */ -#sk_banner { - font-family: var(--font); - font-size: var(--font-size); - font-weight: var(--font-weight); - background: var(--bg); - border-color: var(--border); - color: var(--fg); - opacity: 0.9; -} +// .sk_theme #sk_omnibarSearchArea input, +// .sk_theme #sk_omnibarSearchArea span { +// font-size: var(--font-size); +// } -/* ---------- Popup Keys ---------- */ -#sk_keystroke { - background-color: var(--bg); -} +// .sk_theme .separator { +// color: var(--accent-fg); +// } -.sk_theme kbd .candidates { - color: var(--info-fg); -} +// /* ---------- Popup Notification Banner ---------- */ +// #sk_banner { +// font-family: var(--font); +// font-size: var(--font-size); +// font-weight: var(--font-weight); +// background: var(--bg); +// border-color: var(--border); +// color: var(--fg); +// opacity: 0.9; +// } -.sk_theme span.annotation { - color: var(--accent-fg); -} +// /* ---------- Popup Keys ---------- */ +// #sk_keystroke { +// background-color: var(--bg); +// } -/* ---------- Popup Translation Bubble ---------- */ -#sk_bubble { - background-color: var(--bg) !important; - color: var(--fg) !important; - border-color: var(--border) !important; -} +// .sk_theme kbd .candidates { +// color: var(--info-fg); +// } -#sk_bubble * { - color: var(--fg) !important; -} +// .sk_theme span.annotation { +// color: var(--accent-fg); +// } -#sk_bubble div.sk_arrow div:nth-of-type(1) { - border-top-color: var(--border) !important; - border-bottom-color: var(--border) !important; -} +// /* ---------- Popup Translation Bubble ---------- */ +// #sk_bubble { +// background-color: var(--bg) !important; +// color: var(--fg) !important; +// border-color: var(--border) !important; +// } -#sk_bubble div.sk_arrow div:nth-of-type(2) { - border-top-color: var(--bg) !important; - border-bottom-color: var(--bg) !important; -} +// #sk_bubble * { +// color: var(--fg) !important; +// } -/* ---------- Search ---------- */ -#sk_status, -#sk_find { - font-size: var(--font-size); - border-color: var(--border); -} +// #sk_bubble div.sk_arrow div:nth-of-type(1) { +// border-top-color: var(--border) !important; +// border-bottom-color: var(--border) !important; +// } -.sk_theme kbd { - background: var(--bg-dark); - border-color: var(--border); - box-shadow: none; - color: var(--fg); -} +// #sk_bubble div.sk_arrow div:nth-of-type(2) { +// border-top-color: var(--bg) !important; +// border-bottom-color: var(--bg) !important; +// } -.sk_theme .feature_name span { - color: var(--main-fg); -} +// /* ---------- Search ---------- */ +// #sk_status, +// #sk_find { +// font-size: var(--font-size); +// border-color: var(--border); +// } -/* ---------- ACE Editor ---------- */ -#sk_editor { - background: var(--bg-dark) !important; - height: 50% !important; - /* Remove this to restore the default editor size */ -} +// .sk_theme kbd { +// background: var(--bg-dark); +// border-color: var(--border); +// box-shadow: none; +// color: var(--fg); +// } -.ace_dialog-bottom { - border-top: 1px solid var(--bg) !important; -} +// .sk_theme .feature_name span { +// color: var(--main-fg); +// } -.ace-chrome .ace_print-margin, -.ace_gutter, -.ace_gutter-cell, -.ace_dialog { - background: var(--bg) !important; -} +// /* ---------- ACE Editor ---------- */ +// #sk_editor { +// background: var(--bg-dark) !important; +// height: 50% !important; +// /* Remove this to restore the default editor size */ +// } -.ace-chrome { - color: var(--fg) !important; -} +// .ace_dialog-bottom { +// border-top: 1px solid var(--bg) !important; +// } -.ace_gutter, -.ace_dialog { - color: var(--fg) !important; -} +// .ace-chrome .ace_print-margin, +// .ace_gutter, +// .ace_gutter-cell, +// .ace_dialog { +// background: var(--bg) !important; +// } -.ace_cursor { - color: var(--fg) !important; -} +// .ace-chrome { +// color: var(--fg) !important; +// } -.normal-mode .ace_cursor { - background-color: var(--fg) !important; - border: var(--fg) !important; - opacity: 0.7 !important; -} +// .ace_gutter, +// .ace_dialog { +// color: var(--fg) !important; +// } -.ace_marker-layer .ace_selection { - background: var(--select) !important; -} +// .ace_cursor { +// color: var(--fg) !important; +// } -.ace_editor, -.ace_dialog span, -.ace_dialog input { - font-family: var(--font); - font-size: var(--font-size); - font-weight: var(--font-weight); -}`; -// click `Save` button to make above settings to take effect. \ No newline at end of file +// .normal-mode .ace_cursor { +// background-color: var(--fg) !important; +// border: var(--fg) !important; +// opacity: 0.7 !important; +// } + +// .ace_marker-layer .ace_selection { +// background: var(--select) !important; +// } + +// .ace_editor, +// .ace_dialog span, +// .ace_dialog input { +// font-family: var(--font); +// font-size: var(--font-size); +// font-weight: var(--font-weight); +// }`; +// click `Save` button to make above settings to take effect. +// #endregion diff --git a/tools/obsidian/latex-suite-snippet b/tools/obsidian/latex-suite-snippet new file mode 100644 index 0000000..e76d877 --- /dev/null +++ b/tools/obsidian/latex-suite-snippet @@ -0,0 +1,489 @@ +[ + {trigger: "mk", replacement: "$$0$", options: "tA" + }, + {trigger: "dm", replacement: "$$\n$0\n$$", options: "tAw" + }, + {trigger: "beg", replacement: "\\begin{$0}\n$1\n\\end{$0}", options: "mA" + }, + // Dashes + // {trigger: "--", replacement: "–", options: "tA"}, + // {trigger: "–-", replacement: "—", options: "tA"}, + // {trigger: "—-", replacement: "---", options: "tA"}, + // Greek letters + {trigger: "@a", replacement: "\\alpha", options: "mA" + }, + {trigger: "@b", replacement: "\\beta", options: "mA" + }, + {trigger: "@g", replacement: "\\gamma", options: "mA" + }, + {trigger: "@G", replacement: "\\Gamma", options: "mA" + }, + {trigger: "@d", replacement: "\\delta", options: "mA" + }, + {trigger: "@D", replacement: "\\Delta", options: "mA" + }, + {trigger: "@e", replacement: "\\epsilon", options: "mA" + }, + {trigger: ":e", replacement: "\\varepsilon", options: "mA" + }, + {trigger: "@z", replacement: "\\zeta", options: "mA" + }, + {trigger: "@t", replacement: "\\theta", options: "mA" + }, + {trigger: "@T", replacement: "\\Theta", options: "mA" + }, + {trigger: ":t", replacement: "\\vartheta", options: "mA" + }, + {trigger: "@i", replacement: "\\iota", options: "mA" + }, + {trigger: "@k", replacement: "\\kappa", options: "mA" + }, + {trigger: "@l", replacement: "\\lambda", options: "mA" + }, + {trigger: "@L", replacement: "\\Lambda", options: "mA" + }, + {trigger: "@s", replacement: "\\sigma", options: "mA" + }, + {trigger: "@S", replacement: "\\Sigma", options: "mA" + }, + {trigger: "@u", replacement: "\\upsilon", options: "mA" + }, + {trigger: "@U", replacement: "\\Upsilon", options: "mA" + }, + {trigger: "@o", replacement: "\\omega", options: "mA" + }, + {trigger: "@O", replacement: "\\Omega", options: "mA" + }, + {trigger: "ome", replacement: "\\omega", options: "mA" + }, + {trigger: "Ome", replacement: "\\Omega", options: "mA" + }, + // Text environment + {trigger: "text", replacement: "\\text{$0}$1", options: "mA" + }, + {trigger: "\"", replacement: "\\text{$0}$1", options: "mA" + }, + // Basic operations + {trigger: "sr", replacement: "^{2}", options: "mA" + }, + {trigger: "cb", replacement: "^{3}", options: "mA" + }, + {trigger: "pow", replacement: "^{$0}$1", options: "mA" + }, + {trigger: "_", replacement: "_{$0}$1", options: "mA" + }, + {trigger: "sb", replacement: "_{$0}$1", options: "mA" + }, + {trigger: "sts", replacement: "_\\text{$0}", options: "mA" + }, + {trigger: "sq", replacement: "\\sqrt{ $0 }$1", options: "mA" + }, + {trigger: "//", replacement: "\\frac{$0}{$1}$2", options: "mA" + }, + {trigger: "ee", replacement: "e^{ $0 }$1", options: "mA" + }, + {trigger: "invs", replacement: "^{-1}", options: "mA" + }, + {trigger: /([A-Za-z + ])(\d)/, replacement: "[[0]]_{[[1]]}", options: "rmA", description: "Auto letter subscript", priority: -1 + }, + {trigger: /([^\\ + ])(exp|log|ln)/, replacement: "[[0]]\\[[1]]", options: "rmA" + }, + {trigger: "conj", replacement: "^{*}", options: "mA" + }, + {trigger: "Re", replacement: "\\mathrm{Re}", options: "mA" + }, + {trigger: "Im", replacement: "\\mathrm{Im}", options: "mA" + }, + {trigger: "bf", replacement: "\\mathbf{$0}", options: "mA" + }, + {trigger: "rm", replacement: "\\mathrm{$0}$1", options: "mA" + }, + // Linear algebra + {trigger: /([^\\ + ])(det)/, replacement: "[[0]]\\[[1]]", options: "rmA" + }, + {trigger: "trace", replacement: "\\mathrm{Tr}", options: "mA" + }, + // More operations + {trigger: "([a-zA-Z])hat", replacement: "\\hat{[[0]]}", options: "rmA" + }, + {trigger: "([a-zA-Z])bar", replacement: "\\bar{[[0]]}", options: "rmA" + }, + {trigger: "([a-zA-Z])dot", replacement: "\\dot{[[0]]}", options: "rmA", priority: -1 + }, + {trigger: "([a-zA-Z])ddot", replacement: "\\ddot{[[0]]}", options: "rmA", priority: 1 + }, + {trigger: "([a-zA-Z])tilde", replacement: "\\tilde{[[0]]}", options: "rmA" + }, + {trigger: "([a-zA-Z])und", replacement: "\\underline{[[0]]}", options: "rmA" + }, + {trigger: "([a-zA-Z])vec", replacement: "\\vec{[[0]]}", options: "rmA" + }, + {trigger: "([a-zA-Z]),\\.", replacement: "\\mathbf{[[0]]}", options: "rmA" + }, + {trigger: "([a-zA-Z])\\.,", replacement: "\\mathbf{[[0]]}", options: "rmA" + }, + {trigger: "\\\\(${GREEK}),\\.", replacement: "\\boldsymbol{\\[[0]]}", options: "rmA" + }, + {trigger: "\\\\(${GREEK})\\.,", replacement: "\\boldsymbol{\\[[0]]}", options: "rmA" + }, + {trigger: "hat", replacement: "\\hat{$0}$1", options: "mA" + }, + {trigger: "bar", replacement: "\\bar{$0}$1", options: "mA" + }, + {trigger: "dot", replacement: "\\dot{$0}$1", options: "mA", priority: -1 + }, + {trigger: "ddot", replacement: "\\ddot{$0}$1", options: "mA" + }, + {trigger: "cdot", replacement: "\\cdot", options: "mA" + }, + {trigger: "tilde", replacement: "\\tilde{$0}$1", options: "mA" + }, + {trigger: "und", replacement: "\\underline{$0}$1", options: "mA" + }, + {trigger: "vec", replacement: "\\vec{$0}$1", options: "mA" + }, + // More auto letter subscript + {trigger: /([A-Za-z + ])_(\d\d)/, replacement: "[[0]]_{[[1]]}", options: "rmA" + }, + {trigger: /\\hat{([A-Za-z + ]) + }(\d)/, replacement: "\\hat{[[0]]}_{[[1]]}", options: "rmA" + }, + {trigger: /\\vec{([A-Za-z + ]) + }(\d)/, replacement: "\\vec{[[0]]}_{[[1]]}", options: "rmA" + }, + {trigger: /\\mathbf{([A-Za-z + ]) + }(\d)/, replacement: "\\mathbf{[[0]]}_{[[1]]}", options: "rmA" + }, + {trigger: "xnn", replacement: "x_{n}", options: "mA" + }, + {trigger: "xii", replacement: "x_{i}", options: "mA" + }, + {trigger: "xjj", replacement: "x_{j}", options: "mA" + }, + {trigger: "xp1", replacement: "x_{n+1}", options: "mA" + }, + {trigger: "ynn", replacement: "y_{n}", options: "mA" + }, + {trigger: "yii", replacement: "y_{i}", options: "mA" + }, + {trigger: "yjj", replacement: "y_{j}", options: "mA" + }, + // Symbols + {trigger: "ooo", replacement: "\\infty", options: "mA" + }, + {trigger: "sum", replacement: "\\sum", options: "mA" + }, + {trigger: "prod", replacement: "\\prod", options: "mA" + }, + {trigger: "\\sum", replacement: "\\sum_{${0:i}=${1:1}}^{${2:N}} $3", options: "m" + }, + {trigger: "\\prod", replacement: "\\prod_{${0:i}=${1:1}}^{${2:N}} $3", options: "m" + }, + {trigger: "lim", replacement: "\\lim_{ ${0:n} \\to ${1:\\infty} } $2", options: "mA" + }, + {trigger: "+-", replacement: "\\pm", options: "mA" + }, + {trigger: "-+", replacement: "\\mp", options: "mA" + }, + {trigger: "...", replacement: "\\dots", options: "mA" + }, + {trigger: "nabl", replacement: "\\nabla", options: "mA" + }, + {trigger: "del", replacement: "\\nabla", options: "mA" + }, + {trigger: "xx", replacement: "\\times", options: "mA" + }, + {trigger: "**", replacement: "\\cdot", options: "mA" + }, + {trigger: "para", replacement: "\\parallel", options: "mA" + }, + {trigger: "===", replacement: "\\equiv", options: "mA" + }, + {trigger: "!=", replacement: "\\neq", options: "mA" + }, + {trigger: ">=", replacement: "\\geq", options: "mA" + }, + {trigger: "<=", replacement: "\\leq", options: "mA" + }, + {trigger: ">>", replacement: "\\gg", options: "mA" + }, + {trigger: "<<", replacement: "\\ll", options: "mA" + }, + {trigger: "simm", replacement: "\\sim", options: "mA" + }, + {trigger: "sim=", replacement: "\\simeq", options: "mA" + }, + {trigger: "prop", replacement: "\\propto", options: "mA" + }, + {trigger: "<->", replacement: "\\leftrightarrow ", options: "mA" + }, + {trigger: "->", replacement: "\\to", options: "mA" + }, + {trigger: "!>", replacement: "\\mapsto", options: "mA" + }, + {trigger: "=>", replacement: "\\implies", options: "mA" + }, + {trigger: "=<", replacement: "\\impliedby", options: "mA" + }, + {trigger: "and", replacement: "\\cap", options: "mA" + }, + {trigger: "orr", replacement: "\\cup", options: "mA" + }, + {trigger: "inn", replacement: "\\in", options: "mA" + }, + {trigger: "notin", replacement: "\\not\\in", options: "mA" + }, + {trigger: "\\\\\\", replacement: "\\setminus", options: "mA" + }, + {trigger: "sub=", replacement: "\\subseteq", options: "mA" + }, + {trigger: "sup=", replacement: "\\supseteq", options: "mA" + }, + {trigger: "eset", replacement: "\\emptyset", options: "mA" + }, + {trigger: "set", replacement: "\\{ $0 \\}$1", options: "mA" + }, + {trigger: "e\\xi sts", replacement: "\\exists", options: "mA", priority: 1 + }, + {trigger: "LL", replacement: "\\mathcal{L}", options: "mA" + }, + {trigger: "HH", replacement: "\\mathcal{H}", options: "mA" + }, + {trigger: "CC", replacement: "\\mathbb{C}", options: "mA" + }, + {trigger: "RR", replacement: "\\mathbb{R}", options: "mA" + }, + {trigger: "ZZ", replacement: "\\mathbb{Z}", options: "mA" + }, + {trigger: "NN", replacement: "\\mathbb{N}", options: "mA" + }, + // Handle spaces and backslashes + // Snippet variables can be used as shortcuts when writing snippets. + // For example, ${GREEK} below is shorthand for "alpha|beta|gamma|Gamma|delta|..." + // You can edit snippet variables under the Advanced snippet settings section. + {trigger: "([^\\\\])(${GREEK})", replacement: "[[0]]\\[[1]]", options: "rmA", description: "Add backslash before Greek letters" + }, + {trigger: "([^\\\\])(${SYMBOL})", replacement: "[[0]]\\[[1]]", options: "rmA", description: "Add backslash before symbols" + }, + // Insert space after Greek letters and symbols + {trigger: "\\\\(${GREEK}|${SYMBOL}|${MORE_SYMBOLS})([A-Za-z])", replacement: "\\[[0]] [[1]]", options: "rmA" + }, + {trigger: "\\\\(${GREEK}|${SYMBOL}) sr", replacement: "\\[[0]]^{2}", options: "rmA" + }, + {trigger: "\\\\(${GREEK}|${SYMBOL}) cb", replacement: "\\[[0]]^{3}", options: "rmA" + }, + {trigger: "\\\\(${GREEK}|${SYMBOL}) rd", replacement: "\\[[0]]^{$0}$1", options: "rmA" + }, + {trigger: "\\\\(${GREEK}|${SYMBOL}) hat", replacement: "\\hat{\\[[0]]}", options: "rmA" + }, + {trigger: "\\\\(${GREEK}|${SYMBOL}) dot", replacement: "\\dot{\\[[0]]}", options: "rmA" + }, + {trigger: "\\\\(${GREEK}|${SYMBOL}) bar", replacement: "\\bar{\\[[0]]}", options: "rmA" + }, + {trigger: "\\\\(${GREEK}|${SYMBOL}) vec", replacement: "\\vec{\\[[0]]}", options: "rmA" + }, + {trigger: "\\\\(${GREEK}|${SYMBOL}) tilde", replacement: "\\tilde{\\[[0]]}", options: "rmA" + }, + {trigger: "\\\\(${GREEK}|${SYMBOL}) und", replacement: "\\underline{\\[[0]]}", options: "rmA" + }, + // Derivatives and integrals + {trigger: "par", replacement: "\\frac{ \\partial ${0:y} }{ \\partial ${1:x} } $2", options: "m" + }, + {trigger: /pa([A-Za-z + ])([A-Za-z + ])/, replacement: "\\frac{ \\partial [[0]] }{ \\partial [[1]] } ", options: "rm" + }, + {trigger: "ddt", replacement: "\\frac{d}{dt} ", options: "mA" + }, + {trigger: /([^\\ + ])int/, replacement: "[[0]]\\int", options: "mA", priority: -1 + }, + {trigger: "\\int", replacement: "\\int $0 \\, d${1:x} $2", options: "m" + }, + {trigger: "dint", replacement: "\\int_{${0:0}}^{${1:1}} $2 \\, d${3:x} $4", options: "mA" + }, + {trigger: "oint", replacement: "\\oint", options: "mA" + }, + {trigger: "iint", replacement: "\\iint", options: "mA" + }, + {trigger: "iiint", replacement: "\\iiint", options: "mA" + }, + {trigger: "oinf", replacement: "\\int_{0}^{\\infty} $0 \\, d${1:x} $2", options: "mA" + }, + {trigger: "infi", replacement: "\\int_{-\\infty}^{\\infty} $0 \\, d${1:x} $2", options: "mA" + }, + // Trigonometry + {trigger: /([^\\ + ])(arcsin|sin|arccos|cos|arctan|tan|csc|sec|cot)/, replacement: "[[0]]\\[[1]]", options: "rmA", description: "Add backslash before trig funcs" + }, + {trigger: /\\(arcsin|sin|arccos|cos|arctan|tan|csc|sec|cot)([A-Za-gi-z + ])/, + replacement: "\\[[0]] [[1]]", options: "rmA", + description: "Add space after trig funcs. Skips letter h to allow sinh, cosh, etc." + }, + {trigger: /\\(sinh|cosh|tanh|coth)([A-Za-z + ])/, + replacement: "\\[[0]] [[1]]", options: "rmA", + description: "Add space after hyperbolic trig funcs" + }, + // Visual operations + {trigger: "U", replacement: "\\underbrace{ ${VISUAL} }_{ $0 }", options: "mA" + }, + {trigger: "O", replacement: "\\overbrace{ ${VISUAL} }^{ $0 }", options: "mA" + }, + {trigger: "B", replacement: "\\underset{ $0 }{ ${VISUAL} }", options: "mA" + }, + {trigger: "C", replacement: "\\cancel{ ${VISUAL} }", options: "mA" + }, + {trigger: "K", replacement: "\\cancelto{ $0 }{ ${VISUAL} }", options: "mA" + }, + {trigger: "S", replacement: "\\sqrt{ ${VISUAL} }", options: "mA" + }, + // Physics + {trigger: "kbt", replacement: "k_{B}T", options: "mA" + }, + {trigger: "msun", replacement: "M_{\\odot}", options: "mA" + }, + // Quantum mechanics + {trigger: "dag", replacement: "^{\\dagger}", options: "mA" + }, + {trigger: "o+", replacement: "\\oplus ", options: "mA" + }, + {trigger: "ox", replacement: "\\otimes ", options: "mA" + }, + {trigger: "bra", replacement: "\\bra{$0} $1", options: "mA" + }, + {trigger: "ket", replacement: "\\ket{$0} $1", options: "mA" + }, + {trigger: "brk", replacement: "\\braket{ $0 | $1 } $2", options: "mA" + }, + {trigger: "outer", replacement: "\\ket{${0:\\psi}} \\bra{${0:\\psi}} $1", options: "mA" + }, + // Chemistry + {trigger: "pu", replacement: "\\pu{ $0 }", options: "mA" + }, + {trigger: "cee", replacement: "\\ce{ $0 }", options: "mA" + }, + {trigger: "he4", replacement: "{}^{4}_{2}He ", options: "mA" + }, + {trigger: "he3", replacement: "{}^{3}_{2}He ", options: "mA" + }, + {trigger: "iso", replacement: "{}^{${0:4}}_{${1:2}}${2:He}", options: "mA" + }, + // Environments + {trigger: "pmat", replacement: "\\begin{pmatrix}\n$0\n\\end{pmatrix}", options: "MA" + }, + {trigger: "bmat", replacement: "\\begin{bmatrix}\n$0\n\\end{bmatrix}", options: "MA" + }, + {trigger: "Bmat", replacement: "\\begin{Bmatrix}\n$0\n\\end{Bmatrix}", options: "MA" + }, + {trigger: "vmat", replacement: "\\begin{vmatrix}\n$0\n\\end{vmatrix}", options: "MA" + }, + {trigger: "Vmat", replacement: "\\begin{Vmatrix}\n$0\n\\end{Vmatrix}", options: "MA" + }, + {trigger: "matrix", replacement: "\\begin{matrix}\n$0\n\\end{matrix}", options: "MA" + }, + {trigger: "pmat", replacement: "\\begin{pmatrix}$0\\end{pmatrix}", options: "nA" + }, + {trigger: "bmat", replacement: "\\begin{bmatrix}$0\\end{bmatrix}", options: "nA" + }, + {trigger: "Bmat", replacement: "\\begin{Bmatrix}$0\\end{Bmatrix}", options: "nA" + }, + {trigger: "vmat", replacement: "\\begin{vmatrix}$0\\end{vmatrix}", options: "nA" + }, + {trigger: "Vmat", replacement: "\\begin{Vmatrix}$0\\end{Vmatrix}", options: "nA" + }, + {trigger: "matrix", replacement: "\\begin{matrix}$0\\end{matrix}", options: "nA" + }, + {trigger: "cases", replacement: "\\begin{cases}\n$0\n\\end{cases}", options: "mA" + }, + {trigger: "align", replacement: "\\begin{align}\n$0\n\\end{align}", options: "mA" + }, + {trigger: "array", replacement: "\\begin{array}\n$0\n\\end{array}", options: "mA" + }, + // Brackets + {trigger: "avg", replacement: "\\langle $0 \\rangle $1", options: "mA" + }, + {trigger: "norm", replacement: "\\lvert $0 \\rvert $1", options: "mA", priority: 1 + }, + {trigger: "Norm", replacement: "\\lVert $0 \\rVert $1", options: "mA", priority: 1 + }, + {trigger: "ceil", replacement: "\\lceil $0 \\rceil $1", options: "mA" + }, + {trigger: "floor", replacement: "\\lfloor $0 \\rfloor $1", options: "mA" + }, + {trigger: "mod", replacement: "|$0|$1", options: "mA" + }, + {trigger: "(", replacement: "(${VISUAL})", options: "mA" + }, + {trigger: "[", replacement: "[${VISUAL}]", options: "mA" + }, + {trigger: "{", replacement: "{${VISUAL}}", options: "mA" + }, + {trigger: "(", replacement: "($0)$1", options: "mA" + }, + {trigger: "{", replacement: "{$0}$1", options: "mA" + }, + {trigger: "[", replacement: "[$0]$1", options: "mA" + }, + {trigger: "lr(", replacement: "\\left( $0 \\right) $1", options: "mA" + }, + {trigger: "lr{", replacement: "\\left\\{ $0 \\right\\} $1", options: "mA" + }, + {trigger: "lr[", replacement: "\\left[ $0 \\right] $1", options: "mA" + }, + {trigger: "lr|", replacement: "\\left| $0 \\right| $1", options: "mA" + }, + {trigger: "lra", replacement: "\\left< $0 \\right> $1", options: "mA" + }, + // User defined + {trigger: "b\\otimes ed", replacement: "\\boxed{$1}", options: "mA" + }, + {trigger: "\\disp", replacement: "\\displaystyle $0", options: "mA" + }, + // Misc + // Automatically convert standalone letters in text to math (except a, A, I). + // (Un-comment to enable) + // {trigger: /([^'])\b([B-HJ-Zb-z])\b([\n\s.,?!:'])/, replacement: "[[0]]$[[1]]$[[2]]", options: "tA"}, + // Automatically convert Greek letters in text to math. + // {trigger: "(${GREEK})([\\n\\s.,?!:'])", replacement: "$\\[[0]]$[[1]]", options: "rtAw"}, + // Automatically convert text of the form "x=2" and "x=n+1" to math. + // {trigger: /([A-Za-z]=\d+)([\n\s.,?!:'])/, replacement: "$[[0]]$[[1]]", options: "rtAw"}, + // {trigger: /([A-Za-z]=[A-Za-z][+-]\d+)([\n\s.,?!:'])/, replacement: "$[[0]]$[[1]]", options: "tAw"}, + // Snippet replacements can have placeholders. + {trigger: "tayl", replacement: "${0:f}(${1:x} + ${2:h}) = ${0:f}(${1:x}) + ${0:f}'(${1:x})${2:h} + ${0:f}''(${1:x}) \\frac{${2:h}^{2}}{2!} + \\dots$3", options: "mA", description: "Taylor expansion" + }, + // Snippet replacements can also be JavaScript functions. + // See the documentation for more information. + {trigger: /iden(\d)/, replacement: (match) => { + const n = match[ + 1 + ]; + + let arr = []; + for (let j = 0; j < n; j++) { + arr[j + ] = []; + for (let i = 0; i < n; i++) { + arr[j + ][i + ] = (i === j) ? 1 : 0; + } + } + + let output = arr.map(el => el.join(" & ")).join(" \\\\\n"); + output = `\\begin{pmatrix + }\n${output + }\n\\end{pmatrix + }`; + return output; + }, options: "mA", description: "N x N identity matrix" + }, +] diff --git a/common/obsidian.vimrc b/tools/obsidian/obsidian.vimrc similarity index 100% rename from common/obsidian.vimrc rename to tools/obsidian/obsidian.vimrc diff --git a/tools/powershell/Aliases.ps1 b/tools/powershell/Aliases.ps1 index b835dc0..aaa0860 100644 --- a/tools/powershell/Aliases.ps1 +++ b/tools/powershell/Aliases.ps1 @@ -1,6 +1,6 @@ # $DOTFILES/tools\powershell\Aliases.ps1 # Date: 2024-12-01 -# Author: contact@js0ny.net +# Author: js0ny # Aliases for PowerShell ### VARIABLES ### $EDITOR = "code" diff --git a/tools/powershell/Environment.ps1 b/tools/powershell/Environment.ps1 index cf43c80..dad0a92 100644 --- a/tools/powershell/Environment.ps1 +++ b/tools/powershell/Environment.ps1 @@ -1,6 +1,6 @@ # $DOTFILES/tools\powershell\Environment.ps1 # Date: 2024-12-01 -# Author: contact@js0ny.net +# Author: js0ny # Sourced by Microsoft.PowerShell_profile.ps1 diff --git a/tools/powershell/Prompt.ps1 b/tools/powershell/Prompt.ps1 index e34817b..9f43a8a 100644 --- a/tools/powershell/Prompt.ps1 +++ b/tools/powershell/Prompt.ps1 @@ -1,6 +1,6 @@ # $DOTFILES/tools\powershell\Prompt.ps1 # Date: 2024-12-01 -# Author: contact@js0ny.net +# Author: js0ny # Use starship to set prompt $ENV:STARSHIP_CONFIG = Join-Path $DOTFILES "tools" "starship" "starship_pwsh.toml" diff --git a/tools/vscode/keybindings.json b/tools/vscode/keybindings.json index de4390b..963648f 100644 --- a/tools/vscode/keybindings.json +++ b/tools/vscode/keybindings.json @@ -32,6 +32,7 @@ "command": "-code-runner.run" }, // #endregion + // #region Comment and semicolons { "key": "ctrl+oem_1", // ctrl+; "command": "extension.insertSemicolon", @@ -62,6 +63,7 @@ "command": "-github.copilot.acceptCursorPanelSolution", "when": "github.copilot.activated && github.copilot.panelVisible" }, + // #endregion { "key": "f9", "command": "csdevkit.debug.noDebugFileLaunch" @@ -114,7 +116,52 @@ // #region Nvim-Tree like File Explorer // n, e : move cursor up/down // h : move cursor to parent folder - // l : open file or folder + // i : open file or folder + { + "key": "e", + "command": "list.focusUp", + "when": "notebookEditorFocused && !inputFocus && !notebookOutputInputFocused" + }, + { + "key": "k", + "command": "-list.focusUp", + "when": "notebookEditorFocused && !inputFocus && !notebookOutputInputFocused" + }, + { + "key": "e", + "command": "list.focusUp", + "when": "listFocus && !inputFocus" + }, + { + "key": "k", + "command": "-list.focusUp", + "when": "listFocus && !inputFocus" + }, + { + "key": "f", + "command": "filesExplorer.findInWorkspace", + "when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus" + }, + { + "key": "n", + "command": "list.focusDown", + "when": "listFocus && !inputFocus" + }, + { + "key": "j", + "command": "-list.focusDown", + "when": "listFocus && !inputFocus" + }, + { + "key": "i", + "command": "list.select", + "when": "listFocus && !inputFocus" + }, + { + "key": "l", + "command": "-list.select", + "when": "listFocus && !inputFocus" + }, { // z: Close all folders "key": "z", "command": "workbench.files.action.collapseExplorerFolders", @@ -270,51 +317,6 @@ "when": "editorTextFocus && inputFocus && notebookEditorFocused && vim.mode == 'Normal' && notebookEditorCursorAtBoundary != 'bottom' && notebookEditorCursorAtBoundary != 'none'" }, // #endregion - { - "key": "e", - "command": "list.focusUp", - "when": "notebookEditorFocused && !inputFocus && !notebookOutputInputFocused" - }, - { - "key": "k", - "command": "-list.focusUp", - "when": "notebookEditorFocused && !inputFocus && !notebookOutputInputFocused" - }, - { - "key": "e", - "command": "list.focusUp", - "when": "listFocus && !inputFocus" - }, - { - "key": "k", - "command": "-list.focusUp", - "when": "listFocus && !inputFocus" - }, - { - "key": "f", - "command": "filesExplorer.findInWorkspace", - "when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus" - }, - { - "key": "n", - "command": "list.focusDown", - "when": "listFocus && !inputFocus" - }, - { - "key": "j", - "command": "-list.focusDown", - "when": "listFocus && !inputFocus" - }, - { - "key": "i", - "command": "list.select", - "when": "listFocus && !inputFocus" - }, - { - "key": "l", - "command": "-list.select", - "when": "listFocus && !inputFocus" - }, { "key": "ctrl+shift+g c", "command": "-gitlens.showQuickCommitFileDetails", @@ -482,4 +484,4 @@ "command": "workbench.action.terminal.resizePaneRight", "when": "terminalFocus && terminalHasBeenCreated || terminalFocus && terminalProcessSupported" } -] \ No newline at end of file +] diff --git a/tools/zsh/common.zshrc b/tools/zsh/common.zshrc index d5ee087..123f13c 100644 --- a/tools/zsh/common.zshrc +++ b/tools/zsh/common.zshrc @@ -1,6 +1,6 @@ # $DOTFILES/tools/zsh/common.zshrc # Date: 2024-11-30 -# Author: contact@js0ny.net +# Author: js0ny # This is the entry point for all zsh configuration files # 这是所有zsh配置文件的入口点 diff --git a/tools/zsh/global.zshenv b/tools/zsh/global.zshenv index a9c1a49..9d886d9 100644 --- a/tools/zsh/global.zshenv +++ b/tools/zsh/global.zshenv @@ -1,6 +1,6 @@ # $DOTFILES/tools/zsh/global.zshenv # Date: 2024-11-30 -# Author: contact@js0ny.net +# Author: js0ny # $DOTFILES/tools/zsh/global.zshenv # system-wide zshenv file 系统级别的 zshenv 文件,用于设置全局环境变量 diff --git a/tools/zsh/mod/alias.zsh b/tools/zsh/mod/alias.zsh index f9c51cd..b1db7c3 100644 --- a/tools/zsh/mod/alias.zsh +++ b/tools/zsh/mod/alias.zsh @@ -1,6 +1,6 @@ # $DOTFILES/tools/zsh/mod/alias.zsh # Date: 2024-11-30 -# Author: contact@js0ny.net +# Author: js0ny # Sourced by user's zshrc 在用户的 zshrc 中被引用 # PowerShell Equivalent, for cross-platform compatibility diff --git a/tools/zsh/mod/config.zsh b/tools/zsh/mod/config.zsh index f8cd08b..c4be177 100644 --- a/tools/zsh/mod/config.zsh +++ b/tools/zsh/mod/config.zsh @@ -1,6 +1,6 @@ # $DOTFILES/tools/zsh/mod/config.zsh # Date: 2024-11-30 -# Author: contact@js0ny.net +# Author: js0ny # Sourced by user's zshrc 在用户的 zshrc 中被引用 # ZSH Config, no need to `export` these variables diff --git a/tools/zsh/mod/env.zsh b/tools/zsh/mod/env.zsh index 73beddd..c1fd0d9 100644 --- a/tools/zsh/mod/env.zsh +++ b/tools/zsh/mod/env.zsh @@ -1,6 +1,6 @@ # $DOTFILES/tools/zsh/mod/env.zsh # Date: 2024-11-30 -# Author: contact@js0ny.net +# Author: js0ny # Sourced by user's zshrc 在用户的 zshrc 中被引用 # This file stores only environment variables that only called by diff --git a/tools/zsh/mod/keymap.zsh b/tools/zsh/mod/keymap.zsh index eac5169..e1fbbd5 100644 --- a/tools/zsh/mod/keymap.zsh +++ b/tools/zsh/mod/keymap.zsh @@ -1,6 +1,6 @@ # $DOTFILES/tools/zsh/mod/keymap.zsh # Date: 2024-11-30 -# Author: contact@js0ny.net +# Author: js0ny # Sourced by user's zshrc 在用户的 zshrc 中被引用 diff --git a/tools/zsh/mod/navi.zsh b/tools/zsh/mod/navi.zsh index ef9682b..86cf282 100644 --- a/tools/zsh/mod/navi.zsh +++ b/tools/zsh/mod/navi.zsh @@ -1,6 +1,6 @@ # $DOTFILES/tools/zsh/mod/navi.zsh # Date: 2024-12-01 -# Author: contact@js0ny.net +# Author: js0ny # Sourced by user's zshrc 在用户的 zshrc 中被引用 # Relative navigation # diff --git a/tools/zsh/mod/prompt.zsh b/tools/zsh/mod/prompt.zsh index 01be5dc..2953dcb 100644 --- a/tools/zsh/mod/prompt.zsh +++ b/tools/zsh/mod/prompt.zsh @@ -1,6 +1,6 @@ # $DOTFILES/tools/zsh/mod/prompt.zsh # Date: 2024-11-30 -# Author: contact@js0ny.net +# Author: js0ny # Sourced by user's zshrc 在用户的 zshrc 中被引用 export STARSHIP_CONFIG=$DOTFILES/tools/starship/starship_zsh.toml diff --git a/tools/zsh/zshenv b/tools/zsh/zshenv index d84cf50..99d7d5f 100644 --- a/tools/zsh/zshenv +++ b/tools/zsh/zshenv @@ -1,6 +1,6 @@ # $DOTFILES/tools/zsh/zshenv # Date: 2024-11-30 -# Author: contact@js0ny.net +# Author: js0ny # User-specific environment variables for zsh 用户级别的 zsh 环境变量 # Location: