From 6f2fff80ed5de00bb8f5b463e773ca83352b195c Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Fri, 6 May 2022 09:29:25 -0400 Subject: [PATCH] split out starship, fzf, direnv --- modules/shell/default.nix | 12 ++++++- modules/shell/direnv.nix | 13 +++++++ modules/shell/fish.nix | 55 ++++------------------------- modules/shell/fzf.nix | 30 ++++++++++++++++ modules/shell/starship.nix | 54 +++++++++++++++++++++++++++++ modules/shell/utilities.nix | 2 ++ starship/starship.toml.configlink | 57 ------------------------------- 7 files changed, 117 insertions(+), 106 deletions(-) create mode 100644 modules/shell/direnv.nix create mode 100644 modules/shell/fzf.nix create mode 100644 modules/shell/starship.nix delete mode 100644 starship/starship.toml.configlink diff --git a/modules/shell/default.nix b/modules/shell/default.nix index 5da982d..1c85d84 100644 --- a/modules/shell/default.nix +++ b/modules/shell/default.nix @@ -1 +1,11 @@ -{ ... }: { imports = [ ./fish.nix ./git.nix ./github.nix ./utilities.nix ]; } +{ ... }: { + imports = [ + ./fish.nix + ./starship.nix + ./fzf.nix + ./direnv.nix + ./git.nix + ./github.nix + ./utilities.nix + ]; +} diff --git a/modules/shell/direnv.nix b/modules/shell/direnv.nix new file mode 100644 index 0000000..b278436 --- /dev/null +++ b/modules/shell/direnv.nix @@ -0,0 +1,13 @@ +{ config, ... }: { + + home-manager.users.${config.user}.programs.direnv = { + enable = true; + nix-direnv.enable = true; + config = { + whitelist = { + prefix = [ "/home/${config.user}/dev/personal/dotfiles/" ]; + }; + }; + }; + +} diff --git a/modules/shell/fish.nix b/modules/shell/fish.nix index 7aabb68..a969532 100644 --- a/modules/shell/fish.nix +++ b/modules/shell/fish.nix @@ -1,10 +1,10 @@ -{ config, pkgs, ... }: { +{ config, pkgs, lib, ... }: { users.users.${config.user}.shell = pkgs.fish; home-manager.users.${config.user} = { - home.packages = with pkgs; [ exa fd bat ripgrep ]; + home.packages = with pkgs; [ exa fd bat ripgrep curl ]; programs.fish = { enable = true; @@ -48,14 +48,6 @@ argumentNames = "filename"; body = builtins.readFile ../../fish.configlink/functions/note.fish; }; - projects = { - description = "Jump to a project"; - body = '' - set projdir (ls $PROJ | fzf) - and cd $PROJ/$projdir - and commandline -f execute - ''; - }; recent = { description = "Open a recent file in Vim"; body = builtins.readFile ../../fish.configlink/functions/recent.fish; @@ -86,7 +78,6 @@ lh = "ls -lh"; ll = "ls -alhF"; la = "ls -a"; - lf = "ls -lh | fzf"; c = "cd"; "-" = "cd -"; mkd = "mkdir -pv"; @@ -95,9 +86,7 @@ s = "sudo"; sc = "systemctl"; scs = "systemctl status"; - reb = "nixos-rebuild switch -I nixos-config=${ - builtins.toString ../../nixos/. - }/configuration.nix"; + m = "make"; # Tmux ta = "tmux attach-session"; @@ -111,10 +100,6 @@ # Notes sn = "syncnotes"; - # CLI Tools - h = "http -Fh --all"; # Curl site for headers - m = "make"; # For makefiles - # Fun CLI Tools weather = "curl wttr.in/$WEATHER_CITY"; moon = "curl wttr.in/Moon"; @@ -154,37 +139,11 @@ shellInit = ""; }; - programs.starship = { - enable = true; - enableFishIntegration = true; - }; + home.sessionVariables.fish_greeting = ""; - programs.fzf = { - enable = true; - enableFishIntegration = true; - }; + programs.starship.enableFishIntegration = true; + programs.zoxide.enableFishIntegration = true; + programs.fzf.enableFishIntegration = true; - home.sessionVariables = let fzfCommand = "fd --type file"; - in { - fish_greeting = ""; - FZF_DEFAULT_COMMAND = fzfCommand; - FZF_CTRL_T_COMMAND = fzfCommand; - FZF_DEFAULT_OPTS = "-m --height 50% --border"; - }; - - programs.zoxide = { - enable = true; - enableFishIntegration = true; - }; - - xdg.configFile = { - "starship.toml".source = ../../starship/starship.toml.configlink; - }; - - programs.direnv = { - enable = true; - nix-direnv.enable = true; - config = { whitelist = { prefix = [ "${builtins.toString ../.}/" ]; }; }; - }; }; } diff --git a/modules/shell/fzf.nix b/modules/shell/fzf.nix new file mode 100644 index 0000000..3cc04e4 --- /dev/null +++ b/modules/shell/fzf.nix @@ -0,0 +1,30 @@ +{ config, ... }: { + + home-manager.users.${config.user} = { + + programs.fzf.enable = true; + + programs.fish = { + functions = { + projects = { + description = "Jump to a project"; + body = '' + set projdir (ls $PROJ | fzf) + and cd $PROJ/$projdir + and commandline -f execute + ''; + }; + }; + shellAbbrs = { lf = "ls -lh | fzf"; }; + }; + + home.sessionVariables = let fzfCommand = "fd --type file"; + in { + FZF_DEFAULT_COMMAND = fzfCommand; + FZF_CTRL_T_COMMAND = fzfCommand; + FZF_DEFAULT_OPTS = "-m --height 50% --border"; + }; + + }; + +} diff --git a/modules/shell/starship.nix b/modules/shell/starship.nix new file mode 100644 index 0000000..f69c343 --- /dev/null +++ b/modules/shell/starship.nix @@ -0,0 +1,54 @@ +{ config, lib, ... }: { + + home-manager.users.${config.user}.programs.starship = { + enable = true; + settings = { + add_newline = false; # Don't print new line at the start of the prompt + format = lib.concatStrings [ + "$directory" + "$git_branch" + "$git_commit" + "$git_status" + "$python" + "$cmd_duration" + "$character" + ]; + character = { + success_symbol = "[❯](bold green)"; + error_symbol = "[❯](bold red)"; + vicmd_symbol = "[❮](bold green)"; + }; + cmd_duration = { + min_time = 5000; + show_notifications = true; + min_time_to_notify = 30000; + format = "[$duration]($style) "; + }; + directory = { + truncate_to_repo = true; + truncation_length = 100; + }; + git_branch = { format = "[$symbol$branch]($style)"; }; + git_commit = { + format = "( @ [$hash]($style) )"; + only_detached = false; + }; + git_status = { + format = "([$all_status$ahead_behind]($style) )"; + conflicted = "="; + ahead = "⇡"; + behind = "⇣"; + diverged = "⇕"; + untracked = "⋄"; + stashed = "⩮"; + modified = "∽"; + staged = "+"; + renamed = "»"; + deleted = "✘"; + style = "red"; + }; + python = { format = "[\\($virtualenv\\)]($style)"; }; + }; + }; + +} diff --git a/modules/shell/utilities.nix b/modules/shell/utilities.nix index 68bbf81..257853a 100644 --- a/modules/shell/utilities.nix +++ b/modules/shell/utilities.nix @@ -35,6 +35,8 @@ in { # pass ]; + programs.zoxide.enable = true; # Shortcut jump command + home.file = { ".rgignore".text = ignorePatterns; ".fdignore".text = ignorePatterns; diff --git a/starship/starship.toml.configlink b/starship/starship.toml.configlink deleted file mode 100644 index ba83599..0000000 --- a/starship/starship.toml.configlink +++ /dev/null @@ -1,57 +0,0 @@ -# Don't print a new line at the start of the prompt -add_newline = false -format = """\ - $directory\ - $git_branch\ - $git_commit\ - $git_status\ - $python\ - $character\ - """ - -[character] -success_symbol = "[❯](bold green)" -error_symbol = "[❯](bold red)" -vicmd_symbol = "[❮](bold green)" - -[cmd_duration] -min_time = 3_000 -show_notifications = true -min_time_to_notify = 30_000 -format = "[$duration]($style) " - -[directory] -truncate_to_repo = true -truncation_length = 100 - -[git_branch] -format = "[$symbol$branch]($style)" - -[git_commit] -format = "( @ [$hash]($style) )" -only_detached = false - -[git_status] -format = "([$all_status$ahead_behind]($style) )" -conflicted = "=" -ahead = "⇡" -behind = "⇣" -diverged = "⇕" -untracked = "⋄" -stashed = "⩮" -modified = "∽" -staged = "+" -renamed = "»" -deleted = "✘" -style = "red" - -[python] -symbol = "" -format = '[\($virtualenv\)]($style)' - -[custom.virtualenv] -command = "echo (basename $VIRTUAL_ENV)" # shows output of command -format = "[$output]($style) " -when = "true" -# prefix = "(" -# suffix = ") "