From e9dc4c1090abb01317847c417b75d3960f3da34d Mon Sep 17 00:00:00 2001 From: Matt Singleton Date: Fri, 3 Feb 2023 14:39:07 -0600 Subject: only install platform-appropriate configs based on uname --- config/all/dircolors.conf | 91 ++++++++++++++++++++++++++++++++ config/all/git/config | 43 +++++++++++++++ config/all/git/ignore | 11 ++++ config/all/kitty/kitty.conf | 48 +++++++++++++++++ config/all/tmux/tmux.conf | 55 +++++++++++++++++++ config/all/zsh/.zprofile | 7 +++ config/all/zsh/.zshrc | 4 ++ config/all/zsh/20-appearance.zsh | 79 +++++++++++++++++++++++++++ config/all/zsh/30-behavior.zsh | 54 +++++++++++++++++++ config/all/zsh/40-key-bindings.zsh | 6 +++ config/all/zsh/50-completion.zsh | 27 ++++++++++ config/all/zsh/99-function-overrides.zsh | 8 +++ 12 files changed, 433 insertions(+) create mode 100644 config/all/dircolors.conf create mode 100644 config/all/git/config create mode 100644 config/all/git/ignore create mode 100644 config/all/kitty/kitty.conf create mode 100644 config/all/tmux/tmux.conf create mode 100644 config/all/zsh/.zprofile create mode 100644 config/all/zsh/.zshrc create mode 100644 config/all/zsh/20-appearance.zsh create mode 100644 config/all/zsh/30-behavior.zsh create mode 100644 config/all/zsh/40-key-bindings.zsh create mode 100644 config/all/zsh/50-completion.zsh create mode 100644 config/all/zsh/99-function-overrides.zsh (limited to 'config/all') diff --git a/config/all/dircolors.conf b/config/all/dircolors.conf new file mode 100644 index 0000000..cfd5f8d --- /dev/null +++ b/config/all/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/all/git/config b/config/all/git/config new file mode 100644 index 0000000..0a3bed8 --- /dev/null +++ b/config/all/git/config @@ -0,0 +1,43 @@ +[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 = ~/.config/git/ignore + 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 + +[include] + path = config-local diff --git a/config/all/git/ignore b/config/all/git/ignore new file mode 100644 index 0000000..57dd8e6 --- /dev/null +++ b/config/all/git/ignore @@ -0,0 +1,11 @@ +*.class +*.pyc +*.swo +*.swp +.svn +.swo +*#* +# +.#* +doc/tags +.DS_STORE diff --git a/config/all/kitty/kitty.conf b/config/all/kitty/kitty.conf new file mode 100644 index 0000000..318ce8e --- /dev/null +++ b/config/all/kitty/kitty.conf @@ -0,0 +1,48 @@ +font_family JetBrainsMono Nerd Font Mono +disable_ligatures always +font_size 11.0 + +copy_on_select clipboard +shell_integration disabled +enable_audio_bell no + +# theme: Tempus Dawn +# author: Protesilaos Stavrou (https://protesilaos.com) +# description: Light theme with a soft, slightly desaturated palette (WCAG AA compliant) + +cursor #4a4b4e +cursor_text_color #eff0f2 +url_color #4b529a + +active_border_color #676364 +inactive_border_color #dee2e0 +bell_border_color #8b590a + +active_tab_foreground #206620 +active_tab_background #dee2e0 +inactive_tab_foreground #676364 +inactive_tab_background #eff0f2 + +foreground #4a4b4e +background #eff0f2 +selection_foreground #eff0f2 +selection_background #4a4b4e + +color0 #4a4b4e +color1 #a32a3a +color2 #206620 +color3 #745300 +color4 #4b529a +color5 #8d377e +color6 #086784 +color7 #dee2e0 +color8 #676364 +color9 #a64822 +color10 #187408 +color11 #8b590a +color12 #5c59b2 +color13 #8e45a8 +color14 #3f649c +color15 #eff0f2 + +include local.conf diff --git a/config/all/tmux/tmux.conf b/config/all/tmux/tmux.conf new file mode 100644 index 0000000..b1b98e0 --- /dev/null +++ b/config/all/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/all/zsh/.zprofile b/config/all/zsh/.zprofile new file mode 100644 index 0000000..a9a13c9 --- /dev/null +++ b/config/all/zsh/.zprofile @@ -0,0 +1,7 @@ +if [ "$(uname)" = "Darwin" ]; then + # disable Apple Terminal's annoying session restore feature + SHELL_SESSIONS_DISABLE=1 +fi +if [ "$DESKTOP_SESSION" = "sway-session" ]; then + export $(gnome-keyring-daemon --start) +fi diff --git a/config/all/zsh/.zshrc b/config/all/zsh/.zshrc new file mode 100644 index 0000000..f33ca44 --- /dev/null +++ b/config/all/zsh/.zshrc @@ -0,0 +1,4 @@ +for f in $ZDOTDIR/*.zsh +do + source "${f}" +done diff --git a/config/all/zsh/20-appearance.zsh b/config/all/zsh/20-appearance.zsh new file mode 100644 index 0000000..4f7c8d9 --- /dev/null +++ b/config/all/zsh/20-appearance.zsh @@ -0,0 +1,79 @@ +# +# colorize shell programs + +if ls -Z . &>/dev/null 2>&1; then + # gnu coreutils? + alias ls='ls --color=auto' + eval `dircolors ${XDG_CONFIG_HOME:-${HOME}/.config}/dircolors.conf` +elif (( $+commands[gls] )); then + # prefixed gnu coreutils? + alias ls='gls --color=auto' + eval `gdircolors ${XDG_CONFIG_HOME:-${HOME}/.config}/dircolors.conf` +else + # assume bsd ls + 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/all/zsh/30-behavior.zsh b/config/all/zsh/30-behavior.zsh new file mode 100644 index 0000000..6b2b2c2 --- /dev/null +++ b/config/all/zsh/30-behavior.zsh @@ -0,0 +1,54 @@ +# +# 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 + +# make sure $TERM is installed +# if not, fall back on xterm-256color +infocmp "$TERM" > /dev/null 2>&1 || export TERM=xterm-256color + +# set term title appropriately based on term type +# user@host:current_dir (current_command) +case "$TERM" in + xterm*|rxvt*|screen*|alacritty*|foot) + term_preexec () { + printf '\e]0;%s (%s)\a' ${(%):-'%n@%m:%~'} "$1" + } + term_precmd () { + printf '\e]0;%s\a' ${(%):-'%n@%m:%~'} + } + ;; +esac + +# +# 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/all/zsh/40-key-bindings.zsh b/config/all/zsh/40-key-bindings.zsh new file mode 100644 index 0000000..4deac62 --- /dev/null +++ b/config/all/zsh/40-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/all/zsh/50-completion.zsh b/config/all/zsh/50-completion.zsh new file mode 100644 index 0000000..23cb052 --- /dev/null +++ b/config/all/zsh/50-completion.zsh @@ -0,0 +1,27 @@ +# initialize the completion system +autoload -U compinit +compinit -d "${XDG_CACHE_HOME:-${HOME}/.cache}/zsh/zcompdump" +zmodload zsh/complist + +# 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 + +# disable named-directories autocompletion +zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories +cdpath=(.) + +# don't autocomplete local users for (ssh|ftp|scp|rsync) +zstyle ':completion:*:*:(ssh|ftp|scp|rsync):*' users + +# Use caching so that commands like apt and dpkg complete are useable +zstyle ':completion::complete:*' use-cache 1 +zstyle ':completion:*' cache-path "${XDG_CACHE_HOME:-${HOME}/.cache}/zsh/zcompcache" + +# always rehash commands list +zstyle ':completion:*:commands' rehash 1 diff --git a/config/all/zsh/99-function-overrides.zsh b/config/all/zsh/99-function-overrides.zsh new file mode 100644 index 0000000..8b233e5 --- /dev/null +++ b/config/all/zsh/99-function-overrides.zsh @@ -0,0 +1,8 @@ +preexec () { + type term_preexec &> /dev/null && term_preexec $* + type theme_preexec &> /dev/null && theme_preexec $* +} + +precmd () { + type term_precmd &> /dev/null && term_precmd +} -- cgit v1.2.3