summaryrefslogtreecommitdiff
path: root/homes/kjtsanaktsidis/zsh-config.zsh
blob: a1ce1b3ef43d1c4cfcc85c17b9565746e8110fc3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Initialize prompt system
autoload -Uz promptinit
promptinit

# Set options
setopt extendedglob nomatch notify

# Define gentoo prompt theme
prompt_gentoo_help () {
  cat <<'EOF'
This prompt is color-scheme-able.  You can invoke it thus:

  prompt gentoo [<promptcolor> [<usercolor> [<rootcolor>]]]

EOF
}

prompt_gentoo_setup () {
  local prompt_gentoo_prompt=${1:-'blue'}
  local prompt_gentoo_user=${2:-'green'}
  local prompt_gentoo_root=${3:-'red'}

  if [ "$USER" = 'root' ]
  then
    local base_prompt="%B%F{$prompt_gentoo_root}%m%k "
  else
    local base_prompt="%B%F{$prompt_gentoo_user}%n@%m%k "
  fi
  local post_prompt="%b%f%k"

  local path_prompt="%B%F{$prompt_gentoo_prompt}%1~"
  typeset -g PS1="$base_prompt$path_prompt %# $post_prompt"
  typeset -g PS2="$base_prompt$path_prompt %_> $post_prompt"
  typeset -g PS3="$base_prompt$path_prompt ?# $post_prompt"
}

# Register the prompt with promptinit
prompt_themes+=( gentoo )

# Use the gentoo prompt
prompt gentoo

# keybindings
autoload -U edit-command-line
zle -N edit-command-line
bindkey -e
bindkey '^xe' edit-command-line
bindkey '^x^e' edit-command-line
bindkey "^[[3~" delete-char
bindkey "^[[1;5C" forward-word
bindkey "^[[1;5D" backward-word

# Make sure GPG & SSH keys are properly imported
systemctl --user start manage-secrets.service 2>/dev/null || true