Compare commits
23 commits
Author | SHA1 | Date | |
---|---|---|---|
33ce3aa836 | |||
9f3b8c5de8 | |||
9cf5287c49 | |||
75fb0068a0 | |||
f6002e0668 | |||
a3f9c9f462 | |||
63dc963b00 | |||
e6776b9564 | |||
1975a585c0 | |||
f3ae58d3eb | |||
9061406734 | |||
29a2860649 | |||
51e5d74b70 | |||
2688ff59a1 | |||
a9bec11e31 | |||
7b205e5b2b | |||
3dd89cd9bf | |||
6157aa7c2c | |||
fb2394591b | |||
04f520aa1d | |||
42663a579e | |||
385527ed4c | |||
5389285e02 |
16 changed files with 203 additions and 77 deletions
1
LICENSE
1
LICENSE
|
@ -1,5 +1,6 @@
|
|||
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
|
||||
|
|
|
@ -1,13 +1,23 @@
|
|||
# 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 "$@"
|
||||
}
|
||||
#
|
||||
# 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
|
||||
|
||||
# vim: ft=zsh expandtab tabstop=2 shiftwidth=2
|
||||
|
|
24
plugins/npm
Normal file
24
plugins/npm
Normal file
|
@ -0,0 +1,24 @@
|
|||
#
|
||||
# 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
|
12
plugins/pyenv
Normal file
12
plugins/pyenv
Normal file
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# 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
|
11
plugins/ruby
Normal file
11
plugins/ruby
Normal file
|
@ -0,0 +1,11 @@
|
|||
#
|
||||
# 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
|
16
plugins/rust
Normal file
16
plugins/rust
Normal file
|
@ -0,0 +1,16 @@
|
|||
#
|
||||
# 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
|
|
@ -1,14 +1,11 @@
|
|||
#
|
||||
# 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
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
# common aliases
|
||||
alias grep='grep --color=auto'
|
||||
alias diff='diff --color=auto'
|
||||
alias history='fc -il 1' # redirect history to STDOUT with correct timestamps
|
||||
#
|
||||
# aliases
|
||||
#
|
||||
|
||||
# redirect history to STDOUT with correct timestamps
|
||||
alias history='fc -il 1'
|
||||
|
||||
# safe(r) interactive commands
|
||||
alias rm='rm -i'
|
||||
|
@ -9,10 +11,21 @@ alias cp='cp -i'
|
|||
alias mv='mv -i'
|
||||
|
||||
# ls
|
||||
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'
|
||||
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'
|
||||
|
||||
# directories
|
||||
setopt AUTO_CD # prefix command with 'cd' if it cannot be executed, e.g. '..' becomes 'cd ..'
|
||||
|
@ -40,6 +53,10 @@ 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
|
||||
|
@ -67,8 +84,6 @@ 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
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
#
|
||||
# key bindings
|
||||
#
|
||||
|
||||
# set emacs mode
|
||||
bindkey -e
|
||||
|
||||
# create a zkbd compatible hash;
|
||||
# to add other keys to this hash, see: man 5 terminfo
|
||||
|
@ -30,9 +35,12 @@ 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
|
||||
|
||||
# make sure the terminal is in application mode when zle is active
|
||||
# only then are the values from $terminfo valid
|
||||
|
||||
# Finally, 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() {
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#
|
||||
# completion configuration
|
||||
#
|
||||
|
||||
# have the menu highlight as we cycle through options
|
||||
zstyle ':completion:*' menu select
|
||||
|
@ -18,8 +20,8 @@ setopt COMPLETE_ALIASES
|
|||
# complete . and .. special directories
|
||||
zstyle ':completion:*' special-dirs true
|
||||
|
||||
# use caching so that commands like apt and dpkg complete are useable
|
||||
# enable caching so that commands like apt and dpkg are completeable
|
||||
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
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
# locale [en_NZ]
|
||||
export LANG='en_NZ.UTF-8'
|
||||
export LC_ALL='en_NZ.UTF-8'
|
||||
#
|
||||
# environment variables
|
||||
#
|
||||
|
||||
# set default values
|
||||
export EDITOR='nvim'
|
||||
# set default pager
|
||||
export PAGER='less'
|
||||
export LESS='-R'
|
||||
|
||||
# less - disable histfile generation
|
||||
# ensure less does not generate history file
|
||||
export LESSHISTFILE='/dev/null'
|
||||
|
||||
# vim: ft=zsh expandtab tabstop=2 shiftwidth=2
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
# It is important that this environment variable always reflects the out‐
|
||||
# put of the tty command.
|
||||
|
||||
GPG_TTY=$(tty)
|
||||
export GPG_TTY
|
||||
if command -v gpg-agent &> /dev/null; then
|
||||
GPG_TTY=$(tty)
|
||||
export GPG_TTY
|
||||
fi
|
||||
|
||||
# vim: ft=zsh expandtab tabstop=2 shiftwidth=2
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
#
|
||||
# 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
|
||||
|
@ -11,17 +13,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"
|
||||
|
|
28
source/xdg.zsh
Normal file
28
source/xdg.zsh
Normal file
|
@ -0,0 +1,28 @@
|
|||
#
|
||||
# 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
9
zshenv
|
@ -1,12 +1,15 @@
|
|||
# set environment variable $ZDOTDIR to $HOME/.config/zsh
|
||||
# set environment variables to conform with XDG base directory specification
|
||||
export ZDOTDIR="${HOME}/.config/zsh"
|
||||
# set environment variable $ZCACHEDIR to $HOME/.cache/zsh
|
||||
export ZCACHEDIR="${HOME}/.cache/zsh"
|
||||
# set environment variable $ZSYSDIR to /usr/share/zsh-grawlinson
|
||||
|
||||
# set framework location
|
||||
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
40
zshrc
|
@ -1,27 +1,11 @@
|
|||
# setup umask [0755]
|
||||
umask 0022
|
||||
|
||||
# spath -> plugins; apath -> drop-in path
|
||||
typeset -T SPATH spath
|
||||
typeset -T APATH apath
|
||||
typeset -U PATH path # discard duplicates
|
||||
# ensure there are no duplicates in $PATH
|
||||
typeset -U PATH path
|
||||
|
||||
# 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
|
||||
# user files sourced before system files
|
||||
# completions sourced after the functions they complete
|
||||
fpath+=(
|
||||
"$ZDOTDIR/functions"
|
||||
"$ZDOTDIR/completions"
|
||||
|
@ -31,11 +15,23 @@ fpath+=(
|
|||
"$ZSYSDIR/prompts"
|
||||
)
|
||||
|
||||
# source every zsh file in every APATH directory
|
||||
# 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"
|
||||
)
|
||||
autoload sourceall
|
||||
sourceall zsh
|
||||
|
||||
# plugins
|
||||
# plugins (explicitly loaded)
|
||||
# autosource iterates over SPATH until a matching plugin is found and sourced
|
||||
typeset -T SPATH spath
|
||||
spath=(
|
||||
"$ZDOTDIR/plugins"
|
||||
"$ZSYSDIR/plugins"
|
||||
)
|
||||
autoload autosource
|
||||
autosource coloured-man
|
||||
autosource sudo
|
||||
|
|
Loading…
Reference in a new issue