Having been in this situation (the only binary I could use was bash, although cd 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" ]]; thenecho'dir'elif [[ -f "$item" ]]; thenecho'file'elif [[ -h "$item" ]]; thenecho'link'# not accurate, but symlink is too longelseecho'????'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)")
fishopt -s dotglob
for path in"${paths[@]}"; doif [[ -d "$path" ]]; thenprintf'%s\n'"$path"for item in"$path"/*; do
print_path_listing "$item"doneelif [[ -e "$path" ]]; then
print_path_listing "$path"printf'\n'fidone
}
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.
I wanted to try it on my phone to, since I’m bored sitting on my train to work, but appearently you can’t copy text out of jeroba and now I don’t care enough to open it in my webbrowser
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.
I wanted to try it on my phone to, since I’m bored sitting on my train to work, but appearently you can’t copy text out of jeroba and now I don’t care enough to open it in my webbrowser
FWIW - starting a reply allows you to copy the original text.
TIL
Also if you tap on the ‘kebab’ menu and press
View Source
, you can copy the message.