Merge pull request 'feat(shell): add poke, _fish_mkdir_p utility, and update fish-deps for ov/yay' (#28) from feat/poke-and-fish-deps-ov-yay into main
Reviewed-on: #28
This commit was merged in pull request #28.
This commit is contained in:
@@ -241,7 +241,7 @@ These functions wrap modern alternatives with graceful fallbacks to standard too
|
||||
| `rg` | `rg` | ripgrep with `--hyperlink-format=kitty` |
|
||||
| `ssh` | `ssh` | `kitten ssh` when inside Kitty |
|
||||
| `du` | `du` | `duf` (disks) / `dust` (directories) — auto-detected by argument |
|
||||
| `mkdir` | `mkdir` | Always passes `-p` in interactive mode |
|
||||
| `mkdir` | `mkdir` | Always passes `-p` in interactive mode; reports created directories as `Created directory: ~/path/` (falls back silently when flags like `-m` are present) |
|
||||
| `copy` | `cp` | Strips trailing `/` from a source directory before `cp -r`; falls through to `cp` for all other cases |
|
||||
|
||||
#### `du` — Smart Disk Usage
|
||||
@@ -270,7 +270,8 @@ rm -f file.txt # Falls through to standard rm -f
|
||||
|
||||
| Function | Description |
|
||||
|---|---|
|
||||
| `mkcd <dir>` | Create directory (including missing parents) and `cd` into it |
|
||||
| `mkcd <dir> [-s]` | Create directory (including missing parents) and `cd` into it; shows a tree of newly-created dirs by default; `-s`/`--silent` suppresses the tree |
|
||||
| `poke <file>...` | `touch` with automatic parent directory creation; shows a tree of newly-created dirs |
|
||||
| `ls` | `eza` — long listing, all files, icons, color, hyperlinks |
|
||||
| `lss` | `eza` — size-sorted long listing with gradient color scale |
|
||||
| `lsr` | `eza` — reversed time-sorted oneline listing |
|
||||
|
||||
+17
-30
@@ -11,16 +11,12 @@ if test -f /usr/share/cachyos-fish-config/cachyos-config.fish
|
||||
# Source our tricks over the cachyOS config
|
||||
test -f "$__fish_config_dir/conf.d/tricks.fish"
|
||||
and source "$__fish_config_dir/conf.d/tricks.fish"
|
||||
# CachyOS defines aliases for ls/lt/cleanup that shadow our function files.
|
||||
# Erase them and immediately source our versions.
|
||||
for _fname in ls lt cleanup
|
||||
# Erase CachyOS aliases/functions that shadow our versions, then
|
||||
# re-source our versions since functions --erase removes autoload entries.
|
||||
for _fname in ls lt cleanup copy
|
||||
functions --erase $_fname
|
||||
source "$__fish_config_dir/functions/$_fname.fish"
|
||||
end
|
||||
# CachyOS defines a broken copy command.
|
||||
# Override it with our working function.
|
||||
test -f "$__fish_config_dir/functions/copy.fish"
|
||||
and source "$__fish_config_dir/functions/copy.fish"
|
||||
end
|
||||
set --erase _fname
|
||||
|
||||
@@ -50,7 +46,6 @@ set -gx NVIDIA_SETTINGS_RW_CONFIG_FILE "$XDG_CONFIG_HOME/nvidia/settings"
|
||||
set -gx CODEIUM_HOME "$XDG_CONFIG_HOME/codeium"
|
||||
set -gx WORDLIST "$XDG_CONFIG_HOME/hunspell_en_US"
|
||||
|
||||
# ───────────────────── Misc Configuration variables ─────────────────────
|
||||
# ─────────────────────────── Pager variables ────────────────────────────
|
||||
if type -q ov
|
||||
set -gx PAGER ov
|
||||
@@ -133,7 +128,7 @@ if not type -q fisher
|
||||
set --erase _fisher_reply
|
||||
end
|
||||
|
||||
# ─────────────────────── visual/interactive setup ───────────────────────
|
||||
# ─────────────────────── Visual/Interactive setup ───────────────────────
|
||||
# Run only if we're in an interactive session (not a script or non-interactive shell)
|
||||
if status is-interactive
|
||||
# ────────────────────────────── Key bindings ────────────────────────────
|
||||
@@ -173,8 +168,8 @@ if status is-interactive
|
||||
set -gx CLAUDE_CODE_NO_FLICKER 1
|
||||
|
||||
# ╭────────────────────────────── OVERRIDES ─────────────────────────────╮
|
||||
# | Run these last so they can override any previous settings. |
|
||||
# | This is useful for machine-specific behavior or configurations. |
|
||||
# │ Run these last so they can override any previous settings. │
|
||||
# │ This is useful for machine-specific behavior or configurations. │
|
||||
# ╰────────────────────────────── OVERRIDES ─────────────────────────────╯
|
||||
#
|
||||
# Define user-dots path variable for a more legible secrets/local config.
|
||||
@@ -196,26 +191,18 @@ if status is-interactive
|
||||
test -f "$dot_fish/local.fish"; and source "$dot_fish/local.fish"
|
||||
#
|
||||
# ╭──────────────────────────── END OVERRIDES ──────────────────────────╮
|
||||
# | End of override section. |
|
||||
# │ End of override section. │
|
||||
# ╰──────────────────────────── END OVERRIDES ──────────────────────────╯
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────────────
|
||||
# Tools like starship, zoxide, etc. append init lines below this point via their
|
||||
# setup commands. We manage all integrations through conf.d/ instead, so we
|
||||
# return here to prevent injected lines from conflicting with that setup.
|
||||
#
|
||||
# This catches injections within the interactive block and
|
||||
# prevents them from conflicting with our conf.d/ setup.
|
||||
return # <-- Do not remove this line.
|
||||
# ─────────────────────────────────────────────────────────────────────────
|
||||
end
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# Tools like starship, zoxide, etc. append init lines below this point via their
|
||||
# setup commands. We manage all integrations through conf.d/ instead, so we
|
||||
# return here to prevent injected lines from conflicting with that setup.
|
||||
#
|
||||
# This catches injections outside the interactive block and
|
||||
# prevents them from conflicting with our conf.d/ setup.
|
||||
return # <-- Do not remove this line.
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# ╭──────────────────────────────── !!!NOTE!!! ───────────────────────────────╮
|
||||
# │ Tools like starship, zoxide, etc. append init lines below this point │
|
||||
# │ via their setup commands. We manage these integrations through │
|
||||
# │ conf.d/ instead, so we return here to prevent duplicate or conflicting │
|
||||
# │ inits from being executed. │
|
||||
# │ │
|
||||
# │ If a tool's shell integration appears to do nothing, │
|
||||
# │ check whether its setup command appended an init line here, │
|
||||
# │ then create a conf.d/<tool>.fish instead and place the init in that file. │
|
||||
# ╰───────────────────────────────────────────────────────────────────────────╯
|
||||
|
||||
@@ -16,27 +16,27 @@
|
||||
# uv and cargo are listed first so both are available before fish and other Rust tools.
|
||||
function _fish_deps_catalog
|
||||
set -g _fdc_bins \
|
||||
uv cargo fish fisher starship fzf zoxide direnv paru \
|
||||
uv cargo fish fisher starship fzf zoxide direnv paru yay \
|
||||
wakatime tailscale \
|
||||
eza lsd bat btop dust duf prettyping most rg lazygit lazydocker trash kitty wezterm
|
||||
eza lsd bat btop dust duf prettyping ov rg lazygit lazydocker trash kitty wezterm
|
||||
|
||||
set -g _fdc_tiers \
|
||||
req req req req req req req req rec \
|
||||
req req req req req req req req rec rec \
|
||||
int int \
|
||||
rec rec rec rec rec rec rec rec rec rec rec rec rec rec
|
||||
|
||||
set -g _fdc_cargo \
|
||||
"" "" "" "" starship "" zoxide "" "" \
|
||||
"" "" "" "" starship "" zoxide "" "" "" \
|
||||
"" "" \
|
||||
eza lsd bat "" du-dust "" "" "" ripgrep "" "" trashy "" ""
|
||||
eza lsd bat "" du-dust "" "" ov ripgrep "" "" trashy "" ""
|
||||
|
||||
set -g _fdc_pm \
|
||||
uv cargo fish "" starship fzf zoxide direnv "" \
|
||||
uv cargo fish "" starship fzf zoxide direnv "" yay \
|
||||
wakatime tailscale \
|
||||
eza lsd bat btop dust duf prettyping most ripgrep lazygit lazydocker trash kitty wezterm
|
||||
eza lsd bat btop dust duf prettyping ov ripgrep lazygit lazydocker trash kitty wezterm
|
||||
|
||||
set -g _fdc_special \
|
||||
curl-uv rustup-installer git-cargo-fish fisher-bootstrap curl-installer fzf-update "" "" paru-build \
|
||||
curl-uv rustup-installer git-cargo-fish fisher-bootstrap curl-installer fzf-update "" "" paru-build yay-build \
|
||||
wakatime-binary "" \
|
||||
"" "" "" "" "" "" "" "" "" "" curl-lazydocker "" "" ""
|
||||
end
|
||||
|
||||
@@ -100,6 +100,15 @@ function _fish_deps_install
|
||||
set -a methods special-paru
|
||||
set -a method_labels "build from AUR (makepkg)"
|
||||
end
|
||||
case yay-build
|
||||
if type -q paru
|
||||
set -a methods special-paru-yay
|
||||
set -a method_labels "paru -S yay"
|
||||
end
|
||||
if type -q pacman
|
||||
set -a methods special-yay
|
||||
set -a method_labels "build from AUR (makepkg)"
|
||||
end
|
||||
case pipx
|
||||
if type -q pipx
|
||||
set -a methods special-pipx
|
||||
@@ -202,6 +211,15 @@ function _fish_deps_install
|
||||
end
|
||||
case special-yay-paru
|
||||
yay -S --noconfirm paru
|
||||
case special-paru-yay
|
||||
paru -S --noconfirm yay
|
||||
case special-yay
|
||||
set -l _build_dir (mktemp -d)
|
||||
git clone https://aur.archlinux.org/yay.git $_build_dir
|
||||
and pushd $_build_dir
|
||||
and makepkg -si --noconfirm
|
||||
and popd
|
||||
rm -rf $_build_dir
|
||||
case special-paru
|
||||
set -l _build_dir (mktemp -d)
|
||||
git clone https://aur.archlinux.org/paru.git $_build_dir
|
||||
|
||||
@@ -28,6 +28,21 @@ function _fish_deps_update
|
||||
set -l pm_pkg $_fdc_pm[$i]
|
||||
set -l special $_fdc_special[$i]
|
||||
|
||||
# yay: update via paru if available, else system PM
|
||||
if test "$special" = yay-build
|
||||
if type -q paru
|
||||
echo "Updating $bin..."
|
||||
paru -S --noconfirm yay
|
||||
set updated_any 1
|
||||
else if test -n "$pm_pkg"; and test -n "$pm"
|
||||
echo "Updating $bin..."
|
||||
_fish_deps_pm_upgrade $pm_pkg
|
||||
set updated_any 1
|
||||
end
|
||||
set i (math $i + 1)
|
||||
continue
|
||||
end
|
||||
|
||||
# cargo: update via rustup
|
||||
if test "$special" = rustup-installer
|
||||
if type -q rustup
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
# Copyright (C) 2026 Rootiest
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
# mkdir -p with configurable output.
|
||||
#
|
||||
# Flags:
|
||||
# --path / -p (default) Print "Created: ~/full/path/" on one line
|
||||
# --tree / -t Tree view: dimmed existing anchor + cyan new dirs
|
||||
# --silent / -s No output
|
||||
#
|
||||
# Usage: _fish_mkdir_p [--path|--tree|--silent] <dir>
|
||||
function _fish_mkdir_p --description 'mkdir -p with configurable verbose output'
|
||||
set -l mode path
|
||||
set -l target
|
||||
|
||||
for _arg in $argv
|
||||
switch $_arg
|
||||
case -s --silent
|
||||
set mode silent
|
||||
case -t --tree
|
||||
set mode tree
|
||||
case -p --path
|
||||
set mode path
|
||||
case '*'
|
||||
set target $_arg
|
||||
end
|
||||
end
|
||||
|
||||
test -n "$target"; or return 1
|
||||
test -d "$target"; and return 0
|
||||
|
||||
# Walk up to find deepest existing ancestor; collect dirs to create (shallowest first).
|
||||
set -l to_create
|
||||
set -l cursor $target
|
||||
while not test -d $cursor
|
||||
set -p to_create $cursor
|
||||
set -l up (dirname $cursor)
|
||||
test "$up" = "$cursor"; and break # filesystem root guard
|
||||
set cursor $up
|
||||
end
|
||||
|
||||
mkdir -p $target; or return $status
|
||||
test $mode = silent; and return 0
|
||||
|
||||
if test $mode = path
|
||||
set -l display (string replace -- "$HOME" "~" $target)"/"
|
||||
echo (set_color --bold cyan)"Created directory: "(set_color cyan)"$display"(set_color normal)
|
||||
return 0
|
||||
end
|
||||
|
||||
# Tree mode: dimmed existing anchor, then cyan new dirs.
|
||||
echo (set_color --bold yellow)"Created directories:"(set_color normal)
|
||||
set -l anchor (string replace -- "$HOME" "~" $cursor)"/"
|
||||
echo (set_color brblack)" $anchor"(set_color normal)
|
||||
set -l i 1
|
||||
while test $i -le (count $to_create)
|
||||
set -l spaces (string repeat -n (math "($i - 1) * 4") " ")
|
||||
set -l name (basename $to_create[$i])"/"
|
||||
echo (set_color cyan)" $spaces└── $name"(set_color normal)
|
||||
set i (math $i + 1)
|
||||
end
|
||||
end
|
||||
+16
-5
@@ -22,6 +22,7 @@ function mkcd --description 'Create a directory (with parents) and cd into it'
|
||||
echo
|
||||
echo "$c_head""Flags:$c_rst"
|
||||
echo " $c_flag-h$c_rst, $c_flag--help$c_rst Show this help message"
|
||||
echo " $c_flag-s$c_rst, $c_flag--silent$c_rst Suppress directory creation output"
|
||||
echo
|
||||
echo "$c_head""Examples:$c_rst"
|
||||
echo " $c_cmd""mkcd$c_rst $c_arg~/projects/myapp$c_rst"
|
||||
@@ -29,13 +30,23 @@ function mkcd --description 'Create a directory (with parents) and cd into it'
|
||||
return 0
|
||||
end
|
||||
|
||||
set -l dir $argv[1]
|
||||
set -l silent 0
|
||||
set -l dir
|
||||
for _arg in $argv
|
||||
switch $_arg
|
||||
case -s --silent
|
||||
set silent 1
|
||||
case '*'
|
||||
set dir $_arg
|
||||
end
|
||||
end
|
||||
|
||||
set -l is_new 0
|
||||
if not test -d $dir
|
||||
set is_new 1
|
||||
command mkdir -p $dir
|
||||
or return $status
|
||||
test -d $dir; or set is_new 1
|
||||
if test $silent -eq 1
|
||||
_fish_mkdir_p --silent $dir; or return $status
|
||||
else
|
||||
_fish_mkdir_p --tree $dir; or return $status
|
||||
end
|
||||
|
||||
cd $dir
|
||||
|
||||
+10
-1
@@ -4,7 +4,16 @@
|
||||
# Execute mkdir
|
||||
function mkdir --description 'Execute mkdir'
|
||||
if status is-interactive
|
||||
command mkdir -p $argv
|
||||
# Fall back to command mkdir -p when flags are present (e.g. -m 755)
|
||||
for _arg in $argv
|
||||
if string match -q -- '-*' $_arg
|
||||
command mkdir -p $argv
|
||||
return $status
|
||||
end
|
||||
end
|
||||
for _dir in $argv
|
||||
_fish_mkdir_p --path $_dir
|
||||
end
|
||||
else
|
||||
command mkdir $argv
|
||||
end
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# Copyright (C) 2026 Rootiest
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
function poke --description 'touch with automatic parent directory creation'
|
||||
if test (count $argv) -eq 0
|
||||
echo (set_color red)"poke: no file specified"(set_color normal) >&2
|
||||
return 1
|
||||
end
|
||||
for _path in $argv
|
||||
set -l _dir (dirname $_path)
|
||||
_fish_mkdir_p --tree $_dir
|
||||
touch $_path
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user