Files
dotfiles/.config/zsh/plugins/functionsPre.zsh
druckdev fdfa8a5f8a Cleanup zsh functions and add unbkp()
Add unbkp() that reverses bkp().
Use shorter zsh syntax for disowning a background job.
Add usage string to mangrep.
Expect clang-format config to be in XDG_CONFIG_HOME. Add functionality
of comments.
Use `command` where we want a command to be taken as external.
2020-09-21 18:06:55 +02:00

46 lines
1.1 KiB
Bash

## Author: druckdev
## Created: 2019-10-27 (originally 2019-08-28 as functions.zsh)
## List items in trash if no argument is specified
function _trash_list_default() {
if [ $# -eq 0 ]; then
command trash-list
else
command trash "$@"
fi
}
## Open nemo in current directory if no argument is specified
function _nemo_wd_default() {
if [ $# -eq 0 ]; then
command nemo ./
else
command nemo "$@"
fi
}
## ls function that prints hidden files when there are no regular files
## or if we are in a directory that matches the regex in LS_SHOW_ALL_DIRS
function _ls_show_hidden() {
# Can be overwritten by settings it before calling
local LS_SHOW_ALL_DIRS=${LS_SHOW_ALL_DIRS:-"dotfiles|\.config"}
# if a path is given, target will contain the given directory or the directory in which the
# given file is located
local target
for arg in "$@"; do
if [ -d "$arg" ]; then
target="$arg"
break
elif [ -d "${arg%/*}" ]; then
target="${arg%/*}"
break
fi
done
if [[ -z "$(command ls "$@")" || "$( (cd "$target"; pwd) )" =~ "${LS_SHOW_ALL_DIRS:-^$}" ]]; then
command ls -A "$@"
else
command ls "$@"
fi
}