sync from Linux

This commit is contained in:
js0ny 2025-01-07 22:07:52 +00:00
parent 8bb2d9fbe8
commit 2a0fd9b83f
16 changed files with 317 additions and 617 deletions

View file

@ -52,6 +52,34 @@ const colemak = {
}
}
const vforward = {
add: function (key) { // 转发即将被 unmap 的键
return api.vmap(`vfor${key}`, key)
},
cancel: function (key) { // 删除转发生成的键
api.vunmap(`vfor${key}`)
api.vunmap(key)
},
use: function (key) {
return `vfor${key}`
}
}
const vcolemak = {
forward: function (key) { // 转发即将被 unmap 的键
api.vmap(key, `vcol${key}`)
api.vunmap(`vcol${key}`)
},
use: function (key) {
return `vcol${key}`
},
map: function (a, b) {
api.vmap(vcolemak.use(a), vforward.use(b))
}
}
const forwardFactory = {
push: function (mapLists) { // forward original keys
for (let key in mapLists) {
@ -72,6 +100,35 @@ const forwardFactory = {
}
}
}
const vforwardFactory = {
push: function (mapLists) { // forward original keys
for (let key in mapLists) {
vforward.add(mapLists[key])
}
},
map: function (mapLists) {
for (let key in mapLists) {
vcolemak.map(key, mapLists[key])
}
},
pull: function (mapLists) {
for (let key in mapLists) {
vforward.cancel(mapLists[key])
}
for (let key in mapLists) {
vcolemak.forward(key)
}
}
}
const parseSearchResponse = function (response) {
const res = JSON.parse(response.text);
return res.map(r => r.phrase);
};
const _addSearchAlias = function (alias, name, searchUrl, searchPrefix = 's', acUrl = "https://duckduckgo.com/ac/?q=", parseResponse = parseSearchResponse) {
api.addSearchAlias(alias, name, searchUrl, searchPrefix, acUrl, parseResponse);
}
// #endregion
// #region Keymap
const mapLists = {
@ -124,6 +181,9 @@ const vmapLists = {
forwardFactory.push(mapLists)
forwardFactory.map(mapLists)
vforwardFactory.push(vmapLists)
vforwardFactory.map(vmapLists)
// 鼠标点击
api.unmap('gi')
api.unmap('[[')
@ -138,30 +198,32 @@ forwardFactory.pull(mapLists)
// #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('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;
});
});
api.unmap('os') // StackOverflow
api.vunmap('ss')
api.unmap('ob') // Baidu
api.vunmap('sb')
api.unmap('og') // Google
api.vunmap('sg')
api.unmap('od') // DuckDuckGo
api.vunmap('sd')
/// Common
_addSearchAlias('dd', 'DuckDuckGo', 'https://duckduckgo.com/?q=')
_addSearchAlias('gg', 'Google', 'https://www.google.com/search?q=')
_addSearchAlias('bd', 'Baidu', 'https://www.baidu.com/s?wd=')
_addSearchAlias('bi', 'Bing', 'https://www.bing.com/search?q=')
/// AI Search
_addSearchAlias('fe', 'Felo', 'https://felo.ai/search?q=')
_addSearchAlias('pp', 'Perplexity', 'https://www.perplexity.ai/?q=')
_addSearchAlias('cg', 'ChatGPT', 'https://chat.openai.com/?q=')
/// EECS Related
_addSearchAlias('gh', 'GitHub', 'https://github.com/search?type=repositories&q=')
_addSearchAlias('so', 'StackOverflow', 'https://stackoverflow.com/search?q=')
_addSearchAlias('aw', 'ArchWiki', 'https://wiki.archlinux.org/index.php?search=')
/// Software
_addSearchAlias('sc', 'Scoop', 'https://scoop.sh/#/apps?q=')
_addSearchAlias('br', 'Brew', 'https://duckduckgo.com/?q=!brew ')
// #endregion
// #region Site-specific
@ -184,10 +246,10 @@ 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/ });
// perplexity.ai
api.unmap('<Ctrl-i>', /perplexity.ai/);
// #endregion

View file

@ -135,3 +135,10 @@ if status is-interactive
set IPYTHONDIR $XDG_CONFIG_HOME/ipython
end
end
# Coursier: Scala dependency manager
if command -v coursier > /dev/null
set -gx PATH "$PATH:/home/js0ny/.local/share/coursier/bin"
end
test -d /opt/miniconda3 && source /opt/miniconda3/etc/fish/conf.d/conda.fish

View file

@ -8,6 +8,6 @@
# ln -sf $DOTFILES/tools/fish ~/.config/fish
if command -v starship > /dev/null
set -gx STARSHIP_CONFIG $DOTFILES/tools/starship/starship_fish.toml
set STARSHIP_CONFIG "~/.dotfiles/tools/starship/starship_fish.toml"
starship init fish | source
end

View file

