Last active
October 6, 2022 00:17
-
-
Save allyouaskfor/96e28f18dc761c49e2d6eeafec179b8f to your computer and use it in GitHub Desktop.
List contents of directory after changing into it.
This file contains 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
#!/bin/bash | |
# cd & ls with just "cd" | |
# Original solution found on StackOverflow. I do not have the direct link. | |
# Modified/adjusted by myself to work in line with my own expectations. | |
# Tested and used regularly on macOS with ZSH and Raspberry Pi with BASH. | |
altercd() { | |
cd() { | |
unset -f cd | |
if [[ -z $* ]]; then | |
cd $HOME | |
else | |
cd "$*" | |
fi | |
ls | |
altercd | |
} | |
}; altercd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment