summaryrefslogtreecommitdiff
path: root/zsh
diff options
context:
space:
mode:
Diffstat (limited to 'zsh')
-rw-r--r--zsh/.zshrc1
-rw-r--r--zsh/00_params.zsh15
-rw-r--r--zsh/01_env.zsh15
-rw-r--r--zsh/02_settings.zsh36
-rw-r--r--zsh/Functions/_uri58
-rw-r--r--zsh/Functions/memoize11
-rw-r--r--zsh/aliases.zsh7
-rw-r--r--zsh/completion.zsh23
-rw-r--r--zsh/dircolors141
-rw-r--r--zsh/functions.zsh27
-rw-r--r--zsh/keys.zsh18
-rw-r--r--zsh/zkbd/st-256color-unknown-linux-gnu28
12 files changed, 380 insertions, 0 deletions
diff --git a/zsh/.zshrc b/zsh/.zshrc
new file mode 100644
index 0000000..d9499b6
--- /dev/null
+++ b/zsh/.zshrc
@@ -0,0 +1 @@
+for cfg ($ZDOTDIR/*.zsh) source $cfg
diff --git a/zsh/00_params.zsh b/zsh/00_params.zsh
new file mode 100644
index 0000000..15b8e3e
--- /dev/null
+++ b/zsh/00_params.zsh
@@ -0,0 +1,15 @@
+PROMPT='%F{249}%D{%H}%F{245}%D{%M}%F{242}%D{%S} %F{red}%n%f@%F{blue}%m%f %F{yellow}%1~%f %(!.#.$) '
+
+FCEDIT=$VISUAL
+HISTFILE=$XDG_DATA_HOME/zsh/history
+HISTSIZE=10000
+SAVEHIST=10000000
+REPORTTIME=60
+
+fpath=($ZDOTDIR/Functions $fpath)
+path=($HOME/bin /usr/bin/vendor_perl $path)
+
+# Expand ~zsh to $ZDOTDIR
+hash -d zsh=$ZDOTDIR
+# Same for vim
+hash -d vim=$XDG_CONFIG_HOME/vim
diff --git a/zsh/01_env.zsh b/zsh/01_env.zsh
new file mode 100644
index 0000000..a3886ce
--- /dev/null
+++ b/zsh/01_env.zsh
@@ -0,0 +1,15 @@
+EDITOR="ed -p:"
+VISUAL=vim
+SUDO_EDITOR="vim -Z"
+MANPAGER="vim -M +MANPAGER -"
+PAGER=vimpager
+BROWSER=qutebrowser
+TERMINAL=st
+VIMINIT="let \$MYVIMRC = '$XDG_CONFIG_HOME/vim/main.vim' | source \$MYVIMRC"
+VIMPAGER_RC="$XDG_CONFIG_HOME/vim/main.vim"
+PERLDOC_PAGER=vimpager
+PERLTIDY=$XDG_CONFIG_HOME/perltidy
+
+export EDITOR VISUAL SUDO_EDITOR MANPAGER PAGER BROWSER TERMINAL VIMINIT PERLDOC_PAGER VIMPAGER_RC PERLTIDY
+eval $(dircolors -b)
+eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
diff --git a/zsh/02_settings.zsh b/zsh/02_settings.zsh
new file mode 100644
index 0000000..b4cd758
--- /dev/null
+++ b/zsh/02_settings.zsh
@@ -0,0 +1,36 @@
+# Changing Directories
+setopt auto_cd
+setopt auto_pushd
+setopt pushd_ignore_dups
+setopt pushd_minus
+setopt pushd_silent
+# Completion
+setopt glob_complete
+setopt list_packed
+# Expansion and Globbing
+unsetopt case_glob
+setopt extended_glob
+setopt glob_star_short
+setopt magic_equal_subst
+setopt warn_create_global
+# History
+setopt hist_fcntl_lock
+setopt hist_ignore_all_dups
+setopt hist_reduce_blanks
+setopt hist_save_no_dups
+setopt share_history
+# Input/Output
+setopt interactive_comments
+setopt print_exit_value
+# Job Control
+setopt auto_continue
+setopt long_list_jobs
+# Scripts and Functions
+setopt c_bases
+setopt c_precedences
+setopt local_loops
+setopt pipe_fail
+# Shell Emulation
+setopt csh_junkie_loops
+# Zle
+unsetopt beep
diff --git a/zsh/Functions/_uri b/zsh/Functions/_uri
new file mode 100644
index 0000000..40d1811
--- /dev/null
+++ b/zsh/Functions/_uri
@@ -0,0 +1,58 @@
+compdef uri
+
+local uri_commands
+uri_commands=( \
+ create change scheme has_recognized_scheme \
+ opaque path fragment as_string as_iri canonical \
+ secure authority path path_query query userinfo host \
+ ihost port host_port default_port \
+ media_type data \
+ file dir \
+ user password \
+ gopher_type selector search string \
+ dn attributes scope filter extensions \
+ un_path \
+ to headers \
+ group message \
+ nid nss )
+
+_arguments \
+ '1: :->cmds' \
+ '*:: :->args'
+
+
+case $state in
+ (cmds)
+ _values 'uri commands' $uri_commands
+ ;;
+ (args)
+ _arguments \
+ '--scheme=-:' \
+ '--path=-:' \
+ '--opaque=-[Opaque portion of URI (between scheme: and fragment)]:' \
+ '--fragment=-[Escaped URI fragment (#foo)]:' \
+ '--authority=-:' \
+ '--query=-[Escaped query component]:' \
+ '--userinfo=-[e.g. username:password]:' \
+ '--port=-:' \
+ '--host_port=-[host:port]:' \
+ '--media_type=-[Media type for data: URIs]:' \
+ '--data=-[Data for data: URIs]:' \
+ '--file=-[File for file:, ftp:, etc.]:' \
+ '--gopher_type=-:' \
+ '--selector=-[Gopher selector]:' \
+ '--search=-[Gopher query]:' \
+ '--string=-[Gopher string]:' \
+ '--dn=-[LDAP DN]' \
+ '--attributes=-[LDAP attributes]' \
+ '--scope=-[LDAP search scope]:' \
+ '--extensions=-[LDAP extensions]:' \
+ '--un_path=-[Local socket path for ldapi]:' \
+ '--to=-[Address for mailto:]:' \
+ '--headers=-[mailto: headers]:' \
+ '--group=-[Newsgroup]:' \
+ '--message=-[Newsgroup message]:' \
+ '--nid=-[Namespace identifier for urn:]:' \
+ '--nss=-[Namespace-specific string for urn:]:'
+ ;;
+esac
diff --git a/zsh/Functions/memoize b/zsh/Functions/memoize
new file mode 100644
index 0000000..c58e65d
--- /dev/null
+++ b/zsh/Functions/memoize
@@ -0,0 +1,11 @@
+if ((! $+MEMOIZE)) {
+ declare -Ag MEMOIZE
+}
+
+if (($+MEMOIZE[$*])) {
+ printf '%s' "$MEMOIZE[$*]"
+ return
+}
+
+MEMOIZE[$*]=$(eval $*)
+printf '%s' "$MEMOIZE[$*]"
diff --git a/zsh/aliases.zsh b/zsh/aliases.zsh
new file mode 100644
index 0000000..fcc87c6
--- /dev/null
+++ b/zsh/aliases.zsh
@@ -0,0 +1,7 @@
+alias -g ...='../..'
+alias -g ....='../../..'
+
+alias chmod='chmod -c'
+alias grep='grep --color'
+alias ls='ls --color -A'
+alias l='ls --color -Althur'
diff --git a/zsh/completion.zsh b/zsh/completion.zsh
new file mode 100644
index 0000000..6baf129
--- /dev/null
+++ b/zsh/completion.zsh
@@ -0,0 +1,23 @@
+zstyle ':completion:*' completer _expand _complete _ignored _match _approximate _prefix
+zstyle ':completion:*' completions 1
+zstyle ':completion:*' format 'Completing %d'
+zstyle ':completion:*' glob 1
+zstyle ':completion:*' group-name ''
+zstyle ':completion:*' list-colors ''
+zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
+zstyle ':completion:*' matcher-list '' 'r:|[._-]=** r:|=**' '+m:{[:lower:]}={[:upper:]}' '+l:|=* r:|=*'
+zstyle ':completion:*' max-errors 2 numeric
+zstyle ':completion:*' menu select=1
+zstyle ':completion:*' prompt 'corrections? (%e)'
+zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
+zstyle ':completion:*' substitute 1
+zstyle ':completion:*' verbose true
+zstyle ':completion:*' use-cache on
+zstyle ':completion:*' cache-path $XDG_CACHE_HOME/zsh
+zstyle ':completion:*:functions' ignored-patterns '_*'
+zstyle ':completion:*:kill:*' force-list always
+zstyle ':completion:*:cd:*' ignore-parents parent pwd
+zstyle :compinstall filename '/home/nick/cfg/zsh/completion.zsh'
+
+autoload -Uz compinit
+compinit
diff --git a/zsh/dircolors b/zsh/dircolors
new file mode 100644
index 0000000..e64f1a4
--- /dev/null
+++ b/zsh/dircolors
@@ -0,0 +1,141 @@
+# Configuration file for dircolors, a utility to help you set the
+# LS_COLORS environment variable used by GNU ls with the --color option.
+# Copyright (C) 1996-2016 Free Software Foundation, Inc.
+# Copying and distribution of this file, with or without modification,
+# are permitted provided the copyright notice and this notice are preserved.
+# The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the
+# slackware version of dircolors) are recognized but ignored.
+# Below are TERM entries, which can be a glob patterns, to match
+# against the TERM environment variable to determine if it is colorizable.
+TERM Eterm
+TERM ansi
+TERM *color*
+TERM con[0-9]*x[0-9]*
+TERM cons25
+TERM console
+TERM cygwin
+TERM dtterm
+TERM gnome
+TERM hurd
+TERM jfbterm
+TERM konsole
+TERM kterm
+TERM linux
+TERM linux-c
+TERM mlterm
+TERM putty
+TERM rxvt*
+TERM screen*
+TERM st
+TERM terminator
+TERM tmux*
+TERM vt100
+TERM xterm*
+# Below are the color init strings for the basic file types. A color init
+# string consists of one or more of the following numeric codes:
+# Attribute codes:
+# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
+# Text color codes:
+# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
+# Background color codes:
+# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
+#NORMAL 00 # no color code at all
+#FILE 00 # regular file: use no color at all
+RESET 0 # reset to "normal" color
+DIR 01;34 # directory
+LINK 01;36 # symbolic link. (If you set this to 'target' instead of a
+ # numerical value, the color is as for the file pointed to.)
+MULTIHARDLINK 00 # regular file with more than one link
+FIFO 40;33 # pipe
+SOCK 01;35 # socket
+DOOR 01;35 # door
+BLK 40;33;01 # block device driver
+CHR 40;33;01 # character device driver
+ORPHAN 40;31;01 # symlink to nonexistent file, or non-stat'able file ...
+MISSING 00 # ... and the files they point to
+SETUID 37;41 # file that is setuid (u+s)
+SETGID 30;43 # file that is setgid (g+s)
+CAPABILITY 30;41 # file with capability
+STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w)
+OTHER_WRITABLE 1;31 # dir that is other-writable (o+w) and not sticky
+STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable
+# This is for files with execute permission:
+EXEC 01;32
+# List any file extensions like '.gz' or '.tar' that you would like ls
+# to colorize below. Put the extension, a space, and the color init string.
+# (and any comments you want to add after a '#')
+# If you use DOS-style suffixes, you may want to uncomment the following:
+#.cmd 01;32 # executables (bright green)
+#.exe 01;32
+#.com 01;32
+#.btm 01;32
+#.bat 01;32
+# Or if you want to colorize scripts even if they do not have the
+# executable bit actually set.
+#.sh 01;32
+#.csh 01;32
+ # archives or compressed (bright red)
+.tar 01;31
+.tgz 01;31
+.arc 01;31
+.arj 01;31
+.taz 01;31
+.lha 01;31
+.lz4 01;31
+.lzh 01;31
+.lzma 01;31
+.tlz 01;31
+.txz 01;31
+.tzo 01;31
+.t7z 01;31
+.zip 01;31
+.z 01;31
+.Z 01;31
+.dz 01;31
+.gz 01;31
+.lrz 01;31
+.lz 01;31
+.lzo 01;31
+.xz 01;31
+.zst 01;31
+.tzst 01;31
+.bz2 01;31
+.bz 01;31
+.tbz 01;31
+.tbz2 01;31
+.tz 01;31
+.deb 01;31
+.rpm 01;31
+.jar 01;31
+.war 01;31
+.ear 01;31
+.sar 01;31
+.rar 01;31
+.alz 01;31
+.ace 01;31
+.zoo 01;31
+.cpio 01;31
+.7z 01;31
+.rz 01;31
+.cab 01;31
+# audio formats
+.aac 00;36
+.au 00;36
+.flac 00;36
+.m4a 00;36
+.mid 00;36
+.midi 00;36
+.mka 00;36
+.mp3 00;36
+.mpc 00;36
+.ogg 00;36
+.ra 00;36
+.wav 00;36
+# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions
+.oga 00;36
+.opus 00;36
+.spx 00;36
+.xspf 00;36
+.mk 35
+*Makefile 35
+.pl 5;36;1;4
diff --git a/zsh/functions.zsh b/zsh/functions.zsh
new file mode 100644
index 0000000..6bd9482
--- /dev/null
+++ b/zsh/functions.zsh
@@ -0,0 +1,27 @@
+function mpod {
+ mcpan pod $1 | $PAGER -c 'set ft=perldoc'
+}
+
+function msrc {
+ mcpan src $1 | $PAGER -c 'set ft=perl'
+}
+
+function scratch {
+ local tmp
+ tmp=$(mktemp --suffix=.$1)
+ vim -c 'set ft='$1 $tmp
+ rm $tmp
+}
+
+function note {
+ local note
+ pushd
+ cd ~/notes
+ note=(${(@f)$(fzf --print-query)})
+ if [[ -f $note[2] ]]; then
+ $VISUAL $note[2]
+ else
+ $VISUAL $note[1]
+ fi
+ popd
+}
diff --git a/zsh/keys.zsh b/zsh/keys.zsh
new file mode 100644
index 0000000..f095954
--- /dev/null
+++ b/zsh/keys.zsh
@@ -0,0 +1,18 @@
+KBDFILE=$ZDOTDIR/zkbd/$TERM-$VENDOR-$OSTYPE
+
+[[ -f $KBDFILE ]] && source $KBDFILE
+
+[[ -n ${key[Left]} ]] && bindkey "${key[Left]}" backward-char
+[[ -n ${key[Right]} ]] && bindkey "${key[Right]}" forward-char
+[[ -n ${key[Backspace]} ]] && bindkey "${key[Backspace]}" backward-delete-char
+[[ -n ${key[Delete]} ]] && bindkey "${key[Delete]}" delete-char
+[[ -n ${key[Up]} ]] && bindkey "${key[Up]}" up-line-or-search
+[[ -n ${key[Down]} ]] && bindkey "${key[Down]}" down-line-or-search
+[[ -n ${key[Home]} ]] && bindkey "${key[Home]}" beginning-of-line
+[[ -n ${key[End]} ]] && bindkey "${key[End]}" end-of-line
+
+# MOUSES
+[[ -n ${key[ScrollUp]} ]] && bindkey "${key[ScrollUp]}" up-history
+[[ -n ${key[ScrollDown]} ]] && bindkey "${key[ScrollDown]}" down-history
+
+bindkey '^R' history-incremental-search-backward
diff --git a/zsh/zkbd/st-256color-unknown-linux-gnu b/zsh/zkbd/st-256color-unknown-linux-gnu
new file mode 100644
index 0000000..482e37d
--- /dev/null
+++ b/zsh/zkbd/st-256color-unknown-linux-gnu
@@ -0,0 +1,28 @@
+typeset -g -A key
+
+key[F1]='^[OP'
+key[F2]='^[OQ'
+key[F3]='^[OR'
+key[F4]='^[OS'
+key[F5]='^[[15~'
+key[F6]='^[[17~'
+key[F7]='^[[18~'
+key[F8]='^[[19~'
+key[F9]='^[[20~'
+key[F10]='^[[21~'
+key[F11]='^[[23~'
+key[F12]='^[[24~'
+key[Backspace]='^?'
+key[Insert]='^[[4h'
+key[Home]='^[[H'
+key[PageUp]='^[[5~'
+key[Delete]='^[[P'
+key[End]='^[[4~'
+key[PageDown]='^[[6~'
+key[Up]='^[[A'
+key[Left]='^[[D'
+key[Down]='^[[B'
+key[Right]='^[[C'
+key[Menu]=''''
+key[ScrollUp]='^Y'
+key[ScrollDown]='^E'