summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.chezmoiignore3
-rw-r--r--dot_zshrc.tmpl109
2 files changed, 112 insertions, 0 deletions
diff --git a/.chezmoiignore b/.chezmoiignore
new file mode 100644
index 0000000..6188da9
--- /dev/null
+++ b/.chezmoiignore
@@ -0,0 +1,3 @@
+{{- if ne .chezmoi.os "linux" }}
+dot_zshrc.tmpl
+{{ end }}
diff --git a/dot_zshrc.tmpl b/dot_zshrc.tmpl
new file mode 100644
index 0000000..ab8fbb8
--- /dev/null
+++ b/dot_zshrc.tmpl
@@ -0,0 +1,109 @@
+# Enable colors and change prompt:
+autoload -U colors && colors # Load colors
+# PS1="%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magenta]%}%~%{$fg[red]%}]%{$reset_color%}$%b "
+setopt autocd # Automatically cd into typed directory.
+stty stop undef # Disable ctrl-s to freeze terminal.
+setopt interactive_comments
+
+# History in cache directory:
+HISTSIZE=10000000
+SAVEHIST=10000000
+
+# Add ~/.local/bin to $PATH
+export PATH="$PATH:$HOME/.local/bin"
+
+# Basic auto/tab complete:
+autoload -U compinit
+zstyle ':completion:*' menu select
+zmodload zsh/complist
+compinit
+_comp_options+=(globdots) # Include hidden files.
+
+# vi mode
+bindkey -v
+export KEYTIMEOUT=1
+
+# Use vim keys in tab complete 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
+bindkey -v '^?' backward-delete-char
+
+# Change cursor shape for different vi modes.
+function zle-keymap-select () {
+ case $KEYMAP in
+ vicmd) echo -ne '\e[1 q';; # block
+ viins|main) echo -ne '\e[5 q';; # beam
+ esac
+}
+zle -N zle-keymap-select
+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.
+preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt.
+
+# Use lf to switch directories and bind it to ctrl-o
+lfcd () {
+ tmp="$(mktemp)"
+ lf -last-dir-path="$tmp" "$@"
+ if [ -f "$tmp" ]; then
+ dir="$(cat "$tmp")"
+ rm -f "$tmp" >/dev/null
+ [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir"
+ fi
+}
+bindkey -s '^o' 'lfcd\n'
+
+bindkey -s '^a' 'bc -lq\n'
+
+bindkey -s '^f' 'cd "$(dirname "$(fzf)")"\n'
+
+bindkey '^[[P' delete-char
+
+# Edit line in vim with ctrl-e:
+autoload edit-command-line; zle -N edit-command-line
+bindkey '^e' edit-command-line
+
+
+### ALIASES ###
+
+
+# Use neovim for vim if present.
+[ -x "$(command -v nvim)" ] && alias vim="nvim" vimdiff="nvim -d"
+
+# Verbosity and settings that you pretty much just always are going to want.
+alias \
+ cp="cp -iv" \
+ mv="mv -iv" \
+ rm="rm -vI" \
+ bc="bc -ql" \
+ mkd="mkdir -pv" \
+ ffmpeg="ffmpeg -hide_banner"
+
+# Colorize commands when possible.
+alias \
+ ls="ls -hN --color=auto --group-directories-first" \
+ grep="grep --color=auto" \
+ diff="diff --color=auto" \
+ ip="ip -color=auto"
+
+# These common commands are just too long! Abbreviate them.
+alias \
+ ka="killall" \
+ g="git" \
+ e="$EDITOR" \
+ v="$EDITOR" \
+
+# Changing "ls" to "exa"
+alias ls='exa -al --color=always --group-directories-first' # my preferred listing
+alias la='exa -a --color=always --group-directories-first' # all files and dirs
+alias ll='exa -l --color=always --group-directories-first' # long format
+alias lt='exa -aT --color=always --group-directories-first' # tree listing
+alias l.='exa -a | egrep "^\."'
+
+# Load Starship
+eval "$(starship init zsh)"