289 lines
10 KiB
Nix
Executable file
289 lines
10 KiB
Nix
Executable file
{ config, pkgs, ... }: {
|
|
programs.fish = {
|
|
enable = true;
|
|
interactiveShellInit = ''
|
|
set fish_greeting ""
|
|
set -gx DOTNET_ROOT $HOME/.dotnet
|
|
fish_add_path $DOTNET_ROOT
|
|
fish_add_path $DOTNET_ROOT/tools
|
|
set -gx DOTNET_SYSTEM_NET_DISABLEIPV6 1
|
|
bind \cd\cd\cd delete-or-exit
|
|
bind \cf 'ts; commandline -f repaint'
|
|
if type -q eza
|
|
alias ls='eza --color=always --group-directories-first --icons'
|
|
alias ll='eza -a --color=always --group-directories-first --icons'
|
|
alias la='eza -al --group-directories-first --icons'
|
|
alias lt='eza -aT --level=2 --group-directories-first --icons'
|
|
alias l.='eza -ad .* --group-directories-first --icons'
|
|
else
|
|
printf "You may want to install eza\n"
|
|
end
|
|
if not set -q TMUX
|
|
tmux attach-session -t Main 2>/dev/null; or tmux new-session -s Main
|
|
end
|
|
'';
|
|
shellAliases = {
|
|
rebuild = "sudo nixos-rebuild switch --flake $HOME/NixOS#damagedProperty";
|
|
hms = "home-manager switch";
|
|
sshavatar = "ssh warrentyexpired@192.168.88.111";
|
|
sshvaultnas = "ssh warrentyexpired@192.168.88.100";
|
|
sshservarr = "ssh warrentyexpired@192.168.88.101";
|
|
sshdocker = "ssh warrentyexpired@192.168.88.102";
|
|
sshlive = "ssh mementoadmin@uo-memento.com";
|
|
sshproxy = "ssh warrentyexpired@192.168.88.200";
|
|
stff = "mpv --autofit=10%";
|
|
s = "goto s";
|
|
g = "goto g";
|
|
l = "goto l";
|
|
mv = "mv -i --backup=t";
|
|
cat = "bat";
|
|
};
|
|
shellAbbrs = {
|
|
sshracknerd = ''mosh -p 60001 192.227.229.130 --ssh="ssh -p 5522"'';
|
|
};
|
|
functions = {
|
|
ts = {
|
|
description = "Tmux session manager with fuzzy search and quick jump";
|
|
body = ''
|
|
echo -e ""
|
|
# 1. Show Active Sessions
|
|
set -l active_sessions (tmux list-sessions 2>/dev/null)
|
|
if test -n "$active_sessions"
|
|
echo -e (set_color 99ff99)" Active Sessions:"(set_color normal)
|
|
for line in $active_sessions
|
|
echo -e " $line"
|
|
end
|
|
echo ""
|
|
else
|
|
echo -e (set_color 555555)"(No active sessions)"(set_color normal)
|
|
echo ""
|
|
end
|
|
# 2. Provide choices
|
|
echo -e (set_color 00afaf)" Select an option:"(set_color normal)
|
|
echo -e " [1] Pick from active sessions (Fuzzy search)"
|
|
echo -e " [2] Create NEW custom session"
|
|
echo -e " [w] Enter Tmuxinator Workspaces"
|
|
echo -e " [d] Detach from current session"
|
|
echo -e " [x] Kill a session"
|
|
echo -e " [Enter] Quick jump to "(set_color -o)"Main"(set_color normal)
|
|
echo ""
|
|
read -l -P "Choice > " choice
|
|
switch "$choice"
|
|
case 1
|
|
set -l session (tmux list-sessions -F "#{session_name}" 2>/dev/null | fzf --exit-0 --height=15% --reverse --header="Select Session")
|
|
if test -n "$session"
|
|
if set -q TMUX
|
|
tmux switch-client -t "$session"
|
|
else
|
|
tmux attach-session -t "$session"
|
|
end
|
|
end
|
|
case 2
|
|
read -l -P "Enter name for new session: " new_name
|
|
if test -n "$new_name"
|
|
env -u TMUX tmux new-session -d -s "$new_name" 2>/dev/null
|
|
if set -q TMUX
|
|
tmux switch-client -t "$new_name"
|
|
else
|
|
tmux attach-session -t "$new_name"
|
|
end
|
|
end
|
|
case d D
|
|
if set -q TMUX; tmux detach-client; else; echo "You aren't in a tmux session!"; end
|
|
case w W
|
|
if type -q tmuxinator
|
|
tmuxinator start Workspace
|
|
else
|
|
echo (set_color red)"Error: tmuxinator is not installed."(set_color normal)
|
|
end
|
|
case x X
|
|
set -l session (tmux list-sessions -F "#{session_name}" 2>/dev/null | fzf --exit-0 --height=15% --reverse --header="Select Session to KILL")
|
|
if test -n "$session"
|
|
tmux kill-session -t "$session"
|
|
echo "Killed session: $session"
|
|
ts
|
|
end
|
|
case "" "*"
|
|
env -u TMUX tmux new-session -d -s Main 2>/dev/null
|
|
if set -q TMUX; tmux switch-client -t Main; else; tmux attach-session -t Main; end
|
|
end
|
|
commandline -f repaint
|
|
'';
|
|
};
|
|
lookfor = {
|
|
description = "Lookfor (d)irectory, (f)ile (a)ll (pattern)";
|
|
body = ''
|
|
if test (count $argv) -lt 2
|
|
echo "Usage: lookfor (f)ile|(d)irectory|(a)ll "pattern""
|
|
return 1
|
|
end
|
|
set -l type_flag $argv[1]
|
|
set -l pattern $argv[2]
|
|
switch $type_flag
|
|
case f
|
|
find . -type f -name "*$pattern*" 2>/dev/null
|
|
case d
|
|
find . -type d -name "*$pattern*" 2>/dev/null
|
|
case a
|
|
find . -name "*$pattern*" 2>/dev/null
|
|
case *
|
|
echo "Invalid type: $type_flag. Use f for file or d for directory."
|
|
return 1
|
|
end
|
|
'';
|
|
};
|
|
topsort = {
|
|
description = "Sort files large to small.";
|
|
body = ''
|
|
du -sh * | sort -rh | head -10
|
|
'';
|
|
};
|
|
fish_prompt = {
|
|
body = ''
|
|
set -l white (set_color white)
|
|
set -l brwhite (set_color brwhite)
|
|
set -l green (set_color green)
|
|
set -l red (set_color red)
|
|
set -l blue (set_color blue)
|
|
# Line 1: ┌─ [user] @ [host] - homeFiles status
|
|
echo -s $white"┌─ ["$green$USER$white"] "$brwhite"@ " $white"["$red$hostname$white"]"
|
|
# Line 2: └─ [directory]
|
|
set -l full_path (string replace -r "^$HOME" "~" $PWD)
|
|
echo -s $white"├─ ["$blue$full_path$white"]"
|
|
# Line 3: └─ [(git_branch)] or [$e]
|
|
echo -n $white"└─ ["
|
|
set -l git_info (gitinfo 2>/dev/null)
|
|
if test -n "$git_info"
|
|
echo -n $git_info
|
|
else
|
|
echo -n $brwhite"\$"
|
|
end
|
|
echo -n $white"]"
|
|
# Final prompt symbol and reset
|
|
echo -n $brwhite" "
|
|
set_color normal
|
|
'';
|
|
};
|
|
gitinfo = {
|
|
body = ''
|
|
if git rev-parse --is-inside-work-tree >/dev/null 2>&1
|
|
set -l branch (git branch --show-current)
|
|
set -l staged ""
|
|
set -l dirty ""
|
|
set -l untracked ""
|
|
if not git diff --quiet
|
|
set dirty (set_color yellow)"*"
|
|
end
|
|
if not git diff --cached --quiet
|
|
set staged (set_color green)"+"
|
|
end
|
|
set -l untracked_files (git ls-files --others --exclude-standard)
|
|
if test -n "$untracked_files"
|
|
set untracked (set_color red)" *"
|
|
end
|
|
echo (set_color magenta)"($branch)"$staged$dirty$untracked(set_color normal)
|
|
end
|
|
'';
|
|
};
|
|
cdtmp = {
|
|
body = ''
|
|
set -l directory
|
|
if set -q argv[1]
|
|
set -l folder_name (string replace -all / _ $argv[1])
|
|
set directory "/var/tmp/cdtmp.$folder_name"
|
|
mkdir -p "$directory"
|
|
else
|
|
set directory (mktemp -d --tmpdir=/var/tmp cdtmp.XXXXXXXX)
|
|
end
|
|
if test -d "$directory"
|
|
cd "$directory"
|
|
end
|
|
'';
|
|
};
|
|
stffpl = {
|
|
body = ''
|
|
mpv --autofit=10% --playlist="$argv[1]"
|
|
'';
|
|
};
|
|
mkcd = {
|
|
body = ''
|
|
mkdir -p $argv
|
|
and cd $argv[-1]
|
|
'';
|
|
};
|
|
goto = {
|
|
body = ''
|
|
set -l gotoConfig "$HOME/.config/goto/bookmarks"
|
|
set -l gotoDir "$HOME/.config/goto"
|
|
mkdir -p "$gotoDir"
|
|
touch "$gotoConfig"
|
|
set -l command $argv[1]
|
|
set -l bookmark_name $argv[2]
|
|
if test -z "$command"
|
|
echo "Usage: goto s <name> (save current directory)"
|
|
echo " goto g <name> (go to saved directory)"
|
|
echo " goto d <name> (delete a bookmark)"
|
|
echo " goto l (list all bookmarks)"
|
|
echo " goto e (edit bookmarks file)"
|
|
return
|
|
end
|
|
switch $command
|
|
case s # Save bookmarks
|
|
if test -z "$bookmark_name"
|
|
echo "Error: Must provide a bookmark name to save."
|
|
return 1
|
|
end
|
|
sed -i "/^$bookmark_name:/d" "$gotoConfig"
|
|
echo "$bookmark_name:"(pwd) >> "$gotoConfig"
|
|
echo "Bookmark **$bookmark_name** saved to: **"(pwd)"**"
|
|
case g # Go to bookmark
|
|
if test -z "$bookmark_name"
|
|
echo "Error: Must provide a bookmark name to go to."
|
|
return 1
|
|
end
|
|
set -l target_path (grep "^$bookmark_name:" "$gotoConfig" | cut -d ':' -f 2)
|
|
if test -z "$target_path"
|
|
echo "Error: Bookmark **$bookmark_name** not found."
|
|
return 1
|
|
end
|
|
if test -d "$target_path"
|
|
cd "$target_path"
|
|
echo "Jumping to: **$target_path**"
|
|
else
|
|
echo "Error: Directory **$target_path** does not exist or is not a directory"
|
|
end
|
|
case d # Delete bookmark
|
|
if test -z "$bookmark_name"
|
|
echo "Error: Must provide a bookmark name to delete."
|
|
return 1
|
|
end
|
|
|
|
if grep -q "^$bookmark_name:" "$gotoConfig"
|
|
sed -i "/^$bookmark_name:/d" "$gotoConfig"
|
|
echo "Bookmark **$bookmark_name** deleted."
|
|
else
|
|
echo "Error: Bookmark **$bookmark_name** not found."
|
|
return 1
|
|
end
|
|
case e # Edit bookmarks file
|
|
if set -q EDITOR
|
|
$EDITOR "$gotoConfig"
|
|
else
|
|
nano "$gotoConfig"
|
|
end
|
|
case l # List bookmarks
|
|
if not test -s "$gotoConfig"
|
|
echo "No bookmarks saved yet."
|
|
return 0
|
|
end
|
|
echo "___ **Bookmarks** (Stored in: $gotoDir) ___"
|
|
column -t -s ':' "$gotoConfig"
|
|
case '*'
|
|
echo "Invalid command: $command"
|
|
goto # Show usage
|
|
end
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
}
|