Compare commits

..

No commits in common. "master" and "0.1.0" have entirely different histories.

16 changed files with 77 additions and 203 deletions

View file

@ -1,6 +1,5 @@
The MIT License (MIT)
Copyright (c) 2017 Chloe Kudryavtsev
Copyright (c) 2019 George Rawlinson <mailto:george@rawlinson.net.nz>
Permission is hereby granted, free of charge, to any person obtaining a copy

View file

@ -1,23 +1,13 @@
#
# coloured-man
#
# https://wiki.archlinux.org/index.php/Color_output_in_console#man
if [[ -v OSTYPE ]]; then
if [[ "$OSTYPE" == "linux"* ]]; then
export MANPAGER="less -R --use-color -Dd+r -Du+b"
elif [[ "$OSTYPE" == "darwin"* ]]; then
man() {
LESS_TERMCAP_md=$'\e[01;31m' \
LESS_TERMCAP_me=$'\e[0m' \
LESS_TERMCAP_se=$'\e[0m' \
LESS_TERMCAP_so=$'\e[01;44;33m' \
LESS_TERMCAP_ue=$'\e[0m' \
LESS_TERMCAP_us=$'\e[01;32m' \
command man "$@"
}
fi
fi
# colour output in man
# source: https://wiki.archlinux.org/index.php/Color_output_in_console#man
man() {
LESS_TERMCAP_md=$'\e[01;31m' \
LESS_TERMCAP_me=$'\e[0m' \
LESS_TERMCAP_se=$'\e[0m' \
LESS_TERMCAP_so=$'\e[01;44;33m' \
LESS_TERMCAP_ue=$'\e[0m' \
LESS_TERMCAP_us=$'\e[01;32m' \
command man "$@"
}
# vim: ft=zsh expandtab tabstop=2 shiftwidth=2

View file

@ -1,24 +0,0 @@
#
# npm
#
# Install NPM packages globally without requiring sudo
# https://github.com/sindresorhus/guides/blob/master/npm-global-without-sudo.md
if command -v npm &> /dev/null; then
# Use XDG dirs
export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME/npm/config"
export NPM_CONFIG_CACHE="$XDG_CACHE_HOME/npm"
export NPM_CONFIG_TMP="$XDG_RUNTIME_DIR/npm"
export NPM_CONFIG_PREFIX="$XDG_DATA_HOME/npm"
# add npm binary directory to PATH
path+=("$NPM_CONFIG_PREFIX/bin")
export PATH
# Rare, but some npm packages install man pages...
MANPATH="$NPM_CONFIG_PREFIX/share/man:$(manpath)"
export MANPATH
fi
# vim: ft=zsh expandtab tabstop=2 shiftwidth=2

View file

@ -1,12 +0,0 @@
#
# pyenv
#
# Add pyenv binary directory to PATH
if command -v pyenv &> /dev/null; then
export PYENV_ROOT="$HOME/.cache/pyenv"
PATH="$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH"
export PATH
fi
# vim: ft=zsh expandtab tabstop=2 shiftwidth=2

View file

@ -1,11 +0,0 @@
#
# ruby
#
# Add rubygem binary directory to PATH
if command -v ruby &> /dev/null; then
path+=("$(ruby -e "puts Gem.user_dir")/bin")
export PATH
fi
# vim: ft=zsh expandtab tabstop=2 shiftwidth=2

View file

@ -1,16 +0,0 @@
#
# rust
#
# Add Cargo binary directory to PATH
if command -v cargo &> /dev/null; then
# set CARGO_HOME if not set
if [ -z "${CARGO_HOME}" ]; then
export CARGO_HOME="$HOME/.cargo"
fi
path+=("$CARGO_HOME/bin")
export PATH
fi
# vim: ft=zsh expandtab tabstop=2 shiftwidth=2

View file

