From 2d0c12a033608f7001d71d9a95d72f4fd20dbc67 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 24 May 2024 20:23:56 +0000 Subject: [PATCH] add zshrc --- home/common/core/zsh.nix | 66 +++++++++++++++++++++++++++- home/common/optional/syncthing.nix | 27 ++++++++++++ home/sparky.nix | 1 + hosts/common/users/media/default.nix | 1 + 4 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 home/common/optional/syncthing.nix diff --git a/home/common/core/zsh.nix b/home/common/core/zsh.nix index 67e5dd6..9facad2 100644 --- a/home/common/core/zsh.nix +++ b/home/common/core/zsh.nix @@ -17,7 +17,71 @@ bindkey "^H" backward-delete-char bindkey "^?" backward-delete-char set -o vi - export TERM=xterm + export TERM=xterm-256color + + if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then + SESSION_TYPE="(ssh) " + fi + + #### + # Format prompt + #### + + # Define colors + COLOR_RED="red" + COLOR_MAGENTA="92" + COLOR_YELLOW="3" + COLOR_GREEN="36" + COLOR_BLUE="4" + COLOR_WHITE="7" + + # Format git colors + autoload -Uz compinit && compinit + autoload -Uz add-zsh-hook + autoload -Uz vcs_info + add-zsh-hook precmd vcs_info + + zstyle ':vcs_info:*' enable git + zstyle ':vcs_info:*' formats " %F{cyan}%c%u(%b)%f" + zstyle ':vcs_info:*' actionformats " %F{cyan}%c%u(%b)%f %a" + zstyle ':vcs_info:*' stagedstr "%F{$COLOR_RED}" + zstyle ':vcs_info:*' unstagedstr "%F{$COLOR_RED}" + zstyle ':vcs_info:*' check-for-changes true + + zstyle ':vcs_info:git*+set-message:*' hooks git-untracked + +vi-git-untracked() { + if git --no-optional-locks status --porcelain 2> /dev/null | grep -q "^??"; then + hook_com[staged]+="%F{$COLOR_RED}" + elif git --no-optional-locks status --porcelain 2> /dev/null | grep -q "^A"; then + hook_com[staged]+="%F{$COLOR_YELLOW}" + else + hook_com[staged]+="%F{$COLOR_GREEN}" + fi + } + + # Format prompt + setopt PROMPT_SUBST + PROMPT='%F{'$COLOR_GREEN'}'$(echo "$SESSION_TYPE")''' + PROMPT+='%F{'$COLOR_RED'}[' + PROMPT+='%F{'$COLOR_GREEN'}%n' + PROMPT+='%F{red}@' + PROMPT+='%F{'$COLOR_YELLOW'}%m' + PROMPT+='%F{'$COLOR_RED'}] ' + PROMPT+='%F{'$COLOR_WHITE'}[' + PROMPT+='%F{'$COLOR_YELLOW'}%1~' + PROMPT+='%F{'$COLOR_WHITE'}]' + PROMPT+='$' + PROMPT+='vcs_info_msg_0_' + PROMPT+=' > ' + export PROMPT + setopt autocd # Automatically cd into typed directory. + stty stop undef # Disable ctrl-s to freeze terminal. + setopt interactive_comments + + # General opts + HISTSIZE=10000000 + SAVEHIST=10000000 + setopt appendhistory ''; }; } diff --git a/home/common/optional/syncthing.nix b/home/common/optional/syncthing.nix new file mode 100644 index 0000000..948c27b --- /dev/null +++ b/home/common/optional/syncthing.nix @@ -0,0 +1,27 @@ +{ config, ... }: +let + user = config.home.username; +in +{ + services = { + syncthing = { + enable = true; +# user = "${user}"; +# dataDir = "/home/${user}/sync"; +# configDir = "/home/${user}/.config/syncthing"; +# overrideDevices = true; # overrides any devices added or deleted through the WebUI +# overrideFolders = true; # overrides any folders added or deleted through the WebUI +# settings = { +# devices = { +# "device1" = { id = "UT6263Y-V3GJXNO-6KIGAKZ-KY6UQMD-ER6BT4R-4LPKT2P-V4PCJYZ-ROJZIQQ"; }; +# }; +# folders = { +# "sync" = { # Name of folder in Syncthing, also the folder ID +# path = "/home/${user}/sync"; # Which folder to add to Syncthing +# devices = [ "device1" ]; # Which devices to share the folder with +# }; +# }; +# }; + }; + }; +} diff --git a/home/sparky.nix b/home/sparky.nix index 6c45593..e8a99b9 100644 --- a/home/sparky.nix +++ b/home/sparky.nix @@ -14,6 +14,7 @@ # Import optional ./common/optional/git.nix + ./common/optional/syncthing.nix ]; } diff --git a/hosts/common/users/media/default.nix b/hosts/common/users/media/default.nix index de18918..2242421 100644 --- a/hosts/common/users/media/default.nix +++ b/hosts/common/users/media/default.nix @@ -5,6 +5,7 @@ let sopsHashedPasswordFile = lib.optionalString (lib.hasAttr "sops-nix" inputs) config.sops.secrets."passwords/media".path; secretsDirectory = builtins.toString inputs.nix-secrets; secretsFile = "${secretsDirectory}/secrets.yaml"; + in { users.users.media = {