This commit is contained in:
2026-01-18 23:17:17 +08:00
parent cc988bba6f
commit fd3f507e8c
11 changed files with 103 additions and 454 deletions
+4 -181
View File
@@ -10,186 +10,6 @@
programs.fish = {
enable = true;
# ═══════════════════════════════════════════════════════════════════════════
# SHELL ALIASES
# ═══════════════════════════════════════════════════════════════════════════
shellAliases = {
# Navigation
".." = "cd ..";
"..." = "cd ../..";
"...." = "cd ../../..";
"....." = "cd ../../../..";
# Listings (eza integration handled by programs.eza)
ll = "ls -la";
la = "ls -a";
lt = "ls --tree";
# Git shortcuts
gs = "git status";
gd = "git diff";
gds = "git diff --staged";
ga = "git add";
gc = "git commit";
gp = "git push";
gl = "git pull";
glog = "git log --oneline --graph --decorate";
gco = "git checkout";
gb = "git branch";
# Nix shortcuts
nix-gc = "nix-collect-garbage -d";
nix-search = "nix search nixpkgs";
nrs = "sudo nixos-rebuild switch --flake .";
drs = "darwin-rebuild switch --flake .";
hms = "home-manager switch --flake .";
# Safety nets
rm = "rm -i";
cp = "cp -i";
mv = "mv -i";
# Modern replacements (when available)
cat = "bat --paging=never";
grep = "rg";
find = "fd";
# Misc
c = "clear";
q = "exit";
h = "history";
j = "jobs -l";
path = "echo $PATH | tr ':' '\\n'";
week = "date +%V";
myip = "curl -s https://ipinfo.io/ip";
};
# ═══════════════════════════════════════════════════════════════════════════
# SHELL ABBREVIATIONS (expand as you type, more powerful than aliases)
# ═══════════════════════════════════════════════════════════════════════════
shellAbbrs = {
# Git abbreviations (expand to full commands)
gst = "git status";
gaa = "git add --all";
gcm = "git commit -m";
gca = "git commit --amend";
gcan = "git commit --amend --no-edit";
gpf = "git push --force-with-lease";
grb = "git rebase";
grbi = "git rebase -i";
gsta = "git stash";
gstp = "git stash pop";
# Docker
dps = "docker ps";
dpa = "docker ps -a";
di = "docker images";
dcu = "docker-compose up";
dcd = "docker-compose down";
# Kubernetes
k = "kubectl";
kg = "kubectl get";
kd = "kubectl describe";
kl = "kubectl logs";
kx = "kubectl exec -it";
};
# ═══════════════════════════════════════════════════════════════════════════
# CUSTOM FUNCTIONS
# ═══════════════════════════════════════════════════════════════════════════
functions = {
# Create directory and cd into it
mkcd = "mkdir -p $argv[1]; and cd $argv[1]";
# Quick extract - handles multiple archive formats
extract = ''
if test -f $argv[1]
switch $argv[1]
case '*.tar.bz2'
tar xjf $argv[1]
case '*.tar.gz'
tar xzf $argv[1]
case '*.tar.xz'
tar xJf $argv[1]
case '*.bz2'
bunzip2 $argv[1]
case '*.rar'
unrar x $argv[1]
case '*.gz'
gunzip $argv[1]
case '*.tar'
tar xf $argv[1]
case '*.tbz2'
tar xjf $argv[1]
case '*.tgz'
tar xzf $argv[1]
case '*.zip'
unzip $argv[1]
case '*.Z'
uncompress $argv[1]
case '*.7z'
7z x $argv[1]
case '*'
echo "'$argv[1]' cannot be extracted via extract()"
end
else
echo "'$argv[1]' is not a valid file"
end
'';
# Git clone and cd
gcl = ''
git clone $argv[1]
cd (basename $argv[1] .git)
'';
# Quick backup file
bak = "cp $argv[1] $argv[1].bak.(date +%Y%m%d_%H%M%S)";
# Find process by name
psg = "ps aux | grep -v grep | grep -i $argv[1]";
# Quick HTTP server
serve = ''
set port (test -n "$argv[1]"; and echo $argv[1]; or echo 8000)
echo "Serving on http://localhost:$port"
python3 -m http.server $port
'';
# Weather
weather = ''
set location (test -n "$argv[1]"; and echo $argv[1]; or echo "")
curl -s "wttr.in/$location?format=3"
'';
# Quick nix shell
nsh = "nix-shell -p $argv";
# Reload fish config
reload = "source ~/.config/fish/config.fish; echo 'Fish config reloaded!'";
# Show path entries one per line
pathlist = "echo $PATH | tr ':' '\\n' | nl";
# Create a quick note
note = ''
set note_dir "$HOME/notes"
mkdir -p $note_dir
set note_file "$note_dir/(date +%Y-%m-%d).md"
if test -n "$argv"
echo "- (date +%H:%M) $argv" >> $note_file
echo "Note added to $note_file"
else
$EDITOR $note_file
end
'';
# Show disk usage for current directory, sorted
duf = "du -sh * 2>/dev/null | sort -h";
};
# ═══════════════════════════════════════════════════════════════════════════
# PLUGINS - Curated selection for productivity
@@ -202,7 +22,7 @@
# ── Fuzzy Finding ─────────────────────────────────────────────────────────
# fzf-fish: Superior fzf integration - Ctrl+R history, Ctrl+Alt+F files, Ctrl+V vars
{
name = "fuck.fzf.fish";
name = "fzf.fish";
src = pkgs.fetchFromGitHub {
owner = "PatrickF1";
repo = "fzf.fish";
@@ -252,6 +72,9 @@
# INTERACTIVE SHELL INITIALIZATION
# ═══════════════════════════════════════════════════════════════════════════
interactiveShellInit = ''
# Set up fzf.fish key bindings (Ctrl+R history, Ctrl+Alt+F files, etc.)
fzf_configure_bindings
echo "🐟 "(set_color cyan)(whoami)(set_color normal)" @ "(set_color yellow)(hostname -s)(set_color normal)" in "(set_color green)(prompt_pwd)(set_color normal)
'';