@ -1,11 +1,14 @@
#
# sudo will be inserted before the current command
#
sudo-command-line() {
[[ -z $BUFFER ]] && zle up-history
if [[ $BUFFER == sudo\ * ]]; then
LBUFFER="${LBUFFER#sudo }"
elif [[ $BUFFER == $EDITOR\ * ]]; then
LBUFFER="${LBUFFER#$EDITOR }"
LBUFFER="sudoedit $LBUFFER"
elif [[ $BUFFER == sudoedit\ * ]]; then
LBUFFER="${LBUFFER#sudoedit }"
LBUFFER="$EDITOR $LBUFFER"
else
LBUFFER="sudo $LBUFFER"
fi

View file

@ -1,9 +1,7 @@
#
# aliases
#
# redirect history to STDOUT with correct timestamps
alias history='fc -il 1'
# common aliases
alias grep='grep --color=auto'
alias diff='diff --color=auto'
alias history='fc -il 1' # redirect history to STDOUT with correct timestamps
# safe(r) interactive commands
alias rm='rm -i'
@ -11,21 +9,10 @@ alias cp='cp -i'
alias mv='mv -i'
# ls
if [[ -v OSTYPE ]]; then
if [[ "$OSTYPE" == "linux"* ]]; then
alias ls='ls --color=auto --human-readable --group-directories-first'
elif [[ "$OSTYPE" == "darwin"* ]]; then
# check for coreutils presence, otherwise we're using bsd ls
if command -v gls &> /dev/null; then
alias ls='gls --color=auto --human-readable --group-directories-first'
else
alias ls='ls -G'
fi
fi
fi
alias l='ls -l'
alias la='ls -la'
alias lr='ls -lR'
alias ls='ls --color=auto --human-readable --group-directories-first'
alias l='ls --classify -l'
alias la='ls --classify -la'
alias lr='ls --classify -tR'
# directories
setopt AUTO_CD # prefix command with 'cd' if it cannot be executed, e.g. '..' becomes 'cd ..'
@ -53,10 +40,6 @@ if command -v git &> /dev/null; then
# push/pull
alias gp='git push'
alias gl='git pull'
# diff
alias gd='git diff'
alias gdca='git diff --cached'
fi
# pacman
@ -84,6 +67,8 @@ if command -v pacman &> /dev/null; then
LC_ALL=C pacman -Qei $(pacman -Qu | cut -d " " -f 1) | \
awk 'BEGIN {FS=":"} /^Name/{printf("\033[1;36m%s\033[1;37m", $2)} /^Description/{print $2}'
}
export CHROOT="${XDG_CACHE_HOME}/chroot"
fi
# vim: ft=zsh expandtab tabstop=2 shiftwidth=2

View file

