feat(shell): add CachyOS-derived tricks.fish and copy utilities #22
@@ -49,6 +49,7 @@ This config layers on top of the CachyOS base Fish configuration and adds:
|
|||||||
│ ├── fzf.fish # FZF key binding initialization
|
│ ├── fzf.fish # FZF key binding initialization
|
||||||
│ ├── tailscale.fish # Tailscale CLI completions
|
│ ├── tailscale.fish # Tailscale CLI completions
|
||||||
│ ├── theme.fish # Theme syntax highlighting colors
|
│ ├── theme.fish # Theme syntax highlighting colors
|
||||||
|
│ ├── tricks.fish # PATH additions, bang-bang helpers, history/backup utilities
|
||||||
│ ├── wakatime.fish # WakaTime shell hook
|
│ ├── wakatime.fish # WakaTime shell hook
|
||||||
│ └── zoxide.fish # Zoxide z/zi aliases
|
│ └── zoxide.fish # Zoxide z/zi aliases
|
||||||
├── functions/ # Custom functions (one per file)
|
├── functions/ # Custom functions (one per file)
|
||||||
@@ -184,6 +185,7 @@ These functions wrap modern alternatives with graceful fallbacks to standard too
|
|||||||
| `ssh` | `ssh` | `kitten ssh` when inside Kitty |
|
| `ssh` | `ssh` | `kitten ssh` when inside Kitty |
|
||||||
| `du` | `du` | `duf` (disks) / `dust` (directories) — auto-detected by argument |
|
| `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 |
|
||||||
|
| `copy` | `cp` | Strips trailing `/` from a source directory before `cp -r`; falls through to `cp` for all other cases |
|
||||||
|
|
||||||
#### `du` — Smart Disk Usage
|
#### `du` — Smart Disk Usage
|
||||||
|
|
||||||
@@ -344,6 +346,7 @@ Install method priority: **git+cargo source build** (fish) → **cargo** (other
|
|||||||
| `ffetch` | Run fastfetch with `~/.fastfetch.jsonc` if present |
|
| `ffetch` | Run fastfetch with `~/.fastfetch.jsonc` if present |
|
||||||
| `cffetch` | Clear screen then run fastfetch |
|
| `cffetch` | Clear screen then run fastfetch |
|
||||||
| `hist` | FZF history search — selected command is placed in the prompt and copied to clipboard |
|
| `hist` | FZF history search — selected command is placed in the prompt and copied to clipboard |
|
||||||
|
| `history` | Built-in `history` override — prepends `YYYY-MM-DD HH:MM:SS` timestamps to every entry |
|
||||||
| `qr <text>` | Generate a terminal QR code |
|
| `qr <text>` | Generate a terminal QR code |
|
||||||
|
|
||||||
### Miscellaneous
|
### Miscellaneous
|
||||||
@@ -355,6 +358,7 @@ Install method priority: **git+cargo source build** (fish) → **cargo** (other
|
|||||||
| `scrub` | Recursively purge OS/editor/compiler garbage from CWD; `-a` aggressive mode adds logs, `node_modules`, IDE dirs; `-d` dry-run preview; requires `fd` |
|
| `scrub` | Recursively purge OS/editor/compiler garbage from CWD; `-a` aggressive mode adds logs, `node_modules`, IDE dirs; `-d` dry-run preview; requires `fd` |
|
||||||
| `antigravity` | Wrapper for `agy` (antigravity-cli) that suppresses a noisy warning |
|
| `antigravity` | Wrapper for `agy` (antigravity-cli) that suppresses a noisy warning |
|
||||||
| `antigravity-ide` | Wrapper for `antigravity-ide` binary that suppresses a noisy warning |
|
| `antigravity-ide` | Wrapper for `antigravity-ide` binary that suppresses a noisy warning |
|
||||||
|
| `backup <file>` | Copy `<file>` to `<file>.bak` |
|
||||||
| `bash` | Drop into bash (raw Fish session via `rawfish`) |
|
| `bash` | Drop into bash (raw Fish session via `rawfish`) |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
# Copyright (C) 2026 Rootiest
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
# ────── Borrowed and modified from CachyOS config ─────────
|
||||||
|
# ╭──────────────────────────────────────────────────────────╮
|
||||||
|
# │ Provides PATH additions, bang-bang helpers, │
|
||||||
|
# │ and history/backup utilities │
|
||||||
|
# ╰──────────────────────────────────────────────────────────╯
|
||||||
|
## Environment setup
|
||||||
|
# Apply .profile: use this to put fish compatible .profile stuff in
|
||||||
|
if test -f ~/.fish_profile
|
||||||
|
source ~/.fish_profile
|
||||||
|
end
|
||||||
|
|
||||||
|
# Add ~/.local/bin to PATH
|
||||||
|
if test -d ~/.local/bin
|
||||||
|
if not contains -- ~/.local/bin $PATH
|
||||||
|
set -p PATH ~/.local/bin
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Add depot_tools to PATH
|
||||||
|
if test -d ~/Applications/depot_tools
|
||||||
|
if not contains -- ~/Applications/depot_tools $PATH
|
||||||
|
set -p PATH ~/Applications/depot_tools
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
# Functions needed for !! and !$ https://github.com/oh-my-fish/plugin-bang-bang
|
||||||
|
function __history_previous_command
|
||||||
|
switch (commandline -t)
|
||||||
|
case "!"
|
||||||
|
commandline -t $history[1]
|
||||||
|
commandline -f repaint
|
||||||
|
case "*"
|
||||||
|
commandline -i !
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function __history_previous_command_arguments
|
||||||
|
switch (commandline -t)
|
||||||
|
case "!"
|
||||||
|
commandline -t ""
|
||||||
|
commandline -f history-token-search-backward
|
||||||
|
case "*"
|
||||||
|
commandline -i '$'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if [ "$fish_key_bindings" = fish_vi_key_bindings ]
|
||||||
|
|
||||||
|
bind -Minsert ! __history_previous_command
|
||||||
|
bind -Minsert '$' __history_previous_command_arguments
|
||||||
|
else
|
||||||
|
bind ! __history_previous_command
|
||||||
|
bind '$' __history_previous_command_arguments
|
||||||
|
end
|
||||||
|
|
||||||
|
# Fish command history
|
||||||
|
function history
|
||||||
|
builtin history --show-time='%F %T '
|
||||||
|
end
|
||||||
|
|
||||||
|
function backup --argument filename
|
||||||
|
cp $filename $filename.bak
|
||||||
|
end
|
||||||
+10
-18
@@ -14,6 +14,10 @@ if test -f /usr/share/cachyos-fish-config/cachyos-config.fish
|
|||||||
functions --erase $_fname
|
functions --erase $_fname
|
||||||
source "$__fish_config_dir/functions/$_fname.fish"
|
source "$__fish_config_dir/functions/$_fname.fish"
|
||||||
end
|
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
|
end
|
||||||
set --erase _fname
|
set --erase _fname
|
||||||
|
|
||||||
@@ -122,15 +126,13 @@ if status is-interactive
|
|||||||
fzf --fish | source
|
fzf --fish | source
|
||||||
else
|
else
|
||||||
test -f "$__fish_config_dir/integrations/fzf.fish"
|
test -f "$__fish_config_dir/integrations/fzf.fish"
|
||||||
and source "$__fish_config_dir/integrations/fzf.fish"
|
and source "$__fish_config_dir/integrations/fzf.fish"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
# conf.d/fzf.fish is managed by Fisher and may be restored on fisher
|
# conf.d/fzf.fish is managed by Fisher and may be restored on fisher
|
||||||
# update, so this is the reliable place to strip its bindings when
|
# update, so this is the reliable place to strip its bindings when
|
||||||
# fzf is not installed.
|
# fzf is not installed.
|
||||||
if functions -q _fzf_uninstall_bindings
|
functions -q _fzf_uninstall_bindings; and _fzf_uninstall_bindings
|
||||||
_fzf_uninstall_bindings
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# ──────────────────────────────── DirENV ────────────────────────────────
|
# ──────────────────────────────── DirENV ────────────────────────────────
|
||||||
@@ -139,9 +141,7 @@ if status is-interactive
|
|||||||
#
|
#
|
||||||
# The Auto-Venv script above will ignore directories with a
|
# The Auto-Venv script above will ignore directories with a
|
||||||
# .envrc file (direnv configuration) to prevent conflicts.
|
# .envrc file (direnv configuration) to prevent conflicts.
|
||||||
if type -q direnv
|
type -q direnv; and direnv hook fish | source
|
||||||
direnv hook fish | source
|
|
||||||
end
|
|
||||||
|
|
||||||
# Helps ensure that Claude Code's terminal output is clean and doesn't have flickering issues.
|
# Helps ensure that Claude Code's terminal output is clean and doesn't have flickering issues.
|
||||||
set -gx CLAUDE_CODE_NO_FLICKER 1
|
set -gx CLAUDE_CODE_NO_FLICKER 1
|
||||||
@@ -150,11 +150,7 @@ if status is-interactive
|
|||||||
# Initializes the Starship prompt, which provides a highly customizable and informative command prompt.
|
# Initializes the Starship prompt, which provides a highly customizable and informative command prompt.
|
||||||
# This is wrapped in a check to ensure that it only runs if Starship is installed,
|
# This is wrapped in a check to ensure that it only runs if Starship is installed,
|
||||||
# preventing errors if it's not available.
|
# preventing errors if it's not available.
|
||||||
if type -q starship
|
type -q starship; and starship init fish | source
|
||||||
# STARSHIP_START
|
|
||||||
starship init fish | source
|
|
||||||
# STARSHIP_END
|
|
||||||
end
|
|
||||||
|
|
||||||
# ╭────────────────────────────── OVERRIDES ─────────────────────────────╮
|
# ╭────────────────────────────── OVERRIDES ─────────────────────────────╮
|
||||||
# | Run these last so they can override any previous settings. |
|
# | Run these last so they can override any previous settings. |
|
||||||
@@ -169,9 +165,7 @@ if status is-interactive
|
|||||||
# committed to version control.
|
# committed to version control.
|
||||||
# This allows you to keep things like API keys, database credentials,
|
# This allows you to keep things like API keys, database credentials,
|
||||||
# and other secrets out of your main config files and safely ignored by git.
|
# and other secrets out of your main config files and safely ignored by git.
|
||||||
if test -f "$dot_fish/secrets.fish"
|
test -f "$dot_fish/secrets.fish"; and source "$dot_fish/secrets.fish"
|
||||||
source "$dot_fish/secrets.fish"
|
|
||||||
end
|
|
||||||
|
|
||||||
# ─────────────────────── Source machine-local config ────────────────────
|
# ─────────────────────── Source machine-local config ────────────────────
|
||||||
# Sources a local.fish file if it exists, which can be used for machine-specific
|
# Sources a local.fish file if it exists, which can be used for machine-specific
|
||||||
@@ -179,9 +173,7 @@ if status is-interactive
|
|||||||
# This allows you to have different settings on different machines without affecting
|
# This allows you to have different settings on different machines without affecting
|
||||||
# your main config or secrets files. For example, you might want different PATH additions,
|
# your main config or secrets files. For example, you might want different PATH additions,
|
||||||
# aliases, or environment variables on your work laptop vs. your home desktop.
|
# aliases, or environment variables on your work laptop vs. your home desktop.
|
||||||
if test -f "$dot_fish/local.fish"
|
test -f "$dot_fish/local.fish"; and source "$dot_fish/local.fish"
|
||||||
source "$dot_fish/local.fish"
|
|
||||||
end
|
|
||||||
# ╭──────────────────────────── END OVERRIDES ──────────────────────────╮
|
# ╭──────────────────────────── END OVERRIDES ──────────────────────────╮
|
||||||
# | End of override section. |
|
# | End of override section. |
|
||||||
# ╰──────────────────────────── END OVERRIDES ──────────────────────────╯
|
# ╰──────────────────────────── END OVERRIDES ──────────────────────────╯
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
# Copyright (C) 2026 Rootiest
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
function copy
|
||||||
|
set count (count $argv)
|
||||||
|
if test "$count" = 2; and test -d "$argv[1]"
|
||||||
|
# 'string trim' is built straight into Fish and works everywhere
|
||||||
|
set from (string trim --right --chars=/ $argv[1])
|
||||||
|
set to (echo $argv[2])
|
||||||
|
command cp -r $from $to
|
||||||
|
else
|
||||||
|
command cp $argv
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user