e4743bc8e2
Adds conf.d/tricks.fish (PATH additions for ~/.local/bin and depot_tools, bang-bang key bindings, history timestamp override, backup utility) and functions/copy.fish (smarter cp wrapper that strips trailing slashes from source directories, fixing a CachyOS-specific cp quirk). Updates config.fish to explicitly source copy.fish on startup and refactors several conditional blocks to single-line style for consistency. Syncs README.md to document all new utilities.
68 lines
2.1 KiB
Fish
68 lines
2.1 KiB
Fish
# 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
|