From fd85753fcf251a1b8dcea7ce90534b3f1635b6bf Mon Sep 17 00:00:00 2001 From: Arnie Date: Fri, 10 Jan 2025 09:02:13 +0100 Subject: [PATCH] Prompts and utiltiies --- darwin/common.nix | 7 +- home-manager/becky-dingleberry.nix | 154 ++++++++++++++++++++++ home-manager/lcech-mac-veracode.nix | 183 ++++++++++++++++++-------- home-manager/zsh/common/02-prompt.zsh | 64 --------- 4 files changed, 287 insertions(+), 121 deletions(-) delete mode 100755 home-manager/zsh/common/02-prompt.zsh diff --git a/darwin/common.nix b/darwin/common.nix index 08c2f11..02dc52d 100644 --- a/darwin/common.nix +++ b/darwin/common.nix @@ -76,7 +76,8 @@ in system.defaults = { dock = { autohide = true; - autohide-delay = 0.0; + # Do not need dock, lets be more effective + autohide-delay = 100.0; autohide-time-modifier = 0.25; mineffect = "scale"; minimize-to-application = true; @@ -87,9 +88,9 @@ in tilesize = lib.mkDefault 80; # Hot corners - wvous-bl-corner = hot-corners.MissionControl; + wvous-bl-corner = hot-corners.QuickNote; wvous-br-corner = hot-corners.Launchpad; - wvous-tl-corner = hot-corners.QuickNote; + wvous-tl-corner = hot-corners.MissionControl; }; finder = { diff --git a/home-manager/becky-dingleberry.nix b/home-manager/becky-dingleberry.nix index 9b7be32..6e838cc 100644 --- a/home-manager/becky-dingleberry.nix +++ b/home-manager/becky-dingleberry.nix @@ -1,5 +1,6 @@ { config, + lib, pkgs, ... }: @@ -67,6 +68,8 @@ in # awscli2 # k9s # kubectl + # Terminal image viewer + viu ]; programs.direnv = { @@ -116,6 +119,131 @@ in }; }; + programs.htop = { + enable = true; + }; + + programs.jq = { + enable = true; + }; + + programs.k9s = { + enable = true; + settings = { + k9s = { + refreshRate = 2; + ui = { + logoless = true; + headless = true; + }; + logger = { + tail = 1000; + sinceSeconds = 60 * 30; + fullScreen = true; + showtime = true; + }; + }; + }; + }; + + programs.lsd = { + enable = true; + enableAliases = true; + settings = { + blocks = [ + "permission" + "user" + "group" + "size" + "date" + "git" + "name" + ]; + sorting = { + dir-grouping = "first"; + }; + }; + }; + + programs.mcfly = { + enable = true; + enableZshIntegration = true; + keyScheme = "vim"; + # TODO: Test + fuzzySearchFactor = 2; + + settings = { + colors = { + menubar = { + bg = "black"; + fg = "red"; + }; + darkmode = { + prompt = "cyan"; + timing = "yellow"; + }; + }; + }; + }; + + programs.pay-respects = { + enable = true; + enableZshIntegration = true; + }; + + # programs.spotify-player = { + # enable = true; + # package = config.lib.nixGL.wrap pkgs.spotify-player; + # }; + + # TODO: Configure + # programs.ssh = { + # enable = true; + # }; + + programs.starship = { + enable = true; + enableZshIntegration = true; + + settings = { + format = lib.concatStrings [ + "$username" + "$hostname" + "$directory" + "$character" + ]; + right_format = lib.concatStrings [ + "$git_branch" + "$git_commit" + "$git_state" + "$git_metrics" + "$git_status" + "($cmd_duration)" + ]; + scan_timeout = 25; + add_newline = false; + continuation_prompt = "[▸▹ ](dimmed white)"; + follow_symlinks = false; + directory = { + truncate_to_repo = false; + truncation_length = 20; + truncation_symbol = "…/"; + }; + + cmd_duration = { + min_time = 100; + show_milliseconds = true; + format = "took [$duration]($style) "; + style = "bold yellow"; + }; + + character = { + success_symbol = "✓"; + error_symbol = "⚠"; + }; + }; + }; + programs.zsh = { enable = true; @@ -166,6 +294,32 @@ in ''; }; + systemd.user.services.keepass-sync = { + Unit.Description = "Sync KeePass database"; + + Service = { + Type = "oneshot"; + ExecStart = toString ( + pkgs.writeShellScript "keepass-sync" '' + ${pkgs.coreutils}/bin/cp "/mnt/storage/.circuitry/.secret/default.kdbx" "/mnt/storage/.macshare/.secret/arnie.kdbx" + '' + ); + }; + + Install.WantedBy = [ "default.target" ]; + }; + + systemd.user.timers.keepass-sync = { + Unit.Description = "Timer for KeePass sync"; + + Timer = { + OnBootSec = "1m"; + OnUnitActiveSec = "10m"; + }; + + Install.WantedBy = [ "timers.target" ]; + }; + home.sessionVariables = { EDITOR = "vim"; GO111MODULE = "on"; diff --git a/home-manager/lcech-mac-veracode.nix b/home-manager/lcech-mac-veracode.nix index 614b0f2..66a08d6 100644 --- a/home-manager/lcech-mac-veracode.nix +++ b/home-manager/lcech-mac-veracode.nix @@ -1,4 +1,5 @@ { + lib, pkgs, ... }: @@ -65,6 +66,120 @@ in }; }; + programs.htop = { + enable = true; + }; + + programs.jq = { + enable = true; + }; + + programs.k9s = { + enable = true; + settings = { + k9s = { + refreshRate = 2; + ui = { + logoless = true; + headless = true; + }; + logger = { + tail = 1000; + sinceSeconds = 60 * 30; + fullScreen = true; + showtime = true; + }; + }; + }; + }; + + programs.lsd = { + enable = true; + enableAliases = true; + settings = { + blocks = [ + "permission" + "user" + "group" + "size" + "date" + "git" + "name" + ]; + sorting = { + dir-grouping = "first"; + }; + }; + }; + + programs.mcfly = { + enable = true; + enableZshIntegration = true; + keyScheme = "vim"; + # TODO: Test + fuzzySearchFactor = 2; + + settings = { + colors = { + menubar = { + bg = "black"; + fg = "red"; + }; + darkmode = { + prompt = "cyan"; + timing = "yellow"; + }; + }; + }; + }; + + programs.pay-respects = { + enable = true; + enableZshIntegration = true; + }; + + programs.starship = { + enable = true; + enableZshIntegration = true; + + settings = { + format = lib.concatStrings [ + "$username" + "$hostname" + "$directory" + "$character" + ]; + right_format = lib.concatStrings [ + "$git_branch" + "$git_commit" + "$git_state" + "$git_metrics" + "$git_status" + "($cmd_duration)" + ]; + scan_timeout = 25; + add_newline = false; + continuation_prompt = "[▸▹ ](dimmed white)"; + follow_symlinks = false; + directory = { + truncate_to_repo = false; + truncation_length = 20; + truncation_symbol = "…/"; + }; + + cmd_duration = { + min_time = 100; + show_milliseconds = true; + format = "took [$duration]($style) "; + style = "bold yellow"; + }; + + character = { + success_symbol = "✓"; + error_symbol = "⚠"; + }; + }; + }; programs.zsh = { enable = true; @@ -94,58 +209,18 @@ in GO111MODULE = "on"; TERMINAL = "ghostty"; }; + + launchd.agents.keepass-sync = { + enable = true; + config = { + Program = /bin/cp; + ProgramArguments = [ + "${homedir}/storage/.macshare/.secret/arnie.kdbx" + "${homedir}/arnie.kdbx" + ]; + StartInterval = 60 * 10; + StandardErrorPath = "/var/log/keepass-sync.error.log"; + StandardOutPath = "/var/log/keepass-sync.out.log"; + }; + }; } - -# TODO: launchd timers - -# - -# - -# - -# - -# Label - -# com.example.happybirthday - -# ProgramArguments - -# - -# happybirthday - -# - -# StartCalendarInterval - -# - -# Day - -# 11 - -# Hour - -# 0 - -# Minute - -# 0 - -# Month - -# 7 - -# Weekday - -# 0 - -# - -# - -# diff --git a/home-manager/zsh/common/02-prompt.zsh b/home-manager/zsh/common/02-prompt.zsh deleted file mode 100755 index d5fa3e6..0000000 --- a/home-manager/zsh/common/02-prompt.zsh +++ /dev/null @@ -1,64 +0,0 @@ -function git_prompt_info { - local ref=$(=git symbolic-ref HEAD 2> /dev/null) - local gitst="$(=git status 2> /dev/null)" - - if [[ -f .git/MERGE_HEAD ]]; then - if [[ ${gitst} =~ "unmerged" ]]; then - gitstatus=" %{$fg[red]%}unmerged%{$reset_color%}" - else - gitstatus=" %{$fg[green]%}merged%{$reset_color%}" - fi - elif [[ ${gitst} =~ "Changes to be committed" ]]; then - gitstatus=" %{$fg[blue]%}!%{$reset_color%}" - elif [[ ${gitst} =~ "use \"git add" ]]; then - gitstatus=" %{$fg[red]%}!%{$reset_color%}" - elif [[ -n `git checkout HEAD 2> /dev/null | grep ahead` ]]; then - gitstatus=" %{$fg[yellow]%}*%{$reset_color%}" - else - gitstatus='' - fi - - if [[ -n $ref ]]; then - echo "%{$fg[green]%}⎇ %{$fg_bold[green]%}${ref#refs/heads/}%{$reset_color%}$gitstatus" - fi -} - -function printUser { - - if [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then - echo -n "%{$reset_color%}" - echo -n "%{$fg[yellow]%}%n%{$fg_bold[black]%}@" - echo -n "%{$reset_color%}" - case $(hostname) in - dingleberry) - echo -n "%{$fg[cyan]%}" - ;; - ladybug) - echo -n "%{$fg_bold[green]%}" - ;; - bimbobee) - echo -n "%{$fg_bold[blue]%}" - ;; - lcech-mac) - echo -n "%{$fg[cyan]%}" - ;; - *) - echo -n "%{$fg_bold[red]%}" - ;; - - esac - echo "%M " - fi -} - -function printAwsVault { - if [[ -n "$AWS_VAULT" ]]; then - echo -n "%{$reset_color%}" - echo -n "%{$fg_bold[yellow]%}" - echo -n "[aws-vault: ${AWS_VAULT}]" - echo -n "%{$reset_color%}" - echo -n " " - fi -} - -PROMPT='${PR_BOLD_WHITE}%* $(printUser)$(printAwsVault)${PR_CYAN}%~%<< $(git_prompt_info)${PR_BOLD_WHITE}>%{${reset_color}%} '