summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormhsn <mail@mhsn.net>2024-07-20 15:59:03 +0100
committermhsn <mail@mhsn.net>2024-07-20 15:59:03 +0100
commit7ab77f06d87f436d834ad616643147ad9633943b (patch)
tree8dbf15ce4cca94d0826c83b96f8a3b49ec818cf6
downloaddotfiles-7ab77f06d87f436d834ad616643147ad9633943b.tar.gz
dotfiles-7ab77f06d87f436d834ad616643147ad9633943b.zip
Add .zshrc
-rw-r--r--.zshrc71
1 files changed, 71 insertions, 0 deletions
diff --git a/.zshrc b/.zshrc
new file mode 100644
index 0000000..0fb5c18
--- /dev/null
+++ b/.zshrc
@@ -0,0 +1,71 @@
+# [name@machine ~/some/dir]$ for non-root
+# [machine ~/some/dir]# for root (but in red)
+# Also includes error code between ]$
+PS1="%B%(!.%F{red}.%F{cyan})[%(!..%F{green}%n%F{cyan}@%F{magenta})%M %(!.%F{default}.%F{green})%~%(!.%F{red}.%F{cyan})]%(?.. %F{red}%? )%f%b%(!.#.$) "
+
+# Some coloured commands
+alias ls='ls --color=auto'
+alias grep='grep --color=auto'
+
+# History
+HISTSIZE=10000
+HISTFILE=~/.history
+SAVEHIST=$HISTSIZE
+setopt hist_ignore_space
+
+# Environment variables
+LANG=en_GB.UTF-8
+
+# Autocompletion and tabcompletion
+autoload -U compinit
+zstyle ':completion:*' menu select
+zmodload zsh/complist
+compinit
+_comp_options+=(globdots)
+
+# vi mode
+bindkey -v
+export KEYTIMEOUT=1
+
+# Use vim keys in tab completion menu
+bindkey -M menuselect 'h' vi-backward-char
+bindkey -M menuselect 'k' vi-up-line-or-history
+bindkey -M menuselect 'l' vi-forward-char
+bindkey -M menuselect 'j' vi-down-line-or-history
+
+# 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
+zle-line-init() {
+ zle -K viins
+ echo -ne "\e[5 q"
+}
+zle -N zle-line-init
+echo -ne '\e[5 q'
+
+preexec() { echo -ne '\e[5 q' ;}
+
+# Bind Ctrl-R to reverse history search
+bindkey '^R' history-incremental-search-backward
+# Bind Delete to delete
+bindkey '^[[3~' backward-delete-char
+# Bind Ctrl-Left, Ctrl-Right to noob navigation
+bindkey '^[[1;5C' forward-word
+bindkey '^[[1;5D' backward-word
+bindkey -M vicmd '^[[1;5C' forward-word
+bindkey -M vicmd '^[[1;5D' backward-word
+
+# Syntax highlighting plugin
+source /usr/share/zsh/site-functions/zsh-syntax-highlighting.zsh
+