Skip to content

Instantly share code, notes, and snippets.

@tbielawa
Created September 17, 2019 23:36
Show Gist options
  • Save tbielawa/742778bd915a7b34384646222f97cf06 to your computer and use it in GitHub Desktop.
Save tbielawa/742778bd915a7b34384646222f97cf06 to your computer and use it in GitHub Desktop.
Quick directory `cd`/shell hacks
# Make a named directory and change immediately into it
#
# pwd -> /tmp/cdhacks
# $ cdmkdir zerocool; pwd -> /tmp/cdhacks/zerocool
function cdmkdir () {
mkdir -p ${1} && cd ${1}
}
# Make a temp directory, add it to the top of the directory stack.
# Immediately switch into it.
#
# pwd -> /tmp/cdhacks/zerocool
# $ gotemp; pwd -> /tmp/tmp.ZMRBdB1L6r
# $ popd
# pwd = /tmp/cdhacks/zerocool
alias gotemp='pushd `mktemp -d`'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment