From 2346c135648f56604801433cf3d4d5d786ed075b Mon Sep 17 00:00:00 2001 From: js0ny Date: Tue, 28 Jan 2025 14:26:25 +0000 Subject: [PATCH] feat(shell): Use one keymaps for shell --- tools/bash/bashrc | 0 tools/bash/profile | 170 ++++++++++++++++++++++ tools/bash/xdg-compat.sh | 19 +++ tools/browser/surfingkeys.js | 236 +++++++++++++------------------ tools/fish/conf.d/0init.fish | 14 +- tools/fish/conf.d/alias.fish | 32 +++-- tools/fish/conf.d/keymap.fish | 49 ++++++- tools/fish/conf.d/navi.fish | 27 +++- tools/powershell/Aliases.ps1 | 26 ++-- tools/powershell/Config.ps1 | 8 -- tools/powershell/Environment.ps1 | 3 + tools/powershell/Keymap.ps1 | 16 ++- tools/powershell/Navigation.ps1 | 32 +++-- tools/powershell/Prompt.ps1 | 48 +++---- tools/zsh/mod/alias.zsh | 67 +++++---- tools/zsh/mod/config.zsh | 4 + tools/zsh/mod/keymap.zsh | 5 + tools/zsh/mod/navi.zsh | 38 +++-- tools/zsh/zprofile | 1 + 19 files changed, 530 insertions(+), 265 deletions(-) create mode 100644 tools/bash/bashrc create mode 100644 tools/bash/profile create mode 100644 tools/bash/xdg-compat.sh delete mode 100644 tools/powershell/Config.ps1 create mode 100644 tools/zsh/zprofile diff --git a/tools/bash/bashrc b/tools/bash/bashrc new file mode 100644 index 0000000..e69de29 diff --git a/tools/bash/profile b/tools/bash/profile new file mode 100644 index 0000000..66b160c --- /dev/null +++ b/tools/bash/profile @@ -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" diff --git a/tools/bash/xdg-compat.sh b/tools/bash/xdg-compat.sh new file mode 100644 index 0000000..0285454 --- /dev/null +++ b/tools/bash/xdg-compat.sh @@ -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 diff --git a/tools/browser/surfingkeys.js b/tools/browser/surfingkeys.js index 3574db4..f3f7759 100644 --- a/tools/browser/surfingkeys.js +++ b/tools/browser/surfingkeys.js @@ -26,6 +26,7 @@ settings.showModeStatus = false; // #endregion // #region Helper +// import the API so that no need to use `api` prefix const { aceVimMap, addVimMapKey, @@ -109,20 +110,20 @@ const vColemak = { const forwardFactory = { push: function (mapLists) { // forward original keys - for (let key in mapLists) { + for (const key in mapLists) { // `const` better than `let` forward.add(mapLists[key]); } }, map: function (mapLists) { - for (let key in mapLists) { + for (const key in mapLists) { colemak.map(key, mapLists[key]); } }, pull: function (mapLists) { - for (let key in mapLists) { + for (const key in mapLists) { forward.cancel(mapLists[key]); } - for (let key in mapLists) { + for (const key in mapLists) { colemak.forward(key); } }, @@ -130,25 +131,25 @@ const forwardFactory = { const vForwardFactory = { push: function (mapLists) { // forward original keys - for (let key in mapLists) { + for (const key in mapLists) { vForward.add(mapLists[key]); } }, map: function (mapLists) { - for (let key in mapLists) { + for (const key in mapLists) { vColemak.map(key, mapLists[key]); } }, pull: function (mapLists) { - for (let key in mapLists) { + for (const key in mapLists) { vForward.cancel(mapLists[key]); } - for (let key in mapLists) { + for (const key in mapLists) { vColemak.forward(key); } }, }; - +// TODO: Add more search completion source (with json) const parseSearchResponse = function (response) { const res = JSON.parse(response.text); return res.map((r) => r.phrase); @@ -171,20 +172,13 @@ const _addSearchAlias = function ( parseResponse, ); }; - -var q = (selector) => document.querySelector(selector); -var qs = (selector) => document.querySelectorAll(selector); - -var mapkeyFeed = function (key, desc, target, options) { - mapkey(key, desc, function () { - api.Normal.feedkeys(target) - }); -} - - +// Shortcut for querySelector +const q = (selector) => document.querySelector(selector); +const qs = (selector) => document.querySelectorAll(selector); // #endregion // #region Keymap +// Normal Mode Keymap const mapLists = { /// scroll page // Arrow @@ -212,6 +206,7 @@ const mapLists = { // gh/gi -> Prev/Next History gh: "S", gi: "D", + gl: "gi", // Focus on first input box // t -> Open Link in New Tab t: "gf", // 缩放 @@ -219,7 +214,7 @@ const mapLists = { zo: "ze", zz: "zr", }; - +// Visual Mode Keymap const vMapLists = { n: "j", N: "J", @@ -238,23 +233,20 @@ forwardFactory.map(mapLists); vForwardFactory.push(vMapLists); vForwardFactory.map(vMapLists); -// 鼠标点击 -api.unmap("gi"); -api.unmap("[["); -api.unmap("]]"); -api.unmap(";m"); -api.unmap(";fs"); -api.unmap("O"); -api.unmap("C"); + +// All other unmapped keys should be defined here +// TODO: Add more mouse click keymap +api.unmap("gi"); // conflict with `gi` in `mapLists` +api.unmap("C"); // Use `F` instead (Open Link in New Tab) api.map("g/", "gU"); // Goto Root Domain -// p to site-specific -api.unmap("p"); +// TODO: Add SPC keymap as leader (maybe change `,` to `SPC`) api.unmap(""); // Leader Key + forwardFactory.pull(mapLists); vForwardFactory.pull(vMapLists); // #endregion -// #region Omnibar +// #region Omnibar NOTE: Dosn't work // api.cmap("", ""); // api.cmap("", ""); // api.cmap("", ""); @@ -266,86 +258,60 @@ vForwardFactory.pull(vMapLists); // #endregion // #region Search Alias -removeSearchAlias("s"); // StackOverflow -removeSearchAlias("d"); // DuckDuckGo -removeSearchAlias("g"); // Google -removeSearchAlias("b"); // Baidu -removeSearchAlias("w"); // Bing -removeSearchAlias("y"); // YouTube -/// 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="); -_addSearchAlias( - "wk", - "Wikipedia", - "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="); +const removedSearchAlias = [ + "b", // Baidu + "d", // DuckDuckGo + "e", // Wikipedia + "g", // Google + "s", // StackOverflow + "w", // Bing + "y", // YouTube +]; +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 // #region Site-specific @@ -385,7 +351,7 @@ mapkey(",r", "Regenerate last output", function () { btn[btn.length - 3].click(); }, { domain: /chat.deepseek.com/ }); mapkey(",n", "New Chat", function () { - window.location.href = 'https://chat.deepseek.com/'; + window.location.href = "https://chat.deepseek.com/"; }, { domain: /chat.deepseek.com/ }); mapkey(",t", "Toggle Thinking (R1)", function () { var btns = qs("div.ds-button"); @@ -399,31 +365,32 @@ mapkey(",w", "Toggle Web Search", function () { // #region app.follow.is mapkey(",t", "Toggle ", function () { - var btn = qs("button.no-drag-region") + var btn = qs("button.no-drag-region"); btn[btn.length - 4].click(); }, { domain: /app.follow.is/ }); 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(); }, { domain: /app.follow.is/ }); 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(); }, { domain: /app.follow.is/ }); // #endregion // #region GitHub // utils -const gh = {} +const gh = {}; gh.repoLink = (owner, repo) => `https://github.com/${owner}/${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) => { - const ps = url.split('/').slice(3) - return gh.sourceLink(ps[0], ps[1], ps.slice(4).join('/')); -} + const ps = url.split("/").slice(3); + return gh.sourceLink(ps[0], ps[1], ps.slice(4).join("/")); +}; // github.com mapkey(",e", "Use Web Editor", function () { 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 () { const url = new URL(window.location.href); 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); }, { domain: /raw.githubusercontent.com/ }); mapkey(",R", "Switch to GitHub Repo", function () { const url = new URL(window.location.href); var owner, repo; - owner, repo = url.pathname.split('/').slice(1, 3) + owner, repo = url.pathname.split("/").slice(1, 3); tabOpenLink(gh.repoLink(owner, repo)); }, { domain: /raw.githubusercontent.com/ }); 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 () { tabOpenLink(gh.rawToSource(window.location.href)); }, { domain: /raw.githubusercontent.com/ }); - - - // #endregion GitHub // #region perplexity.ai @@ -492,13 +456,13 @@ mapkey(",S", "Open Source in GitHub (New Page)", function () { * 3 - 写作 * 4 - 视频 * 5 - 社交 -*/ + */ const perplexityFocusOn = function (n) { - qs("span.grow button")[0].click() + qs("span.grow button")[0].click(); setTimeout(() => { // Wait for the DOM to update qs("div.shadow-subtle div.group\\/item")[n].click(); }, 100); -} +}; unmap("", /perplexity.ai/); // allows to use perplexity web keybindings mapkey(",b", "Add Perplexity Bookmark", function () { // button.border:nth-child(2) @@ -509,19 +473,19 @@ mapkey(",w", "Toggle Writing/Web Search", function () { perplexityFocusOn(3); }, { domain: /perplexity.ai/ }); mapkey(",s", "Start Generating", function () { - var btns = qs("span.grow button") + var btns = qs("span.grow button"); btns[btns.length - 1].click(); }, { domain: /perplexity.ai/ }); mapkey(",y", "Yank Last Output", function () { - var toolbars = qs("div.mt-sm") - var last = toolbars[toolbars.length - 1] - var btns = last.querySelectorAll("button") + var toolbars = qs("div.mt-sm"); + var last = toolbars[toolbars.length - 1]; + var btns = last.querySelectorAll("button"); btns[4].click(); }, { domain: /perplexity.ai/ }); mapkey(",r", "Change model to regenerate last output", function () { - var toolbars = qs("div.mt-sm") - var last = toolbars[toolbars.length - 1] - var btns = last.querySelectorAll("button") + var toolbars = qs("div.mt-sm"); + var last = toolbars[toolbars.length - 1]; + var btns = last.querySelectorAll("button"); btns[1].click(); }, { domain: /perplexity.ai/ }); // #endregion @@ -543,7 +507,6 @@ addVimMapKey( motion: "findNext", motionArgs: { forward: false, toJumplist: true }, }, - // Word movement { keys: "j", @@ -562,7 +525,6 @@ addVimMapKey( inclusive: true, }, }, - // Insert mode entries { keys: "l", @@ -642,5 +604,5 @@ addVimMapKey( // #endregion // #region Hints -api.Hints.setCharacters('qwfpgarstdcv') +api.Hints.setCharacters("qwfpgarstdcv"); // Left-hand keys // #endregion diff --git a/tools/fish/conf.d/0init.fish b/tools/fish/conf.d/0init.fish index 1b7a47f..3d63614 100644 --- a/tools/fish/conf.d/0init.fish +++ b/tools/fish/conf.d/0init.fish @@ -23,14 +23,16 @@ set -gx EDITOR nvim set -gx VISUAL nvim # Minimal PATH for early commands -set -gx PATH /usr/local/bin /usr/bin /bin /usr/sbin /sbin ~/.local/bin $PATH - -if test -d /opt/homebrew/bin # macOS - set -gx PATH /opt/homebrew/bin $PATH -else if test -d /home/linuxbrew/.linuxbrew/bin # Linux - set -gx PATH /home/linuxbrew/.linuxbrew/bin $PATH +for dir in /usr/local/bin /usr/bin /bin /usr/sbin /sbin "$HOME/.local/bin" + if test -d "$dir" -a ! -L "$dir" + fish_add_path "$dir" + 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 set -gx HOMEBREW_NO_ENV_HINTS end diff --git a/tools/fish/conf.d/alias.fish b/tools/fish/conf.d/alias.fish index a279315..7971b2e 100644 --- a/tools/fish/conf.d/alias.fish +++ b/tools/fish/conf.d/alias.fish @@ -21,12 +21,10 @@ alias sn="sudo nvim -u ~/.config/nvim/init.lua" # Dev # abbr --add py python3 abbr --add ipy ipython -abbr --add reload "source $__fish_config_dir/config.fish" -abbr --add pulldots "cd $DOTFILES && git pull" # lsd - modern ls 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 ll 'lsd -l' abbr --add tree 'ls --tree' @@ -48,14 +46,9 @@ end function tv touch $argv[1] && nvim $argv[1] end -function zls - z $argv[1] && ls -end # Use neovide as gVim -if command -v neovide > /dev/null - abbr --add gvi "neovide" -end +abbr --add gvi "neovide" if command -v brew > /dev/null abbr --add brewi "brew install" @@ -69,11 +62,28 @@ if command -v pacman > /dev/null abbr --add paci "sudo pacman -S" abbr --add pacr "sudo pacman -R" 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 if test "$TERM" = "xterm-ghostty" -o "$TERM" = "xterm-kitty" abbr --add icat "kitten icat" 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 + +# 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 diff --git a/tools/fish/conf.d/keymap.fish b/tools/fish/conf.d/keymap.fish index 3a9c09e..399115c 100644 --- a/tools/fish/conf.d/keymap.fish +++ b/tools/fish/conf.d/keymap.fish @@ -8,6 +8,9 @@ # ln -sf $DOTFILES/tools/fish ~/.config/fish +# read key: `fish_key_reader` +# get current bindings: `bind` + fish_vi_key_bindings # Colemak hnei @@ -17,12 +20,52 @@ fish_vi_key_bindings # n # v # bind -M default 'h' backward-char -bind -M default 'n' down-or-search -bind -M default 'e' up-or-search -bind -M default 'i' forward-char +bind -M default n down-or-search +bind -M default e up-or-search +bind -M default i forward-char # Similar position to [i] in QWERTY bind -M default -m insert l 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 +# C-r : fzf history search +# C-t : fzf file search +# A-c : fzf directory search diff --git a/tools/fish/conf.d/navi.fish b/tools/fish/conf.d/navi.fish index e247aa7..e5898b6 100644 --- a/tools/fish/conf.d/navi.fish +++ b/tools/fish/conf.d/navi.fish @@ -8,14 +8,27 @@ # 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 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 diff --git a/tools/powershell/Aliases.ps1 b/tools/powershell/Aliases.ps1 index 367eced..b919191 100644 --- a/tools/powershell/Aliases.ps1 +++ b/tools/powershell/Aliases.ps1 @@ -2,27 +2,28 @@ # Date: 2024-12-01 # Author: js0ny # Aliases for PowerShell -### VARIABLES ### -$EDITOR = "code" -# Shell Equivalents # + +# Unix Shell Equivalents # Set-Alias "touch" "New-Item" ${function:l} = { Get-ChildItem -Force } -${function:tree} = { lsd.exe --tree $args } +${function:tree} = { lsd --tree $args } Set-Alias "which" "Get-Command" -# Shell Configurations # -${function:pulldots} = { Set-Location -Path $DOTFILES && git pull } - # Editors # Set-Alias "v" "nvim" Set-Alias "c" "code" -Set-Alias "gvi" "neovide" +Get-Command neovide -ErrorAction SilentlyContinue > $null && Set-Alias "gvi" "neovide" + + # File Creation # 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 tv { param ( [string] $filename) New-Item $filename && nvim $filename } 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 ### @@ -30,7 +31,10 @@ function cdls { param( [string] $dirname) Set-Location $dirname && Get-ChildItem Set-Alias "py" "python" Set-Alias "ipy" "ipython" -if ($isWindows) { - # Debugging - # function kex { wsl -d kali-linux kex --sl -s } +if ($Env:WEZTERM) { + # Environment variable injected by wezterm/wezterm.lua + ${function:icat} = { wezterm imgcat $args } +} +elseif ($Env:KITTY) { + ${function:icat} = { kitty +kitten icat $args } } diff --git a/tools/powershell/Config.ps1 b/tools/powershell/Config.ps1 deleted file mode 100644 index 431131c..0000000 --- a/tools/powershell/Config.ps1 +++ /dev/null @@ -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 } -} diff --git a/tools/powershell/Environment.ps1 b/tools/powershell/Environment.ps1 index dad0a92..c7742f8 100644 --- a/tools/powershell/Environment.ps1 +++ b/tools/powershell/Environment.ps1 @@ -8,3 +8,6 @@ # interactive session. $env:IPYTHONDIR = "$env:AppData\ipython" +$env:EDITOR = "code --wait" +$env:VISUAL = "code --wait" +$env:PAGER = "less" diff --git a/tools/powershell/Keymap.ps1 b/tools/powershell/Keymap.ps1 index eddfc65..938f4d5 100644 --- a/tools/powershell/Keymap.ps1 +++ b/tools/powershell/Keymap.ps1 @@ -1,7 +1,11 @@ # aka PSReadLine + +# read key: [System.Console]::ReadKey() +# get current bindings: Get-PSReadLineKeyHandler + # PSReadLineOptions Set-PSReadLineOption -EditMode Vi # Vi Keybindings -Set-PSReadLineOption -PredictionViewStyle ListView +Set-PSReadLineOption -PredictionViewStyle InlineView Set-PSReadLineOption -PredictionSource HistoryAndPlugin # Set-PSReadLineOption -ContinuationPrompt "`e[36m CR > " # Use Starship instead # 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+e" -Function EndOfLine 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+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 to Invoke MenuComplete Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete diff --git a/tools/powershell/Navigation.ps1 b/tools/powershell/Navigation.ps1 index c5ad86e..463d482 100644 --- a/tools/powershell/Navigation.ps1 +++ b/tools/powershell/Navigation.ps1 @@ -1,14 +1,28 @@ # ${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 (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 (Join-Path -Path .. -ChildPath ..) -ChildPath ..) -ChildPath ..) -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 (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 ..) } # Absolute navigation -${function:docs} = { Set-Location -Path (Join-Path -Path $HOME -ChildPath "Documents") } -${function:down} = { Set-Location -Path (Join-Path -Path $HOME -ChildPath "Downloads") } -${function:dt} = { Set-Location -Path (Join-Path -Path $HOME -ChildPath "Desktop") } -${function:one} = { Set-Location -Path (Join-Path -Path $HOME -ChildPath "OneDrive") } +${function:docs} = { Set-Location -Path (Join-Path -Path $HOME -ChildPath "Documents") } +${function:down} = { Set-Location -Path (Join-Path -Path $HOME -ChildPath "Downloads") } +${function:dt} = { Set-Location -Path (Join-Path -Path $HOME -ChildPath "Desktop") } +${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 - } +} diff --git a/tools/powershell/Prompt.ps1 b/tools/powershell/Prompt.ps1 index d8dc647..105dacd 100644 --- a/tools/powershell/Prompt.ps1 +++ b/tools/powershell/Prompt.ps1 @@ -20,31 +20,31 @@ $PSStyle.Formatting.Verbose = $Flavor.Yellow.Foreground() $PSStyle.Formatting.Warning = $Flavor.Peach.Foreground() $Colors = @{ - # Largely based on the Code Editor style guide - # Emphasis, ListPrediction and ListPredictionSelected are inspired by the Catppuccin fzf theme - - # Powershell colours - Emphasis = $Flavor.Red.Foreground() - Selection = $Flavor.Surface0.Background() - - # PSReadLine prediction colours - InlinePrediction = $Flavor.Overlay0.Foreground() - ListPrediction = $Flavor.Mauve.Foreground() - ListPredictionSelected = $Flavor.Surface0.Background() + # Largely based on the Code Editor style guide + # Emphasis, ListPrediction and ListPredictionSelected are inspired by the Catppuccin fzf theme - # Syntax highlighting - Command = $Flavor.Blue.Foreground() - Comment = $Flavor.Overlay0.Foreground() - Default = $Flavor.Text.Foreground() - Error = $Flavor.Red.Foreground() - Keyword = $Flavor.Mauve.Foreground() - Member = $Flavor.Rosewater.Foreground() - Number = $Flavor.Peach.Foreground() - Operator = $Flavor.Sky.Foreground() - Parameter = $Flavor.Pink.Foreground() - String = $Flavor.Green.Foreground() - Type = $Flavor.Yellow.Foreground() - Variable = $Flavor.Lavender.Foreground() + # Powershell colours + Emphasis = $Flavor.Red.Foreground() + Selection = $Flavor.Surface0.Background() + + # PSReadLine prediction colours + InlinePrediction = $Flavor.Overlay0.Foreground() + ListPrediction = $Flavor.Mauve.Foreground() + ListPredictionSelected = $Flavor.Surface0.Background() + + # Syntax highlighting + Command = $Flavor.Blue.Foreground() + Comment = $Flavor.Overlay0.Foreground() + Default = $Flavor.Text.Foreground() + Error = $Flavor.Red.Foreground() + Keyword = $Flavor.Mauve.Foreground() + Member = $Flavor.Rosewater.Foreground() + Number = $Flavor.Peach.Foreground() + Operator = $Flavor.Sky.Foreground() + Parameter = $Flavor.Pink.Foreground() + String = $Flavor.Green.Foreground() + Type = $Flavor.Yellow.Foreground() + Variable = $Flavor.Lavender.Foreground() } # Set the colours diff --git a/tools/zsh/mod/alias.zsh b/tools/zsh/mod/alias.zsh index 25c12fc..76d268e 100644 --- a/tools/zsh/mod/alias.zsh +++ b/tools/zsh/mod/alias.zsh @@ -8,37 +8,37 @@ alias ni=touch alias cls=clear 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 # 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 cl='clang -std=c99' alias clpp='clang++ -std=c++2b' alias python=python3 # Set the default Python version to Python 3 -alias py=python # Alias for Python -alias pip=pip3 # Alias for pip -# alias bashcfg="nvim ~/.bashrc" -alias zshcfg="nvim $ZDOTDIR/.zshrc" -alias shcfg=zshcfg -alias reload="source $ZDOTDIR/.zshrc" -alias nvimrc="nvim $XDG_CONFIG_HOME/nvim/" -alias pulldots="cd $DOTFILES && git pull" +alias py=python +alias ipy=ipython + +alias reload="source $ZDOTDIR/.zshrc" -# 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 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 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 -# fzf - Fuzzy Finder -# export FZF_DEFAULT_OPTS_FILE=~/.dotfiles/common/fzfrc # Functions # mkcd() { @@ -54,21 +54,6 @@ tv(){ 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" @@ -93,7 +78,21 @@ if command -v brew > /dev/null; then alias brewr="brew uninstall" 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 {md,markdown}=code -alias -s {py,sh,rb,pl,php,java,c,cpp,h,hpp}=nvim +alias -s {py,rb,pl,php,java,c,cpp,h,hpp}=nvim 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 diff --git a/tools/zsh/mod/config.zsh b/tools/zsh/mod/config.zsh index c62f4b5..b2c1a8d 100644 --- a/tools/zsh/mod/config.zsh +++ b/tools/zsh/mod/config.zsh @@ -20,14 +20,18 @@ plugins=( "zsh-autosuggestions" "zsh-syntax-highlighting" "zsh-history-substring-search" + "zsh-completions" ) plugin_dir="$ZDOTDIR/plugins" for plugin in "${plugins[@]}"; do plugin_path="$plugin_dir/$plugin/$plugin.zsh" + plugin_path_alt="$plugin_dir/$plugin/$plugin.plugin.zsh" if [[ -f $plugin_path ]]; then source "$plugin_path" + elif [[ -f $plugin_path_alt ]]; then + source "$plugin_path_alt" else echo "Warning: Plugin not found: $plugin_path" fi diff --git a/tools/zsh/mod/keymap.zsh b/tools/zsh/mod/keymap.zsh index c0b6a80..527f61f 100644 --- a/tools/zsh/mod/keymap.zsh +++ b/tools/zsh/mod/keymap.zsh @@ -4,6 +4,9 @@ # Sourced by user's zshrc 在用户的 zshrc 中被引用 +# read key: `fish_key_reader` +# get current bindings: `bindkey` + bindkey -v # Vi Keybindings # Colemak hnei @@ -38,6 +41,8 @@ bindkey '^P' up-line-or-history bindkey '^N' down-line-or-history bindkey '^R' history-incremental-search-backward bindkey '^K' kill-line +# Zsh will parse to C-h +bindkey '^H' backward-kill-word # LEADER CONVENTION # ^X defines as a prefix key in shell diff --git a/tools/zsh/mod/navi.zsh b/tools/zsh/mod/navi.zsh index 86cf282..8272724 100644 --- a/tools/zsh/mod/navi.zsh +++ b/tools/zsh/mod/navi.zsh @@ -3,19 +3,7 @@ # Author: js0ny # 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 # alias dotfiles="cd $DOTFILES && ls" @@ -37,5 +25,29 @@ fi # macOS specific, no OneDrive & Google Drive on Linux if [ "$(uname)" = "Darwin" ]; then 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 diff --git a/tools/zsh/zprofile b/tools/zsh/zprofile new file mode 100644 index 0000000..3bfe9da --- /dev/null +++ b/tools/zsh/zprofile @@ -0,0 +1 @@ +export FZF_DEFAULT_OPTS_FILE="$DOTFILES/common/fzfrc"