2022-09-29 08:09:13 +00:00
|
|
|
|
{ config, pkgs, lib, ... }:
|
2021-09-29 23:00:14 +00:00
|
|
|
|
|
2023-07-09 15:31:59 +00:00
|
|
|
|
with lib;
|
2021-09-29 23:00:14 +00:00
|
|
|
|
{
|
2021-12-08 22:13:43 +00:00
|
|
|
|
imports = [
|
|
|
|
|
./tide/nix-shell.nix
|
|
|
|
|
];
|
2021-09-29 23:00:14 +00:00
|
|
|
|
|
2023-07-09 15:31:59 +00:00
|
|
|
|
options.programs.fish.everywhereAbbrs = mkOption {
|
|
|
|
|
type = types.attrsOf types.str;
|
|
|
|
|
description = "Abbreviations that expands everywhere";
|
|
|
|
|
default = { };
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
config.home.packages = with pkgs; [
|
2023-02-05 12:58:35 +00:00
|
|
|
|
timg
|
|
|
|
|
# For fzf.fish
|
|
|
|
|
fzf
|
|
|
|
|
fd
|
|
|
|
|
bat
|
|
|
|
|
];
|
2022-06-07 21:27:18 +00:00
|
|
|
|
|
2023-07-09 15:31:59 +00:00
|
|
|
|
config.programs.fish = {
|
2021-12-08 22:13:43 +00:00
|
|
|
|
enable = true;
|
2022-11-01 10:09:05 +00:00
|
|
|
|
functions = {
|
|
|
|
|
# Simplify nix usage!
|
2022-11-01 10:38:34 +00:00
|
|
|
|
nx = {
|
|
|
|
|
body = ''
|
|
|
|
|
set impure
|
|
|
|
|
if test $argv[1] = "--impure"
|
|
|
|
|
set impure "--impure"
|
|
|
|
|
set argv $argv[2..]
|
|
|
|
|
end
|
|
|
|
|
if test (count $argv) -gt 0
|
|
|
|
|
nix run $impure nixpkgs#$argv[1] -- $argv[2..]
|
|
|
|
|
else
|
|
|
|
|
echo "nx [--impure] {package} [args...]"
|
2023-02-10 10:52:00 +00:00
|
|
|
|
return 1
|
2022-11-01 10:38:34 +00:00
|
|
|
|
end
|
|
|
|
|
'';
|
|
|
|
|
wraps = "nix run";
|
|
|
|
|
description = "Runs an app from the nixpkgs store.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
nsh = {
|
|
|
|
|
description = "Spawns a shell from the given nixpkgs packages";
|
|
|
|
|
wraps = "nix shell";
|
|
|
|
|
body = ''
|
|
|
|
|
set impure
|
|
|
|
|
if test $argv[1] = "--impure"
|
|
|
|
|
set impure "--impure"
|
|
|
|
|
set argv $argv[2..]
|
|
|
|
|
end
|
|
|
|
|
if test (count $argv) -gt 0
|
|
|
|
|
set minusc (contains -i -- "-c" $argv)
|
|
|
|
|
if test -z $minusc
|
|
|
|
|
nix shell $impure nixpkgs#$argv -c fish
|
|
|
|
|
else if test $minusc -eq (count $argv)
|
|
|
|
|
echo "nsh [--impure] {packages} [-c command args...]"
|
|
|
|
|
return 1
|
|
|
|
|
else
|
|
|
|
|
nix shell $impure nixpkgs#$argv[..(math $minusc - 1)] $argv[$minusc..]
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
echo "nsh [--impure] {packages} [-c command args...]"
|
|
|
|
|
return 1
|
|
|
|
|
end
|
|
|
|
|
'';
|
|
|
|
|
};
|
2022-11-01 10:09:05 +00:00
|
|
|
|
# Grep stuff
|
|
|
|
|
eg = {
|
|
|
|
|
body = ''
|
|
|
|
|
if test (count $argv) -gt 0
|
|
|
|
|
${pkgs.ripgrep}/bin/rg --vimgrep $argv | e
|
|
|
|
|
else
|
|
|
|
|
echo "eg {ripgrep options}"
|
|
|
|
|
return 1
|
|
|
|
|
end
|
|
|
|
|
'';
|
|
|
|
|
wraps = "rg";
|
|
|
|
|
description = "Search with ripgrep and put results into the editor";
|
|
|
|
|
};
|
2023-07-09 15:31:59 +00:00
|
|
|
|
echo-today = "date +%F";
|
2022-11-01 10:09:05 +00:00
|
|
|
|
};
|
2021-09-29 23:00:14 +00:00
|
|
|
|
|
2021-12-08 22:13:43 +00:00
|
|
|
|
tide = {
|
|
|
|
|
nix-shell.enable = true;
|
|
|
|
|
};
|
2021-09-29 23:00:14 +00:00
|
|
|
|
|
2021-12-08 22:13:43 +00:00
|
|
|
|
shellAliases = {
|
|
|
|
|
cat = "bat --theme=GitHub ";
|
2023-03-12 17:19:39 +00:00
|
|
|
|
catp = "bat --theme=GitHub -p ";
|
2021-12-08 22:13:43 +00:00
|
|
|
|
l = "exa -l --color=always ";
|
2023-07-09 15:31:59 +00:00
|
|
|
|
};
|
2021-09-29 23:00:14 +00:00
|
|
|
|
|
2023-07-09 15:31:59 +00:00
|
|
|
|
everywhereAbbrs = {
|
|
|
|
|
lsports =
|
|
|
|
|
if pkgs.stdenv.isDarwin
|
|
|
|
|
then "lsof -i -P | grep LISTEN"
|
|
|
|
|
else "ss -tulp";
|
2021-12-08 22:13:43 +00:00
|
|
|
|
};
|
2021-09-29 23:00:14 +00:00
|
|
|
|
|
2021-12-08 22:13:43 +00:00
|
|
|
|
shellInit = ''
|
|
|
|
|
# Source brew integration
|
|
|
|
|
if test -e /opt/homebrew/bin/brew
|
|
|
|
|
/opt/homebrew/bin/brew shellenv | source
|
|
|
|
|
end
|
|
|
|
|
'';
|
2021-10-09 02:52:28 +00:00
|
|
|
|
|
2021-12-08 22:13:43 +00:00
|
|
|
|
interactiveShellInit = ''
|
2022-05-30 20:33:24 +00:00
|
|
|
|
function fish_greeting
|
2022-06-07 21:27:18 +00:00
|
|
|
|
${pkgs.timg}/bin/timg ${./arona.jpg}
|
|
|
|
|
printf (env LANG=ja_JP.UTF-8 date +"ご主人様、お帰りなさい!\n今日は%A、%Y年%m月%d日ですねー!今の時間って、%H時%M分です〜 \n言って言ってご主人様、コンピュターちゃんと何がするつもりでしょーか?〜エヘヘっ\n")
|
2022-05-30 20:33:24 +00:00
|
|
|
|
end
|
2021-09-29 23:00:14 +00:00
|
|
|
|
|
2022-10-31 11:05:14 +00:00
|
|
|
|
functions --copy fish_title __original_fish_title
|
|
|
|
|
functions --erase fish_title
|
|
|
|
|
function fish_title
|
|
|
|
|
echo (__original_fish_title) - fish
|
|
|
|
|
end
|
|
|
|
|
|
2021-12-08 22:13:43 +00:00
|
|
|
|
# Set up an editor alias
|
|
|
|
|
if test -n "$EDITOR"
|
|
|
|
|
alias e="$EDITOR"
|
|
|
|
|
else
|
|
|
|
|
alias e="kak"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Source iTerm2 integration
|
2022-06-10 17:41:53 +00:00
|
|
|
|
if test -e ~/.iterm2_shell_integration.fish; and test $__CFBundleIdentifier = "com.googlecode.iterm2"
|
|
|
|
|
source ~/.iterm2_shell_integration.fish
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Source Kitty integration
|
|
|
|
|
if set -q KITTY_INSTALLATION_DIR
|
|
|
|
|
set --global KITTY_SHELL_INTEGRATION enabled
|
|
|
|
|
source "$KITTY_INSTALLATION_DIR/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish"
|
|
|
|
|
set --prepend fish_complete_path "$KITTY_INSTALLATION_DIR/shell-integration/fish/vendor_completions.d"
|
2022-07-14 23:26:09 +00:00
|
|
|
|
|
|
|
|
|
# Add fish to PATH if installed as a MacOS App
|
|
|
|
|
test -e $KITTY_INSTALLATION_DIR/../../MacOS && set -x PATH $PATH "$KITTY_INSTALLATION_DIR/../../MacOS"
|
2022-06-10 17:41:53 +00:00
|
|
|
|
end
|
2021-12-08 22:13:43 +00:00
|
|
|
|
|
|
|
|
|
# Enable vi keybindings
|
|
|
|
|
fish_vi_key_bindings
|
|
|
|
|
## Set some kak-focused keybindings
|
|
|
|
|
bind -M default gi beginning-of-line
|
|
|
|
|
bind -M default gl end-of-line
|
2022-04-25 20:57:23 +00:00
|
|
|
|
|
2023-07-09 15:31:59 +00:00
|
|
|
|
# Everywhere abbrs
|
|
|
|
|
${
|
|
|
|
|
concatStringsSep "\n"
|
|
|
|
|
(mapAttrsToList (k: v: "abbr --add --position anywhere -- ${k} ${escapeShellArg v}")
|
|
|
|
|
config.programs.fish.everywhereAbbrs)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Replace today with actual today
|
|
|
|
|
abbr --add --position anywhere today -f echo-today
|
|
|
|
|
|
2022-04-25 20:57:23 +00:00
|
|
|
|
# Set up direnv
|
2023-04-18 21:26:31 +00:00
|
|
|
|
# ${pkgs.direnv}/bin/direnv hook fish | source
|
2022-10-17 13:58:13 +00:00
|
|
|
|
|
|
|
|
|
# Set up tty for GPG
|
|
|
|
|
export GPG_TTY=(tty)
|
2023-02-05 12:58:35 +00:00
|
|
|
|
|
|
|
|
|
# Set up fzf bindings
|
|
|
|
|
fzf_configure_bindings --directory=\ct --processes=\cp
|
2023-02-10 10:52:00 +00:00
|
|
|
|
|
|
|
|
|
# Perl stuff
|
|
|
|
|
set -x PATH ${config.home.homeDirectory}/perl5/bin $PATH 2>/dev/null;
|
|
|
|
|
set -q PERL5LIB; and set -x PERL5LIB ${config.home.homeDirectory}/perl5/lib/perl5:$PERL5LIB;
|
|
|
|
|
set -q PERL5LIB; or set -x PERL5LIB ${config.home.homeDirectory}/perl5/lib/perl5;
|
|
|
|
|
set -q PERL_LOCAL_LIB_ROOT; and set -x PERL_LOCAL_LIB_ROOT ${config.home.homeDirectory}/perl5:$PERL_LOCAL_LIB_ROOT;
|
|
|
|
|
set -q PERL_LOCAL_LIB_ROOT; or set -x PERL_LOCAL_LIB_ROOT ${config.home.homeDirectory}/perl5;
|
|
|
|
|
set -x PERL_MB_OPT --install_base\ \"${config.home.homeDirectory}/perl5\";
|
|
|
|
|
set -x PERL_MM_OPT INSTALL_BASE=${config.home.homeDirectory}/perl5;
|
2023-03-25 10:40:36 +00:00
|
|
|
|
|
|
|
|
|
# Sway!
|
|
|
|
|
if status --is-login; and which sway >/dev/null; and test -z $DISPLAY; and test (tty) = "/dev/tty1"
|
|
|
|
|
read -P "Press enter to start sway..."; and exec sway
|
|
|
|
|
end
|
2021-12-08 22:13:43 +00:00
|
|
|
|
'';
|
|
|
|
|
plugins = [
|
|
|
|
|
{
|
|
|
|
|
name = "tide";
|
|
|
|
|
src = pkgs.fetchFromGitHub {
|
|
|
|
|
owner = "IlanCosman";
|
|
|
|
|
repo = "tide";
|
2023-04-16 10:49:10 +00:00
|
|
|
|
rev = "447945d2cff8f70d5c791dd4eec8b322d37798dd";
|
|
|
|
|
# sha256 = lib.fakeSha256;
|
|
|
|
|
sha256 = "sha256-1c2E3UC3r9hPfijAQoZ/+4yXieFxC4+hkk7wUyr30NM=";
|
2021-09-29 23:08:16 +00:00
|
|
|
|
};
|
2021-12-08 22:13:43 +00:00
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
name = "fzf";
|
|
|
|
|
src = pkgs.fetchFromGitHub {
|
2023-02-05 12:58:35 +00:00
|
|
|
|
owner = "PatrickF1";
|
|
|
|
|
repo = "fzf.fish";
|
|
|
|
|
rev = "v9.7";
|
|
|
|
|
sha256 = "sha256-haNSqXJzLL3JGvD4JrASVmhLJz6i9lna6/EdojXdFOo=";
|
2021-09-29 23:00:14 +00:00
|
|
|
|
};
|
2021-12-08 22:13:43 +00:00
|
|
|
|
}
|
2022-09-29 08:09:13 +00:00
|
|
|
|
{
|
|
|
|
|
name = "fenv";
|
|
|
|
|
src = pkgs.fetchFromGitHub {
|
|
|
|
|
owner = "oh-my-fish";
|
|
|
|
|
repo = "plugin-foreign-env";
|
|
|
|
|
rev = "b3dd471bcc885b597c3922e4de836e06415e52dd";
|
|
|
|
|
sha256 = "sha256-3h03WQrBZmTXZLkQh1oVyhv6zlyYsSDS7HTHr+7WjY8=";
|
|
|
|
|
};
|
|
|
|
|
}
|
2021-12-08 22:13:43 +00:00
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# Source files
|
2023-07-09 15:31:59 +00:00
|
|
|
|
config.home.file = {
|
2021-12-08 22:13:43 +00:00
|
|
|
|
"fish/change_cmd.fish" = {
|
|
|
|
|
source = ./. + "/change_cmd.fish";
|
|
|
|
|
target = ".config/fish/conf.d/change_cmd.fish";
|
|
|
|
|
};
|
|
|
|
|
"fish/pls.fish" = {
|
|
|
|
|
source = ./. + "/pls.fish";
|
|
|
|
|
target = ".config/fish/conf.d/pls.fish";
|
2021-09-29 23:00:14 +00:00
|
|
|
|
};
|
2021-12-08 22:13:43 +00:00
|
|
|
|
};
|
2021-09-29 23:00:14 +00:00
|
|
|
|
}
|