mirror of
https://github.com/js0ny/dotfiles.git
synced 2025-12-21 08:43:00 +00:00
feat(shell): Use one keymaps for shell
This commit is contained in:
parent
68ff1bb357
commit
2346c13564
19 changed files with 530 additions and 265 deletions
0
tools/bash/bashrc
Normal file
0
tools/bash/bashrc
Normal file
170
tools/bash/profile
Normal file
170
tools/bash/profile
Normal file
|
|
@ -0,0 +1,170 @@
|
||||||
|
# Before antidots
|
||||||
|
if [ -n "$BASH_VERSION" ] && [ -f "$HOME/.bash_profile" ]; then
|
||||||
|
. "$HOME/.bash_profile"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$BASH_VERSION" ] && [ -f "$XDG_CONFIG_HOME/bash/bashrc" ]; then
|
||||||
|
. "$XDG_CONFIG_HOME/bash/bashrc"
|
||||||
|
fi
|
||||||
|
|
||||||
|
pathadd() {
|
||||||
|
# 检查是否存在且不在 PATH 中
|
||||||
|
if [[ -d "$1" && ":$PATH:" != *":$1:"* ]]; then
|
||||||
|
# 检查是否是符号链接
|
||||||
|
if [[ -L "$1" ]]; then
|
||||||
|
# 检查符号链接指向的目标是否存在
|
||||||
|
if [[ -e "$1" ]]; then
|
||||||
|
PATH="$1:$PATH"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# 普通目录直接添加
|
||||||
|
PATH="$1:$PATH"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
pathadd "$HOME/.local/bin"
|
||||||
|
pathadd "$HOME/.local/sbin"
|
||||||
|
|
||||||
|
|
||||||
|
# Dynamically Add Path
|
||||||
|
minimal_path=(
|
||||||
|
"/bin"
|
||||||
|
"/sbin"
|
||||||
|
"/usr/bin"
|
||||||
|
"/usr/sbin"
|
||||||
|
"/usr/local/bin"
|
||||||
|
"/usr/local/sbin"
|
||||||
|
"$HOME/.local/bin"
|
||||||
|
"$HOME/.local/sbin"
|
||||||
|
)
|
||||||
|
|
||||||
|
for p in "${minimal_path[@]}"; do
|
||||||
|
pathadd "$p"
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -d "/opt/homebrew/bin" ]; then # macOS
|
||||||
|
export PATH="/opt/homebrew/bin:$PATH"
|
||||||
|
elif [ -d "/home/linuxbrew/.linuxbrew/bin" ]; then # Linux
|
||||||
|
export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# macOS Specific
|
||||||
|
# This syntax is POSIX standard, for portability
|
||||||
|
if [ "$(uname)" = "Darwin" ]; then
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Linux Specific
|
||||||
|
if [ "$(uname)" = "Linux" ]; then
|
||||||
|
# CUDA
|
||||||
|
export CUDA_CACHE_PATH="$XDG_CACHE_HOME"/nv
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Azure CLI
|
||||||
|
if command -v az > /dev/null; then
|
||||||
|
export AZURE_CONFIG_DIR="$XDG_DATA_HOME"/azure
|
||||||
|
fi
|
||||||
|
# Bun JS
|
||||||
|
# mv ~/.bun $XDG_DATA_HOME/bun
|
||||||
|
# ln -sf $XDG_DATA_HOME/bun/bin/bun ~/.local/bin/bun
|
||||||
|
if command -v bun > /dev/null; then
|
||||||
|
export BUN_INSTALL="$XDG_DATA_HOME"/bun
|
||||||
|
export PATH="$BUN_INSTALL/bin:$PATH"
|
||||||
|
[ -s "$BUN_INSTALL/_bun" ] && source "$BUN_INSTALL/_bun"
|
||||||
|
fi
|
||||||
|
# Cargo
|
||||||
|
if command -v cargo > /dev/null; then
|
||||||
|
export CARGO_HOME="$XDG_DATA_HOME"/cargo
|
||||||
|
export PATH="$CARGO_HOME/bin:$PATH"
|
||||||
|
fi
|
||||||
|
# CGDB
|
||||||
|
if command -v cgdb > /dev/null; then
|
||||||
|
export CGDB_DIR="$XDG_CONFIG_HOME"/cgdb
|
||||||
|
fi
|
||||||
|
# .NET
|
||||||
|
if command -v dotnet > /dev/null; then
|
||||||
|
export DOTNET_CLI_HOME="$XDG_DATA_HOME"/dotnet
|
||||||
|
export PATH="$DOTNET_CLI_HOME/.dotnet/tools:$PATH"
|
||||||
|
fi
|
||||||
|
# Docker
|
||||||
|
if command -v docker > /dev/null; then
|
||||||
|
export DOCKER_CONFIG="$XDG_CONFIG_HOME"/docker
|
||||||
|
fi
|
||||||
|
# GnuPG
|
||||||
|
if command -v gpg > /dev/null; then
|
||||||
|
export GNUPGHOME="$XDG_DATA_HOME"/gnupg
|
||||||
|
fi
|
||||||
|
# Go
|
||||||
|
export GOPATH="$XDG_DATA_HOME"/go
|
||||||
|
export PATH="$GOPATH/bin:$PATH"
|
||||||
|
# Julia
|
||||||
|
if command -v julia > /dev/null; then
|
||||||
|
export JULIA_DEPOT_PATH="$XDG_DATA_HOME/julia:$JULIA_DEPOT_PATH"
|
||||||
|
fi
|
||||||
|
# Node.js
|
||||||
|
if command -v node > /dev/null; then
|
||||||
|
export NODE_REPL_HISTORY="$XDG_STATE_HOME"/node/repl_history
|
||||||
|
export TS_NODE_REPL_HISTORY="$XDG_STATE_HOME"/node/ts_node_repl_history
|
||||||
|
export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME"/npm/npmrc
|
||||||
|
export NPM_CONFIG_INIT_MODULE="$XDG_CONFIG_HOME"/npm/config/npm-init.js
|
||||||
|
export NPM_CONFIG_CACHE="$XDG_CACHE_HOME"/npm
|
||||||
|
export NPM_CONFIG_TMP="$XDG_RUNTIME_DIR"/npm
|
||||||
|
fi
|
||||||
|
# Parallel
|
||||||
|
if command -v parallel > /dev/null; then
|
||||||
|
export PARALLEL_HOME="$XDG_CONFIG_HOME"/parallel
|
||||||
|
fi
|
||||||
|
# Python
|
||||||
|
# Works only with Python 3.13.0a3 and later
|
||||||
|
if command -v python3 > /dev/null; then
|
||||||
|
export PYTHON_HISTORY="$XDG_DATA_HOME"/python/history
|
||||||
|
fi
|
||||||
|
# GNU Screen
|
||||||
|
if command -v screen > /dev/null; then
|
||||||
|
export SCREENRC="$XDG_CONFIG_HOME"/screen/screenrc
|
||||||
|
export SCREENDIR="${XDG_RUNTIME_DIR}/screen"
|
||||||
|
fi
|
||||||
|
# Ruby Gem
|
||||||
|
# Ruby Gem
|
||||||
|
if command -v gem > /dev/null; then
|
||||||
|
setopt nullglob
|
||||||
|
for dir in "$HOME/.local/share/gem/ruby/"*/bin; do
|
||||||
|
if [ -d "$dir" ]; then
|
||||||
|
export PATH="$dir:$PATH"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
unsetopt nullglob
|
||||||
|
fi
|
||||||
|
# Spacemacs
|
||||||
|
if command -v emacs > /dev/null; then
|
||||||
|
export SPACEMACSDIR="$XDG_CONFIG_HOME"/spacemacs
|
||||||
|
fi
|
||||||
|
# tldr
|
||||||
|
# Works only with C client (did not verify)
|
||||||
|
if command -v tldr > /dev/null; then
|
||||||
|
export TLDR_CACHE_DIR="$XDG_CACHE_HOME"/tldr
|
||||||
|
fi
|
||||||
|
# W3M
|
||||||
|
if command -v w3m > /dev/null; then
|
||||||
|
export W3M_DIR="$XDG_DATA_HOME"/w3m
|
||||||
|
fi
|
||||||
|
# Wakatime
|
||||||
|
if command -v wakatime > /dev/null; then
|
||||||
|
export WAKATIME_HOME="$XDG_CONFIG_HOME/wakatime"
|
||||||
|
fi
|
||||||
|
# Wget
|
||||||
|
if command -v wget > /dev/null; then
|
||||||
|
alias wget='wget --hsts-file="$XDG_CACHE_HOME/wget-hsts"'
|
||||||
|
fi
|
||||||
|
# zsh .zcompdump
|
||||||
|
# compinit -d "$XDG_CACHE_HOME"/zsh/zcompdump-"$ZSH_VERSION"
|
||||||
|
# Vcpkg
|
||||||
|
if command -v vcpkg > /dev/null; then
|
||||||
|
export VCPKG_ROOT="$XDG_DATA_HOME"/vcpkg
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
export PADER="less -R"
|
||||||
|
export EDITOR="nvim"
|
||||||
|
export VISUAL="nvim"
|
||||||
19
tools/bash/xdg-compat.sh
Normal file
19
tools/bash/xdg-compat.sh
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
# $DOTFILES/tools/bash/xdg-compat.sh
|
||||||
|
# Author: js0ny
|
||||||
|
# Date: 2025-01-28
|
||||||
|
# Sourced by /etc/profile
|
||||||
|
|
||||||
|
# Location: /etc/profile.d/xdg-compat.sh
|
||||||
|
# cp $DOTFILES/tools/bash/xdg-compat.sh /etc/profile.d/xdg-compat.sh
|
||||||
|
|
||||||
|
# Set XDG Base Directory Path
|
||||||
|
export XDG_CONFIG_HOME="$HOME/.config"
|
||||||
|
export XDG_CACHE_HOME="~/.cache"
|
||||||
|
export XDG_DATA_HOME="~/.local/share"
|
||||||
|
export XDG_STATE_HOME="~/.local/state"
|
||||||
|
export XDG_RUNTIME_DIR="/run/user/$(id -u)"
|
||||||
|
|
||||||
|
# Source user's XDG-compliant Bash configs
|
||||||
|
if [ -f "$XDG_CONFIG_HOME/bash/profile" ]; then
|
||||||
|
. "$XDG_CONFIG_HOME/bash/profile"
|
||||||
|
fi
|
||||||
|
|
@ -26,6 +26,7 @@ settings.showModeStatus = false;
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region Helper
|
// #region Helper
|
||||||
|
// import the API so that no need to use `api` prefix
|
||||||
const {
|
const {
|
||||||
aceVimMap,
|
aceVimMap,
|
||||||
addVimMapKey,
|
addVimMapKey,
|
||||||
|
|
@ -109,20 +110,20 @@ const vColemak = {
|
||||||
const forwardFactory = {
|
const forwardFactory = {
|
||||||
push: function (mapLists) {
|
push: function (mapLists) {
|
||||||
// forward original keys
|
// forward original keys
|
||||||
for (let key in mapLists) {
|
for (const key in mapLists) { // `const` better than `let`
|
||||||
forward.add(mapLists[key]);
|
forward.add(mapLists[key]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
map: function (mapLists) {
|
map: function (mapLists) {
|
||||||
for (let key in mapLists) {
|
for (const key in mapLists) {
|
||||||
colemak.map(key, mapLists[key]);
|
colemak.map(key, mapLists[key]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
pull: function (mapLists) {
|
pull: function (mapLists) {
|
||||||
for (let key in mapLists) {
|
for (const key in mapLists) {
|
||||||
forward.cancel(mapLists[key]);
|
forward.cancel(mapLists[key]);
|
||||||
}
|
}
|
||||||
for (let key in mapLists) {
|
for (const key in mapLists) {
|
||||||
colemak.forward(key);
|
colemak.forward(key);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -130,25 +131,25 @@ const forwardFactory = {
|
||||||
const vForwardFactory = {
|
const vForwardFactory = {
|
||||||
push: function (mapLists) {
|
push: function (mapLists) {
|
||||||
// forward original keys
|
// forward original keys
|
||||||
for (let key in mapLists) {
|
for (const key in mapLists) {
|
||||||
vForward.add(mapLists[key]);
|
vForward.add(mapLists[key]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
map: function (mapLists) {
|
map: function (mapLists) {
|
||||||
for (let key in mapLists) {
|
for (const key in mapLists) {
|
||||||
vColemak.map(key, mapLists[key]);
|
vColemak.map(key, mapLists[key]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
pull: function (mapLists) {
|
pull: function (mapLists) {
|
||||||
for (let key in mapLists) {
|
for (const key in mapLists) {
|
||||||
vForward.cancel(mapLists[key]);
|
vForward.cancel(mapLists[key]);
|
||||||
}
|
}
|
||||||
for (let key in mapLists) {
|
for (const key in mapLists) {
|
||||||
vColemak.forward(key);
|
vColemak.forward(key);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
// TODO: Add more search completion source (with json)
|
||||||
const parseSearchResponse = function (response) {
|
const parseSearchResponse = function (response) {
|
||||||
const res = JSON.parse(response.text);
|
const res = JSON.parse(response.text);
|
||||||
return res.map((r) => r.phrase);
|
return res.map((r) => r.phrase);
|
||||||
|
|
@ -171,20 +172,13 @@ const _addSearchAlias = function (
|
||||||
parseResponse,
|
parseResponse,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
// Shortcut for querySelector
|
||||||
var q = (selector) => document.querySelector(selector);
|
const q = (selector) => document.querySelector(selector);
|
||||||
var qs = (selector) => document.querySelectorAll(selector);
|
const qs = (selector) => document.querySelectorAll(selector);
|
||||||
|
|
||||||
var mapkeyFeed = function (key, desc, target, options) {
|
|
||||||
mapkey(key, desc, function () {
|
|
||||||
api.Normal.feedkeys(target)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region Keymap
|
// #region Keymap
|
||||||
|
// Normal Mode Keymap
|
||||||
const mapLists = {
|
const mapLists = {
|
||||||
/// scroll page
|
/// scroll page
|
||||||
// Arrow
|
// Arrow
|
||||||
|
|
@ -212,6 +206,7 @@ const mapLists = {
|
||||||
// gh/gi -> Prev/Next History
|
// gh/gi -> Prev/Next History
|
||||||
gh: "S",
|
gh: "S",
|
||||||
gi: "D",
|
gi: "D",
|
||||||
|
gl: "gi", // Focus on first input box
|
||||||
// t -> Open Link in New Tab
|
// t -> Open Link in New Tab
|
||||||
t: "gf",
|
t: "gf",
|
||||||
// 缩放
|
// 缩放
|
||||||
|
|
@ -219,7 +214,7 @@ const mapLists = {
|
||||||
zo: "ze",
|
zo: "ze",
|
||||||
zz: "zr",
|
zz: "zr",
|
||||||
};
|
};
|
||||||
|
// Visual Mode Keymap
|
||||||
const vMapLists = {
|
const vMapLists = {
|
||||||
n: "j",
|
n: "j",
|
||||||
N: "J",
|
N: "J",
|
||||||
|
|
@ -238,23 +233,20 @@ forwardFactory.map(mapLists);
|
||||||
|
|
||||||
vForwardFactory.push(vMapLists);
|
vForwardFactory.push(vMapLists);
|
||||||
vForwardFactory.map(vMapLists);
|
vForwardFactory.map(vMapLists);
|
||||||
// 鼠标点击
|
|
||||||
api.unmap("gi");
|
// All other unmapped keys should be defined here
|
||||||
api.unmap("[[");
|
// TODO: Add more mouse click keymap
|
||||||
api.unmap("]]");
|
api.unmap("gi"); // conflict with `gi` in `mapLists`
|
||||||
api.unmap(";m");
|
api.unmap("C"); // Use `F` instead (Open Link in New Tab)
|
||||||
api.unmap(";fs");
|
|
||||||
api.unmap("O");
|
|
||||||
api.unmap("C");
|
|
||||||
api.map("g/", "gU"); // Goto Root Domain
|
api.map("g/", "gU"); // Goto Root Domain
|
||||||
// p to site-specific
|
// TODO: Add SPC keymap as leader (maybe change `,` to `SPC`)
|
||||||
api.unmap("p");
|
|
||||||
api.unmap("<space>"); // Leader Key
|
api.unmap("<space>"); // Leader Key
|
||||||
|
|
||||||
forwardFactory.pull(mapLists);
|
forwardFactory.pull(mapLists);
|
||||||
vForwardFactory.pull(vMapLists);
|
vForwardFactory.pull(vMapLists);
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region Omnibar
|
// #region Omnibar NOTE: Dosn't work
|
||||||
// api.cmap("<Ctrl-a>", "<Ctrl-ArrowUp>");
|
// api.cmap("<Ctrl-a>", "<Ctrl-ArrowUp>");
|
||||||
// api.cmap("<Ctrl-e>", "<Ctrl-ArrowDown>");
|
// api.cmap("<Ctrl-e>", "<Ctrl-ArrowDown>");
|
||||||
// api.cmap("<Ctrl-f>", "<ArrowRight>");
|
// api.cmap("<Ctrl-f>", "<ArrowRight>");
|
||||||
|
|
@ -266,86 +258,60 @@ vForwardFactory.pull(vMapLists);
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region Search Alias
|
// #region Search Alias
|
||||||
removeSearchAlias("s"); // StackOverflow
|
|
||||||
removeSearchAlias("d"); // DuckDuckGo
|
|
||||||
removeSearchAlias("g"); // Google
|
|
||||||
removeSearchAlias("b"); // Baidu
|
|
||||||
removeSearchAlias("w"); // Bing
|
|
||||||
removeSearchAlias("y"); // YouTube
|
|
||||||
|
|
||||||
/// Common
|
const removedSearchAlias = [
|
||||||
_addSearchAlias("dd", "DuckDuckGo", "https://duckduckgo.com/?q=");
|
"b", // Baidu
|
||||||
_addSearchAlias("gg", "Google", "https://www.google.com/search?q=");
|
"d", // DuckDuckGo
|
||||||
_addSearchAlias("bd", "Baidu", "https://www.baidu.com/s?wd=");
|
"e", // Wikipedia
|
||||||
_addSearchAlias("bi", "Bing", "https://www.bing.com/search?q=");
|
"g", // Google
|
||||||
_addSearchAlias(
|
"s", // StackOverflow
|
||||||
"wk",
|
"w", // Bing
|
||||||
"Wikipedia",
|
"y", // YouTube
|
||||||
"https://en.wikipedia.org/w/index.php?title=Special:Search&search=",
|
];
|
||||||
);
|
|
||||||
_addSearchAlias("re", "Reddit", "https://www.reddit.com/search?q=");
|
|
||||||
_addSearchAlias("st", "Steam", "https://store.steampowered.com/search/?term=");
|
|
||||||
_addSearchAlias(
|
|
||||||
"ud",
|
|
||||||
"UrbanDictionary",
|
|
||||||
"https://www.urbandictionary.com/define.php?term=",
|
|
||||||
);
|
|
||||||
_addSearchAlias("tw", "X", "https://twitter.com/search?q=");
|
|
||||||
_addSearchAlias("de", "Thesaurus", "https://www.onelook.com/?w=");
|
|
||||||
_addSearchAlias(
|
|
||||||
"ww",
|
|
||||||
"WantWords",
|
|
||||||
"https://www.shenyandayi.com/wantWordsResult?lang=zh&query=",
|
|
||||||
);
|
|
||||||
/// 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=");
|
|
||||||
_addSearchAlias("mc", "Metacritic", "https://www.metacritic.com/search/");
|
|
||||||
/// EECS Related
|
|
||||||
_addSearchAlias(
|
|
||||||
"gh",
|
|
||||||
"GitHub",
|
|
||||||
"https://github.com/search?type=repositories&q=",
|
|
||||||
);
|
|
||||||
_addSearchAlias("so", "StackOverflow", "https://stackoverflow.com/search?q=");
|
|
||||||
_addSearchAlias("se", "StackExchange", "https://stackexchange.com/search?q=");
|
|
||||||
_addSearchAlias(
|
|
||||||
"aw",
|
|
||||||
"ArchWiki",
|
|
||||||
"https://wiki.archlinux.org/index.php?search=",
|
|
||||||
);
|
|
||||||
_addSearchAlias("wa", "WolframAlpha", "https://www.wolframalpha.com/input/?i=");
|
|
||||||
_addSearchAlias("eb", "ebay", "https://www.ebay.co.uk/sch/i.html?kw=");
|
|
||||||
// Programming language packages
|
|
||||||
_addSearchAlias("py", "pypi", "https://pypi.org/search/?q=");
|
|
||||||
_addSearchAlias("ng", "NuGet", "https://www.nuget.org/packages?q=");
|
|
||||||
_addSearchAlias("np", "npm", "https://www.npmjs.com/search?q=");
|
|
||||||
// Package Manager Search
|
|
||||||
_addSearchAlias("wg", "winget", "https://winget.ragerworks.com/search/all/");
|
|
||||||
_addSearchAlias("sc", "Scoop", "https://scoop.sh/#/apps?q=");
|
|
||||||
_addSearchAlias("br", "HomeBrew", "https://duckduckgo.com/?q=!brew ");
|
|
||||||
_addSearchAlias("au", "AUR", "https://aur.archlinux.org/packages?K=");
|
|
||||||
_addSearchAlias("pa", "Pacman", "https://archlinux.org/packages/?q=");
|
|
||||||
_addSearchAlias("ap", "APT", "https://packages.ubuntu.com/search?keywords=");
|
|
||||||
_addSearchAlias(
|
|
||||||
"a2",
|
|
||||||
"AlternativeTo",
|
|
||||||
"https://alternativeto.net/browse/search/?q=",
|
|
||||||
);
|
|
||||||
_addSearchAlias(
|
|
||||||
"cr",
|
|
||||||
"Chrome Web Store",
|
|
||||||
"https://chrome.google.com/webstore/search/",
|
|
||||||
);
|
|
||||||
/// Video
|
|
||||||
_addSearchAlias(
|
|
||||||
"yt",
|
|
||||||
"YouTube",
|
|
||||||
"https://www.youtube.com/results?search_query=",
|
|
||||||
);
|
|
||||||
_addSearchAlias("bl", "Bilibili", "https://search.bilibili.com/all?keyword=");
|
|
||||||
|
|
||||||
|
removedSearchAlias.forEach((alias) => removeSearchAlias(alias));
|
||||||
|
|
||||||
|
const searchAliases = [
|
||||||
|
["a2", "AlternativeTo", "https://alternativeto.net/browse/search/?q="],
|
||||||
|
["ap", "APT", "https://packages.ubuntu.com/search?keywords="],
|
||||||
|
["au", "AUR", "https://aur.archlinux.org/packages?K="],
|
||||||
|
["aw", "ArchWiki", "https://wiki.archlinux.org/index.php?search="],
|
||||||
|
["bd", "Baidu", "https://www.baidu.com/s?wd="],
|
||||||
|
["bi", "Bing", "https://www.bing.com/search?q="],
|
||||||
|
["bl", "Bilibili", "https://search.bilibili.com/all?keyword="]
|
||||||
|
["br", "HomeBrew", "https://duckduckgo.com/?q=!brew "],
|
||||||
|
["cg", "ChatGPT", "https://chat.openai.com/?q="],
|
||||||
|
["cr", "Chrome Web Store", "https://chrome.google.com/webstore/search/"],
|
||||||
|
["dd", "DuckDuckGo", "https://duckduckgo.com/?q="],
|
||||||
|
["de", "Thesaurus", "https://www.onelook.com/?w="],
|
||||||
|
["eb", "ebay", "https://www.ebay.co.uk/sch/i.html?kw="],
|
||||||
|
["fe", "Felo", "https://felo.ai/search?q="],
|
||||||
|
["gh", "GitHub", "https://github.com/search?type=repositories&q="],
|
||||||
|
["gg", "Google", "https://www.google.com/search?q="],
|
||||||
|
["mc", "Metacritic", "https://www.metacritic.com/search/"],
|
||||||
|
["ng", "NuGet", "https://www.nuget.org/packages?q="],
|
||||||
|
["np", "npm", "https://www.npmjs.com/search?q="],
|
||||||
|
["pa", "Pacman", "https://archlinux.org/packages/?q="],
|
||||||
|
["pp", "Perplexity", "https://www.perplexity.ai/?q="],
|
||||||
|
["py", "pypi", "https://pypi.org/search/?q="],
|
||||||
|
["re", "Reddit", "https://www.reddit.com/search?q="],
|
||||||
|
["sc", "Scoop", "https://scoop.sh/#/apps?q="],
|
||||||
|
["se", "StackExchange", "https://stackexchange.com/search?q="],
|
||||||
|
["so", "StackOverflow", "https://stackoverflow.com/search?q="],
|
||||||
|
["st", "Steam", "https://store.steampowered.com/search/?term="],
|
||||||
|
["tw", "X", "https://twitter.com/search?q="],
|
||||||
|
["ud", "UrbanDictionary", "https://www.urbandictionary.com/define.php?term="],
|
||||||
|
["wa", "WolframAlpha", "https://www.wolframalpha.com/input/?i="],
|
||||||
|
["wg", "winget", "https://winget.ragerworks.com/search/all/"],
|
||||||
|
["wk", "Wikipedia", "https://en.wikipedia.org/w/index.php?title=Special:Search&search="],
|
||||||
|
["ww", "WantWords", "https://www.shenyandayi.com/wantWordsResult?lang=zh&query="],
|
||||||
|
["yt", "YouTube", "https://www.youtube.com/results?search_query="],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Add all search aliases
|
||||||
|
searchAliases.forEach(([alias, name, url]) => {
|
||||||
|
_addSearchAlias(alias, name, url);
|
||||||
|
});
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region Site-specific
|
// #region Site-specific
|
||||||
|
|
@ -385,7 +351,7 @@ mapkey(",r", "Regenerate last output", function () {
|
||||||
btn[btn.length - 3].click();
|
btn[btn.length - 3].click();
|
||||||
}, { domain: /chat.deepseek.com/ });
|
}, { domain: /chat.deepseek.com/ });
|
||||||
mapkey(",n", "New Chat", function () {
|
mapkey(",n", "New Chat", function () {
|
||||||
window.location.href = 'https://chat.deepseek.com/';
|
window.location.href = "https://chat.deepseek.com/";
|
||||||
}, { domain: /chat.deepseek.com/ });
|
}, { domain: /chat.deepseek.com/ });
|
||||||
mapkey(",t", "Toggle Thinking (R1)", function () {
|
mapkey(",t", "Toggle Thinking (R1)", function () {
|
||||||
var btns = qs("div.ds-button");
|
var btns = qs("div.ds-button");
|
||||||
|
|
@ -399,31 +365,32 @@ mapkey(",w", "Toggle Web Search", function () {
|
||||||
|
|
||||||
// #region app.follow.is
|
// #region app.follow.is
|
||||||
mapkey(",t", "Toggle ", function () {
|
mapkey(",t", "Toggle ", function () {
|
||||||
var btn = qs("button.no-drag-region")
|
var btn = qs("button.no-drag-region");
|
||||||
btn[btn.length - 4].click();
|
btn[btn.length - 4].click();
|
||||||
}, { domain: /app.follow.is/ });
|
}, { domain: /app.follow.is/ });
|
||||||
|
|
||||||
mapkey(",a", "Toggle AI Summary", function () {
|
mapkey(",a", "Toggle AI Summary", function () {
|
||||||
var btn = qs("button.no-drag-region")
|
var btn = qs("button.no-drag-region");
|
||||||
btn[btn.length - 3].click();
|
btn[btn.length - 3].click();
|
||||||
}, { domain: /app.follow.is/ });
|
}, { domain: /app.follow.is/ });
|
||||||
|
|
||||||
mapkey(",o", "Toggle Original Website", function () {
|
mapkey(",o", "Toggle Original Website", function () {
|
||||||
var btn = qs("button.no-drag-region")
|
var btn = qs("button.no-drag-region");
|
||||||
btn[btn.length - 4].click();
|
btn[btn.length - 4].click();
|
||||||
}, { domain: /app.follow.is/ });
|
}, { domain: /app.follow.is/ });
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region GitHub
|
// #region GitHub
|
||||||
// utils
|
// utils
|
||||||
const gh = {}
|
const gh = {};
|
||||||
gh.repoLink = (owner, repo) => `https://github.com/${owner}/${repo}`;
|
gh.repoLink = (owner, repo) => `https://github.com/${owner}/${repo}`;
|
||||||
gh.pageLink = (owner, repo) => `https://${owner}.github.io/${repo}/`;
|
gh.pageLink = (owner, repo) => `https://${owner}.github.io/${repo}/`;
|
||||||
gh.sourceLink = (owner, repo, path) => `${gh.repoLink(owner, repo)}/tree/${path}`;
|
gh.sourceLink = (owner, repo, path) =>
|
||||||
|
`${gh.repoLink(owner, repo)}/tree/${path}`;
|
||||||
gh.rawToSource = (url) => {
|
gh.rawToSource = (url) => {
|
||||||
const ps = url.split('/').slice(3)
|
const ps = url.split("/").slice(3);
|
||||||
return gh.sourceLink(ps[0], ps[1], ps.slice(4).join('/'));
|
return gh.sourceLink(ps[0], ps[1], ps.slice(4).join("/"));
|
||||||
}
|
};
|
||||||
// github.com
|
// github.com
|
||||||
mapkey(",e", "Use Web Editor", function () {
|
mapkey(",e", "Use Web Editor", function () {
|
||||||
const url = new URL(window.location.href);
|
const url = new URL(window.location.href);
|
||||||
|
|
@ -464,13 +431,13 @@ mapkey(",R", "Go to GitHub Repo (New tab)", function () {
|
||||||
mapkey(",r", "Switch to GitHub Repo", function () {
|
mapkey(",r", "Switch to GitHub Repo", function () {
|
||||||
const url = new URL(window.location.href);
|
const url = new URL(window.location.href);
|
||||||
var owner, repo;
|
var owner, repo;
|
||||||
owner, repo = url.pathname.split('/').slice(1, 3)
|
owner, repo = url.pathname.split("/").slice(1, 3);
|
||||||
window.location.href = gh.repoLink(owner, repo);
|
window.location.href = gh.repoLink(owner, repo);
|
||||||
}, { domain: /raw.githubusercontent.com/ });
|
}, { domain: /raw.githubusercontent.com/ });
|
||||||
mapkey(",R", "Switch to GitHub Repo", function () {
|
mapkey(",R", "Switch to GitHub Repo", function () {
|
||||||
const url = new URL(window.location.href);
|
const url = new URL(window.location.href);
|
||||||
var owner, repo;
|
var owner, repo;
|
||||||
owner, repo = url.pathname.split('/').slice(1, 3)
|
owner, repo = url.pathname.split("/").slice(1, 3);
|
||||||
tabOpenLink(gh.repoLink(owner, repo));
|
tabOpenLink(gh.repoLink(owner, repo));
|
||||||
}, { domain: /raw.githubusercontent.com/ });
|
}, { domain: /raw.githubusercontent.com/ });
|
||||||
mapkey(",s", "Open Source in GitHub", function () {
|
mapkey(",s", "Open Source in GitHub", function () {
|
||||||
|
|
@ -479,9 +446,6 @@ mapkey(",s", "Open Source in GitHub", function () {
|
||||||
mapkey(",S", "Open Source in GitHub (New Page)", function () {
|
mapkey(",S", "Open Source in GitHub (New Page)", function () {
|
||||||
tabOpenLink(gh.rawToSource(window.location.href));
|
tabOpenLink(gh.rawToSource(window.location.href));
|
||||||
}, { domain: /raw.githubusercontent.com/ });
|
}, { domain: /raw.githubusercontent.com/ });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// #endregion GitHub
|
// #endregion GitHub
|
||||||
|
|
||||||
// #region perplexity.ai
|
// #region perplexity.ai
|
||||||
|
|
@ -492,13 +456,13 @@ mapkey(",S", "Open Source in GitHub (New Page)", function () {
|
||||||
* 3 - 写作
|
* 3 - 写作
|
||||||
* 4 - 视频
|
* 4 - 视频
|
||||||
* 5 - 社交
|
* 5 - 社交
|
||||||
*/
|
*/
|
||||||
const perplexityFocusOn = function (n) {
|
const perplexityFocusOn = function (n) {
|
||||||
qs("span.grow button")[0].click()
|
qs("span.grow button")[0].click();
|
||||||
setTimeout(() => { // Wait for the DOM to update
|
setTimeout(() => { // Wait for the DOM to update
|
||||||
qs("div.shadow-subtle div.group\\/item")[n].click();
|
qs("div.shadow-subtle div.group\\/item")[n].click();
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
};
|
||||||
unmap("<Ctrl-i>", /perplexity.ai/); // allows to use perplexity web keybindings
|
unmap("<Ctrl-i>", /perplexity.ai/); // allows to use perplexity web keybindings
|
||||||
mapkey(",b", "Add Perplexity Bookmark", function () {
|
mapkey(",b", "Add Perplexity Bookmark", function () {
|
||||||
// button.border:nth-child(2)
|
// button.border:nth-child(2)
|
||||||
|
|
@ -509,19 +473,19 @@ mapkey(",w", "Toggle Writing/Web Search", function () {
|
||||||
perplexityFocusOn(3);
|
perplexityFocusOn(3);
|
||||||
}, { domain: /perplexity.ai/ });
|
}, { domain: /perplexity.ai/ });
|
||||||
mapkey(",s", "Start Generating", function () {
|
mapkey(",s", "Start Generating", function () {
|
||||||
var btns = qs("span.grow button")
|
var btns = qs("span.grow button");
|
||||||
btns[btns.length - 1].click();
|
btns[btns.length - 1].click();
|
||||||
}, { domain: /perplexity.ai/ });
|
}, { domain: /perplexity.ai/ });
|
||||||
mapkey(",y", "Yank Last Output", function () {
|
mapkey(",y", "Yank Last Output", function () {
|
||||||
var toolbars = qs("div.mt-sm")
|
var toolbars = qs("div.mt-sm");
|
||||||
var last = toolbars[toolbars.length - 1]
|
var last = toolbars[toolbars.length - 1];
|
||||||
var btns = last.querySelectorAll("button")
|
var btns = last.querySelectorAll("button");
|
||||||
btns[4].click();
|
btns[4].click();
|
||||||
}, { domain: /perplexity.ai/ });
|
}, { domain: /perplexity.ai/ });
|
||||||
mapkey(",r", "Change model to regenerate last output", function () {
|
mapkey(",r", "Change model to regenerate last output", function () {
|
||||||
var toolbars = qs("div.mt-sm")
|
var toolbars = qs("div.mt-sm");
|
||||||
var last = toolbars[toolbars.length - 1]
|
var last = toolbars[toolbars.length - 1];
|
||||||
var btns = last.querySelectorAll("button")
|
var btns = last.querySelectorAll("button");
|
||||||
btns[1].click();
|
btns[1].click();
|
||||||
}, { domain: /perplexity.ai/ });
|
}, { domain: /perplexity.ai/ });
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
@ -543,7 +507,6 @@ addVimMapKey(
|
||||||
motion: "findNext",
|
motion: "findNext",
|
||||||
motionArgs: { forward: false, toJumplist: true },
|
motionArgs: { forward: false, toJumplist: true },
|
||||||
},
|
},
|
||||||
|
|
||||||
// Word movement
|
// Word movement
|
||||||
{
|
{
|
||||||
keys: "j",
|
keys: "j",
|
||||||
|
|
@ -562,7 +525,6 @@ addVimMapKey(
|
||||||
inclusive: true,
|
inclusive: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
// Insert mode entries
|
// Insert mode entries
|
||||||
{
|
{
|
||||||
keys: "l",
|
keys: "l",
|
||||||
|
|
@ -642,5 +604,5 @@ addVimMapKey(
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region Hints
|
// #region Hints
|
||||||
api.Hints.setCharacters('qwfpgarstdcv')
|
api.Hints.setCharacters("qwfpgarstdcv"); // Left-hand keys
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
|
||||||
|
|
@ -23,14 +23,16 @@ set -gx EDITOR nvim
|
||||||
set -gx VISUAL nvim
|
set -gx VISUAL nvim
|
||||||
|
|
||||||
# Minimal PATH for early commands
|
# Minimal PATH for early commands
|
||||||
set -gx PATH /usr/local/bin /usr/bin /bin /usr/sbin /sbin ~/.local/bin $PATH
|
for dir in /usr/local/bin /usr/bin /bin /usr/sbin /sbin "$HOME/.local/bin"
|
||||||
|
if test -d "$dir" -a ! -L "$dir"
|
||||||
if test -d /opt/homebrew/bin # macOS
|
fish_add_path "$dir"
|
||||||
set -gx PATH /opt/homebrew/bin $PATH
|
end
|
||||||
else if test -d /home/linuxbrew/.linuxbrew/bin # Linux
|
|
||||||
set -gx PATH /home/linuxbrew/.linuxbrew/bin $PATH
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Homebrew/Linuxbrew
|
||||||
|
test -d /opt/homebrew/bin && fish_add_path /opt/homebrew/bin
|
||||||
|
test -d /home/linuxbrew/.linuxbrew/bin && fish_add_path /home/linuxbrew/.linuxbrew/bin
|
||||||
|
|
||||||
if command -v brew > /dev/null
|
if command -v brew > /dev/null
|
||||||
set -gx HOMEBREW_NO_ENV_HINTS
|
set -gx HOMEBREW_NO_ENV_HINTS
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,10 @@ alias sn="sudo nvim -u ~/.config/nvim/init.lua"
|
||||||
# Dev #
|
# Dev #
|
||||||
abbr --add py python3
|
abbr --add py python3
|
||||||
abbr --add ipy ipython
|
abbr --add ipy ipython
|
||||||
abbr --add reload "source $__fish_config_dir/config.fish"
|
|
||||||
abbr --add pulldots "cd $DOTFILES && git pull"
|
|
||||||
|
|
||||||
# lsd - modern ls
|
# lsd - modern ls
|
||||||
if command -v lsd > /dev/null
|
if command -v lsd > /dev/null
|
||||||
alias ls='lsd -A -I .DS_Store -I .git -I .gitkeep'
|
alias ls='lsd -A'
|
||||||
abbr --add l 'lsd -lah'
|
abbr --add l 'lsd -lah'
|
||||||
abbr --add ll 'lsd -l'
|
abbr --add ll 'lsd -l'
|
||||||
abbr --add tree 'ls --tree'
|
abbr --add tree 'ls --tree'
|
||||||
|
|
@ -48,14 +46,9 @@ end
|
||||||
function tv
|
function tv
|
||||||
touch $argv[1] && nvim $argv[1]
|
touch $argv[1] && nvim $argv[1]
|
||||||
end
|
end
|
||||||
function zls
|
|
||||||
z $argv[1] && ls
|
|
||||||
end
|
|
||||||
|
|
||||||
# Use neovide as gVim
|
# Use neovide as gVim
|
||||||
if command -v neovide > /dev/null
|
abbr --add gvi "neovide"
|
||||||
abbr --add gvi "neovide"
|
|
||||||
end
|
|
||||||
|
|
||||||
if command -v brew > /dev/null
|
if command -v brew > /dev/null
|
||||||
abbr --add brewi "brew install"
|
abbr --add brewi "brew install"
|
||||||
|
|
@ -69,11 +62,28 @@ if command -v pacman > /dev/null
|
||||||
abbr --add paci "sudo pacman -S"
|
abbr --add paci "sudo pacman -S"
|
||||||
abbr --add pacr "sudo pacman -R"
|
abbr --add pacr "sudo pacman -R"
|
||||||
abbr --add pacu "sudo pacman -Syu"
|
abbr --add pacu "sudo pacman -Syu"
|
||||||
abbr --add pacs "sudo pacman -Ss"
|
if command -v paru > /dev/null
|
||||||
|
abbr --add pacs "paru -Ss"
|
||||||
|
elif command -v yay > /dev/null
|
||||||
|
abbr --add pacs "yay -Ss"
|
||||||
|
else
|
||||||
|
abbr --add pacs "pacman -Ss"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if test "$TERM" = "xterm-ghostty" -o "$TERM" = "xterm-kitty"
|
if test "$TERM" = "xterm-ghostty" -o "$TERM" = "xterm-kitty"
|
||||||
abbr --add icat "kitten icat"
|
abbr --add icat "kitten icat"
|
||||||
else if test "$TERM_PROGRAM" = "WezTerm"
|
else if test "$TERM_PROGRAM" = "WezTerm"
|
||||||
abbr --add icat "wezterm imgcat"
|
if test "$WSL_DISTRO_NAME"
|
||||||
|
abbr --add icat "wezterm.exe imgcat"
|
||||||
|
else
|
||||||
|
abbr --add icat "wezterm imgcat"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Bash Style Command Substitution
|
||||||
|
# https://github.com/fish-shell/fish-shell/wiki/Bash-Style-Command-Substitution-and-Chaining-(!!-!$)
|
||||||
|
|
||||||
|
function __last_history_item; echo $history[1]; end
|
||||||
|
|
||||||
|
abbr -a !! --position anywhere --function __last_history_item
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,9 @@
|
||||||
# ln -sf $DOTFILES/tools/fish ~/.config/fish
|
# ln -sf $DOTFILES/tools/fish ~/.config/fish
|
||||||
|
|
||||||
|
|
||||||
|
# read key: `fish_key_reader`
|
||||||
|
# get current bindings: `bind`
|
||||||
|
|
||||||
fish_vi_key_bindings
|
fish_vi_key_bindings
|
||||||
|
|
||||||
# Colemak hnei
|
# Colemak hnei
|
||||||
|
|
@ -17,12 +20,52 @@ fish_vi_key_bindings
|
||||||
# n
|
# n
|
||||||
# v
|
# v
|
||||||
# bind -M default 'h' backward-char
|
# bind -M default 'h' backward-char
|
||||||
bind -M default 'n' down-or-search
|
bind -M default n down-or-search
|
||||||
bind -M default 'e' up-or-search
|
bind -M default e up-or-search
|
||||||
bind -M default 'i' forward-char
|
bind -M default i forward-char
|
||||||
|
|
||||||
# Similar position to [i] in QWERTY
|
# Similar position to [i] in QWERTY
|
||||||
bind -M default -m insert l repaint-mode
|
bind -M default -m insert l repaint-mode
|
||||||
bind -M default -m insert L beginning-of-line repaint-mode
|
bind -M default -m insert L beginning-of-line repaint-mode
|
||||||
|
|
||||||
|
# Ne{[k]s}t -> fish doesnt have this feature
|
||||||
|
|
||||||
|
# [J]ump
|
||||||
|
bind -M default j forward-word
|
||||||
|
bind -M default J forward-bigword
|
||||||
|
|
||||||
|
# Use N to Join
|
||||||
|
bind -M default N end-of-line delete-char
|
||||||
|
|
||||||
|
# Emacs Hybrid
|
||||||
|
bind -M default \cp up-or-search
|
||||||
|
bind -M default \cn down-or-search
|
||||||
|
bind -M default \cf forward-char
|
||||||
|
bind -M default \cb backward-char
|
||||||
|
bind -M default \ca beginning-of-line
|
||||||
|
bind -M default \ce end-of-line
|
||||||
|
bind -M default \ck kill-line
|
||||||
|
|
||||||
|
bind -M insert \cp up-or-search
|
||||||
|
bind -M insert \cn down-or-search
|
||||||
|
bind -M insert \cf forward-char
|
||||||
|
bind -M insert \cb backward-char
|
||||||
|
bind -M insert \ca beginning-of-line
|
||||||
|
bind -M insert \ce end-of-line
|
||||||
|
bind -M insert \ck kill-line
|
||||||
|
bind -M insert \cw backward-kill-path-component
|
||||||
|
|
||||||
|
|
||||||
|
# ctrl + backspace
|
||||||
|
bind -M insert \b backward-kill-path-component
|
||||||
|
# alt + backspace
|
||||||
|
bind -M insert \e\x7F backward-kill-line
|
||||||
|
# ctrl + delete
|
||||||
|
bind -M insert \e\[3\;5~ kill-word
|
||||||
|
# alt + delete (d$)
|
||||||
|
bind -M insert \e\[3\;3~ kill-line
|
||||||
|
|
||||||
fzf --fish | source
|
fzf --fish | source
|
||||||
|
# C-r : fzf history search
|
||||||
|
# C-t : fzf file search
|
||||||
|
# A-c : fzf directory search
|
||||||
|
|
|
||||||
|
|
@ -8,14 +8,27 @@
|
||||||
# ln -sf $DOTFILES/tools/fish ~/.config/fish
|
# ln -sf $DOTFILES/tools/fish ~/.config/fish
|
||||||
|
|
||||||
|
|
||||||
alias ..="cd .."
|
|
||||||
alias ...="cd ../.."
|
|
||||||
alias ....="cd ../../.."
|
|
||||||
alias .....="cd ../../../.."
|
|
||||||
alias ......="cd ../../../../.."
|
|
||||||
|
|
||||||
abbr --add \- 'cd -'
|
|
||||||
|
|
||||||
if command -v zoxide > /dev/null
|
if command -v zoxide > /dev/null
|
||||||
zoxide init fish | source
|
zoxide init fish | source
|
||||||
|
alias ..="z .."
|
||||||
|
alias ...="z ../.."
|
||||||
|
alias ....="z ../../.."
|
||||||
|
alias .....="z ../../../.."
|
||||||
|
alias ......="z ../../../../.."
|
||||||
|
|
||||||
|
abbr --add \- 'z -'
|
||||||
|
|
||||||
|
|
||||||
|
function zls
|
||||||
|
z $argv[1] && ls
|
||||||
|
end
|
||||||
|
else
|
||||||
|
alias ..="cd .."
|
||||||
|
alias ...="cd ../.."
|
||||||
|
alias ....="cd ../../.."
|
||||||
|
alias .....="cd ../../../.."
|
||||||
|
alias ......="cd ../../../../.."
|
||||||
|
|
||||||
|
abbr --add \- 'cd -'
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,27 +2,28 @@
|
||||||
# Date: 2024-12-01
|
# Date: 2024-12-01
|
||||||
# Author: js0ny
|
# Author: js0ny
|
||||||
# Aliases for PowerShell
|
# Aliases for PowerShell
|
||||||
### VARIABLES ###
|
|
||||||
$EDITOR = "code"
|
# Unix Shell Equivalents #
|
||||||
# Shell Equivalents #
|
|
||||||
Set-Alias "touch" "New-Item"
|
Set-Alias "touch" "New-Item"
|
||||||
${function:l} = { Get-ChildItem -Force }
|
${function:l} = { Get-ChildItem -Force }
|
||||||
${function:tree} = { lsd.exe --tree $args }
|
${function:tree} = { lsd --tree $args }
|
||||||
Set-Alias "which" "Get-Command"
|
Set-Alias "which" "Get-Command"
|
||||||
|
|
||||||
# Shell Configurations #
|
|
||||||
${function:pulldots} = { Set-Location -Path $DOTFILES && git pull }
|
|
||||||
|
|
||||||
# Editors #
|
# Editors #
|
||||||
Set-Alias "v" "nvim"
|
Set-Alias "v" "nvim"
|
||||||
Set-Alias "c" "code"
|
Set-Alias "c" "code"
|
||||||
Set-Alias "gvi" "neovide"
|
Get-Command neovide -ErrorAction SilentlyContinue > $null && Set-Alias "gvi" "neovide"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# File Creation #
|
# File Creation #
|
||||||
function mkcd { param ( [string] $dirname) New-Item -ItemType Directory -Name $dirname && Set-Location $dirname }
|
function mkcd { param ( [string] $dirname) New-Item -ItemType Directory -Name $dirname && Set-Location $dirname }
|
||||||
function tc { param ( [string] $filename) New-Item $filename && code $filename }
|
function tc { param ( [string] $filename) New-Item $filename && code $filename }
|
||||||
function tv { param ( [string] $filename) New-Item $filename && nvim $filename }
|
function tv { param ( [string] $filename) New-Item $filename && nvim $filename }
|
||||||
function cdls { param( [string] $dirname) Set-Location $dirname && Get-ChildItem }
|
function cdls { param( [string] $dirname) Set-Location $dirname && Get-ChildItem }
|
||||||
|
function zls { param( [string] $dirname) z $dirname && Get-ChildItem }
|
||||||
|
function zl { param( [string] $dirname) z $dirname && lsd }
|
||||||
|
|
||||||
|
|
||||||
### Dev ###
|
### Dev ###
|
||||||
|
|
||||||
|
|
@ -30,7 +31,10 @@ function cdls { param( [string] $dirname) Set-Location $dirname && Get-ChildItem
|
||||||
Set-Alias "py" "python"
|
Set-Alias "py" "python"
|
||||||
Set-Alias "ipy" "ipython"
|
Set-Alias "ipy" "ipython"
|
||||||
|
|
||||||
if ($isWindows) {
|
if ($Env:WEZTERM) {
|
||||||
# Debugging
|
# Environment variable injected by wezterm/wezterm.lua
|
||||||
# function kex { wsl -d kali-linux kex --sl -s }
|
${function:icat} = { wezterm imgcat $args }
|
||||||
|
}
|
||||||
|
elseif ($Env:KITTY) {
|
||||||
|
${function:icat} = { kitty +kitten icat $args }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
|
|
||||||
if ($Env:WEZTERM) {
|
|
||||||
# Environment variable injected by wezterm/wezterm.lua
|
|
||||||
${function:icat} = { wezterm imgcat $args }
|
|
||||||
}
|
|
||||||
elseif ($Env:KITTY) {
|
|
||||||
${function:icat} = { kitty +kitten icat $args }
|
|
||||||
}
|
|
||||||
|
|
@ -8,3 +8,6 @@
|
||||||
# interactive session.
|
# interactive session.
|
||||||
|
|
||||||
$env:IPYTHONDIR = "$env:AppData\ipython"
|
$env:IPYTHONDIR = "$env:AppData\ipython"
|
||||||
|
$env:EDITOR = "code --wait"
|
||||||
|
$env:VISUAL = "code --wait"
|
||||||
|
$env:PAGER = "less"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
# aka PSReadLine
|
# aka PSReadLine
|
||||||
|
|
||||||
|
# read key: [System.Console]::ReadKey()
|
||||||
|
# get current bindings: Get-PSReadLineKeyHandler
|
||||||
|
|
||||||
# PSReadLineOptions
|
# PSReadLineOptions
|
||||||
Set-PSReadLineOption -EditMode Vi # Vi Keybindings
|
Set-PSReadLineOption -EditMode Vi # Vi Keybindings
|
||||||
Set-PSReadLineOption -PredictionViewStyle ListView
|
Set-PSReadLineOption -PredictionViewStyle InlineView
|
||||||
Set-PSReadLineOption -PredictionSource HistoryAndPlugin
|
Set-PSReadLineOption -PredictionSource HistoryAndPlugin
|
||||||
# Set-PSReadLineOption -ContinuationPrompt "`e[36m CR > " # Use Starship instead
|
# Set-PSReadLineOption -ContinuationPrompt "`e[36m CR > " # Use Starship instead
|
||||||
# PSReadLineKeyHandlers
|
# PSReadLineKeyHandlers
|
||||||
|
|
@ -24,7 +28,15 @@ Set-PSReadLineKeyHandler -Chord "Control+Oem4" -Function ViCommandMode -ViMode I
|
||||||
Set-PSReadLineKeyHandler -Chord "Ctrl+a" -Function BeginningOfLine
|
Set-PSReadLineKeyHandler -Chord "Ctrl+a" -Function BeginningOfLine
|
||||||
Set-PSReadLineKeyHandler -Chord "Ctrl+e" -Function EndOfLine
|
Set-PSReadLineKeyHandler -Chord "Ctrl+e" -Function EndOfLine
|
||||||
Set-PSReadLineKeyHandler -Chord "Ctrl+p" -Function PreviousHistory
|
Set-PSReadLineKeyHandler -Chord "Ctrl+p" -Function PreviousHistory
|
||||||
Set-PSReadLineKeyHandler -Chord "Ctrl+p" -Function PreviousHistory
|
Set-PSReadLineKeyHandler -Chord "Ctrl+f" -Function AcceptNextSuggestionWord
|
||||||
|
Set-PSReadLineKeyHandler -Chord "Alt+f" -Function AcceptSuggestion
|
||||||
Set-PSReadLineKeyHandler -Chord "Ctrl+n" -Function NextHistory
|
Set-PSReadLineKeyHandler -Chord "Ctrl+n" -Function NextHistory
|
||||||
|
Set-PSReadLineKeyHandler -Chord "Ctrl+w" -Function BackwardKillWord
|
||||||
|
Set-PSReadLineKeyHandler -Chord "Ctrl+Backspace" -Function BackwardKillWord
|
||||||
|
Set-PSReadLineKeyHandler -Chord "Ctrl+Shift+Backspace" -Function BackwardKillLine
|
||||||
|
Set-PSReadLineKeyHandler -Chord "Alt+Backspace" -Function BackwardKillLine
|
||||||
|
Set-PSReadLineKeyHandler -Chord "Ctrl+Delete" -Function KillWord
|
||||||
|
Set-PSReadLineKeyHandler -Chord "Ctrl+Shift+Delete" -Function KillLine
|
||||||
|
Set-PSReadLineKeyHandler -Chord "Alt+Delete" -Function KillLine
|
||||||
## Use <Tab> to Invoke MenuComplete
|
## Use <Tab> to Invoke MenuComplete
|
||||||
Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete
|
Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,28 @@
|
||||||
# ${function:~} = { Set-Location -Path ~ } cd is better
|
# ${function:~} = { Set-Location -Path ~ } cd is better
|
||||||
${function:...} = { Set-Location -Path (Join-Path -Path (Join-Path -Path .. -ChildPath ..) -ChildPath ..) }
|
${function:...} = { Set-Location -Path (Join-Path -Path (Join-Path -Path .. -ChildPath ..) -ChildPath ..) }
|
||||||
${function:....} = { Set-Location -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path .. -ChildPath ..) -ChildPath ..) -ChildPath ..) }
|
${function:....} = { Set-Location -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path .. -ChildPath ..) -ChildPath ..) -ChildPath ..) }
|
||||||
${function:.....} = { Set-Location -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path .. -ChildPath ..) -ChildPath ..) -ChildPath ..) -ChildPath ..) }
|
${function:.....} = { Set-Location -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path .. -ChildPath ..) -ChildPath ..) -ChildPath ..) -ChildPath ..) }
|
||||||
${function:......} = { Set-Location -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path .. -ChildPath ..) -ChildPath ..) -ChildPath ..) -ChildPath ..) -ChildPath ..) }
|
${function:......} = { Set-Location -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path .. -ChildPath ..) -ChildPath ..) -ChildPath ..) -ChildPath ..) -ChildPath ..) }
|
||||||
|
|
||||||
# Absolute navigation
|
# Absolute navigation
|
||||||
${function:docs} = { Set-Location -Path (Join-Path -Path $HOME -ChildPath "Documents") }
|
${function:docs} = { Set-Location -Path (Join-Path -Path $HOME -ChildPath "Documents") }
|
||||||
${function:down} = { Set-Location -Path (Join-Path -Path $HOME -ChildPath "Downloads") }
|
${function:down} = { Set-Location -Path (Join-Path -Path $HOME -ChildPath "Downloads") }
|
||||||
${function:dt} = { Set-Location -Path (Join-Path -Path $HOME -ChildPath "Desktop") }
|
${function:dt} = { Set-Location -Path (Join-Path -Path $HOME -ChildPath "Desktop") }
|
||||||
${function:one} = { Set-Location -Path (Join-Path -Path $HOME -ChildPath "OneDrive") }
|
${function:one} = { Set-Location -Path (Join-Path -Path $HOME -ChildPath "OneDrive") }
|
||||||
|
|
||||||
|
|
||||||
Invoke-Expression (& { (zoxide init powershell | Out-String) })
|
if (Get-Command zoxide -ErrorAction SilentlyContinue) {
|
||||||
|
Invoke-Expression (& { (zoxide init powershell | Out-String) })
|
||||||
|
${function:...} = { z -Path (Join-Path -Path .. -ChildPath ..) }
|
||||||
|
${function:....} = { z -Path (Join-Path -Path (Join-Path -Path .. -ChildPath ..) -ChildPath ..) }
|
||||||
|
${function:.....} = { z -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path .. -ChildPath ..) -ChildPath ..) -ChildPath ..) }
|
||||||
|
${function:......} = { z -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path .. -ChildPath ..) -ChildPath ..) -ChildPath ..) -ChildPath ..) }
|
||||||
|
${function:z-} = { z - }
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
${function:...} = { Set-Location -Path (Join-Path -Path .. -ChildPath ..) }
|
||||||
|
${function:....} = { Set-Location -Path (Join-Path -Path (Join-Path -Path .. -ChildPath ..) -ChildPath ..) }
|
||||||
|
${function:.....} = { Set-Location -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path .. -ChildPath ..) -ChildPath ..) -ChildPath ..) }
|
||||||
|
${function:......} = { Set-Location -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path .. -ChildPath ..) -ChildPath ..) -ChildPath ..) -ChildPath ..) }
|
||||||
|
${function:z-} = { Set-Location - }
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,31 +20,31 @@ $PSStyle.Formatting.Verbose = $Flavor.Yellow.Foreground()
|
||||||
$PSStyle.Formatting.Warning = $Flavor.Peach.Foreground()
|
$PSStyle.Formatting.Warning = $Flavor.Peach.Foreground()
|
||||||
|
|
||||||
$Colors = @{
|
$Colors = @{
|
||||||
# Largely based on the Code Editor style guide
|
# Largely based on the Code Editor style guide
|
||||||
# Emphasis, ListPrediction and ListPredictionSelected are inspired by the Catppuccin fzf theme
|
# Emphasis, ListPrediction and ListPredictionSelected are inspired by the Catppuccin fzf theme
|
||||||
|
|
||||||
# Powershell colours
|
# Powershell colours
|
||||||
Emphasis = $Flavor.Red.Foreground()
|
Emphasis = $Flavor.Red.Foreground()
|
||||||
Selection = $Flavor.Surface0.Background()
|
Selection = $Flavor.Surface0.Background()
|
||||||
|
|
||||||
# PSReadLine prediction colours
|
# PSReadLine prediction colours
|
||||||
InlinePrediction = $Flavor.Overlay0.Foreground()
|
InlinePrediction = $Flavor.Overlay0.Foreground()
|
||||||
ListPrediction = $Flavor.Mauve.Foreground()
|
ListPrediction = $Flavor.Mauve.Foreground()
|
||||||
ListPredictionSelected = $Flavor.Surface0.Background()
|
ListPredictionSelected = $Flavor.Surface0.Background()
|
||||||
|
|
||||||
# Syntax highlighting
|
# Syntax highlighting
|
||||||
Command = $Flavor.Blue.Foreground()
|
Command = $Flavor.Blue.Foreground()
|
||||||
Comment = $Flavor.Overlay0.Foreground()
|
Comment = $Flavor.Overlay0.Foreground()
|
||||||
Default = $Flavor.Text.Foreground()
|
Default = $Flavor.Text.Foreground()
|
||||||
Error = $Flavor.Red.Foreground()
|
Error = $Flavor.Red.Foreground()
|
||||||
Keyword = $Flavor.Mauve.Foreground()
|
Keyword = $Flavor.Mauve.Foreground()
|
||||||
Member = $Flavor.Rosewater.Foreground()
|
Member = $Flavor.Rosewater.Foreground()
|
||||||
Number = $Flavor.Peach.Foreground()
|
Number = $Flavor.Peach.Foreground()
|
||||||
Operator = $Flavor.Sky.Foreground()
|
Operator = $Flavor.Sky.Foreground()
|
||||||
Parameter = $Flavor.Pink.Foreground()
|
Parameter = $Flavor.Pink.Foreground()
|
||||||
String = $Flavor.Green.Foreground()
|
String = $Flavor.Green.Foreground()
|
||||||
Type = $Flavor.Yellow.Foreground()
|
Type = $Flavor.Yellow.Foreground()
|
||||||
Variable = $Flavor.Lavender.Foreground()
|
Variable = $Flavor.Lavender.Foreground()
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set the colours
|
# Set the colours
|
||||||
|
|
|
||||||
|
|
@ -8,37 +8,37 @@ alias ni=touch
|
||||||
alias cls=clear
|
alias cls=clear
|
||||||
alias ii=open
|
alias ii=open
|
||||||
|
|
||||||
|
# Editors #
|
||||||
|
alias v=nvim
|
||||||
|
alias c=code
|
||||||
|
# Use neovide as gVim
|
||||||
|
alias gvi="neovide"
|
||||||
|
alias sv="sudo vim -u ~/.dotfiles/common/vim.noxdg.vimrc"
|
||||||
|
alias sn="sudo nvim -u ~/.config/nvim/init.lua"
|
||||||
|
|
||||||
# Dev #
|
# Dev #
|
||||||
alias gpp='g++ -std=c++2b' # Set the default C++ standard to C++20
|
alias gpp='g++ -std=c++2b' # Set the default C++ standard to C++20
|
||||||
alias gcc='gcc -std=c99' # Set the default C standard to C99
|
alias gcc='gcc -std=c99' # Set the default C standard to C99
|
||||||
alias cl='clang -std=c99'
|
alias cl='clang -std=c99'
|
||||||
alias clpp='clang++ -std=c++2b'
|
alias clpp='clang++ -std=c++2b'
|
||||||
alias python=python3 # Set the default Python version to Python 3
|
alias python=python3 # Set the default Python version to Python 3
|
||||||
alias py=python # Alias for Python
|
alias py=python
|
||||||
alias pip=pip3 # Alias for pip
|
alias ipy=ipython
|
||||||
# alias bashcfg="nvim ~/.bashrc"
|
|
||||||
alias zshcfg="nvim $ZDOTDIR/.zshrc"
|
alias reload="source $ZDOTDIR/.zshrc"
|
||||||
alias shcfg=zshcfg
|
|
||||||
alias reload="source $ZDOTDIR/.zshrc"
|
|
||||||
alias nvimrc="nvim $XDG_CONFIG_HOME/nvim/"
|
|
||||||
alias pulldots="cd $DOTFILES && git pull"
|
|
||||||
|
|
||||||
# Editors #
|
|
||||||
alias v=nvim
|
|
||||||
alias c=code
|
|
||||||
alias sv="sudo vim -u ~/.dotfiles/common/vim.noxdg.vimrc"
|
|
||||||
alias sn="sudo nvim -u ~/.config/nvim/init.lua"
|
|
||||||
|
|
||||||
# lsd - modern ls
|
# lsd - modern ls
|
||||||
if command -v lsd > /dev/null; then
|
if command -v lsd > /dev/null; then
|
||||||
alias ls='lsd -A -I .DS_Store -I .git'
|
alias ls='lsd -A'
|
||||||
alias l='lsd -lah'
|
alias l='lsd -lah'
|
||||||
alias ll='lsd -l'
|
alias ll='lsd -l'
|
||||||
alias tree='lsd --tree -I .DS_Store -I .git -A'
|
alias tree='lsd --tree -A'
|
||||||
|
else
|
||||||
|
alias l='ls -lah'
|
||||||
|
alias ll='ls -l'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# fzf - Fuzzy Finder
|
|
||||||
# export FZF_DEFAULT_OPTS_FILE=~/.dotfiles/common/fzfrc
|
|
||||||
|
|
||||||
# Functions #
|
# Functions #
|
||||||
mkcd() {
|
mkcd() {
|
||||||
|
|
@ -54,21 +54,6 @@ tv(){
|
||||||
touch $1 && nvim $1
|
touch $1 && nvim $1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Use neovide as gVim
|
|
||||||
gvi() {
|
|
||||||
local target=$1
|
|
||||||
|
|
||||||
if command -v neovide.exe > /dev/null; then
|
|
||||||
neovide.exe "$target"
|
|
||||||
else
|
|
||||||
if command -v neovide > /dev/null; then
|
|
||||||
neovide "$target"
|
|
||||||
else
|
|
||||||
echo "neovide is not installed"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
alias update="source $DOTFILES/scripts/update.zsh"
|
alias update="source $DOTFILES/scripts/update.zsh"
|
||||||
|
|
||||||
|
|
@ -93,7 +78,21 @@ if command -v brew > /dev/null; then
|
||||||
alias brewr="brew uninstall"
|
alias brewr="brew uninstall"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# `-s` suffix alias
|
||||||
|
# % readme.md -> glow readme.md
|
||||||
|
alias -s {md,markdown}=glow
|
||||||
alias -s {htm,html,css,scss,js,jsx,ts,tsx,json,jsonc}=code
|
alias -s {htm,html,css,scss,js,jsx,ts,tsx,json,jsonc}=code
|
||||||
alias -s {md,markdown}=code
|
alias -s {py,rb,pl,php,java,c,cpp,h,hpp}=nvim
|
||||||
alias -s {py,sh,rb,pl,php,java,c,cpp,h,hpp}=nvim
|
|
||||||
alias -s {cs,csx,fs,fsx,razor}=code
|
alias -s {cs,csx,fs,fsx,razor}=code
|
||||||
|
|
||||||
|
# TODO: Does not work
|
||||||
|
if [ "$TERM" = "xterm-ghostty" ] || [ "$TERM" = "xterm-kitty" ]; then
|
||||||
|
alias icat="kitten icat"
|
||||||
|
elif [ "$TERM_PROGRAM" = "WezTerm" ]; then
|
||||||
|
if [ -n "$WSL_DISTRO_NAME" ]; then
|
||||||
|
alias icat="wezterm.exe imgcat"
|
||||||
|
else
|
||||||
|
alias icat="wezterm imgcat"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
|
||||||
|
|
@ -20,14 +20,18 @@ plugins=(
|
||||||
"zsh-autosuggestions"
|
"zsh-autosuggestions"
|
||||||
"zsh-syntax-highlighting"
|
"zsh-syntax-highlighting"
|
||||||
"zsh-history-substring-search"
|
"zsh-history-substring-search"
|
||||||
|
"zsh-completions"
|
||||||
)
|
)
|
||||||
|
|
||||||
plugin_dir="$ZDOTDIR/plugins"
|
plugin_dir="$ZDOTDIR/plugins"
|
||||||
|
|
||||||
for plugin in "${plugins[@]}"; do
|
for plugin in "${plugins[@]}"; do
|
||||||
plugin_path="$plugin_dir/$plugin/$plugin.zsh"
|
plugin_path="$plugin_dir/$plugin/$plugin.zsh"
|
||||||
|
plugin_path_alt="$plugin_dir/$plugin/$plugin.plugin.zsh"
|
||||||
if [[ -f $plugin_path ]]; then
|
if [[ -f $plugin_path ]]; then
|
||||||
source "$plugin_path"
|
source "$plugin_path"
|
||||||
|
elif [[ -f $plugin_path_alt ]]; then
|
||||||
|
source "$plugin_path_alt"
|
||||||
else
|
else
|
||||||
echo "Warning: Plugin not found: $plugin_path"
|
echo "Warning: Plugin not found: $plugin_path"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,9 @@
|
||||||
# Sourced by user's zshrc 在用户的 zshrc 中被引用
|
# Sourced by user's zshrc 在用户的 zshrc 中被引用
|
||||||
|
|
||||||
|
|
||||||
|
# read key: `fish_key_reader`
|
||||||
|
# get current bindings: `bindkey`
|
||||||
|
|
||||||
bindkey -v # Vi Keybindings
|
bindkey -v # Vi Keybindings
|
||||||
|
|
||||||
# Colemak hnei
|
# Colemak hnei
|
||||||
|
|
@ -38,6 +41,8 @@ bindkey '^P' up-line-or-history
|
||||||
bindkey '^N' down-line-or-history
|
bindkey '^N' down-line-or-history
|
||||||
bindkey '^R' history-incremental-search-backward
|
bindkey '^R' history-incremental-search-backward
|
||||||
bindkey '^K' kill-line
|
bindkey '^K' kill-line
|
||||||
|
# Zsh will parse <C-Backspace> to C-h
|
||||||
|
bindkey '^H' backward-kill-word
|
||||||
|
|
||||||
# LEADER CONVENTION
|
# LEADER CONVENTION
|
||||||
# ^X defines as a prefix key in shell
|
# ^X defines as a prefix key in shell
|
||||||
|
|
|
||||||
|
|
@ -3,19 +3,7 @@
|
||||||
# Author: js0ny
|
# Author: js0ny
|
||||||
# Sourced by user's zshrc 在用户的 zshrc 中被引用
|
# Sourced by user's zshrc 在用户的 zshrc 中被引用
|
||||||
|
|
||||||
# Relative navigation #
|
|
||||||
alias ..="cd .."
|
|
||||||
alias ...="cd ../.."
|
|
||||||
alias ....="cd ../../.."
|
|
||||||
alias .....="cd ../../../.."
|
|
||||||
alias ......="cd ../../../../.."
|
|
||||||
|
|
||||||
# Use `-` to jump to the previous directory
|
|
||||||
# Oh-My-Zsh defines a similar one
|
|
||||||
function - { cd - }
|
|
||||||
|
|
||||||
# Use `z` to jump to a directory
|
|
||||||
eval "$(zoxide init zsh)"
|
|
||||||
|
|
||||||
# Absolute navigation #
|
# Absolute navigation #
|
||||||
alias dotfiles="cd $DOTFILES && ls"
|
alias dotfiles="cd $DOTFILES && ls"
|
||||||
|
|
@ -37,5 +25,29 @@ fi
|
||||||
# macOS specific, no OneDrive & Google Drive on Linux
|
# macOS specific, no OneDrive & Google Drive on Linux
|
||||||
if [ "$(uname)" = "Darwin" ]; then
|
if [ "$(uname)" = "Darwin" ]; then
|
||||||
alias one="cd $HOME/OneDrive"
|
alias one="cd $HOME/OneDrive"
|
||||||
alias gdrive="cd $HOME/Google\ Drive"
|
alias gdrive="cd $HOME/Google Drive"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if command -v zoxide > /dev/null ; then
|
||||||
|
eval "$(zoxide init zsh)"
|
||||||
|
# Relative navigation #
|
||||||
|
alias ..="z .."
|
||||||
|
alias ...="z ../.."
|
||||||
|
alias ....="z ../../.."
|
||||||
|
alias .....="z ../../../.."
|
||||||
|
alias ......="z ../../../../.."
|
||||||
|
# Use `-` to jump to the previous directory
|
||||||
|
# Oh-My-Zsh defines a similar one
|
||||||
|
alias - "z -"
|
||||||
|
zls(){
|
||||||
|
cd $1 && ls
|
||||||
|
}
|
||||||
|
else
|
||||||
|
alias ..="cd .."
|
||||||
|
alias ...="cd ../.."
|
||||||
|
alias ....="cd ../../.."
|
||||||
|
alias .....="cd ../../../.."
|
||||||
|
alias ......="cd ../../../../.."
|
||||||
|
alias - "cd -"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
1
tools/zsh/zprofile
Normal file
1
tools/zsh/zprofile
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
export FZF_DEFAULT_OPTS_FILE="$DOTFILES/common/fzfrc"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue