Last active
September 19, 2016 13:45
-
-
Save mjbogusz/75e9f6703dc53d8e8c21c21ef8529a4d to your computer and use it in GitHub Desktop.
Oh-my-zsh plugin, 'cloning' last used working directory to newly-opening shells.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local USERNAME=`id -un` | |
| local TMPFILE_NAME=`ls -t /tmp/ | grep -m 1 clonepwd-${USERNAME}-` | |
| if ( [ "${TMPFILE_NAME}" ] ); then | |
| local TMPFILE="/tmp/${TMPFILE_NAME}" | |
| local CLONEDIR=`cat ${TMPFILE}` | |
| if ( [ "${CLONEDIR}" ] ); then | |
| cd "${CLONEDIR}" | |
| fi | |
| else | |
| local TMPFILE=`mktemp -t clonepwd-${USERNAME}-XXXXXX` | |
| fi | |
| export CLONEPWD_TMPFILE="${TMPFILE}" | |
| function clonepwd_precmd() { | |
| echo `pwd` > "${CLONEPWD_TMPFILE}" | |
| } | |
| precmd_functions+=(clonepwd_precmd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment