From e6a2618400edcddc2a80ef2776871ca01992be03 Mon Sep 17 00:00:00 2001 From: Matt Singleton Date: Sat, 6 Feb 2021 13:39:13 -0600 Subject: big refactor to use XDG base dir spec --- config/dircolors.conf | 91 +++++++++++++++++++++++++++++++++++++++ config/git/config | 38 ++++++++++++++++ config/git/ignore | 11 +++++ config/tmux/tmux.conf | 55 +++++++++++++++++++++++ config/zsh/.zshrc | 3 ++ config/zsh/appearance.zsh | 73 +++++++++++++++++++++++++++++++ config/zsh/behavior.zsh | 65 ++++++++++++++++++++++++++++ config/zsh/completion.zsh | 52 ++++++++++++++++++++++ config/zsh/function-overrides.zsh | 8 ++++ config/zsh/key-bindings.zsh | 6 +++ config/zsh/zshrc | 17 ++++++++ config/zsh/zshrc-local | 23 ++++++++++ 12 files changed, 442 insertions(+) create mode 100644 config/dircolors.conf create mode 100644 config/git/config create mode 100644 config/git/ignore create mode 100644 config/tmux/tmux.conf create mode 100644 config/zsh/.zshrc create mode 100644 config/zsh/appearance.zsh create mode 100644 config/zsh/behavior.zsh create mode 100644 config/zsh/completion.zsh create mode 100644 config/zsh/function-overrides.zsh create mode 100644 config/zsh/key-bindings.zsh create mode 100644 config/zsh/zshrc create mode 100644 config/zsh/zshrc-local (limited to 'config') diff --git a/config/dircolors.conf b/config/dircolors.conf new file mode 100644 index 0000000..cfd5f8d --- /dev/null +++ b/config/dircolors.conf @@ -0,0 +1,91 @@ +# Copyright (C) 1996, 1999-2010 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. + +# +# Colorizable terminals + +TERM Eterm +TERM ansi +TERM color-xterm +TERM con132x25 +TERM con132x30 +TERM con132x43 +TERM con132x60 +TERM con80x25 +TERM con80x28 +TERM con80x30 +TERM con80x43 +TERM con80x50 +TERM con80x60 +TERM cons25 +TERM console +TERM cygwin +TERM dtterm +TERM eterm-color +TERM gnome +TERM gnome-256color +TERM jfbterm +TERM konsole +TERM kterm +TERM linux +TERM linux-c +TERM mach-color +TERM mlterm +TERM putty +TERM rxvt +TERM rxvt-256color +TERM rxvt-cygwin +TERM rxvt-cygwin-native +TERM rxvt-unicode +TERM rxvt-unicode-256color +TERM rxvt-unicode256 +TERM screen +TERM screen-256color +TERM screen-256color-bce +TERM screen-bce +TERM screen-w +TERM screen.rxvt +TERM screen.linux +TERM terminator +TERM vt100 +TERM xterm +TERM xterm-16color +TERM xterm-256color +TERM xterm-88color +TERM xterm-color +TERM xterm-debian + +# +# Generic types + +# 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 + +RESET 0 # reset to "normal" color +DIR 34 # directory +LINK 36 # symbolic link +FIFO 40;33 # pipe +SOCK 35 # socket +DOOR 35 # door +BLK 40;33 # block device driver +CHR 40;33 # character device driver +ORPHAN 40;31 # symlink to nonexistent file, or non-stat'able file +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 34;42 # dir that is other-writable (o+w) and not sticky +STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable +EXEC 32 # executable files + +# +# Extension-based + +#.tar.gz 01;31 diff --git a/config/git/config b/config/git/config new file mode 100644 index 0000000..f68fed8 --- /dev/null +++ b/config/git/config @@ -0,0 +1,38 @@ +[user] + name = Matt Singleton + email = matt@xcolour.net + +[alias] + st = status + ci = commit + br = branch + co = checkout + df = diff + lg = log -p + +[core] + whitespace = trailing-space,space-before-tab,cr-at-eol + editor = vim + autocrlf = input + excludesfile = /Users/matt/.gitignore + pager = less -+$LESS -RSX + +[push] + default = nothing + +[color] + ui = true + +[mergetool] + keepTemporaries = false + prompt = false + +[merge] + tool = meld + +[diff] + tool = meld +[init] + defaultBranch = main +[pull] + ff = only diff --git a/config/git/ignore b/config/git/ignore new file mode 100644 index 0000000..57dd8e6 --- /dev/null +++ b/config/git/ignore @@ -0,0 +1,11 @@ +*.class +*.pyc +*.swo +*.swp +.svn +.swo +*#* +# +.#* +doc/tags +.DS_STORE diff --git a/config/tmux/tmux.conf b/config/tmux/tmux.conf new file mode 100644 index 0000000..b1b98e0 --- /dev/null +++ b/config/tmux/tmux.conf @@ -0,0 +1,55 @@ +# vi bindings +set -g status-keys vi +setw -g mode-keys vi + +# reasonable history buffer +set -g history-limit 10000 + +# status line +setw -g window-status-current-style bright +set -g status-right '#(date "+%H:%M %Z %Y-%m-%d")' +set -g status-style bg=white +set -g status-left " #S@#h " +set -g status-left-length 15 +set -g status-left-style bg=green,fg=white + +# ui +set -g set-titles on +set -g default-terminal "screen-256color" +set -ga terminal-overrides ",xterm-256color:Tc" +set -g pane-border-style fg=white + +# splits +bind | split-window -h +bind \\ split-window -h +bind - split-window -v + +# reversed to match vim split names +bind v select-layout even-horizontal +bind h select-layout even-vertical + +# vim-style resize +bind -r H resize-pane -L 2 +bind -r J resize-pane -D 2 +bind -r K resize-pane -U 2 +bind -r L resize-pane -R 2 + +# vim-style move +bind h select-pane -L +bind j select-pane -D +bind k select-pane -U +bind l select-pane -R + +# unbind arrow keys +unbind Up +unbind Down +unbind Left +unbind Right +unbind M-Up +unbind M-Down +unbind M-Left +unbind M-Right +unbind C-Up +unbind C-Down +unbind C-Left +unbind C-Right diff --git a/config/zsh/.zshrc b/config/zsh/.zshrc new file mode 100644 index 0000000..ee3ebdd --- /dev/null +++ b/config/zsh/.zshrc @@ -0,0 +1,3 @@ +# just a shim to make the real zshrc not hidden +# since zsh doesn't support renaming the config +source "$ZDOTDIR/zshrc" diff --git a/config/zsh/appearance.zsh b/config/zsh/appearance.zsh new file mode 100644 index 0000000..e7132a8 --- /dev/null +++ b/config/zsh/appearance.zsh @@ -0,0 +1,73 @@ +# +# colorize shell programs + +if ls --color -d . &>/dev/null 2>&1; then + alias ls='ls --color=tty' + eval `dircolors ${XDG_CONFIG_HOME:-${HOME}/.config}/dircolors.conf` +else + alias ls='ls -G' + export LSCOLORS="exgxbxdxcxegedxbxgxcxd" +fi + +# grep +export GREP_COLOR='1;32' +alias grep='grep --color=auto' +alias egrep='egrep --color=auto' +alias fgrep='fgrep --color=auto' + +# less +export LESS_TERMCAP_mb=$'\e[0;31m' # begin blinking - red +export LESS_TERMCAP_md=$'\e[0;34m' # begin bold - blue +export LESS_TERMCAP_me=$'\e[0m' # end mode +export LESS_TERMCAP_so=$'\e[30;46m' # begin standout mode - black on cyan +export LESS_TERMCAP_se=$'\e[0m' # end standout mode +export LESS_TERMCAP_us=$'\e[4;33m' # begin underline - yellow underline +export LESS_TERMCAP_ue=$'\e[0m' # end underline + +# +# make a sweet prompt + +autoload colors; colors; +setopt prompt_subst # expansion of color codes, etc. in the prompt + +# print the fully resolved shell command with time stamp +# to be run from zsh's builtin 'preexec' with all arguments passed through ($*) +function theme_preexec () { + echo "($fg[magenta]`date +%r`$reset_color) $fg[cyan]$3$reset_color" +} + +# print the prompt char in red if the last command exited non-zero +function prompt_char { + echo "%(?.$.%{$fg[red]%}$%{$reset_color%})" +} + +function repo_prompt_info { + # git + ref=$(git symbolic-ref HEAD 2> /dev/null || git rev-parse --short HEAD 2> /dev/null) + if [ $? -eq 0 ]; then + #repo=$(basename $(git rev-parse --show-toplevel)) + echo "%{$fg[cyan]%}%{\e[1m%}${ref#refs/heads/}%{$reset_color%}" + return + fi +} + +function workspace_prompt_info { + repo=$(repo_prompt_info) + if [ "$repo" ]; then + echo "[$repo] " + return + fi +} + +# print the hostname in green if local, else red +function hostname_info { + if [[ $ZSH_LOCAL_ENV == "true" ]]; then + echo "%{$fg[green]%}%{$ZSH_HOST_PREFIX%}%m%{$ZSH_HOST_SUFFIX%}%{$reset_color%}" + else + echo "%{$fg[red]%}%{$ZSH_HOST_PREFIX%}%m%{$ZSH_HOST_SUFFIX%}%{$reset_color%}" + fi +} + +# a colorful multiline prompt using the above defined functions +PROMPT=$'%{$fg[yellow]%}%n%{$reset_color%}@$(hostname_info):%{$fg[blue]%}%~%{$reset_color%} +$(workspace_prompt_info)$(prompt_char)%{$reset_color%} ' diff --git a/config/zsh/behavior.zsh b/config/zsh/behavior.zsh new file mode 100644 index 0000000..e7e6b81 --- /dev/null +++ b/config/zsh/behavior.zsh @@ -0,0 +1,65 @@ +# +# execution + +setopt rm_star_wait # wait 10 seconds before accepting 'rm *' confirmation +export REPORTTIME=5 # report timing for any command longer than 5 seconds +unsetopt flowcontrol # disable ^s from freezing the terminal + +# +# history + +HISTFILE="${XDG_DATA_HOME:-${HOME}/.local/share}/zsh/history" +HISTSIZE=10000 +SAVEHIST=10000 + +setopt hist_ignore_all_dups # ignore dups including non-sequential ones +setopt share_history # share command history data between sessions +setopt hist_verify # load hist into command buffer rather than exec immediately + +# +# term support + +# set term title appropriately based on term type +# user@host:current_dir (current_command) +case "$TERM" in + xterm*|rxvt*|screen*|alacritty*) + term_preexec () { + printf '\e]0;%s (%s)\a' ${(%):-'%n@%m:%~'} "$1" + } + term_precmd () { + printf '\e]0;%s\a' ${(%):-'%n@%m:%~'} + } + ;; +esac + +# +# virtualenv + +if [ -e /usr/local/bin/virtualenvwrapper_lazy.sh ]; then + vew=/usr/local/bin/virtualenvwrapper_lazy.sh +elif [ -e /usr/share/virtualenvwrapper/virtualenvwrapper_lazy.sh ]; then + vew=/usr/share/virtualenvwrapper/virtualenvwrapper_lazy.sh +fi + +if [ -n "$vew" ]; then + export VIRTUAL_ENV_DISABLE_PROMPT=true + export WORKON_HOME=~/.virtualenv/envs + source $vew +fi + +# +# draw a horizontal separator + +function hr { + printf "$bg[red]${(l:$COLUMNS:: :)}$reset_color\n" + printf "$bg[yellow]${(l:$COLUMNS:: :)}\n" + printf "$bg[green]${(l:$COLUMNS:: :)}\n" + printf "$bg[cyan]${(l:$COLUMNS:: :)}\n" + printf "$bg[blue]${(l:$COLUMNS:: :)}\n" + printf "$bg[magenta]${(l:$COLUMNS:: :)}$reset_color\n" +} + +# +# less + +export LESS=-i diff --git a/config/zsh/completion.zsh b/config/zsh/completion.zsh new file mode 100644 index 0000000..740e9a3 --- /dev/null +++ b/config/zsh/completion.zsh @@ -0,0 +1,52 @@ +# initialize the completion system +autoload -U compinit +zmodload zsh/complist +compinit -d "${XDG_CACHE_HOME:-${HOME}/.cache}/zsh/zcompdump-${ZSH_VERSION}" + +# complete only after the second consecutive tab +setopt auto_menu + +# use GNU ls color specification for completion menu +zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} + +# use menu selection by default +zstyle ':completion:*:default' menu select + +# custom completion list for processes (just current user's) +zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w" +# special colors for kill completion listing +zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' + +# disable named-directories autocompletion +zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories +cdpath=(.) + +# use /etc/hosts and known_hosts for hostname completion +[ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=() +[ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$( /dev/null && term_preexec $* + type theme_preexec &> /dev/null && theme_preexec $* +} + +precmd () { + type term_precmd &> /dev/null && term_precmd +} diff --git a/config/zsh/key-bindings.zsh b/config/zsh/key-bindings.zsh new file mode 100644 index 0000000..4deac62 --- /dev/null +++ b/config/zsh/key-bindings.zsh @@ -0,0 +1,6 @@ +bindkey -e # use emacs mode +bindkey '^r' history-incremental-search-backward # ctrl-r +bindkey '^[[Z' reverse-menu-complete # shift-tab + +bindkey '\e[3~' delete-char # make sure delete key works +bindkey ' ' magic-space # also do history expansion on space diff --git a/config/zsh/zshrc b/config/zsh/zshrc new file mode 100644 index 0000000..2a0fcf0 --- /dev/null +++ b/config/zsh/zshrc @@ -0,0 +1,17 @@ +export EDITOR=vim +export LANG=en_US.UTF-8 + +if [ -e "$ZDOTDIR/zshrc-local" ]; then + source "$ZDOTDIR/zshrc-local" +fi + +source "$ZDOTDIR/appearance.zsh" +source "$ZDOTDIR/behavior.zsh" +source "$ZDOTDIR/completion.zsh" +source "$ZDOTDIR/key-bindings.zsh" + +# override builtin functions (preexec, precmd, etc.) +source "$ZDOTDIR/function-overrides.zsh" + +# user bin should take absolute priority +export PATH="$HOME/bin:$PATH" diff --git a/config/zsh/zshrc-local b/config/zsh/zshrc-local new file mode 100644 index 0000000..50a16b2 --- /dev/null +++ b/config/zsh/zshrc-local @@ -0,0 +1,23 @@ +# get sbin on the path +#export PATH="/usr/sbin:/sbin:$PATH" + +# move homebrew stuff to the beginning of the search path +#export PATH="/usr/local/bin:/usr/local/sbin:$PATH" +#export MANPATH="/usr/local/man:$MANPATH" +#export PATH="/usr/local/opt/python/libexec/bin:$PATH" +#export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" +#export MANPATH="/usr/local/opt/coreutils/libexec/gnuman:$MANPATH" +#export PATH="/usr/local/opt/findutils/libexec/gnubin:$PATH" +#export MANPATH="/usr/local/opt/findutils/libexec/gnuman:$MANPATH" +#export PATH="/usr/local/opt/grep/libexec/gnubin:$PATH" +#export MANPATH="/usr/local/opt/grep/libexec/gnuman:$MANPATH" + +# Java +#export JAVA_HOME="$(/usr/libexec/java_home -v 1.8)" + +# start the ssh agent on login and stop on logout +#eval `ssh-agent -s` +#trap 'eval `ssh-agent -k`' 0 + +# prompt hostname is highlighted in red for non-local envs +export ZSH_LOCAL_ENV=true -- cgit v1.2.3