From 2e7ed25fdff27ee4c42c46ed53d29d228fffe4e1 Mon Sep 17 00:00:00 2001 From: earnest ma Date: Thu, 1 Jul 2021 21:42:48 -0400 Subject: [PATCH] Add zsh and common shell configurations --- .config/shell/start.sh | 51 ++++++++++++++++++++++++++++++++++++++++++ .config/zsh/.zshenv | 8 +++++++ .config/zsh/.zshrc | 28 +++++++++++++++++++++++ .zshenv | 3 +++ 4 files changed, 90 insertions(+) create mode 100755 .config/shell/start.sh create mode 100644 .config/zsh/.zshenv create mode 100644 .config/zsh/.zshrc create mode 100644 .zshenv diff --git a/.config/shell/start.sh b/.config/shell/start.sh new file mode 100755 index 0000000..622a42f --- /dev/null +++ b/.config/shell/start.sh @@ -0,0 +1,51 @@ +#!/usr/bin/sh + +# Common startup shell script + +# Don't re-run this script +# [ -n "$E_STARTED" ] || . $HOME/.config/shell/start.sh +export E_SCRIPTS_DIR="$HOME/.config/shell" + +export XDG_CONFIG_HOME="$HOME/.config" +export XDG_USER_CONFIG_DIR="$XDG_CONFIG_HOME" +export XDG_DATA_HOME="$HOME/.local/share" +export XDG_CACHE_HOME="$HOME/.cache" + +export LANG=en_CA.UTF-8 +# TZ + +# functions to add directories to $PATH +path_add(){ + PATH="$1:$PATH" +} + +path_add_end(){ + PATH="$PATH:$1" +} + +# Avoid having too many things in ~/ ----------------------- +path_add "$HOME/.local/bin" +path_add "$HOME/.config/shell/bin" + +# Rust, cargo +export CARGO_HOME="$XDG_DATA_HOME/cargo" +[ -f $CARGO_HOME/env ] && . "$CARGO_HOME/env" + +# golang +path_add "/usr/local/go/bin" +export GOPROXY=direct +export GOPATH="$XDG_DATA_HOME/go" +path_add "$GOPATH/bin" + +# node, npm, yarn +export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME/npm/npmrc" + + +alias wget="wget --hsts-file=$XDG_CACHE_HOME/wget-hsts" +export GNUPGHOME="$XDG_DATA_HOME/gnupg" + + +export PATH # just in case + +# Note that this script has been run +export E_STARTED=1 diff --git a/.config/zsh/.zshenv b/.config/zsh/.zshenv new file mode 100644 index 0000000..92738f9 --- /dev/null +++ b/.config/zsh/.zshenv @@ -0,0 +1,8 @@ +# `.zshenv' is sourced on all invocations of the shell, unless the -f +# option is set. It should contain commands to set the command search +# path, plus other important environment variables. + +# `.zshenv' should not contain commands that produce output or assume +# the shell is attached to a tty. + +[ -n "$E_STARTED" ] || . $HOME/.config/shell/start.sh diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc new file mode 100644 index 0000000..77d2ce8 --- /dev/null +++ b/.config/zsh/.zshrc @@ -0,0 +1,28 @@ +# `.zshrc' is sourced in interactive shells. It should contain +# commands to set up aliases, functions, options, key bindings, etc. + +autoload -U colors && colors + +HISTSIZE=10000 +SAVEHIST=10000 +HISTFILE=$XDG_CACHE_HOME/zshhistory + +autoload -U compinit +zstyle ':completion:*' menu select +zmodload zsh/complist +compinit +_comp_options+=(globdots) # include hidden files + +echo "Hi" + +# edit line in editor w/ ctrl-e (from Luke Smith's .zshrc) +autoload edit-command-line; zle -N edit-command-line +bindkey '^e' edit-command-line + +[ -f "$E_SCRIPTS_DIR/aliases.sh" ] && source "$E_SCRIPTS_DIR/aliases.sh" + +# Run `git -C .config/zsh/autocomplete pull' to update +source $ZDOTDIR/autocomplete/zsh-autocomplete.plugin.zsh + +# This must be placed at the end +source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh diff --git a/.zshenv b/.zshenv new file mode 100644 index 0000000..1758e8c --- /dev/null +++ b/.zshenv @@ -0,0 +1,3 @@ +# load everything from ~/.config/zsh +export ZDOTDIR="$HOME/.config/zsh" +[ -f "$ZDOTDIR/.zshenv" ] && source $ZDOTDIR/.zshenv