From c005b5b65c9834be1ebe9813c45e591f9ab23da4 Mon Sep 17 00:00:00 2001 From: Agatha Lovelace Date: Fri, 28 Jul 2023 21:28:23 +0200 Subject: [PATCH] Port fish config --- common/default.nix | 2 + common/home_manager/common.nix | 69 +++++++++++++++++++++++++++++++--- 2 files changed, 66 insertions(+), 5 deletions(-) diff --git a/common/default.nix b/common/default.nix index 9a6fb78..96d9bcf 100644 --- a/common/default.nix +++ b/common/default.nix @@ -43,8 +43,10 @@ # Packages used on all systems environment.systemPackages = with pkgs; [ comma + dogdns git killall + mtr openssl rsync sqlite-interactive diff --git a/common/home_manager/common.nix b/common/home_manager/common.nix index 3b66657..6626227 100644 --- a/common/home_manager/common.nix +++ b/common/home_manager/common.nix @@ -82,11 +82,6 @@ fish = { enable = true; - interactiveShellInit = builtins.readFile (pkgs.fetchurl { - url = - "https://git.lain.faith/sorceress/dotfiles/raw/commit/80be649e9663e3db67041192c714329e20b10cc9/.config/fish/config.fish"; - sha256 = "sha256-ZZCTXnRZfotksiJj7iVJnLz+XnWHTlIsZzv3gbbZoRQ="; - }); plugins = [ { name = "fzf"; @@ -107,6 +102,70 @@ }; } ]; + functions = { + expand-dot-to-parent-directory-path = '' + # expand ... to ../.. etc + # https://github.com/fish-shell/fish-shell/issues/1891#issuecomment-451961517 + + # Get commandline up to cursor + set -l cmd (commandline --cut-at-cursor) + + # Match last line + switch $cmd[-1] + case '*..' + commandline --insert '/.' + case '*' + commandline --insert '.' + end + ''; + impostor = '' + echo $argv[1] | string sub -s 13 | fold -w1 | shuf | tr -d '\n' | sed 's/^/cccccbeujtje/' + ''; + }; + shellInit = '' + set -Ux AWT_TOOLKIT MToolkit + set -Ux JDK_JAVA_OPTIONS "-Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -Dswing.crossplatformlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -Djdk.gtk.version=3 -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true" + + # Zoxide + set -Ux _ZO_FZF_OPTS "--no-sort --height=30% --exit-0 --select-1 --bind=ctrl-z:ignore" + + # Fix locale errors in Nix + set -Ux LOCALE_ARCHIVE /usr/lib/locale/locale-archive + + # PATH + set -gx fish_user_paths $fish_user_paths \ + /home/agatha/.local/bin \ + /home/agatha/.cargo/bin \ + /home/agatha/.cabal/bin + + if type -q ruby + fish_add_path -a (ruby -e 'print Gem.user_dir')/bin + end + + # Aliases + alias cat bat + alias ip 'ip -color=always' + alias youtube-dl-audio 'yt-dlp --ignore-errors --output "%(title)s.%(ext)s" --extract-audio --audio-format best' + + bind . 'expand-dot-to-parent-directory-path' + + if test -d ~/.gnupg + set -e SSH_AGENT_PID + set -x SSH_AUTH_SOCK (gpgconf --list-dirs agent-ssh-socket) + # so gpg-agent knows in what tty to prompt for key passwords + set -x GPG_TTY (tty) + gpg-connect-agent updatestartuptty /bye > /dev/null + end + ''; + interactiveShellInit = '' + if type -q exa + alias ls 'exa -lFhT --group-directories-first --level 1' + end + + if type -q zoxide + zoxide init --cmd v fish | source + end + ''; }; command-not-found.enable = false;