commit 3ba199cd65cef429670151b9b9ce922b22ccb629
parent 9e3a540159fbd197468d6fbf15b56d80060b2f14
Author: Alex Balgavy <a.balgavy@gmail.com>
Date: Sat, 25 Apr 2020 23:04:59 +0200
shell: reorganising & shellopts
Former-commit-id: 64fc474783c5dbf6c668f833b522a0c777b17040
Diffstat:
5 files changed, 41 insertions(+), 27 deletions(-)
diff --git a/dot.map b/dot.map
@@ -47,10 +47,8 @@ emacs:
# All shell configs
shell:
-- aliases: ~/.aliases
-- functions: ~/.functions
- zshenv: ~/.zshenv
-- zshrc: ~/.zshrc
+- zshrc: ~/.config/zsh/zshrc
- bash_profile: ~/.bash_profile
- bashrc: ~/.bashrc
- profile: ~/.profile
diff --git a/shell/bashrc b/shell/bashrc
@@ -1,7 +1,7 @@
. $HOME/.dotfiles/shell/z/z.sh
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
-[[ -f ~/.aliases ]] && source ~/.aliases
-[[ -f ~/.functions ]] && source ~/.functions
+[[ -f $DOTFILES/shell/aliases ]] && source $DOTFILES/shell/aliases
+[[ -f $DOTFILES/shell/functions ]] && source $DOTFILES/shell/functions
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
diff --git a/shell/use-config-dir b/shell/use-config-dir
@@ -9,3 +9,4 @@ export _Z_DATA="$HOME/.cache/z/z-data"
export HTTPIE_CONFIG_DIR="$HOME/.config/httpie"
export CABAL_DIR="$HOME/.config/cabal"
export GHCUP_INSTALL_BASE_PREFIX="$HOME/.config"
+export ZDOTDIR="$HOME/.config/zsh"
diff --git a/shell/zshenv b/shell/zshenv
@@ -1 +1,2 @@
. $HOME/.profile
+HISTFILE=${ZDOTDIR:-$HOME}/.zsh_history
diff --git a/shell/zshrc b/shell/zshrc
@@ -1,10 +1,6 @@
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block, everything else may go below.
-if [ -n "$VIMRUNTIME" ]; then set -o vi
-else set -o emacs
-fi
-
[ -n "$DOTFILES" ] || { echo '$DOTFILES not set' && exit 1; }
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
@@ -17,8 +13,33 @@ source_if_exists() {
fi
}
-# Allow comments in shell
-setopt interactivecomments
+# Options
+if [ -n "$VIMRUNTIME" ]; then set -o vi
+else set -o emacs
+fi
+setopt alwaystoend # On completion, move cursor to end of word
+setopt autocd # If I forget 'cd' before a path
+setopt autopushd # Make cd push old directory onto stack
+setopt completeinword # Completion from both ends of word
+setopt extendedhistory # Save timestamp and duration of commands in histfile
+setopt interactivecomments # Allow comments
+setopt monitor # Allow job control
+setopt nocaseglob # Globs should be case insensitive
+setopt noflowcontrol # Disable ^S and ^Q
+setopt promptsubst # Parameter expansion, command subst, arithmetic expansion done in prompt
+setopt pushdignoredups # Don't pushd duplicate directories
+setopt pushdminus # Exchange meanings of + and - on directory stack
+
+# History options
+setopt sharehistory # Import commands from histfile and append typed to histfile
+setopt appendhistory # Append to history
+setopt incappendhistory # Append immediately, not at shell exit
+setopt histexpiredupsfirst # When trimming history, remove duplicates first
+setopt histignoredups # Don't save command into history if duplicate of previous
+setopt histignorespace # Don't save command into history if starts with space
+setopt histfindnodups # Ignore duplicates when searching
+setopt histreduceblanks # Remove blank lines from history
+setopt histverify # Show expansion first before executing
# Enable extra completions
fpath=($DOTFILES/shell/zsh-completions/src $DOTFILES/shell/zsh-completions-mine/ $fpath)
@@ -31,20 +52,13 @@ source $DOTFILES/shell/oh-my-zsh-defaults/keys.zsh
# Auto correct commands, with exceptions (from oh-my-zsh)
-if [[ "$ENABLE_CORRECTION" == "true" ]]; then
- alias cp='nocorrect cp'
- alias ebuild='nocorrect ebuild'
- alias gist='nocorrect gist'
- alias heroku='nocorrect heroku'
- alias hpodder='nocorrect hpodder'
- alias man='nocorrect man'
- alias mkdir='nocorrect mkdir'
- alias mv='nocorrect mv'
- alias mysql='nocorrect mysql'
- alias sudo='nocorrect sudo'
-
- setopt correct_all
-fi
+alias cp='nocorrect cp'
+alias man='nocorrect man'
+alias mkdir='nocorrect mkdir'
+alias mv='nocorrect mv'
+alias sudo='nocorrect sudo'
+setopt correct
+setopt correct_all
# Import colorscheme from 'wal' asynchronously
# & # Run the process in the background.
@@ -79,8 +93,8 @@ source_if_exists $DOTFILES/shell/zsh-plugins/bundler.plugin.zsh
source_if_exists $DOTFILES/shell/zsh-plugins/gitignore.plugin.zsh
# Enable custom aliases and functions
-source_if_exists ~/.aliases
-source_if_exists ~/.functions
+source_if_exists "$DOTFILES/shell/aliases"
+source_if_exists "$DOTFILES/shell/functions"
insert-arg-of-prev-cmd() {
: ${NUMERIC:-1}