From d198b662b08edd677d80c3f9eb9223029e032815 Mon Sep 17 00:00:00 2001 From: Julian Mutter Date: Wed, 24 Aug 2022 16:39:59 +0200 Subject: [PATCH] Add zsh custom plugins --- .dotter/global.toml | 3 ++- zsh/custom-plugins/last-working-dir.zsh | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 zsh/custom-plugins/last-working-dir.zsh diff --git a/.dotter/global.toml b/.dotter/global.toml index 721a40f..8f69cee 100644 --- a/.dotter/global.toml +++ b/.dotter/global.toml @@ -35,7 +35,8 @@ alacritty = "~/.config/alacritty" starship = "~/.config/" [zsh.files] -zsh = "~/" +"zsh/.zshrc" = "~/.zshrc" +"zsh/custom-plugins" = "~/.oh-my-zsh/custom" [polybar.files] polybar = "~/.config/polybar" diff --git a/zsh/custom-plugins/last-working-dir.zsh b/zsh/custom-plugins/last-working-dir.zsh new file mode 100644 index 0000000..bc0afbb --- /dev/null +++ b/zsh/custom-plugins/last-working-dir.zsh @@ -0,0 +1,17 @@ +#!/usr/bin/zsh +# +# My version of the last-working-dir plugin (https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/last-working-dir/last-working-dir.plugin.zsh) +# +# Updates the last directory once directory is changed +autoload -U add-zsh-hook +add-zsh-hook chpwd chpwd_last_working_dir +chpwd_last_working_dir() { + # Don't run in subshells + [[ "$ZSH_SUBSHELL" -eq 0 ]] || return 0 + pwd > ~/.last-working-dir +} + +# Changes directory to the last working directory +lwd() { + [[ -r ~/.last-working-dir ]] && cd $(cat ~/.last-working-dir) +}