Add helper functions
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# $LWS/rc/functions.sh
|
||||
# Linux Workspace Functions
|
||||
|
||||
function xlog() {
|
||||
if true_false "$LWS_DEBUG"; then
|
||||
@@ -21,6 +21,18 @@ function utime() {
|
||||
date '+%s.%N'
|
||||
}
|
||||
|
||||
function sqltime() {
|
||||
date '+%Y-%m-%d %H:%M:%S'
|
||||
}
|
||||
|
||||
function lines() {
|
||||
tr ":" "\n"
|
||||
}
|
||||
|
||||
function path() {
|
||||
echo "$PATH" | lines
|
||||
}
|
||||
|
||||
function in_path() {
|
||||
[[ "$PATH" =~ (^|:)"${1}"(:|$) ]]
|
||||
}
|
||||
@@ -49,6 +61,10 @@ function prepend_path_try() {
|
||||
fi
|
||||
}
|
||||
|
||||
function remove_path() {
|
||||
PATH=$(path | grep -v "$1" | tr "\n" ":")
|
||||
}
|
||||
|
||||
function uniq_path() {
|
||||
echo "$PATH" | tr ":" "\n" | awk '!seen[$0]++' | tr "\n" ":" | sed -r 's/:+/:/g' | sed -r 's/^:|:$//g'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user