pub-solar-os/modules/terminal-life/zsh/default.nix

139 lines
4 KiB
Nix
Raw Normal View History

{ config, pkgs, self, ... }:
2021-05-30 19:10:28 +00:00
let
psCfg = config.pub-solar;
xdg = config.home-manager.users."${psCfg.user.name}".xdg;
in
{
enable = true;
enableAutosuggestions = true;
enableCompletion = true;
dotDir = ".config/zsh";
history = {
ignoreDups = true;
expireDuplicatesFirst = true;
ignoreSpace = true;
path = "$HOME/.local/share/zsh/zsh_history";
save = 10000;
size = 10000;
};
loginExtra = ''
[ "$(tty)" = "/dev/tty1" ] && exec ${pkgs.sway-service}/bin/sway-service
'';
2021-05-30 19:10:28 +00:00
shellAliases = {
nano = "nvim";
vi = "nvim";
vim = "nvim";
mutt = "neomutt";
ls = "exa";
la = "exa --group-directories-first -lag";
fm = "vifm .";
vifm = "vifm .";
wget = "wget --hsts-file=$XDG_CACHE_HOME/wget-hsts";
irssi = "irssi --config=$XDG_CONFIG_HOME/irssi/config --home=$XDG_DATA_HOME/irssi";
drone = "DRONE_TOKEN=$(secret-tool lookup drone token) drone";
no = "manix \"\" | grep '^# ' | sed 's/^# \(.*\) (.*/\1/;s/ (.*//;s/^# //' | fzf --preview=\"manix '{}'\" | xargs manix";
# fix nixos-option
nixos-option = "nixos-option -I nixpkgs=${self}/lib/compat";
2022-01-31 11:16:36 +00:00
myip = "dig +short myip.opendns.com @208.67.222.222 2>&1";
2021-05-30 19:10:28 +00:00
};
2022-06-05 01:07:50 +00:00
plugins = [
{
# will source ohmyzsh/plugins/z/
name = "zsh-plugins-z";
file = "plugins/z/z.sh";
src = pkgs.fetchFromGitHub {
owner = "ohmyzsh";
repo = "ohmyzsh";
rev = "249c708ed3a4a7a63d16a6e911a46b6fb9623cbd";
2022-06-05 01:07:50 +00:00
sha256 = "sha256-NAVotL5RxpS/zKnO+ngMIjv787lqc1dj/c4blQrQcvU=";
};
}
{
name = "zsh-powerlevel10k";
file = "powerlevel10k.zsh-theme";
src = pkgs.fetchFromGitHub {
owner = "romkatv";
repo = "powerlevel10k";
rev = "3bfbb8294fd61d3fb9f75f944b178eb9c8c2c0f7";
sha256 = "sha256-xZOTbCt0Erl3pTsUbumx5OCti9dmNsOrSvovKy8Zvh8=";
2022-06-05 01:07:50 +00:00
};
}
{
name = "zsh-fast-syntax-highlighting";
file = "F-Sy-H.plugin.zsh";
2022-06-05 01:07:50 +00:00
src = pkgs.fetchFromGitHub {
owner = "z-shell";
repo = "F-Sy-H";
rev = "c0b8c1484bc482de98ff3149817197159cab3b33";
sha256 = "sha256-OLeeFPNx3dWZgJSvKqKzAeFloXQRNbvJKNBBYavzkSE=";
2022-06-05 01:07:50 +00:00
};
}
{
name = "zsh-nix-shell";
file = "nix-shell.plugin.zsh";
2022-06-05 01:07:50 +00:00
src = pkgs.fetchFromGitHub {
owner = "chisui";
repo = "zsh-nix-shell";
rev = "af6f8a266ea1875b9a3e86e14796cadbe1cfbf08";
2022-06-05 01:07:50 +00:00
sha256 = "sha256-BjgMhILEL/qdgfno4LR64LSB8n9pC9R+gG7IQWwgyfQ=";
};
}
];
2021-05-30 19:10:28 +00:00
initExtra = ''
bindkey -v
bindkey -v 'jj' vi-cmd-mode
bindkey -a 'i' up-line
bindkey -a 'k' down-line
bindkey -a 'j' backward-char
bindkey -a 'h' vi-insert
bindkey '^[[H' beginning-of-line
bindkey '^[[F' end-of-line
bindkey '^R' history-incremental-pattern-search-backward
bindkey '^ ' autosuggest-accept
bindkey '^q' push-line-or-edit
bindkey '^R' fzf-history-widget
# ArrowUp/Down start searching history with current input
2022-01-19 00:13:15 +00:00
autoload -U up-line-or-beginning-search
autoload -U down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey "^[[A" up-line-or-beginning-search
bindkey "^[[B" down-line-or-beginning-search
bindkey "^P" up-line-or-beginning-search
bindkey "^N" down-line-or-beginning-search
2021-05-30 19:10:28 +00:00
# MAKE CTRL+S WORK IN VIM
stty -ixon
stty erase '^?'
2022-04-30 15:51:41 +00:00
precmd () {
DIR_NAME=$(pwd | sed "s|^$HOME|~|g")
echo -e -n "\e]2;$DIR_NAME\e\\"
2022-06-04 17:32:12 +00:00
2022-06-04 18:29:09 +00:00
if [ $(date +%d%m) = '0104' ]; then
if [ $? -eq 0 ]; then
echo "Success! That was a great command! I can't wait to see what amazing stuff you'll be up to next."
fi
2022-06-04 17:32:12 +00:00
fi
2022-04-30 15:51:41 +00:00
}
2021-05-30 19:10:28 +00:00
# If a command is not found, show me where it is
source ${pkgs.nix-index}/etc/profile.d/command-not-found.sh
''
+ builtins.readFile ./base16.zsh
+ builtins.readFile ./p10k.zsh
+
''
source ${pkgs.fzf}/share/fzf/key-bindings.zsh
source ${pkgs.fzf}/share/fzf/completion.zsh
source ${pkgs.git-bug}/share/zsh/site-functions/git-bug
eval "$(direnv hook zsh)"
'';
2021-05-30 19:10:28 +00:00
}