zsh: Make nix-shell pretty and update ps1

This commit is contained in:
caem 2024-07-15 01:25:14 +02:00
parent 947368779d
commit 032fd38053
Signed by: caem
GPG key ID: 69A830D03203405F
7 changed files with 39 additions and 14 deletions

View file

@ -2,3 +2,7 @@
alias reload="exec zsh"
if [ -x "$(command -v nix)" ]; then
alias nix-develop="nix develop -c $SHELL"
fi

View file

@ -1,17 +1,17 @@
#!/usr/bin/env zsh
if [ -z "$FZF_TAB_FILE" ]; then
if [ -z "$FZF_TAB_PLUGIN" ]; then
if [ ! -d "$HOME/.cache/fzf-tab" ]; then
echo "Installing fzf-tab"
git clone "https://github.com/Aloxaf/fzf-tab" "$HOME/.cache/fzf-tab"
fi
FZF_TAB_FILE="$HOME/.cache/fzf-tab/fzf-tab.plugin.zsh"
FZF_TAB_PLUGIN="$HOME/.cache/fzf-tab/fzf-tab.plugin.zsh"
fi
autoload -Uz compinit
compinit
source "$FZF_TAB_FILE"
source "$FZF_TAB_PLUGIN"
zstyle ':completion:*:git-checkout:*' sort false
if [ -n "$TMUX" ]; then

View file

@ -0,0 +1,7 @@
#!/usr/bin/env zsh
# Nix specific zsh configuration
if [ -x "$(command -v nix)" ]; then
source "$NIX_SHELL_PLUGIN"
fi

View file

@ -9,10 +9,21 @@ case "$distro" in
*) dicon="%F{yellow}[󰘧]%f" ;;
esac
if [ -n "$IN_NIX_SHELL" ]; then
if [ -z "$NIX_SHELL_PACKAGES" ]; then
nix_shell_ps1="%F{red}nix-shell%f"
else
nix_shell_ps1="%F{red}{ $NIX_SHELL_PACKAGES }%f"
fi
else
nix_shell_ps1=""
fi
setopt prompt_subst
autoload -Uz vcs_info
precmd () { vcs_info }
zstyle ':vcs_info:*' formats ' %F{yellow}(%b)%f'
zstyle ':vcs_info:*' formats ' %F{yellow}(%b)%f '
export PS1='$dicon %n@%m %F{green}%~%f$vcs_info_msg_0_> '
NL=$'\n'
export PS1='%F{green}%~%f$vcs_info_msg_0_$nix_shell_ps1$NL$dicon > '

View file

@ -9,10 +9,10 @@ setopt SHARE_HISTORY
setopt HIST_IGNORE_SPACE
setopt HIST_SAVE_NO_DUPS
if [ -z "$AUTOSUGGEST_FILE" ]; then
if [ -z "$AUTOSUGGEST_PLUGIN" ]; then
import_file="/usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh"
else
import_file="$AUTOSUGGEST_FILE"
import_file="$AUTOSUGGEST_PLUGIN"
fi
if [ ! -f "$import_file" ]; then

View file

@ -1,9 +1,9 @@
#!/usr/bin/env zsh
if [ -z "$SYNTAX_FILE" ]; then
if [ -z "$SYNTAX_PLUGIN" ]; then
import_file="/usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
else
import_file="$SYNTAX_FILE"
import_file="$SYNTAX_PLUGIN"
fi
if [ ! -f "$import_file" ]; then