I am immune to /dev/sda for I only have nvme
I love the nvme partition naming. Looking at you nvme1n1p3
/dev/nvme1s²2s²2p⁶3s²3p⁶4s²3d¹⁰4p²
… but
cd
is a built-inIt would be pretty useless if cd was a child process that changed its own directory, only to return to bash and be back where you started.
Having been in this situation (the only binary I could use was
bash
, althoughcd
was a bash builtin for me),echo *
is your friend. Even better is something like this:get_path_type() { local item item="$1" [[ -z "$item" ]] && { echo 'wrong arg count passed to get_path_type'; return 1; } if [[ -d "$item" ]]; then echo 'dir' elif [[ -f "$item" ]]; then echo 'file' elif [[ -h "$item" ]]; then echo 'link' # not accurate, but symlink is too long else echo '????' fi } print_path_listing() { local path path_type path="$1" [[ -z "$path" ]] && { echo 'wrong arg count passed to print_path_listing'; return 1; } path_type="$(get_path_type "$path")" printf '%s\t%s\n' "$path_type" "$path" } ls() { local path paths item symlink_regex paths=("$@") if ((${#paths[@]} == 0)); then paths=("$(pwd)") fi shopt -s dotglob for path in "${paths[@]}"; do if [[ -d "$path" ]]; then printf '%s\n' "$path" for item in "$path"/*; do print_path_listing "$item" done elif [[ -e "$path" ]]; then print_path_listing "$path" printf '\n' fi done }
This is recreated from memory and will likely have several nasty bugs. I also wrote it and quickly tested it entirely on my phone which was a bit painful. It should be pure bash, so it’ll work in this type of situation.
EDIT: I’m bored and sleep deprived and wanted to do something, hence this nonsense. I’ve taken the joke entirely too seriously.
Obligatory XKCD