Skip to content

Instantly share code, notes, and snippets.

@raamdev
Created May 19, 2014 23:23
Show Gist options
  • Select an option

  • Save raamdev/8513448439b24264e9a2 to your computer and use it in GitHub Desktop.

Select an option

Save raamdev/8513448439b24264e9a2 to your computer and use it in GitHub Desktop.
pushd()
{
if [ $# -eq 0 ]; then
DIR="${HOME}"
else
DIR="$1"
fi
builtin pushd "${DIR}" > /dev/null
ls -al
echo "DIRSTACK: "
dirs -v
}
pushd_builtin()
{
builtin pushd > /dev/null
echo "DIRSTACK: "
dirs -v
}
popd()
{
builtin popd > /dev/null
echo "DIRSTACK: "
dirs -v
}
go()
{
eval cd ~"${1}"
}
ls_enhanced()
{
if [ $# -eq 0 ]; then
DIR="."
fi
if [ $# -eq 1 ]; then
DIR="."
fi
if [ $# -gt 1 ]; then
DIR="$2"
fi
ls -alG "${DIR}"
echo "DIRSTACK: "
dirs -v
}
alias cd='pushd'
alias back='popd'
alias flip='pushd_builtin'
alias ls='ls_enhanced'
alias go='go'
@jaswrks
Copy link
Copy Markdown

jaswrks commented May 28, 2014

Awesome. Thank you! Love how these work together. The back/flip commands are nice and the DIRSTACK is great too. Also love the go alias. However, I decided I prefer not to type the leading / when I use it; so I altered it just slightly.

go()
{
    eval cd ~/"${1}";
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment