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 1 year 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
# The background for selections
selection_background #FFFACD

background #282828
background #1d2021
background_opacity 1.0

color0 #282c34
color1 #cc6666
color2 #87bd68
color3 #dfaf8f
color4 #81a2be
color5 #dc8cc3
color6 #72a0a8
color7 #dcdccc
color8 #709080
color9 #dca3a3
color10 #c3bf9f
color11 #f0dfaf
color12 #94bff3
color0 #282828
color1 #cc241d
color2 #98971a
color3 #d79921
color4 #458588
color5 #b16286
color6 #689d6a
color7 #a89984
color8 #928374
color9 #fb4934
color10 #b8bb26
color11 #fabd2f
color12 #83a598
color13 #d3869b
color14 #8ec07c
color15 #ebdbb2

# Advanced {{{


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

@@ -65,7 +65,7 @@
[[ $D > 0 ]] && printf '%dd ' $D
[[ $H > 0 ]] && printf '%dh ' $H
[[ $M > 0 ]] && printf '%dm ' $M
[[ $D > 0 || $H > 0 || $M > 0 ]] && printf 'and '
[[ $D > 0 || $H > 0 || $M > 0 ]] && printf ''
printf '%ds\n' $S
}

@@ -95,70 +95,46 @@
# Prompt Functions
# ================

# Set color of lambda based on exit code
exit_code_status() {
if [[ "$?" == "0" ]]; then
echo -e '\e[1;32m'
else
echo -e '\e[1;32m'
fi
}

