Force order of functions and aliases
This commit is contained in:
41
rc/01-functions.sh
Normal file
41
rc/01-functions.sh
Normal file
@@ -0,0 +1,41 @@
|
||||
# $LWS/rc/functions.sh
|
||||
|
||||
function jql() {
|
||||
jq -C . "$@" | less -r
|
||||
}
|
||||
|
||||
function ffile() {
|
||||
local filename="$1"
|
||||
shift
|
||||
file $(type -p "$filename") $@
|
||||
}
|
||||
|
||||
# print time in seconds with nanoseconds precission
|
||||
function utime() {
|
||||
date '+%s.%N'
|
||||
}
|
||||
|
||||
function in_path() {
|
||||
[[ "$PATH" =~ (^|:)"${1}"(:|$) ]]
|
||||
}
|
||||
|
||||
function append_path() {
|
||||
if ! in_path "$1"; then
|
||||
PATH="$PATH:$1"
|
||||
fi
|
||||
}
|
||||
|
||||
function prepend_path() {
|
||||
if ! in_path "$1"; then
|
||||
PATH="$1:$PATH"
|
||||
fi
|
||||
}
|
||||
|
||||
function uniq_path() {
|
||||
echo "$PATH" | tr ":" "\n" | awk '!seen[$0]++' | tr "\n" ":" | sed -r 's/:+/:/g' | sed -r 's/^:|:$//g'
|
||||
}
|
||||
|
||||
function can_run() {
|
||||
local application="$1"
|
||||
command -v "$application" > /dev/null
|
||||
}
|
||||
Reference in New Issue
Block a user