about summary refs log tree commit diff stats
path: root/hm/soispha/conf/zsh/config
diff options
context:
space:
mode:
Diffstat (limited to 'hm/soispha/conf/zsh/config')
-rw-r--r--hm/soispha/conf/zsh/config/custom_cursor.sh40
-rw-r--r--hm/soispha/conf/zsh/config/zsh-init.sh39
-rw-r--r--hm/soispha/conf/zsh/config/zsh-prompt.sh63
3 files changed, 142 insertions, 0 deletions
diff --git a/hm/soispha/conf/zsh/config/custom_cursor.sh b/hm/soispha/conf/zsh/config/custom_cursor.sh
new file mode 100644
index 00000000..9a6da012
--- /dev/null
+++ b/hm/soispha/conf/zsh/config/custom_cursor.sh
@@ -0,0 +1,40 @@
+# Change cursor shape for different vi modes.
+function zle-keymap-select {
+  if [[ ${KEYMAP} == vicmd ]] ||
+     [[ $1 = 'block' ]]; then
+    echo -ne '\e[1 q'
+  elif [[ ${KEYMAP} == main ]] ||
+       [[ ${KEYMAP} == viins ]] ||
+       [[ ${KEYMAP} = '' ]] ||
+       [[ $1 = 'beam' ]]; then
+    echo -ne '\e[5 q'
+  fi
+}
+zle -N zle-keymap-select
+
+# ci", ci', ci`, di", etc
+autoload -U select-quoted
+zle -N select-quoted
+for m in visual viopp; do
+  for c in {a,i}{\',\",\`}; do
+    bindkey -M $m $c select-quoted
+  done
+done
+
+# ci{, ci(, ci<, di{, etc
+autoload -U select-bracketed
+zle -N select-bracketed
+for m in visual viopp; do
+  for c in {a,i}${(s..)^:-'()[]{}<>bB'}; do
+    bindkey -M $m $c select-bracketed
+  done
+done
+
+zle-line-init() {
+    zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere)
+    echo -ne "\e[5 q"
+}
+zle -N zle-line-init
+
+echo -ne '\e[5 q' # Use beam shape cursor on startup.
+precmd() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt.
diff --git a/hm/soispha/conf/zsh/config/zsh-init.sh b/hm/soispha/conf/zsh/config/zsh-init.sh
new file mode 100644
index 00000000..4d54d058
--- /dev/null
+++ b/hm/soispha/conf/zsh/config/zsh-init.sh
@@ -0,0 +1,39 @@
+# If not running interactively, don't do anything
+[[ $- != *i* ]] && return
+
+# Flex on the ubuntu users
+[ "$NVIM" ] || hyfetch
+#loginctl show-session $XDG_SESSION_ID
+
+## Enable colors and change prompt:
+#autoload -Uz colors && colors
+#autoload -Uz compinit && compinit -u
+## Edit line in vim buffer ctrl-v
+autoload -Uz edit-command-line; zle -N edit-command-line
+## Enter vim buffer from normal mode
+#autoload -Uz edit-command-line && zle -N edit-command-line
+bindkey "^V" edit-command-line
+
+## zstyles
+#zstyle ':completion:*' menu select
+## Auto complete with case insensitivity
+#zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
+
+#zmodload zsh/complist
+#fpath+=/home/dt/.config/zsh/comp
+#compinit
+#_comp_options+=(globdots)		# Include hidden files.
+#
+## Source configs
+#source "${ZDOTDIR}/ali.sh"
+#source "${ZDOTDIR}/prompt.sh"
+#source "${ZDOTDIR}/hotkeys.sh"
+#source "./${path_custom_cursor}"
+#source ~/.local/lib/shell/lib
+#
+## Load zsh-syntax-highlighting
+#source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
+## Suggest aliases for commands
+#source /usr/share/zsh/plugins/zsh-you-should-use/you-should-use.plugin.zsh
+#
+##eval "$(lua ~/scripts/z.lua --init zsh enhanced)"
diff --git a/hm/soispha/conf/zsh/config/zsh-prompt.sh b/hm/soispha/conf/zsh/config/zsh-prompt.sh
new file mode 100644
index 00000000..26d478ef
--- /dev/null
+++ b/hm/soispha/conf/zsh/config/zsh-prompt.sh
@@ -0,0 +1,63 @@
+#vim:ft=zsh
+_command_time_preexec() {
+    timer=${timer:-$SECONDS}
+}
+
+_command_time_precmd() {
+    PROMPT_TMP_DIR=$(mktemp)
+  if [ $timer ]; then
+    ts=$(($SECONDS - $timer))
+    tts=$ts
+    mi=0
+    ho=0
+    if [ $ts -ge 3 ];then
+        while [ $ts -ge 60 ];do
+            ts=$((ts-60))
+            mi=$((mi+1))
+        done
+
+        while [ $mi -ge 60 ];do
+            mi=$((mi-60))
+            ho=$((ho+1))
+        done
+
+        if [ $tts -ge 3600 ];then
+            out=$(printf '%dh %dm %ds\n' $ho $mi $ts)
+        elif [ $tts -ge 60 ];then
+            out=$(printf '%dm %ds\n' $mi $ts)
+        elif [ $tts -lt 60 ];then
+             out=$(printf '%ds\n' $ts)
+        fi
+
+    export psvar[1]="took $(printf '%s ' "$out")"
+    echo $psvar[1] > $PROMPT_TMP_DIR
+    fi
+
+    unset timer
+    unset ts
+    unset tts
+    unset mi
+    unset ho
+fi
+}
+
+_command_ro_precmd() {
+if ! [ -w $(pwd) ];then
+    echo " "
+fi
+}
+
+preexec_functions+=(_command_time_preexec)
+precmd_functions+=(_command_time_precmd)
+
+blue="14"
+red="9"
+white="15"
+setopt PROMPT_SUBST
+export PROMPT='%(?.%F{$blue}.%F{$red})%B%3~%(!. %F{$red}as root %f. )%F{$white}$(if [ -n $PROMPT_TMP_DIR ];then cat $PROMPT_TMP_DIR 2>/dev/null; rm $PROMPT_TMP_DIR 2>/dev/null;fi)%f%(?.%F{$blue}.%F{$red})%F{$red}$(_command_ro_precmd)%F{$blue}❯ %b%f'
+export RPROMPT=''
+
+#%(2V.%F{$red}%2v%f$(export psvar[2]="") .)
+
+# TODO::
+# Add git support