This repository has been archived on 2024-03-04. You can view files and clone it, but cannot push or open issues or pull requests.
linux/.config/bash/module/Ls.sh

65 lines
1.3 KiB
Bash

# Unset possible system-defined aliases.
unalias l ll lll llll la lla &> /dev/null
unset l ll lll llll la lla &> /dev/null
# List files in dirs.
# Current dir by default.
# Usage: l [DIRS]
function l() {
ls -lhv --si --group-directories-first -- "$@"
}
# List last modified files first.
# Current dir by default.
# Usage: ll [DIRS]
function ll() {
ls -lhvtr --si -- "$@"
}
# List files in tree structure.
# Current dir by default.
# Depth can be omitted by passing `-` (dash).
# Usage: lll [DEPTH] [DIRS]
function lll() {
local IFS=$'\n'
local depth="${1}"
local target=("${@:2}")
[[ "${target}" = "" ]] && target="."
[[ "${depth}" = "" ]] && depth=666
[[ "${depth}" = "-" ]] && depth=666
tree -a -L "${depth}" -- "${target[@]}"
}
# List files recursively.
# Current dir by default.
# Usage: llll [DIRS]
function llll() {
ls -RlAhv --si --group-directories-first -- "$@"
}
# List all files in dirs, incl. hidden files.
# Current dir by default.
# Usage: la [DIRS]
function la() {
ls -lAh --si --group-directories-first -- "$@"
}
# List all files in dirs, incl. hidden files, sorted by mtime.
# Current dir by default.
# Usage: lla [DIRS]
function lla() {
ls -lAhtr --si -- "$@"
}
# List only files.
function _ls_file() {
ls --classify | grep -v \/$
}
# List only dirs.
function _ls_dir() {
ls --classify | grep \/$ | sed -e "s/\/$//"
}