zsh:functions: Use portable syntax for functions

Use a portable syntax for the function headers.
Since I do not know where these functions could end in the future it
makes it easier and more consistent to use the portable syntax.
This commit is contained in:
2020-11-02 02:04:38 +01:00
parent 6eac13011a
commit f0a0ba06c2

View File

@@ -2,7 +2,7 @@
## Created: 2019-08-28 ## Created: 2019-08-28
## Compares two pdfs based on the result of pdftotext ## Compares two pdfs based on the result of pdftotext
function pdfdiff() { pdfdiff() {
if [[ $# -eq 2 && -r "$1" && -r "$2" ]]; then if [[ $# -eq 2 && -r "$1" && -r "$2" ]]; then
diff <(pdftotext "$1" -) <(pdftotext "$2" -) diff <(pdftotext "$1" -) <(pdftotext "$2" -)
else else
@@ -12,7 +12,7 @@ function pdfdiff() {
} }
## Gets Passwd from bitwarden and copies it into the clipboard ## Gets Passwd from bitwarden and copies it into the clipboard
function bwpwd() { bwpwd() {
if bw "get" "password" "$@" >/dev/null; then if bw "get" "password" "$@" >/dev/null; then
bw "get" "password" "$@" | tr -d '\n' | setclip bw "get" "password" "$@" | tr -d '\n' | setclip
else else
@@ -21,7 +21,7 @@ function bwpwd() {
} }
## creates directory and changes into it ## creates directory and changes into it
function mkcd () { mkcd () {
# Create directory # Create directory
mkdir "$@" mkdir "$@"
# shift arguments if mkdir options were used # shift arguments if mkdir options were used
@@ -35,7 +35,7 @@ function mkcd () {
} }
## Encode and decode qr-codes ## Encode and decode qr-codes
function qr() { qr() {
if [[ $# -eq 1 && -r "$1" ]]; then if [[ $# -eq 1 && -r "$1" ]]; then
zbarimg "$1" zbarimg "$1"
else else
@@ -44,7 +44,7 @@ function qr() {
} }
## Edit config file ## Edit config file
function conf() { conf() {
local CONF_EDITOR local CONF_EDITOR
if [[ -n "$EDITOR" ]]; then if [[ -n "$EDITOR" ]]; then
CONF_EDITOR="$EDITOR" CONF_EDITOR="$EDITOR"
@@ -126,7 +126,7 @@ function conf() {
} }
## Change into config dir ## Change into config dir
function c() { c() {
CONF_DIR="$(_get_config_dir $*)" CONF_DIR="$(_get_config_dir $*)"
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
cd "$CONF_DIR" cd "$CONF_DIR"
@@ -136,7 +136,7 @@ function c() {
fi fi
} }
## Get config directory ## Get config directory
function _get_config_dir() { _get_config_dir() {
if [[ $# -gt 1 ]]; then if [[ $# -gt 1 ]]; then
printf "\033[1;31mPlease specify one config.\n\033[0m" >&2 printf "\033[1;31mPlease specify one config.\n\033[0m" >&2
return 1 return 1
@@ -153,7 +153,7 @@ function _get_config_dir() {
} }
## Function that resolves a command to the end ## Function that resolves a command to the end
function resolve() { resolve() {
# TODO: comment!! # TODO: comment!!
# In script mode only the result and its arguments are printed # In script mode only the result and its arguments are printed
# The result can then be used directly by other scripts without further # The result can then be used directly by other scripts without further
@@ -246,7 +246,7 @@ function resolve() {
} }
## Grep a keyword at the beginning of a line (ignoring whitespace) in a man page ## Grep a keyword at the beginning of a line (ignoring whitespace) in a man page
function mangrep() { mangrep() {
if [[ $# -lt 2 ]]; then if [[ $# -lt 2 ]]; then
printf "usage: mangrep <man page> <pattern> [<man flags>]\n" >&2 printf "usage: mangrep <man page> <pattern> [<man flags>]\n" >&2
printf "example: mangrep bash \"(declare|typeset)\"\n" >&2 printf "example: mangrep bash \"(declare|typeset)\"\n" >&2
@@ -294,7 +294,7 @@ crypt-umount() {
} }
## List items in trash if no argument is specified ## List items in trash if no argument is specified
function trash() { trash() {
if (( ! $# )); then if (( ! $# )); then
command trash-list command trash-list
else else
@@ -303,7 +303,7 @@ function trash() {
} }
## Open nemo in current directory if no argument is specified ## Open nemo in current directory if no argument is specified
function nemo() { nemo() {
if (( ! $# )); then if (( ! $# )); then
command nemo . command nemo .
else else