@ -21,3 +21,7 @@ if status is-interactive
# Default / Fallback case
end
end
# bun
set --export BUN_INSTALL "$HOME/.bun"
set --export PATH $BUN_INSTALL/bin $PATH

View file

@ -4,7 +4,7 @@
# Use starship to set prompt
$ENV:STARSHIP_CONFIG = Join-Path $DOTFILES "tools" "starship" "starship_pwsh.toml"
# Invoke-Expression (&starship init powershell)
Invoke-Expression (&starship init powershell)
# Below is the backup of original prompt function
# $promptTime = $true

View file

@ -1,202 +0,0 @@
# starship.toml
# ~/.config/starship.toml
format = '''$os$time $username @ $hostname $directory $all$character'''
add_newline = true
[time]
disabled = false
format = '[\[$time\]](purple)'
time_format = '%H:%M'
[username]
format = '[$user](bold)'
show_always = true
[hostname]
ssh_only = false
ssh_symbol = '󰞉 '
[directory]
truncation_length = 2
truncate_to_repo = true
read_only = " 󰌾"
style ="bold cyan"
truncation_symbol = ".../"
[directory.substitutions]
"~/Documents" = "󰈙 "
"~/Downloads" = " "
"~/Music" = " "
"~/Pictures" = " "
"Source" = " "
"src" = " "
[aws]
symbol = " "
[buf]
symbol = " "
[c]
symbol = " "
[conda]
symbol = " "
[crystal]
symbol = " "
[dart]
symbol = " "
[docker_context]
symbol = " "
[elixir]
symbol = " "
[elm]
symbol = " "
[fennel]
symbol = " "
[fossil_branch]
symbol = " "
[git_branch]
symbol = " "
[git_commit]
tag_symbol = '  '
[golang]
symbol = " "
[guix_shell]
symbol = " "
[haskell]
symbol = " "
[haxe]
symbol = " "
[hg_branch]
symbol = " "
[java]
symbol = " "
[julia]
symbol = " "
[kotlin]
symbol = " "
[lua]
symbol = " "
[memory_usage]
symbol = "󰍛 "
[meson]
symbol = "󰔷 "
[nim]
symbol = "󰆥 "
[nix_shell]
symbol = " "
[nodejs]
symbol = " "
[ocaml]
symbol = " "
[os]
disabled = false
[os.symbols]
Alpaquita = " "
Alpine = " "
AlmaLinux = " "
Amazon = " "
Android = " "
Arch = " "
Artix = " "
CentOS = " "
Debian = " "
DragonFly = " "
Emscripten = " "
EndeavourOS = " "
Fedora = " "
FreeBSD = " "
Garuda = "󰛓 "
Gentoo = " "
HardenedBSD = "󰞌 "
Illumos = "󰈸 "
Kali = " "
Linux = " "
Mabox = " "
Macos = " "
Manjaro = " "
Mariner = " "
MidnightBSD = " "
Mint = " "
NetBSD = " "
NixOS = " "
OpenBSD = "󰈺 "
openSUSE = " "
OracleLinux = "󰌷 "
Pop = " "
Raspbian = " "
Redhat = " "
RedHatEnterprise = " "
RockyLinux = " "
Redox = "󰀘 "
Solus = "󰠳 "
SUSE = " "
Ubuntu = " "
Unknown = " "
Void = " "
Windows = "󰍲 "
[package]
symbol = "󰏗 "
[perl]
symbol = " "
[php]
symbol = " "
[pijul_channel]
symbol = " "
[python]
symbol = " "
[rlang]
symbol = "󰟔 "
[ruby]
symbol = " "
[rust]
symbol = "󱘗 "
[scala]
symbol = " "
[swift]
symbol = " "
[zig]
symbol = " "
[gradle]
symbol = " "

View file

