From 491580840af0a46c327e1b1f31085ff14d51ec7f Mon Sep 17 00:00:00 2001 From: Bert Peters Date: Sun, 9 Feb 2020 19:07:02 +0100 Subject: [PATCH] Remember recently visited directories. --- .gitignore | 3 +++ zsh/.config/zsh/.zshrc | 10 ++++++++++ zsh/.config/zsh/.zshtheme | 10 ++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index b2ff884..f4beeab 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,9 @@ # vim netrwhist exists and I don't know what it does vim/.vim/.netrwhist +# zsh's recent dirs shouldn't be versioned +zsh/.config/zsh/.chpwd-recent-dirs + # Ignore the installation of services for now. systemd/.config/systemd/user/default.target.wants systemd/.config/systemd/user/timers.target.wants diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index 2ea5533..274735e 100644 --- a/zsh/.config/zsh/.zshrc +++ b/zsh/.config/zsh/.zshrc @@ -75,6 +75,9 @@ alias wget="wget --hsts-file=\"$XDG_CACHE_HOME/wget-hsts\"" alias makej="make -j$(nproc)" alias sdc='sudo docker-compose' +# Ensure we can make cheap copies on btrfs +alias cp='cp --reflink=auto' + if (( $+commands[thefuck] )) then alias fuck='$(thefuck $(fc -ln -1))' @@ -211,6 +214,13 @@ SAVEHIST=$HISTSIZE setopt autocd # Automatically cd to dirs typed setopt notify +##################### +# Directory history # +##################### + +autoload -Uz chpwd_recent_dirs cdr add-zsh-hook +add-zsh-hook chpwd chpwd_recent_dirs + ###################################### # Application-specific configuration # ###################################### diff --git a/zsh/.config/zsh/.zshtheme b/zsh/.config/zsh/.zshtheme index db012c4..7865824 100644 --- a/zsh/.config/zsh/.zshtheme +++ b/zsh/.config/zsh/.zshtheme @@ -6,6 +6,9 @@ autoload -U colors && colors # Initialize VCS prompt configuration autoload -Uz vcs_info +# And the hooks system +autoload -Uz add-zsh-hook + zstyle ':vcs_info:*' enable git svn zstyle ':vcs_info:*' check-for-changes true zstyle ':vcs_info:*' check-for-staged-changes true @@ -74,20 +77,23 @@ function prompt_rprompt() { echo "${(j::)rprompt}" } -function precmd () { +function prompt_precmd () { # Set window title to username@machine: pwd print -Pn "\e]0;%n@%m: %2~\a" # Load VCS info vcs_info } -function preexec () { +function prompt_preexec () { # Set window title to command about to be executed. if [[ -n $1 ]]; then print -Pn "\e]0;$1\a" fi } +add-zsh-hook precmd prompt_precmd +add-zsh-hook preexec prompt_preexec + PS1="$(prompt_ps1)" RPROMPT="$(prompt_rprompt)"