2024-10-18 14:14:58 +02:00
|
|
|
{
|
|
|
|
description = "jiriks74's ZSH configuration";
|
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs = {
|
|
|
|
self,
|
|
|
|
nixpkgs,
|
|
|
|
flake-utils,
|
|
|
|
...
|
2024-10-24 00:27:43 +02:00
|
|
|
} @ inputs: let
|
|
|
|
inherit (self) outputs;
|
|
|
|
# Supported systems for your flake packages, shell, etc.
|
|
|
|
systems = [
|
|
|
|
"aarch64-linux"
|
|
|
|
"i686-linux"
|
|
|
|
"x86_64-linux"
|
|
|
|
"aarch64-darwin"
|
|
|
|
"x86_64-darwin"
|
|
|
|
];
|
|
|
|
# This is a function that generates an attribute by calling a function you
|
|
|
|
# pass to it, with each system as an argument
|
|
|
|
forAllSystems = nixpkgs.lib.genAttrs systems;
|
|
|
|
in {
|
|
|
|
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra);
|
2024-10-18 14:49:12 +02:00
|
|
|
homeManagerModules = {
|
2024-10-24 00:27:43 +02:00
|
|
|
default = {
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: {
|
|
|
|
home.packages = with pkgs; [
|
2024-10-18 14:49:12 +02:00
|
|
|
nix-zsh-completions
|
|
|
|
|
|
|
|
asciinema # Terminal recording
|
|
|
|
libnotify # Notifications
|
|
|
|
websocat # For asciinema v2 streams
|
|
|
|
|
|
|
|
tldr
|
|
|
|
lsd
|
|
|
|
bat
|
|
|
|
eza
|
|
|
|
trash-cli
|
2024-10-24 00:27:43 +02:00
|
|
|
fzf # enhancd
|
|
|
|
fd # enhancd
|
2024-10-18 14:49:12 +02:00
|
|
|
# rofi # for fd
|
|
|
|
gnutar # ex
|
2024-10-24 00:27:43 +02:00
|
|
|
bzip3 # ex
|
|
|
|
unzip # ex
|
|
|
|
p7zip # ex
|
|
|
|
unrar # ex
|
|
|
|
gzip # ex
|
2024-10-18 14:49:12 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
programs = {
|
|
|
|
# nix-index = {
|
|
|
|
# enable = true;
|
|
|
|
# enableZshIntegration = true;
|
|
|
|
# };
|
|
|
|
# thefuck = {
|
|
|
|
# enable = true;
|
|
|
|
# enableZshIntegration = true;
|
|
|
|
# };
|
|
|
|
direnv = {
|
2024-10-18 14:14:58 +02:00
|
|
|
enable = true;
|
2024-10-18 14:49:12 +02:00
|
|
|
enableZshIntegration = true;
|
|
|
|
nix-direnv.enable = true;
|
2024-10-18 14:14:58 +02:00
|
|
|
};
|
|
|
|
|
2024-10-18 14:49:12 +02:00
|
|
|
zsh = {
|
|
|
|
enable = true;
|
|
|
|
enableCompletion = true;
|
|
|
|
zplug = {
|
|
|
|
enable = true;
|
|
|
|
plugins = [
|
2024-10-24 00:27:43 +02:00
|
|
|
{
|
|
|
|
name = "romkatv/powerlevel10k";
|
|
|
|
tags = ["as:theme" "depth:1"];
|
|
|
|
} # Installations with additional options. For the list of options, please refer to Zplug README.
|
|
|
|
{name = "z-shell/F-Sy-H";} # Feature-rich Syntax Highlighting for Zsh
|
2024-10-18 14:49:12 +02:00
|
|
|
# { name = "zsh-users/zsh-syntax-highlighting"; }
|
2024-10-24 00:27:43 +02:00
|
|
|
{name = "zsh-users/zsh-completions";} # Adds some missing completions to zsh
|
|
|
|
{name = "zsh-users/zsh-autosuggestions";} # Simple plugin installation
|
|
|
|
{name = "MichaelAquilina/zsh-you-should-use";} # Did you forget to use an alias?
|
|
|
|
{name = "davidde/git";} # Aliases for git
|
|
|
|
{
|
|
|
|
name = "babarot/enhancd";
|
|
|
|
tags = ["use:init.sh"];
|
|
|
|
} # Includes simmilar functionality to zsh-z
|
|
|
|
{name = "supercrabtree/k";} # Directory listings for Zsh with git features.
|
|
|
|
{
|
|
|
|
name = "plugins/command-not-found";
|
|
|
|
tags = ["from:oh-my-zsh"];
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "gko/ssh-connect";
|
|
|
|
tags = ["use:ssh-connect.sh"];
|
|
|
|
} # List of most used ssh connections
|
|
|
|
{name = "agkozak/zsh-z";} # Jump arount your filesystem with ease
|
|
|
|
{name = "sineto/web-search";}
|
|
|
|
{name = "zsh-users/zaw";} # Desctiptions for command outputs (afaik)zplug "plugins/git", from:oh-my-zsh
|
2024-10-18 14:49:12 +02:00
|
|
|
# { name = "plugins/dirhistory"; tags = [ "from:oh-my-zsh" ]; }
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
initExtraFirst = ''
|
|
|
|
if [[ "''${ZSH_PROFILE}" -eq 1 ]]; then
|
|
|
|
zmodload zsh/zprof # Profiling. Enable `zprof` at the end of initExtra too.
|
|
|
|
else
|
|
|
|
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
|
|
|
|
# Initialization code that may require console input (password prompts, [y/n]
|
|
|
|
# confirmations, etc.) must go above this block; everything else may go below.
|
|
|
|
if [[ -r "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh" ]]; then
|
|
|
|
source "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh"
|
|
|
|
fi
|
2024-10-18 14:14:58 +02:00
|
|
|
fi
|
2024-10-18 14:49:12 +02:00
|
|
|
'';
|
2024-10-18 14:14:58 +02:00
|
|
|
|
2024-10-18 14:49:12 +02:00
|
|
|
initExtra = ''
|
|
|
|
# Remove nix from path if we are in a container (distrobox)
|
|
|
|
if [ -v DISTROBOX_ENTER_PATH ]; then
|
|
|
|
export PATH=$(echo $PATH | tr ':' '\n' | grep -vE '/nix/|/run/wrappers|\.nix-profile|/etc/profiles/per-user/jirka/bin|/run/current-system/sw/bin' | tr '\n' ':')
|
|
|
|
export PATH=$(echo $PATH | sed 's/:$//')
|
|
|
|
fi
|
|
|
|
|
|
|
|
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
|
|
|
|
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
|
|
|
|
|
|
|
|
export YSU_MESSAGE_POSITION="after" # you-should-use plugin
|
|
|
|
export ASCIINEMA_API_URL=https://asciinema.stefka.eu
|
|
|
|
if [ -v ASCIINEMA_REC ]; then
|
|
|
|
_zsh_autosuggest_disable
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Basic auto/tab complete:
|
|
|
|
autoload -U compinit
|
|
|
|
zstyle ':completion:*' menu select
|
|
|
|
zmodload zsh/complist
|
|
|
|
compinit
|
|
|
|
_comp_options+=(globdots) # Include hidden files.
|
|
|
|
|
|
|
|
# Custom ZSH Binds
|
|
|
|
bindkey '^ ' autosuggest-accept
|
|
|
|
bindkey "^[[H" beginning-of-line
|
|
|
|
bindkey "^[[F" end-of-line
|
|
|
|
bindkey "^[[1;5C" forward-word
|
|
|
|
bindkey "^[[1;5D" backward-word
|
|
|
|
bindkey "^[[3~" delete-char
|
|
|
|
|
|
|
|
# Extracting
|
|
|
|
ex ()
|
|
|
|
{
|
|
|
|
if [ -f $1 ] ; then
|
|
|
|
case $1 in
|
|
|
|
*.tar.bz2) tar xjf $1 ;;
|
|
|
|
*.tar.gz) tar xzf $1 ;;
|
|
|
|
*.tar.xz) tar xJf $1 ;;
|
|
|
|
*.bz2) bunzip3 $1 ;;
|
|
|
|
*.rar) unrar x $1 ;;
|
|
|
|
*.gz) gunzip $1 ;;
|
|
|
|
*.tar) tar xf $1 ;;
|
|
|
|
*.tbz2) tar xjf $1 ;;
|
|
|
|
*.tgz) tar xzf $1 ;;
|
|
|
|
*.zip) unzip $1 ;;
|
|
|
|
*.Z) uncompress $1;;
|
|
|
|
*.7z) 7z x $1 ;;
|
|
|
|
*) echo "'$1' cannot be extracted via ex()" ;;
|
|
|
|
esac
|
|
|
|
else
|
|
|
|
echo "'$1' is not a valid file"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Kitty binds
|
|
|
|
if [ "$TERM" = "xterm-kitty" ]; then
|
|
|
|
alias ssh="kitty +kitten ssh"
|
|
|
|
alias icat="kitty +kitten icat"
|
|
|
|
alias d="kitty +kitten diff"
|
|
|
|
alias get="kitty +kitten transfer"
|
|
|
|
alias put="kitty +kitten transfer --direction=upload"
|
|
|
|
alias kclip="kitty +kitten clipboard"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Special aliases that may not work with Nix config
|
|
|
|
# Command line head / tail shortcuts
|
|
|
|
alias H="| head";
|
|
|
|
alias T="| tail";
|
|
|
|
alias G="| grep";
|
|
|
|
alias L="| less";
|
|
|
|
alias M="| most";
|
|
|
|
alias LL="2>&1 | less";
|
|
|
|
alias CA="2>&1 | cat -A";
|
|
|
|
alias NE="2> /dev/null";
|
|
|
|
alias NUL="> /dev/null 2>&1";
|
|
|
|
alias P="2>&1| pygmentize -l pytb";
|
|
|
|
if [[ "''${ZSH_PROFILE}" -eq 1 ]]; then
|
|
|
|
zprof
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
|
|
|
shellAliases = {
|
|
|
|
# update = "sudo nixos-rebuild switch";
|
|
|
|
|
2024-10-24 00:27:43 +02:00
|
|
|
ls = "lsd";
|
2024-10-18 14:49:12 +02:00
|
|
|
# ls, the common ones I use a lot shortened for rapid fire usage
|
2024-10-24 00:27:43 +02:00
|
|
|
l = "ls -lFh"; #size,show type,human readable
|
|
|
|
la = "ls -lAFh"; #long list,show almost all,show type,human readable
|
|
|
|
lr = "ls -tRFh"; #sorted by date,recursive,show type,human readable
|
|
|
|
lt = "ls -ltFh"; #long list,sorted by date,show type,human readable
|
|
|
|
ll = "ls -l"; #long list
|
|
|
|
ldot = "ls -ld .*";
|
|
|
|
lS = "ls -1FSsh";
|
|
|
|
lart = "ls -1Fcart";
|
|
|
|
lrt = "ls -1Fcrt";
|
|
|
|
|
|
|
|
grep = "grep --color";
|
|
|
|
sgrep = "grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS} ";
|
|
|
|
|
|
|
|
t = "tail -f";
|
|
|
|
|
|
|
|
dud = "du -d 1 -h";
|
|
|
|
duf = "du -sh *";
|
2024-10-18 14:49:12 +02:00
|
|
|
# fd="find . -type d -name";
|
2024-10-24 00:27:43 +02:00
|
|
|
ff = "find . -type f -name";
|
2024-10-18 14:49:12 +02:00
|
|
|
|
2024-10-24 00:27:43 +02:00
|
|
|
h = "history";
|
|
|
|
hgrep = "fc -El 0 | grep";
|
|
|
|
help = "man";
|
|
|
|
p = "ps -f";
|
|
|
|
sortnr = "sort -n -r";
|
|
|
|
unexport = "unset";
|
2024-10-18 14:49:12 +02:00
|
|
|
|
|
|
|
# Use trash instead of rm if available
|
2024-10-24 00:27:43 +02:00
|
|
|
rm = "trash";
|
|
|
|
cp = "cp -i";
|
|
|
|
mv = "mv -i";
|
2024-10-18 14:49:12 +02:00
|
|
|
|
2024-10-24 00:27:43 +02:00
|
|
|
cls = "clear";
|
2024-10-18 14:49:12 +02:00
|
|
|
|
2024-10-24 00:27:43 +02:00
|
|
|
sshc = "ssh-connect";
|
2024-10-18 14:49:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
history = {
|
|
|
|
# ignoreAllDups = true;
|
|
|
|
path = "${config.xdg.cacheHome}/zhistory";
|
|
|
|
save = 10000;
|
|
|
|
size = 10000;
|
|
|
|
# share = true;
|
|
|
|
};
|
2024-10-18 14:14:58 +02:00
|
|
|
};
|
|
|
|
};
|
2024-10-24 00:27:43 +02:00
|
|
|
|
2024-10-18 14:49:12 +02:00
|
|
|
home.file = {
|
|
|
|
# ".zprofile".source = ./zprofile;
|
|
|
|
};
|
2024-10-18 14:14:58 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|