@ -1,208 +1,144 @@
# starship.toml
# ~/.config/starship.toml
format = '''$os$time $username @ $hostname $directory $all$character'''
continuation_prompt = "[r % ](bold cyan) " # Doesn't work in fish
format = """
[](#9A348E)\
$os\
$username\
[](bg:#DA627D fg:#9A348E)\
$directory\
[](fg:#DA627D bg:#FCA17D)\
$git_branch\
$git_status\
[](fg:#FCA17D bg:#86BBD8)\
$c\
$elixir\
$elm\
$golang\
$gradle\
$haskell\
$java\
$julia\
$nodejs\
$nim\
$rust\
$scala\
[](fg:#86BBD8 bg:#06969A)\
$docker_context\
[](fg:#06969A bg:#33658A)\
$time\
[ ](fg:#33658A)\
"""
add_newline = true
[time]
disabled = false
format = '[\[$time\]](purple)'
time_format = '%H:%M'
# Disable the blank line at the start of the prompt
# add_newline = false
# You can also replace your username with a neat symbol like  or disable this
# and use the os module below
[username]
format = '[$user](bold)'
show_always = true
style_user = "bg:#9A348E"
style_root = "bg:#9A348E"
format = '[$user ]($style)'
disabled = false
[hostname]
ssh_only = false
ssh_symbol = '󰞉 '
[character]
success_symbol = "[󰈺 >](bold green)"
error_symbol = "[󰈺 >](bold red)"
vimcmd_symbol = "[ <](bold green)"
# An alternative to the username module which displays a symbol that
# represents the current operating system
[os]
style = "bg:#9A348E"
disabled = true # Disabled by default
[directory]
truncation_length = 2
truncate_to_repo = true
read_only = " 󰌾"
style = "bold cyan"
truncation_symbol = ".../"
style = "bg:#DA627D"
format = "[ $path ]($style)"
truncation_length = 3
truncation_symbol = "…/"
# Here is how you can shorten some long paths by text replacement
# similar to mapped_locations in Oh My Posh:
[directory.substitutions]
"~/Documents" = "󰈙 "
"~/Downloads" = " "
"~/Music" = " "
"~/Pictures" = " "
"Source" = " "
"src" = " "
[aws]
symbol = " "
[buf]
symbol = " "
"Documents" = "󰈙 "
"Downloads" = " "
"Music" = " "
"Pictures" = " "
# Keep in mind that the order matters. For example:
# "Important Documents" = " 󰈙 "
# will not be replaced, because "Documents" was already substituted before.
# So either put "Important Documents" before "Documents" or use the substituted version:
# "Important 󰈙 " = " 󰈙 "
[c]
symbol = " "
[conda]
symbol = " "
[crystal]
symbol = " "
[dart]
symbol = " "
style = "bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'
[docker_context]
symbol = " "
style = "bg:#06969A"
format = '[ $symbol $context ]($style)'
[elixir]
symbol = " "
symbol = " "
style = "bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'
[elm]
symbol = " "
[fennel]
symbol = " "
[fossil_branch]
symbol = " "
style = "bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'
[git_branch]
symbol = " "
symbol = ""
style = "bg:#FCA17D"
format = '[ $symbol $branch ]($style)'
[git_commit]
tag_symbol = '  '
[git_status]
style = "bg:#FCA17D"
format = '[$all_status$ahead_behind ]($style)'
[golang]
symbol = " "
style = "bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'
[guix_shell]
symbol = " "
[gradle]
style = "bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'
[haskell]
symbol = " "
[haxe]
symbol = " "
[hg_branch]
symbol = " "
style = "bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'
[java]
symbol = " "
style = "bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'
[julia]
symbol = " "
style = "bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'
[kotlin]
symbol = " "
[lua]
symbol = " "
[memory_usage]
symbol = "󰍛 "
[meson]
symbol = "󰔷 "
[nodejs]
symbol = ""
style = "bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'
[nim]
symbol = "󰆥 "
[nix_shell]
symbol = " "
[nodejs]
symbol = " "
[ocaml]
symbol = " "
[os]
disabled = false
[os.symbols]
Alpaquita = " "
Alpine = " "
AlmaLinux = " "
Amazon = " "
Android = " "
Arch = " "
Artix = " "
CentOS = " "
Debian = " "
DragonFly = " "
Emscripten = " "
EndeavourOS = " "
Fedora = " "
FreeBSD = " "
Garuda = "󰛓 "
Gentoo = " "
HardenedBSD = "󰞌 "
Illumos = "󰈸 "
Kali = " "
Linux = " "
Mabox = " "
Macos = " "
Manjaro = " "
Mariner = " "
MidnightBSD = " "
Mint = " "
NetBSD = " "
NixOS = " "
OpenBSD = "󰈺 "
openSUSE = " "
OracleLinux = "󰌷 "
Pop = " "
Raspbian = " "
Redhat = " "
RedHatEnterprise = " "
RockyLinux = " "
Redox = "󰀘 "
Solus = "󰠳 "
SUSE = " "
Ubuntu = " "
Unknown = " "
Void = " "
Windows = "󰍲 "
[package]
symbol = "󰏗 "
[perl]
symbol = " "
[php]
symbol = " "
[pijul_channel]
symbol = " "
[python]
symbol = " "
[rlang]
symbol = "󰟔 "
[ruby]
symbol = " "
style = "bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'
[rust]
symbol = "󱘗 "
symbol = ""
style = "bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'
[scala]
symbol = " "
style = "bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'
[swift]
symbol = " "
[zig]
symbol = " "
[gradle]
symbol = " "
[time]
disabled = false
time_format = "%R" # Hour:Minute Format
style = "bg:#33658A"
format = '[ ♥ $time ]($style)'

View file

@ -3,6 +3,6 @@
# Author: js0ny
# Sourced by user's zshrc 在用户的 zshrc 中被引用
export STARSHIP_CONFIG=$DOTFILES/tools/starship/starship_zsh.toml
# export STARSHIP_CONFIG=$DOTFILES/tools/starship/starship_zsh.toml
eval "$(starship init zsh)"