@ -1,9 +1,4 @@
#
# key bindings
#
# set emacs mode
bindkey -e
# create a zkbd compatible hash;
# to add other keys to this hash, see: man 5 terminfo
@ -35,12 +30,9 @@ zle -N down-line-or-beginning-search
[[ -n "${key[PageUp]}" ]] && bindkey -- "${key[PageUp]}" up-line-or-history
[[ -n "${key[PageDown]}" ]] && bindkey -- "${key[PageDown]}" down-line-or-history
[[ -n "${key[ShiftTab]}" ]] && bindkey -- "${key[ShiftTab]}" reverse-menu-complete
bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - move forward one word
bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - move backward one word
# Finally, make sure the terminal is in application mode, when zle is
# active. Only then are the values from $terminfo valid.
# make sure the terminal is in application mode when zle is active
# only then are the values from $terminfo valid
if (( ${+terminfo[smkx]} && ${+terminfo[rmkx]} )); then
autoload -Uz add-zle-hook-widget
zle_application_mode_start() {

View file

@ -1,6 +1,4 @@
#
# completion configuration
#
# have the menu highlight as we cycle through options
zstyle ':completion:*' menu select
@ -20,8 +18,8 @@ setopt COMPLETE_ALIASES
# complete . and .. special directories
zstyle ':completion:*' special-dirs true
# enable caching so that commands like apt and dpkg are completeable
# use caching so that commands like apt and dpkg complete are useable
zstyle ':completion::complete:*' use-cache 1
zstyle ':completion::complete:*' cache-path "${ZCACHEDIR}"
zstyle ':completion::complete:*' cache-path "{$ZCACHEDIR}"
# vim: ft=zsh expandtab tabstop=2 shiftwidth=2

View file

@ -1,12 +1,13 @@
#
# environment variables
#
# locale [en_NZ]
export LANG='en_NZ.UTF-8'
export LC_ALL='en_NZ.UTF-8'
# set default pager
# set default values
export EDITOR='nvim'
export PAGER='less'
export LESS='-R'
# ensure less does not generate history file
# less - disable histfile generation
export LESSHISTFILE='/dev/null'
# vim: ft=zsh expandtab tabstop=2 shiftwidth=2

View file

@ -9,9 +9,7 @@
# It is important that this environment variable always reflects the out
# put of the tty command.
if command -v gpg-agent &> /dev/null; then
GPG_TTY=$(tty)
export GPG_TTY
fi
GPG_TTY=$(tty)
export GPG_TTY
# vim: ft=zsh expandtab tabstop=2 shiftwidth=2

View file

@ -1,11 +1,9 @@
#
# zsh-specific options
#
# general
setopt NO_BEEP # disable terminal beep
setopt MULTI_OS # pipe to multiple outputs
setopt INTERACTIVE_COMMENTS # allow comments in interactive shell
setopt VI # vi-like keybindings
#setopt KSH_ARRAYS # whoever thought non-0 indices needs to be shot
# globbing
setopt NO_CASE_GLOB # case insensitive globbing
@ -13,17 +11,17 @@ setopt EXTENDED_GLOB # enable zsh globbing features
setopt NUMERIC_GLOB_SORT # sort globs numerically, not by letter
# history
HISTSIZE=100000 # set history size to 100K
SAVEHIST="${HISTSIZE}" # cap history size at 100K
setopt EXTENDED_HISTORY # record timestamp on command in HISTFILE
setopt HIST_EXPIRE_DUPS_FIRST # delete duplicates first when HISTFILE > HISTSIZE
setopt APPEND_HISTORY # ignore duplicate commands in history list
setopt HIST_FIND_NO_DUPS # when searching history don't display results already cycled through twice
setopt HIST_IGNORE_SPACE # ignore commands that start with space
setopt HIST_VERIFY # show command with history expansion to user before running it
setopt SHARE_HISTORY # shares history across multiple zsh sessions, in real time
setopt HIST_IGNORE_ALL_DUPS # do not write commands to history that are duplicates of the previous command
setopt HIST_REDUCE_BLANKS # remove erroneous blanks from commands before appending to history
HISTSIZE=100000 # set history size to 100K
SAVEHIST="${HISTSIZE}" # cap history size at 100K
setopt EXTENDED_HISTORY # record timestamp on command in HISTFILE
setopt HIST_EXPIRE_DUPS_FIRST # delete duplicates first when HISTFILE > HISTSIZE
setopt APPEND_HISTORY # ignore duplicate commands in history list
setopt HIST_FIND_NO_DUPS # when searching history don't display results already cycled through twice
setopt HIST_IGNORE_SPACE # ignore commands that start with space
setopt HIST_VERIFY # show command with history expansion to user before running it
setopt SHARE_HISTORY # shares history across multiple zsh sessions, in real time
setopt HIST_IGNORE_ALL_DUPS # do not write commands to history that are duplicates of the previous command
setopt HIST_REDUCE_BLANKS # remove erroneous blanks from commands before appending to history
# create history file
[ -z "${HISTFILE}" ] && HISTFILE="${ZCACHEDIR}/zhistory"

View file

@ -1,28 +0,0 @@
#
# xdg base directory variables
#
# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
if [ -z "${XDG_CONFIG_HOME}" ]; then
export XDG_CONFIG_HOME="${HOME}/.config"
fi
if [ -z "${XDG_CACHE_HOME}" ]; then
export XDG_CACHE_HOME="${HOME}/.cache"
fi
if [ -z "${XDG_DATA_HOME}" ]; then
export XDG_DATA_HOME="${HOME}/.local/share"
fi
if [ -z "${XDG_STATE_HOME}" ]; then
export XDG_STATE_HOME="${HOME}/.local/state"
fi
# XDG_RUNTIME_DIR is set when using pam_systemd
if [[ "$OSTYPE" == "darwin"* ]]; then
export XDG_RUNTIME_DIR=/tmp
fi
# vim: ft=zsh expandtab tabstop=2 shiftwidth=2

9
zshenv
View file

@ -1,15 +1,12 @@
# set environment variables to conform with XDG base directory specification
# set environment variable $ZDOTDIR to $HOME/.config/zsh
export ZDOTDIR="${HOME}/.config/zsh"
# set environment variable $ZCACHEDIR to $HOME/.cache/zsh
export ZCACHEDIR="${HOME}/.cache/zsh"
# set framework location
# set environment variable $ZSYSDIR to /usr/share/zsh-grawlinson
export ZSYSDIR="/usr/share/zsh-grawlinson"
# create missing folders
if [ ! -d "${ZDOTDIR}" ]; then mkdir -p "${ZDOTDIR}"; fi
if [ ! -d "${ZCACHEDIR}" ]; then mkdir -p "${ZCACHEDIR}"; fi
# create empty zshrc if it does not exist
if [ ! -e "${ZDOTDIR}/.zshrc" ]; then touch "${ZDOTDIR}/.zshrc"; fi
# vim: ft=zsh expandtab tabstop=2 shiftwidth=2

40
zshrc
View file

@ -1,11 +1,27 @@
# setup umask [0755]
umask 0022
# ensure there are no duplicates in $PATH
typeset -U PATH path
# spath -> plugins; apath -> drop-in path
typeset -T SPATH spath
typeset -T APATH apath
typeset -U PATH path # discard duplicates
# user files sourced before system files
# completions sourced after the functions they complete
# example: append to path, then make available to child processes
# path+=('$VAR'); export PATH
# default path values
spath=(
"$ZDOTDIR/plugins"
"$ZSYSDIR/plugins"
)
apath=(
"$ZDOTDIR/source"
"$ZSYSDIR/source"
)
# user stuff comes first
# completions come after the functions they complete
fpath+=(
"$ZDOTDIR/functions"
"$ZDOTDIR/completions"
@ -15,23 +31,11 @@ fpath+=(
"$ZSYSDIR/prompts"
)
# drop-in directory (like /etc/zsh.d)
# sourceall iterates over APATH, sourcing every file it finds
typeset -T APATH apath
apath=(
"$ZDOTDIR/source"
"$ZSYSDIR/source"
)
# source every zsh file in every APATH directory
autoload sourceall
sourceall zsh
# plugins (explicitly loaded)
# autosource iterates over SPATH until a matching plugin is found and sourced
typeset -T SPATH spath
spath=(
"$ZDOTDIR/plugins"
"$ZSYSDIR/plugins"
)
# plugins
autoload autosource
autosource coloured-man
autosource sudo