dotfiles/homedir/.config/bash.d/common

42 lines
902 B
Bash

#!/bin/bash
echo() { printf '%s\n' "$*"; }
msg() { printf '%s\n' "$*"; }
err() { printf '%s\n' "$*" >&2; }
set_title() { printf '\033]0;%s\007' "$1"; }
trap_error() { err "The command has returned a non-zero exit code ($?)."; }
x() { exec xinit -- -nolisten tcp vt9; }
is_coreutils() {
declare out
out=$( df --version 2>/dev/null )
(( $? )) && {
err 'df --version exited with an error. This is not GNU coreutils'
return 3
}
[[ "$out" =~ 'GNU coreutils' ]] || {
err 'Version output does not contain "GNU coreutils". This is not GNU coreutils.'
return 1
}
}
fuck() { sudo $(history -p \!\!); }
err() { printf '%s\n' "$*"; }
is_function() {
[[ $(type -t "$1") == 'function' ]]
}
if is_coreutils; then
ls() { $(type -P ls) -l -hb --group-directories-first --color=auto "$@"; }
mv() { $(type -P mv) -v "$@"; }
cp() { $(type -P cp) -v "$@"; }
rm() { $(type -P rm) -v "$@"; }
fi