nixos-config/modules/programs/shell-zsh.nix

178 lines
4.8 KiB
Nix
Raw Normal View History

2019-10-24 02:20:38 +02:00
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.programs.custom.zsh;
in {
options.programs.custom.zsh = {
enable = mkEnableOption "enable zsh";
mainUser = mkOption {
2019-12-20 05:54:26 +01:00
type = with types; nullOr str;
2019-10-24 02:20:38 +02:00
default = null;
description = ''
the main User if available
'';
};
};
config = mkIf cfg.enable {
programs.zsh = {
2019-12-20 05:54:26 +01:00
enable = true;
enableCompletion = true;
2019-10-24 02:20:38 +02:00
#autosuggestions.enable = true;
syntaxHighlighting.enable = true;
ohMyZsh = {
custom = "/etc/zshcustom/";
enable = true;
# powerline themes
# ----------------
#theme = "agnoster";
theme = "powerlevel9k/powerlevel9k";
plugins = [
"git"
"git-flow"
"screen"
"taskwarrior"
2019-10-24 02:20:38 +02:00
"systemd"
"tmux"
"vi-mode"
"wd"
];
};
loginShellInit = ''
export TERM="xterm-256color"
'';
shellAliases = {
2019-12-20 05:54:26 +01:00
ls = "ls --color=tty";
l = "ls -CFh";
la = "ls -Ah";
ll = "ls -lh";
lt = "ls -lct --reverse";
less = "less -S";
top = "htop";
todo = "task todo";
active = "task active";
2019-10-24 02:20:38 +02:00
version = "date '+%Y%m%d%H%M%S'";
2019-12-20 05:54:26 +01:00
vclip = "xclip -selection clipboard";
df = "df -h";
2019-10-24 02:20:38 +02:00
timestamp = "date +%Y%m%d%H%M%S";
2019-12-20 05:54:26 +01:00
nix-search = "nix-env -qaP";
nix-list = ''nix-env -qaP "*" --description'';
nix-list-haskell = ''nix-env -f "<nixpkgs>" -qaP -A haskellPackages'';
nix-list-node = ''nix-env -f "<nixpkgs>" -qaP -A nodePackages'';
nix-list-beam = ''nix-env -f "<nixpkgs>" -qaP -A beamPackages'';
2019-10-24 02:20:38 +02:00
# nix-find = "clear ; ${pkgs.nix-index}/bin/nix-locate -1 -w";
nix-show-garbadge-roots = "ls -lh /nix/var/nix/gcroots/auto/";
};
};
#environment.systemPackages = [
# pkgs.nix-index # make nix-index also available to users
#];
# only used to make quick config changes
# --------------------------------------
environment.etc."zshcustom/mainuser.zsh".source =
2019-12-20 05:54:26 +01:00
pkgs.writeText "mainuser-zsh" (if (cfg.mainUser != null) then ''
source ${config.users.users.mainUser.home}/.zshrc
'' else
"# programs.custom.zsh.mainUser not set ");
2019-10-24 02:20:38 +02:00
# Theme
# -----
# make sure powerline-fonts is set in `fonts.fonts`
2019-12-20 05:54:26 +01:00
environment.etc."zshcustom/themes/powerlevel9k".source =
pkgs.fetchFromGitHub {
owner = "bhilburn";
repo = "powerlevel9k";
rev = "v0.6.4";
sha256 = "104wvlni3rilpw9v1dk848lnw8cm8qxl64xs70j04ly4s959dyb5";
};
environment.etc."zshcustom/powerlevel9kpatch.zsh".source =
pkgs.writeText "powerlevel9kpatch.zsh" ''
# this shows all the colors which are available
# ---------------------------------------------
# for code ({000..255}) print -P -- "$code: %F{$code}This is how your text would look like%f"
# prompt elements
# ---------------
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vi_mode context dir vcs custom_jail background_jobs time status)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()
# vi mode
# -------
POWERLEVEL9K_VI_MODE_INSERT_FOREGROUND="black"
POWERLEVEL9K_VI_MODE_INSERT_BACKGROUND="blue"
POWERLEVEL9K_VI_MODE_NORMAL_FOREGROUND="black"
POWERLEVEL9K_VI_MODE_NORMAL_BACKGROUND="yellow"
# context
# -------
POWERLEVEL9K_CONTEXT_DEFAULT_FOREGROUND="green"
POWERLEVEL9K_CONTEXT_DEFAULT_BACKGROUND="008"
POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND="008"
POWERLEVEL9K_CONTEXT_ROOT_BACKGROUND="red"
POWERLEVEL9K_CONTEXT_REMOTE_FOREGROUND="008"
POWERLEVEL9K_CONTEXT_REMOTE_BACKGROUND="red"
# dir
# ---
POWERLEVEL9K_DIR_HOME_FOREGROUND="black"
POWERLEVEL9K_DIR_HOME_BACKGROUND="yellow"
POWERLEVEL9K_DIR_HOME_SUBFOLDER_FOREGROUND="black"
POWERLEVEL9K_DIR_HOME_SUBFOLDER_BACKGROUND="yellow"
POWERLEVEL9K_DIR_DEFAULT_FOREGROUND="black"
POWERLEVEL9K_DIR_DEFAULT_BACKGROUND="green"
# root_indicator
# --------------
POWERLEVEL9K_ROOT_ICON="#"
POWERLEVEL9K_ROOT_INDICATOR_FOREGROUND="black"
POWERLEVEL9K_ROOT_INDICATOR_BACKGROUND="red"
# background_jobs
# ---------------
POWERLEVEL9K_BACKGROUND_JOBS_ICON=""
# status
# ------
POWERLEVEL9K_STATUS_OK_BACKGROUND="008"
POWERLEVEL9K_STATUS_ERROR_BACKGROUND="008"
# time
# ----
POWERLEVEL9K_TIME_FOREGROUND="008"
POWERLEVEL9K_TIME_BACKGROUND="006"
# jail indicator
# --------------
POWERLEVEL9K_CUSTOM_JAIL="[ -z $JAIL ] || echo $JAIL"
POWERLEVEL9K_CUSTOM_JAIL_BACKGROUND="red"
POWERLEVEL9K_CUSTOM_JAIL_FOREGROUND="black"
'';
2019-10-24 02:20:38 +02:00
};
}