Skip to content

Instantly share code, notes, and snippets.

@lelandbatey
Last active October 15, 2021 23:59
Show Gist options
  • Save lelandbatey/71e3f720f72dc67b4360 to your computer and use it in GitHub Desktop.
Save lelandbatey/71e3f720f72dc67b4360 to your computer and use it in GitHub Desktop.
In place cd; cd won't create a newline and prompt
# Original
# function cd { command cd $@ > /dev/null; echo -ne "\r\e[1A\e[J"; }
# Written by Kate Adams: https://github.com/KateAdams
function cd {
command cd $1 > /dev/null # pipe stdout, but not stderr
local ret=$?
if [[ $ret == 0 ]]; then
# \r = return to start of line
# \e[1A = move cursor up a line
# \e[J = clear everything after the cursor
echo -ne "\r\e[1A\e[J"
fi
return $ret
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment