Browse Source

Update vi-mode keybinds, use gruvbox color scheme

* Update lock script, taken from arch-laptop
* Remove cruft from zah.zsh-theme, style it based
  on pygmalion.zsh-theme
* Don't load NVM at all due to long startup,
  source ~/usr/share/nvm/init.sh instead when
  needed
arch-desktop
Andrew Zah 9 months ago
parent
commit
aee7203ad1
Signed by: Andrew Zah <zah@andrewzah.com> GPG Key ID: 0AE942445EB70FAA
6 changed files with 286 additions and 80 deletions
  1. 17
    14
      .config/kitty/kitty.conf
  2. 29
    53
      .oh-my-zsh/themes/zah.zsh-theme
  3. 87
    3
      scripts/lock
  4. 12
    9
      zsh/exports.zsh
  5. 140
    0
      zsh/zah.zsh-theme
  6. 1
    1
      zsh/zsh-path.zsh

+ 17
- 14
.config/kitty/kitty.conf View File

@@ -234,22 +234,25 @@ selection_foreground #000000
234 234
 # The background for selections
235 235
 selection_background #FFFACD
236 236
 
237
-background #282828
237
+background #1d2021
238 238
 background_opacity 1.0
239 239
 
240
-color0 #282c34
241
-color1 #cc6666
242
-color2 #87bd68
243
-color3 #dfaf8f
244
-color4 #81a2be
245
-color5 #dc8cc3
246
-color6 #72a0a8
247
-color7 #dcdccc
248
-color8 #709080
249
-color9 #dca3a3
250
-color10 #c3bf9f
251
-color11 #f0dfaf
252
-color12 #94bff3
240
+color0 #282828
241
+color1 #cc241d
242
+color2 #98971a
243
+color3 #d79921
244
+color4 #458588
245
+color5 #b16286
246
+color6 #689d6a
247
+color7 #a89984
248
+color8 #928374
249
+color9 #fb4934
250
+color10 #b8bb26
251
+color11 #fabd2f
252
+color12 #83a598
253
+color13 #d3869b
254
+color14 #8ec07c
255
+color15 #ebdbb2
253 256
 
254 257
 # Advanced {{{
255 258
 

+ 29
- 53
.oh-my-zsh/themes/zah.zsh-theme View File

@@ -65,7 +65,7 @@
65 65
     [[ $D > 0 ]] && printf '%dd ' $D
66 66
     [[ $H > 0 ]] && printf '%dh ' $H
67 67
     [[ $M > 0 ]] && printf '%dm ' $M
68
-    [[ $D > 0 || $H > 0 || $M > 0 ]] && printf 'and '
68
+    [[ $D > 0 || $H > 0 || $M > 0 ]] && printf ''
69 69
     printf '%ds\n' $S
70 70
   }
71 71
 
@@ -95,70 +95,46 @@
95 95
 # Prompt Functions
96 96
 # ================
97 97
 
