dendrify: comfy-station
This commit is contained in:
80
old/modules/home/zsh/default.nix
Normal file
80
old/modules/home/zsh/default.nix
Normal file
@@ -0,0 +1,80 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
cfg = config.hive.zsh;
|
||||
omz_custom = "${config.home.homeDirectory}/.config/omz_custom";
|
||||
in {
|
||||
options.hive.zsh = {
|
||||
enable = lib.mkEnableOption "Enable Zsh";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
home.file."${omz_custom}" = {
|
||||
source = ./static/omz_custom;
|
||||
recursive = true;
|
||||
};
|
||||
|
||||
# direnv
|
||||
programs.direnv = {
|
||||
enable = true;
|
||||
enableZshIntegration = true;
|
||||
nix-direnv.enable = true;
|
||||
};
|
||||
|
||||
# fancy ls command
|
||||
programs.lsd = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
# Zsh
|
||||
programs.zsh = {
|
||||
enable = true;
|
||||
enableCompletion = true;
|
||||
syntaxHighlighting.enable = true;
|
||||
|
||||
history.size = 10000;
|
||||
history.path = "${config.xdg.dataHome}/zsh/history";
|
||||
oh-my-zsh = {
|
||||
enable = true;
|
||||
plugins = [
|
||||
"docker"
|
||||
"docker-compose"
|
||||
"fzf"
|
||||
"git"
|
||||
"pass"
|
||||
"poetry"
|
||||
"python"
|
||||
"rust"
|
||||
];
|
||||
theme = "my_bureau";
|
||||
custom = omz_custom;
|
||||
};
|
||||
};
|
||||
|
||||
home.packages = with pkgs; [
|
||||
bat
|
||||
fzf
|
||||
git
|
||||
htop
|
||||
killall
|
||||
mmtui
|
||||
nh
|
||||
nix-output-monitor
|
||||
nix-search-cli
|
||||
nix-tree
|
||||
nixpkgs-fmt
|
||||
pass
|
||||
pay-respects
|
||||
ranger
|
||||
unzip
|
||||
vim
|
||||
w3m
|
||||
wget
|
||||
yt-dlp
|
||||
zip
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
# oh-my-zsh Bureau Theme
|
||||
|
||||
### NVM
|
||||
|
||||
ZSH_THEME_NVM_PROMPT_PREFIX="%B⬡%b "
|
||||
ZSH_THEME_NVM_PROMPT_SUFFIX=""
|
||||
|
||||
### Git [±master ▾●]
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="[%{$fg_bold[green]%}±%{$reset_color%}%{$fg_bold[white]%}"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}]"
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}✓%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_AHEAD="%{$fg[cyan]%}▴%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_BEHIND="%{$fg[magenta]%}▾%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_STAGED="%{$fg_bold[green]%}●%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$fg_bold[yellow]%}●%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}●%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_STASHED="(%{$fg_bold[blue]%}✹%{$reset_color%})"
|
||||
|
||||
bureau_nix_shell () {
|
||||
if [ -n "$IN_NIX_SHELL" ]; then
|
||||
if [ -n "$out" ]; then
|
||||
local name=$(basename $(realpath -mL "$out/../../"))
|
||||
echo -n "[nix-shell@$name]"
|
||||
else
|
||||
echo -n "[nix-shell]"
|
||||
fi
|
||||
else
|
||||
echo -n ""
|
||||
fi
|
||||
}
|
||||
|
||||
bureau_nix_shell_prompt () {
|
||||
if [ -n "$IN_NIX_SHELL" ]; then
|
||||
echo -n "[nix]"
|
||||
else
|
||||
echo -n ""
|
||||
fi
|
||||
}
|
||||
|
||||
bureau_git_info () {
|
||||
local ref
|
||||
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
|
||||
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
|
||||
echo "${ref#refs/heads/}"
|
||||
}
|
||||
|
||||
bureau_git_status() {
|
||||
local result gitstatus
|
||||
gitstatus="$(command git status --porcelain -b 2>/dev/null)"
|
||||
|
||||
# check status of files
|
||||
local gitfiles="$(tail -n +2 <<< "$gitstatus")"
|
||||
if [[ -n "$gitfiles" ]]; then
|
||||
if [[ "$gitfiles" =~ $'(^|\n)[AMRD]. ' ]]; then
|
||||
result+="$ZSH_THEME_GIT_PROMPT_STAGED"
|
||||
fi
|
||||
if [[ "$gitfiles" =~ $'(^|\n).[MTD] ' ]]; then
|
||||
result+="$ZSH_THEME_GIT_PROMPT_UNSTAGED"
|
||||
fi
|
||||
if [[ "$gitfiles" =~ $'(^|\n)\\?\\? ' ]]; then
|
||||
result+="$ZSH_THEME_GIT_PROMPT_UNTRACKED"
|
||||
fi
|
||||
if [[ "$gitfiles" =~ $'(^|\n)UU ' ]]; then
|
||||
result+="$ZSH_THEME_GIT_PROMPT_UNMERGED"
|
||||
fi
|
||||
else
|
||||
result+="$ZSH_THEME_GIT_PROMPT_CLEAN"
|
||||
fi
|
||||
|
||||
# check status of local repository
|
||||
local gitbranch="$(head -n 1 <<< "$gitstatus")"
|
||||
if [[ "$gitbranch" =~ '^## .*ahead' ]]; then
|
||||
result+="$ZSH_THEME_GIT_PROMPT_AHEAD"
|
||||
fi
|
||||
if [[ "$gitbranch" =~ '^## .*behind' ]]; then
|
||||
result+="$ZSH_THEME_GIT_PROMPT_BEHIND"
|
||||
fi
|
||||
if [[ "$gitbranch" =~ '^## .*diverged' ]]; then
|
||||
result+="$ZSH_THEME_GIT_PROMPT_DIVERGED"
|
||||
fi
|
||||
|
||||
# check if there are stashed changes
|
||||
if command git rev-parse --verify refs/stash &> /dev/null; then
|
||||
result+="$ZSH_THEME_GIT_PROMPT_STASHED"
|
||||
fi
|
||||
|
||||
echo $result
|
||||
}
|
||||
|
||||
bureau_git_prompt() {
|
||||
# ignore non git folders and hidden repos (adapted from lib/git.zsh)
|
||||
if ! command git rev-parse --git-dir &> /dev/null \
|
||||
|| [[ "$(command git config --get oh-my-zsh.hide-info 2>/dev/null)" == 1 ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# check git information
|
||||
local gitinfo=$(bureau_git_info)
|
||||
if [[ -z "$gitinfo" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# quote % in git information
|
||||
local output="${gitinfo:gs/%/%%}"
|
||||
|
||||
# check git status
|
||||
local gitstatus=$(bureau_git_status)
|
||||
if [[ -n "$gitstatus" ]]; then
|
||||
output+=" $gitstatus"
|
||||
fi
|
||||
|
||||
echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${output}${ZSH_THEME_GIT_PROMPT_SUFFIX}"
|
||||
}
|
||||
|
||||
|
||||
_PATH="%{$fg_bold[white]%}%~%{$reset_color%}"
|
||||
|
||||
if [[ $EUID -eq 0 ]]; then
|
||||
_USERNAME="%{$fg_bold[red]%}%n"
|
||||
_LIBERTY="%{$fg[red]%}#"
|
||||
else
|
||||
_USERNAME="%{$fg_bold[white]%}%n"
|
||||
_LIBERTY="%{$fg[green]%}$"
|
||||
fi
|
||||
_USERNAME="$_USERNAME%{$reset_color%}@%m"
|
||||
_LIBERTY="$_LIBERTY%{$reset_color%}"
|
||||
|
||||
|
||||
get_space () {
|
||||
local STR=$1$2
|
||||
local zero='%([BSUbfksu]|([FB]|){*})'
|
||||
local LENGTH=${#${(S%%)STR//$~zero/}}
|
||||
local SPACES=$(( COLUMNS - LENGTH - ${ZLE_RPROMPT_INDENT:-1} ))
|
||||
|
||||
(( SPACES > 0 )) || return
|
||||
printf ' %.0s' {1..$SPACES}
|
||||
}
|
||||
|
||||
_1LEFT="$_USERNAME $_PATH"
|
||||
_1RIGHT="[%*]"
|
||||
|
||||
bureau_precmd () {
|
||||
_1SPACES=`get_space $_1LEFT $_1RIGHT`
|
||||
print
|
||||
print -rP "$_1LEFT$_1SPACES$_1RIGHT"
|
||||
}
|
||||
|
||||
setopt prompt_subst
|
||||
PROMPT='$(bureau_nix_shell_prompt)> $_LIBERTY '
|
||||
RPROMPT='$(nvm_prompt_info) $(bureau_nix_shell) $(bureau_git_prompt)'
|
||||
|
||||
autoload -U add-zsh-hook
|
||||
add-zsh-hook precmd bureau_precmd
|
||||
Reference in New Issue
Block a user