nix/home/program/bash/module/Ls.nix

71 lines
1.6 KiB
Nix
Raw Normal View History

2024-04-06 03:03:58 +03:00
{ ... }: {
text = ''
# 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() {
2024-06-22 23:34:03 +03:00
# ls -lhv --si --group-directories-first --color=auto -- "$@"
2024-06-23 23:25:19 +03:00
ccd "$@"
2024-04-06 03:03:58 +03:00
}
# List last modified files first.
# Current dir by default.
# Usage: ll [DIRS]
function ll() {
2024-06-23 23:25:19 +03:00
ls -lhv --si --group-directories-first --color=auto -- "$@"
# ls -lhvtr --si --color=auto -- "$@"
2024-04-06 03:03:58 +03:00
}
# 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 --color=auto -- "$@"
}
# List all files in dirs, incl. hidden files.
# Current dir by default.
# Usage: la [DIRS]
function la() {
ls -lAh --si --group-directories-first --color=auto -- "$@"
}
# List all files in dirs, incl. hidden files, sorted by mtime.
# Current dir by default.
# Usage: lla [DIRS]
function lla() {
ls -lAhtr --si --color=auto -- "$@"
}
# List only files.
function _ls_file() {
ls --classify | grep -v \/$
}
# List only dirs.
function _ls_dir() {
ls --classify | grep \/$ | sed -e "s/\/$//"
}
'';
}