98
-  # Set color of lambda based on exit code
99
-  exit_code_status() {
100
-    if [[ "$?" == "0" ]]; then
101
-      echo -e '\e[1;32m'
102
-    else 
103
-      echo -e '\e[1;32m'
104
-    fi
105
-  }
106
-
107
-  function prompt_ruby() {
108
-    if [[ ! -f Gemfile || ! -f Rakefile || ! -n *.rb(#qN^/) ]]; then
109
-      return
110
-    fi
98
+  function insert-mode () { echo "%{$fg_bold[yellow]%}[INSERT]%{$reset_color%}" }
99
+  function normal-mode () { echo "%{$fg_bold[magenta]%}[NORMAL]%{$reset_color%}" }
111 100
 
112
-    local ruby_version
101
+  function user_host_status () { echo "%{$fg[magenta]%}%n%{$fg[cyan]%}@%{$fg[yellow]%}%m%{$fg_bold[red]%}:%{$reset_color%}" }
113 102
 
114
-    if _exists rbenv; then
115
-      ruby_version=$(rbenv version-name)
103
+  # Set color of lambda based on exit code
104
+  function exit_code_status() {
105
+    if [[ "$?" != "0" ]]; then
106
+      echo -e "%{$fg_bold[red]%}"
116 107
     else
117
-      return
108
+      echo -e "%{$fg_bold[green]%}"
118 109
     fi
110
+  }
119 111
 
120
-    [[ "${ruby_version}" == "system" ]] && return
121
-
122
-    # Add 'v' before ruby version that starts with a number
123
-    [[ "${ruby_version}" =~ ^[0-9].+$ ]] && ruby_version="v${ruby_version}"
124
-
125
-    _prompt_section \
126
-      "" \
127
-      "" \
128
-      "Ruby ${ruby_version}" \
129
-      ""
112
+  function dir_status() {
113
+    echo "%{$fg_bold[cyan]%}%0~%{$reset_color%}"
130 114
   }
131 115
 
132
-  function prompt_crystal() {
133
-    if [[ ! -f shard.yml || ! -n *.cr(#qN^/) ]]; then
134
-      return
135
-    fi
116
+  # Wrap up in set_prompt so it can be 
117
+  # refreshed by time functions, etc
118
+  function set_prompt() {
119
+    case ${KEYMAP} in
120
+      (vicmd)       VI_MODE="$(normal-mode)" ;;
121
+      (main|viins)  VI_MODE="$(insert-mode)" ;;
122
+      (*)           VI_MODE="$(insert-mode)" ;;
123
+    esac
136 124
 
137
-    local crystal_version
125
+    PROMPT='$(exit_code_status)λ ($(_convertsecs $(get_time))) $(user_host_status)$(dir_status) $(exit_code_status)\$ %{$reset_color%} '
138 126
 
139
-    if _exists crystal; then
140
-      crystal_version=$(crystal -v | awk '{print $2;exit}')
127
+    if [[ -n $(git_prompt_info) ]]; then
128
+      RPROMPT='${VI_MODE} {$(git_prompt_info)}%{$reset_color%} $(git_prompt_status)%{$reset_color%}'
141 129
     else
142
-      return
130
+      RPROMPT='${VI_MODE}'
143 131
     fi
144
-
145
-    # Add 'v' before crystal version that starts with a number
146
-    [[ "${crystal_version}" =~ ^[0-9].+$ ]] && crystal_version="v${crystal_version}"
147
-
148
-    _prompt_section \
149
-      "" \
150
-      "" \
151
-      "Crystal ${crystal_version}" \
152
-      ""
153 132
   }
154 133
 
155
-  set_prompt_plugins() {
134
+  function zle-line-init zle-keymap-select {
135
+    set_prompt
136
+    zle reset-prompt
156 137
   }
157 138
 
158
-  # Wrap up in set_prompt so it can be 
159
-  # refreshed by time functions, etc
160
-  set_prompt() {
161
-    PROMPT='%{$(exit_code_status)%}λ $(_convertsecs $(get_time)) %{${PR_BOLD_GREEN}%}[%c] ⇒ %{$reset_color%} '
162
-    RPROMPT='{$(git_prompt_info)}%{$reset_color%} $(git_prompt_status)%{$reset_color%}'
163
-  }
164
-  set_prompt # init
139
+  zle -N zle-line-init
140
+  zle -N zle-keymap-select

+ 87
- 3
scripts/lock View File

@@ -1,4 +1,88 @@
1 1
 #!/bin/bash
2
-scrot /tmp/screenshot.png
3
-convert /tmp/screenshot.png -blur 0x5 /tmp/screenshotblur.png
4
-/home/andrei/.config/i3/i3lock-fancy-multimonitor/lock -n -p -b=0x5
2
+
3
+# Defaults
4
+# Taken from https://github.com/guimeira/i3lock-fancy-multimonitor
5
+#
6
+# Modified to remove TEXT option & logic,
7
+#   and use /home/<user>/.config/i3lock
8
+#   dir for images.
9
+
10
+DISPLAY_RE="([0-9]+)x([0-9]+)\\+([0-9]+)\\+([0-9]+)"
11
+IMAGE_RE="([0-9]+)x([0-9]+)"
12
+FOLDER="/home/$(whoami)/.config/i3lock"
13
+LOCK="$FOLDER/lock.png"
14
+PARAMS=""
15
+OUTPUT_IMAGE="/tmp/i3lock.png"
16
+PIXELATE=false
17
+BLURTYPE="1x1"
18
+
19
+# Read user input
20
+POSITIONAL=()
21
+for i in "$@"
22
+do
23
+  case $i in
24
+  -h|--help)
25
+    echo "lock: Syntax: lock [-n|--no-text] [-p|--pixelate] [-b=VAL|--blur=VAL]"
26
+    echo "for correct blur values, read: http://www.imagemagick.org/Usage/blur/#blur_args"
27
+    exit
28
+    shift
29
+    ;;
30
+  -b=*|--blur=*)
31
+    VAL="${i#*=}"
32
+    BLURTYPE=(${VAL//=/ }) 
33
+    shift
34
+    ;;
35
+  -p|--pixelate)
36
+    PIXELATE=true
37
+    shift # past argument
38
+    ;;
39
+  *)    # unknown option
40
+    echo "unknown option: $i"
41
+    exit
42
+    POSITIONAL+=("$1") # save it in an array for later
43
+    shift # past argument
44
+    ;;
45
+  esac
46
+done
47
+set -- "${POSITIONAL[@]}" # restore positional parameters
48
+
49
+#Take screenshot:
50
+scrot -z $OUTPUT_IMAGE
51
+
52
+#Get dimensions of the lock image:
53
+LOCK_IMAGE_INFO=`identify $LOCK`
54
+[[ $LOCK_IMAGE_INFO =~ $IMAGE_RE ]]
55
+IMAGE_WIDTH=${BASH_REMATCH[1]}
56
+IMAGE_HEIGHT=${BASH_REMATCH[2]}
57
+
58
+#Execute xrandr to get information about the monitors:
59
+while read LINE
60
+do
61
+  #If we are reading the line that contains the position information:
62
+  if [[ $LINE =~ $DISPLAY_RE ]]; then
63
+    #Extract information and append some parameters to the ones that will be given to ImageMagick:
64
+    WIDTH=${BASH_REMATCH[1]}
65
+    HEIGHT=${BASH_REMATCH[2]}
66
+    X=${BASH_REMATCH[3]}
67
+    Y=${BASH_REMATCH[4]}
68
+    POS_X=$(($X+$WIDTH/2-$IMAGE_WIDTH/2))
69
+    POS_Y=$(($Y+$HEIGHT/2-$IMAGE_HEIGHT/2))
70
+
71
+    PARAMS="$PARAMS '$LOCK' '-geometry' '+$POS_X+$POS_Y' '-composite'"
72
+  fi
73
+done <<<"`xrandr`"
74
+
75
+#Execute ImageMagick:
76
+if $PIXELATE ; then
77
+  PARAMS="'$OUTPUT_IMAGE' '-scale' '10%' '-scale' '1000%' $PARAMS '$OUTPUT_IMAGE'"
78
+else
79
+  PARAMS="'$OUTPUT_IMAGE' '-level' '0%,100%,0.6' '-blur' '$BLURTYPE' $PARAMS '$OUTPUT_IMAGE'"
80
+fi
81
+
82
+eval convert $PARAMS
83
+
84
+#Lock the screen:
85
+i3lock -i $OUTPUT_IMAGE -t
86
+
87
+#Remove the generated image:
88
+rm $OUTPUT_IMAGE

+ 12
- 9
zsh/exports.zsh View File

@@ -1,14 +1,17 @@
1 1
 #!/usr/bin/env bash
2 2
 
3
-# ZSH 
3
+###
4
+### ZSH 
5
+###
6
+
4 7
 export UPDATE_ZSH_DAYS=1
5 8
 
6
-# MPW
7
-MPW_FULLNAME="Andrew Zah"
8
-MPW_FORMAT='none'
9
+# Set vi mode timeout to 0.1
10
+export KEYTIMEOUT=1
9 11
 
10
-# Custom
11
-########
12
+###
13
+### Custom
14
+###
12 15
 
13 16
 export TERM=xterm-kitty
14 17
 
@@ -22,9 +25,9 @@ export EDITOR='nvim'
22 25
 export LANG='en_US.UTF-8';
23 26
 export LC_ALL='en_US.UTF-8';
24 27
 
25
-#########
26
-# Apps
27
-#########
28
+###
29
+### Apps
30
+###
28 31
 
29 32
 # Vim FZF
30 33
 export FZF_DEFAULT_COMMAND='rg --files --no-ignore --hidden --follow --glob "!.git/*"'

+ 140
- 0
zsh/zah.zsh-theme View File

@@ -0,0 +1,140 @@
1
+# This is based on theunraveler and spaceship themes
2
+
3
+# Variables
4
+# =========
5
+
6
+  ZSH_THEME_GIT_PROMPT_PREFIX=""
7
+  ZSH_THEME_GIT_PROMPT_SUFFIX=""
8
+  ZSH_THEME_GIT_PROMPT_DIRTY=""
9
+  ZSH_THEME_GIT_PROMPT_CLEAN=""
10
+  #https://www.utf8icons.com/character/67587/cypriot-syllable-o
11
+  ZSH_THEME_GIT_PROMPT_ADDED="%{$PR_BOLD_GREEN%} 𐠃"
12
+
13
+  #https://www.utf8icons.com/character/5819/runic-letter-haegl-h
14
+  ZSH_THEME_GIT_PROMPT_MODIFIED="%{$PR_BOLD_YELLOW%} ᚻ"
15
+
16
+  # https://www.utf8icons.com/character/5815/runic-letter-gebo-gyfu-g
17
+  ZSH_THEME_GIT_PROMPT_DELETED="%{$PR_BOLD_RED%} ᚷ"
18
+
19
+  # https://www.utf8icons.com/character/10499/rightwards-double-arrow-with-vertical-stroke
20
+  ZSH_THEME_GIT_PROMPT_RENAMED="%{$PR_BOLD_BLUE%} ⤃"
21
+
22
+  # https://www.utf8icons.com/character/1986/nko-digit-two
23
+  ZSH_THEME_GIT_PROMPT_UNMERGED="%{$PR_BOLD_MAGENTA%} ߂"
24
+
25
+  # https://www.utf8icons.com/character/67620/cypriot-syllable-re
26
+  ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$PR_BOLD_CYAN%} 𐠤"
27
+
28
+# Helper Functions
29
+# ================
30
+  _prompt_section() {
31
+    local color prefix content suffix
32
+    [[ -n $1 ]] && color="%F{$1}"  || color="%f"
33
+    [[ -n $2 ]] && prefix="$2"     || prefix=""
34
+    [[ -n $3 ]] && content="$3"    || content=""
35
+    [[ -n $4 ]] && suffix="$4"     || suffix=""
36
+
37
+    [[ -z $3 && -z $4 ]] && content=$2 prefix=''
38
+
39
+    echo -n "%{%B%}" # set bold
40
+    if [[ $PROMPT_PREFIXES_SHOW == true ]]; then
41
+      echo -n "$prefix"
42
+    fi
43
+    echo -n "%{%b%}" # unset bold
44
+
45
+    echo -n "%{%B$color%}" # set color
46
+    echo -n "$content"     # section content
47
+    echo -n "%{%b%f%}"     # unset color
48
+
49
+    echo -n "%{%B%}" # reset bold, if it was diabled before
50
+    if [[ $PROMPT_SUFFIXES_SHOW == true ]]; then
51
+      echo -n "$suffix"
52
+    fi
53
+    echo -n "%{%b%}" # unset bold
54
+}
55
+  _exists() {
56
+    command -v $1 > /dev/null 2>&1
57
+  }
58
+
59
+  _convertsecs() {
60
+    local T=$1
61
+    local D=$((T/60/60/24))
62
+    local H=$((T/60/60%24))
63
+    local M=$((T/60%60))
64
+    local S=$((T%60))
65
+    [[ $D > 0 ]] && printf '%dd ' $D
66
+    [[ $H > 0 ]] && printf '%dh ' $H
67
+    [[ $M > 0 ]] && printf '%dm ' $M
68
+    [[ $D > 0 || $H > 0 || $M > 0 ]] && printf ''
69
+    printf '%ds\n' $S
70
+  }
71
+
72
+# ZSH Hooks
73
+# =========
74
+
75
+# TIME
76
+# track elapsed time
77
+  function preexec() {
78
+    timer=${timer:-$SECONDS}
79
+  }
80
+
81
+  function precmd() {
82
+    if [ $timer ]; then
83
+      timer_show=$(($SECONDS - $timer))
84
+      set_prompt
85
+      unset timer
86
+    fi
87
+  }
88
+
89
+  get_time() {
90
+    if [[ -n "${timer_show}" ]]; then
91
+      echo -e "${timer_show}"
92
+    fi
93
+  }
94
+
95
+# Prompt Functions
96
+# ================
97
+
98
+  function insert-mode () { echo "%{$fg_bold[yellow]%}[INSERT]%{$reset_color%}" }
99
+  function normal-mode () { echo "%{$fg_bold[magenta]%}[NORMAL]%{$reset_color%}" }
100
+
101
+  function user_host_status () { echo "%{$fg[magenta]%}%n%{$fg[cyan]%}@%{$fg[yellow]%}%m%{$fg_bold[red]%}:%{$reset_color%}" }
102
+
103
+  # Set color of lambda based on exit code
104
+  function exit_code_status() {
105
+    if [[ "$?" != "0" ]]; then
106
+      echo -e "%{$fg_bold[red]%}"
107
+    else
108
+      echo -e "%{$fg_bold[green]%}"
109
+    fi
110
+  }
111
+
112
+  function dir_status() {
113
+    echo "%{$fg_bold[cyan]%}%0~%{$reset_color%}"
114
+  }
115
+
116
+  # Wrap up in set_prompt so it can be 
117
+  # refreshed by time functions, etc
118
+  function set_prompt() {
119
+    case ${KEYMAP} in
120
+      (vicmd)       VI_MODE="$(normal-mode)" ;;
121
+      (main|viins)  VI_MODE="$(insert-mode)" ;;
122
+      (*)           VI_MODE="$(insert-mode)" ;;
123
+    esac
124
+
125
+    PROMPT='$(exit_code_status)λ ($(_convertsecs $(get_time))) $(user_host_status)$(dir_status) $(exit_code_status)\$ %{$reset_color%} '
126
+
127
+    if [[ -n $(git_prompt_info) ]]; then
128
+      RPROMPT='${VI_MODE} {$(git_prompt_info)}%{$reset_color%} $(git_prompt_status)%{$reset_color%}'
129
+    else
130
+      RPROMPT='${VI_MODE}'
131
+    fi
132
+  }
133
+
134
+  function zle-line-init zle-keymap-select {
135
+    set_prompt
136
+    zle reset-prompt
137
+  }
138
+
139
+  zle -N zle-line-init
140
+  zle -N zle-keymap-select

+ 1
- 1
zsh/zsh-path.zsh View File

@@ -5,4 +5,4 @@ export PATH="$HOME/.cargo/bin:$PATH"
5 5
 eval "$(rbenv init -)"
6 6
 
7 7
 # nvm
8
-source /usr/share/nvm/init-nvm.sh
8
+# source /usr/share/nvm/init-nvm.sh

Loading…
Cancel
Save