function prompt_ruby() {
if [[ ! -f Gemfile || ! -f Rakefile || ! -n *.rb(#qN^/) ]]; then
return
fi
function insert-mode () { echo "%{$fg_bold[yellow]%}[INSERT]%{$reset_color%}" }
function normal-mode () { echo "%{$fg_bold[magenta]%}[NORMAL]%{$reset_color%}" }

local ruby_version
function user_host_status () { echo "%{$fg[magenta]%}%n%{$fg[cyan]%}@%{$fg[yellow]%}%m%{$fg_bold[red]%}:%{$reset_color%}" }

if _exists rbenv; then
ruby_version=$(rbenv version-name)
# Set color of lambda based on exit code
function exit_code_status() {
if [[ "$?" != "0" ]]; then
echo -e "%{$fg_bold[red]%}"
else
return
echo -e "%{$fg_bold[green]%}"
fi
}

[[ "${ruby_version}" == "system" ]] && return

# Add 'v' before ruby version that starts with a number
[[ "${ruby_version}" =~ ^[0-9].+$ ]] && ruby_version="v${ruby_version}"

_prompt_section \
"" \
"" \
"Ruby ${ruby_version}" \
""
function dir_status() {
echo "%{$fg_bold[cyan]%}%0~%{$reset_color%}"
}

function prompt_crystal() {
if [[ ! -f shard.yml || ! -n *.cr(#qN^/) ]]; then
return
fi
# Wrap up in set_prompt so it can be
# refreshed by time functions, etc
function set_prompt() {
case ${KEYMAP} in
(vicmd) VI_MODE="$(normal-mode)" ;;
(main|viins) VI_MODE="$(insert-mode)" ;;
(*) VI_MODE="$(insert-mode)" ;;
esac

local crystal_version
PROMPT='$(exit_code_status)λ ($(_convertsecs $(get_time))) $(user_host_status)$(dir_status) $(exit_code_status)\$ %{$reset_color%} '

if _exists crystal; then
crystal_version=$(crystal -v | awk '{print $2;exit}')
if [[ -n $(git_prompt_info) ]]; then
RPROMPT='${VI_MODE} {$(git_prompt_info)}%{$reset_color%} $(git_prompt_status)%{$reset_color%}'
else
return
RPROMPT='${VI_MODE}'
fi

# Add 'v' before crystal version that starts with a number
[[ "${crystal_version}" =~ ^[0-9].+$ ]] && crystal_version="v${crystal_version}"

_prompt_section \
"" \
"" \
"Crystal ${crystal_version}" \
""
}

set_prompt_plugins() {
function zle-line-init zle-keymap-select {
set_prompt
zle reset-prompt
}

# Wrap up in set_prompt so it can be
# refreshed by time functions, etc
set_prompt() {
PROMPT='%{$(exit_code_status)%}λ $(_convertsecs $(get_time)) %{${PR_BOLD_GREEN}%}[%c] ⇒ %{$reset_color%} '
RPROMPT='{$(git_prompt_info)}%{$reset_color%} $(git_prompt_status)%{$reset_color%}'
}
set_prompt # init
zle -N zle-line-init
zle -N zle-keymap-select

+ 87
- 3
scripts/lock View File

@@ -1,4 +1,88 @@
#!/bin/bash
scrot /tmp/screenshot.png
convert /tmp/screenshot.png -blur 0x5 /tmp/screenshotblur.png
/home/andrei/.config/i3/i3lock-fancy-multimonitor/lock -n -p -b=0x5

# Defaults
# Taken from https://github.com/guimeira/i3lock-fancy-multimonitor
#
# Modified to remove TEXT option & logic,
# and use /home/<user>/.config/i3lock
# dir for images.

DISPLAY_RE="([0-9]+)x([0-9]+)\\+([0-9]+)\\+([0-9]+)"
IMAGE_RE="([0-9]+)x([0-9]+)"
FOLDER="/home/$(whoami)/.config/i3lock"
LOCK="$FOLDER/lock.png"
PARAMS=""
OUTPUT_IMAGE="/tmp/i3lock.png"
PIXELATE=false
BLURTYPE="1x1"

# Read user input
POSITIONAL=()
for i in "$@"
do
case $i in
-h|--help)
echo "lock: Syntax: lock [-n|--no-text] [-p|--pixelate] [-b=VAL|--blur=VAL]"
echo "for correct blur values, read: http://www.imagemagick.org/Usage/blur/#blur_args"
exit
shift
;;
-b=*|--blur=*)
VAL="${i#*=}"
BLURTYPE=(${VAL//=/ })
shift
;;
-p|--pixelate)
PIXELATE=true
shift # past argument
;;
*) # unknown option
echo "unknown option: $i"
exit
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters

#Take screenshot:
scrot -z $OUTPUT_IMAGE

#Get dimensions of the lock image:
LOCK_IMAGE_INFO=`identify $LOCK`
[[ $LOCK_IMAGE_INFO =~ $IMAGE_RE ]]
IMAGE_WIDTH=${BASH_REMATCH[1]}
IMAGE_HEIGHT=${BASH_REMATCH[2]}

#Execute xrandr to get information about the monitors:
while read LINE
do
#If we are reading the line that contains the position information:
if [[ $LINE =~ $DISPLAY_RE ]]; then
#Extract information and append some parameters to the ones that will be given to ImageMagick:
WIDTH=${BASH_REMATCH[1]}
HEIGHT=${BASH_REMATCH[2]}
X=${BASH_REMATCH[3]}
Y=${BASH_REMATCH[4]}
POS_X=$(($X+$WIDTH/2-$IMAGE_WIDTH/2))
POS_Y=$(($Y+$HEIGHT/2-$IMAGE_HEIGHT/2))

PARAMS="$PARAMS '$LOCK' '-geometry' '+$POS_X+$POS_Y' '-composite'"
fi
done <<<"`xrandr`"

#Execute ImageMagick:
if $PIXELATE ; then
PARAMS="'$OUTPUT_IMAGE' '-scale' '10%' '-scale' '1000%' $PARAMS '$OUTPUT_IMAGE'"
else
PARAMS="'$OUTPUT_IMAGE' '-level' '0%,100%,0.6' '-blur' '$BLURTYPE' $PARAMS '$OUTPUT_IMAGE'"
fi

eval convert $PARAMS

#Lock the screen:
i3lock -i $OUTPUT_IMAGE -t

#Remove the generated image:
rm $OUTPUT_IMAGE

+ 12
- 9
zsh/exports.zsh View File

@@ -1,14 +1,17 @@
#!/usr/bin/env bash

# ZSH
###
### ZSH
###

export UPDATE_ZSH_DAYS=1

# MPW
MPW_FULLNAME="Andrew Zah"
MPW_FORMAT='none'
# Set vi mode timeout to 0.1
export KEYTIMEOUT=1

# Custom
########
###
### Custom
###

export TERM=xterm-kitty

@@ -22,9 +25,9 @@ export EDITOR='nvim'
export LANG='en_US.UTF-8';
export LC_ALL='en_US.UTF-8';

#########
# Apps
#########
###
### Apps
###

# Vim FZF
export FZF_DEFAULT_COMMAND='rg --files --no-ignore --hidden --follow --glob "!.git/*"'

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

@@ -0,0 +1,140 @@
# This is based on theunraveler and spaceship themes

# Variables
# =========

ZSH_THEME_GIT_PROMPT_PREFIX=""
ZSH_THEME_GIT_PROMPT_SUFFIX=""
ZSH_THEME_GIT_PROMPT_DIRTY=""
ZSH_THEME_GIT_PROMPT_CLEAN=""
#https://www.utf8icons.com/character/67587/cypriot-syllable-o
ZSH_THEME_GIT_PROMPT_ADDED="%{$PR_BOLD_GREEN%} 𐠃"

#https://www.utf8icons.com/character/5819/runic-letter-haegl-h
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$PR_BOLD_YELLOW%} ᚻ"

# https://www.utf8icons.com/character/5815/runic-letter-gebo-gyfu-g
ZSH_THEME_GIT_PROMPT_DELETED="%{$PR_BOLD_RED%} ᚷ"

# https://www.utf8icons.com/character/10499/rightwards-double-arrow-with-vertical-stroke
ZSH_THEME_GIT_PROMPT_RENAMED="%{$PR_BOLD_BLUE%} ⤃"

# https://www.utf8icons.com/character/1986/nko-digit-two
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$PR_BOLD_MAGENTA%} ߂"

# https://www.utf8icons.com/character/67620/cypriot-syllable-re
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$PR_BOLD_CYAN%} 𐠤"

# Helper Functions
# ================
_prompt_section() {
local color prefix content suffix
[[ -n $1 ]] && color="%F{$1}" || color="%f"
[[ -n $2 ]] && prefix="$2" || prefix=""
[[ -n $3 ]] && content="$3" || content=""
[[ -n $4 ]] && suffix="$4" || suffix=""

[[ -z $3 && -z $4 ]] && content=$2 prefix=''

echo -n "%{%B%}" # set bold
if [[ $PROMPT_PREFIXES_SHOW == true ]]; then
echo -n "$prefix"
fi
echo -n "%{%b%}" # unset bold

echo -n "%{%B$color%}" # set color
echo -n "$content" # section content
echo -n "%{%b%f%}" # unset color

echo -n "%{%B%}" # reset bold, if it was diabled before
if [[ $PROMPT_SUFFIXES_SHOW == true ]]; then
echo -n "$suffix"
fi
echo -n "%{%b%}" # unset bold
}
_exists() {
command -v $1 > /dev/null 2>&1
}

_convertsecs() {
local T=$1
local D=$((T/60/60/24))
local H=$((T/60/60%24))
local M=$((T/60%60))
local S=$((T%60))
[[ $D > 0 ]] && printf '%dd ' $D
[[ $H > 0 ]] && printf '%dh ' $H
[[ $M > 0 ]] && printf '%dm ' $M
[[ $D > 0 || $H > 0 || $M > 0 ]] && printf ''
printf '%ds\n' $S
}

# ZSH Hooks
# =========

# TIME
# track elapsed time
function preexec() {
timer=${timer:-$SECONDS}
}

function precmd() {
if [ $timer ]; then
timer_show=$(($SECONDS - $timer))
set_prompt
unset timer
fi
}

get_time() {
if [[ -n "${timer_show}" ]]; then
echo -e "${timer_show}"
fi
}

# Prompt Functions
# ================

function insert-mode () { echo "%{$fg_bold[yellow]%}[INSERT]%{$reset_color%}" }
function normal-mode () { echo "%{$fg_bold[magenta]%}[NORMAL]%{$reset_color%}" }

function user_host_status () { echo "%{$fg[magenta]%}%n%{$fg[cyan]%}@%{$fg[yellow]%}%m%{$fg_bold[red]%}:%{$reset_color%}" }

# Set color of lambda based on exit code
function exit_code_status() {
if [[ "$?" != "0" ]]; then
echo -e "%{$fg_bold[red]%}"
else
echo -e "%{$fg_bold[green]%}"
fi
}

function dir_status() {
echo "%{$fg_bold[cyan]%}%0~%{$reset_color%}"
}

# Wrap up in set_prompt so it can be
# refreshed by time functions, etc
function set_prompt() {
case ${KEYMAP} in
(vicmd) VI_MODE="$(normal-mode)" ;;
(main|viins) VI_MODE="$(insert-mode)" ;;
(*) VI_MODE="$(insert-mode)" ;;
esac

PROMPT='$(exit_code_status)λ ($(_convertsecs $(get_time))) $(user_host_status)$(dir_status) $(exit_code_status)\$ %{$reset_color%} '

if [[ -n $(git_prompt_info) ]]; then
RPROMPT='${VI_MODE} {$(git_prompt_info)}%{$reset_color%} $(git_prompt_status)%{$reset_color%}'
else
RPROMPT='${VI_MODE}'
fi
}

function zle-line-init zle-keymap-select {
set_prompt
zle reset-prompt
}

zle -N zle-line-init
zle -N zle-keymap-select

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

@@ -5,4 +5,4 @@ export PATH="$HOME/.cargo/bin:$PATH"
eval "$(rbenv init -)"

# nvm
source /usr/share/nvm/init-nvm.sh
# source /usr/share/nvm/init-nvm.sh

Loading…
Cancel
Save