2023-08-04 19:20:13 +00:00
|
|
|
{ pkgs, lib, config, ... }:
|
|
|
|
{
|
2023-07-28 23:03:24 +00:00
|
|
|
programs.fish = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
shellAbbrs = rec {
|
2023-12-07 16:08:34 +00:00
|
|
|
ccat = "egrep -v '^\s*(#|\\$)'";
|
2023-08-24 17:21:55 +00:00
|
|
|
g = "git";
|
2023-08-04 20:47:34 +00:00
|
|
|
ga = "git add";
|
2023-08-08 14:35:27 +00:00
|
|
|
gc = "git commit"; # interactive commit
|
|
|
|
gcm = "git commit -m"; # quick commit
|
2023-08-24 17:21:55 +00:00
|
|
|
gg = "git graph";
|
2023-08-04 20:47:34 +00:00
|
|
|
gs = "git status";
|
2023-07-28 23:03:24 +00:00
|
|
|
jqless = "jq -C | less -r";
|
2023-08-01 18:46:11 +00:00
|
|
|
n = "nix";
|
2023-08-04 18:29:05 +00:00
|
|
|
sshpass = "ssh -o PubkeyAuthentication=no";
|
2023-08-02 16:37:52 +00:00
|
|
|
tf = "terraform";
|
|
|
|
tfyolo = "terraform apply -auto-approve";
|
2023-07-28 23:03:24 +00:00
|
|
|
v = "vim";
|
2023-08-24 17:21:55 +00:00
|
|
|
vi = "vim";
|
2023-07-28 23:03:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
shellAliases = {
|
2024-05-02 14:01:36 +00:00
|
|
|
top = "btop";
|
2023-07-28 23:03:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
functions = {
|
2024-03-22 14:50:39 +00:00
|
|
|
# cht.sh integration
|
|
|
|
cht = "curl cheat.sh/$argv";
|
2023-07-28 23:03:24 +00:00
|
|
|
# Disable greeting
|
|
|
|
fish_greeting = "";
|
2024-02-26 22:24:58 +00:00
|
|
|
fish_prompt = ''
|
|
|
|
set -l last_pipestatus $pipestatus
|
|
|
|
set -lx __fish_last_status $status # Export for __fish_print_pipestatus.
|
|
|
|
set -l normal (set_color normal)
|
|
|
|
set -q fish_color_status
|
|
|
|
or set -g fish_color_status red
|
|
|
|
|
|
|
|
# Detect if we're in a nix-shell
|
|
|
|
set -l nix_shell_info (
|
|
|
|
if test -n "$IN_NIX_SHELL"
|
|
|
|
echo -n "[nix-shell] "
|
|
|
|
end
|
|
|
|
)
|
|
|
|
|
|
|
|
# Color the prompt differently when we're root
|
|
|
|
set -l color_cwd $fish_color_cwd
|
|
|
|
set -l suffix '>'
|
|
|
|
if functions -q fish_is_root_user; and fish_is_root_user
|
|
|
|
if set -q fish_color_cwd_root
|
|
|
|
set color_cwd $fish_color_cwd_root
|
|
|
|
end
|
|
|
|
set suffix '#'
|
|
|
|
end
|
|
|
|
|
|
|
|
# Write pipestatus
|
|
|
|
# If the status was carried over (if no command is issued or if `set` leaves the status untouched), don't bold it.
|
|
|
|
set -l bold_flag --bold
|
|
|
|
set -q __fish_prompt_status_generation; or set -g __fish_prompt_status_generation $status_generation
|
|
|
|
if test $__fish_prompt_status_generation = $status_generation
|
|
|
|
set bold_flag
|
|
|
|
end
|
|
|
|
set __fish_prompt_status_generation $status_generation
|
|
|
|
set -l status_color (set_color $fish_color_status)
|
|
|
|
set -l statusb_color (set_color $bold_flag $fish_color_status)
|
|
|
|
set -l prompt_status (__fish_print_pipestatus "[" "]" "|" "$status_color" "$statusb_color" $last_pipestatus)
|
|
|
|
|
|
|
|
echo -n -s (prompt_login)' ' (set_color $color_cwd) (prompt_pwd) $normal (fish_vcs_prompt) $normal " "$nix_shell_info $prompt_status $suffix " "
|
|
|
|
'';
|
2024-05-05 13:56:36 +00:00
|
|
|
get-local-ip = "ip addr show $(ip route | grep default | awk '{print $5}') | grep 'inet ' | awk '{print $2}' | cut -d/ -f1";
|
|
|
|
|
2023-08-04 15:28:43 +00:00
|
|
|
ssh = "TERM=xterm command ssh $argv";
|
2023-07-28 23:03:24 +00:00
|
|
|
# Rebuild home-manager
|
|
|
|
switch-home = "home-manager switch -b backup --flake ${config.home.homeDirectory}/.dotfiles#$USER@$(hostname -s)";
|
2023-09-24 00:14:49 +00:00
|
|
|
switch-nix = "sudo nixos-rebuild switch --flake ${config.home.homeDirectory}/.dotfiles";
|
2023-07-28 23:03:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
interactiveShellInit =
|
2024-01-18 15:38:06 +00:00
|
|
|
# Launch tmux
|
|
|
|
''
|
|
|
|
if not set -q TMUX
|
2024-04-24 14:16:27 +00:00
|
|
|
tmux attach-session -t $(hostname -s) || tmux new-session -s $(hostname -s) -c $HOME
|
2024-01-18 15:38:06 +00:00
|
|
|
end
|
|
|
|
'' +
|
2023-07-28 23:03:24 +00:00
|
|
|
# Open command buffer in vim when alt+e is pressed
|
|
|
|
''
|
|
|
|
bind \ee edit_command_buffer
|
|
|
|
'' +
|
|
|
|
# Use vim bindings and cursors
|
|
|
|
''
|
|
|
|
fish_vi_key_bindings
|
2024-02-11 04:00:23 +00:00
|
|
|
set fish_cursor_default block
|
|
|
|
set fish_cursor_insert block blink
|
2023-07-28 23:03:24 +00:00
|
|
|
set fish_cursor_replace_one underscore blink
|
|
|
|
set fish_cursor_visual block
|
|
|
|
'' +
|
2023-07-29 01:08:31 +00:00
|
|
|
# Restore ctrl+f to accept suggestions
|
|
|
|
''
|
|
|
|
bind -M insert \cf forward-char
|
|
|
|
bind -M default \cf forward-char
|
|
|
|
bind -M visual \cf forward-char
|
|
|
|
'' +
|
2023-07-28 23:03:24 +00:00
|
|
|
# Use terminal colors
|
|
|
|
''
|
|
|
|
set -U fish_color_autosuggestion brblack
|
|
|
|
set -U fish_color_cancel -r
|
|
|
|
set -U fish_color_command brgreen
|
|
|
|
set -U fish_color_comment brmagenta
|
|
|
|
set -U fish_color_cwd green
|
|
|
|
set -U fish_color_cwd_root red
|
|
|
|
set -U fish_color_end brmagenta
|
|
|
|
set -U fish_color_error brred
|
|
|
|
set -U fish_color_escape brcyan
|
|
|
|
set -U fish_color_history_current --bold
|
|
|
|
set -U fish_color_host normal
|
|
|
|
set -U fish_color_match --background=brblue
|
|
|
|
set -U fish_color_normal normal
|
|
|
|
set -U fish_color_operator cyan
|
|
|
|
set -U fish_color_param brblue
|
|
|
|
set -U fish_color_quote yellow
|
|
|
|
set -U fish_color_redirection bryellow
|
|
|
|
set -U fish_color_search_match 'bryellow' '--background=brblack'
|
|
|
|
set -U fish_color_selection 'white' '--bold' '--background=brblack'
|
|
|
|
set -U fish_color_status red
|
|
|
|
set -U fish_color_user brgreen
|
|
|
|
set -U fish_color_valid_path --underline
|
|
|
|
set -U fish_pager_color_completion normal
|
|
|
|
set -U fish_pager_color_description yellow
|
|
|
|
set -U fish_pager_color_prefix 'white' '--bold' '--underline'
|
|
|
|
set -U fish_pager_color_progress 'brwhite' '--background=cyan'
|
2024-03-22 14:50:39 +00:00
|
|
|
'' +
|
|
|
|
# load cht.sh completions
|
|
|
|
''
|
|
|
|
complete -c cht -xa '(curl -s cheat.sh/:list)'
|
2024-05-23 18:47:41 +00:00
|
|
|
'' +
|
|
|
|
# print a happy tree
|
|
|
|
''
|
2024-05-23 19:00:54 +00:00
|
|
|
cbonsai -p -m "$(fortune)"
|
2023-07-28 23:03:24 +00:00
|
|
|
'';
|
|
|
|
};
|
2023-12-07 16:08:34 +00:00
|
|
|
}
|