adopt qtools as 'official' name in variables

This commit is contained in:
ville rantanen
2017-06-11 10:41:27 +03:00
parent 932e75cac7
commit 903206e610

48
rc
View File

@@ -1,36 +1,36 @@
# source me to enable tools # source me to enable tools
case $OSTYPE in case $OSTYPE in
darwin*) darwin*)
TOOLSPATH=$( realpath $( dirname "$BASH_SOURCE" ) ) QTOOLSPATH=$( realpath $( dirname "$BASH_SOURCE" ) )
;; ;;
*) *)
TOOLSPATH=$( readlink -f $( dirname "$BASH_SOURCE" ) ) QTOOLSPATH=$( readlink -f $( dirname "$BASH_SOURCE" ) )
;; ;;
esac esac
PATH=$PATH:"$TOOLSPATH"/bin PATH=$PATH:"$QTOOLSPATH"/bin
[[ "$1" = "-f" ]] && PATH="$TOOLSPATH"/bin:$PATH [[ "$1" = "-f" ]] && PATH="$QTOOLSPATH"/bin:$PATH
. "$TOOLSPATH"/qcd_function . "$QTOOLSPATH"/qcd_function
path_remove_duplicates path_remove_duplicates
[[ -f "$TOOLSPATH"/tsv/tsvkit.sh ]] && . "$TOOLSPATH"/tsv/tsvkit.sh &>/dev/null [[ -f "$QTOOLSPATH"/tsv/tsvkit.sh ]] && . "$QTOOLSPATH"/tsv/tsvkit.sh &>/dev/null
function _q-tools-reload { function _q-tools-reload {
# reload self # reload self
[[ -z "$TOOLSPATH" ]] && return [[ -z "$QTOOLSPATH" ]] && return
source "$TOOLSPATH"/rc source "$QTOOLSPATH"/rc
} }
function _q-tools-update { function _q-tools-update {
# update self # update self
[[ -z "$TOOLSPATH" ]] && return [[ -z "$QTOOLSPATH" ]] && return
[[ -w "$TOOLSPATH" ]] || return [[ -w "$QTOOLSPATH" ]] || return
"$TOOLSPATH"/rc -u "$QTOOLSPATH"/rc -u
_q-tools-reload _q-tools-reload
} }
function _self_update() { function _self_update() {
touch "$TOOLSPATH"/.lastupdate touch "$QTOOLSPATH"/.lastupdate
pushd "$TOOLSPATH" > /dev/null pushd "$QTOOLSPATH" > /dev/null
[[ "$1" = "-u" ]] && { [[ "$1" = "-u" ]] && {
hg pull -u https://bitbucket.org/MoonQ/tools hg pull -u https://bitbucket.org/MoonQ/tools
} || { } || {
@@ -38,23 +38,23 @@ function _self_update() {
} }
popd > /dev/null popd > /dev/null
# ncsv update # ncsv update
[[ -d "$TOOLSPATH"/ncsv ]] && { [[ -d "$QTOOLSPATH"/ncsv ]] && {
pushd "$TOOLSPATH"/ncsv > /dev/null pushd "$QTOOLSPATH"/ncsv > /dev/null
[[ "$1" = "-u" ]] && { [[ "$1" = "-u" ]] && {
hg pull -u hg pull -u
} || { } || {
timeout 10 hg pull -u > /dev/null 2>&1 timeout 10 hg pull -u > /dev/null 2>&1
} }
ln -sfT ../ncsv/ncsv/ncsv.py "$TOOLSPATH"/bin/ncsv ln -sfT ../ncsv/ncsv/ncsv.py "$QTOOLSPATH"/bin/ncsv
popd > /dev/null popd > /dev/null
} || true } || true
} }
function _check_ncsv() { function _check_ncsv() {
[[ -d "$TOOLSPATH"/ncsv ]] || { [[ -d "$QTOOLSPATH"/ncsv ]] || {
hg clone https://bitbucket.org/MoonQ/ncsv "$TOOLSPATH"/ncsv hg clone https://bitbucket.org/MoonQ/ncsv "$QTOOLSPATH"/ncsv
ln -sfT ../ncsv/ncsv/ncsv.py "$TOOLSPATH"/bin/ncsv ln -sfT ../ncsv/ncsv/ncsv.py "$QTOOLSPATH"/bin/ncsv
} }
} }
@@ -69,16 +69,16 @@ unset -f _check_ncsv
# Update self weekly, # Update self weekly,
# if folder writable, if repository, if an interactive terminal, if not updated the last week # if folder writable, if repository, if an interactive terminal, if not updated the last week
TOOLS_TO_UPDATE=1 TOOLS_TO_UPDATE=1
[[ -w "$TOOLSPATH" ]] || TOOLS_TO_UPDATE=0 [[ -w "$QTOOLSPATH" ]] || TOOLS_TO_UPDATE=0
[[ -w "$TOOLSPATH"/.hg ]] || TOOLS_TO_UPDATE=0 [[ -w "$QTOOLSPATH"/.hg ]] || TOOLS_TO_UPDATE=0
[[ -t 0 ]] || TOOLS_TO_UPDATE=0 [[ -t 0 ]] || TOOLS_TO_UPDATE=0
[[ -t 1 ]] || TOOLS_TO_UPDATE=0 [[ -t 1 ]] || TOOLS_TO_UPDATE=0
[[ -t 2 ]] || TOOLS_TO_UPDATE=0 [[ -t 2 ]] || TOOLS_TO_UPDATE=0
[[ -f "$TOOLSPATH"/.lastupdate ]] || touch -t 0101010101 "$TOOLSPATH"/.lastupdate 2> /dev/null [[ -f "$QTOOLSPATH"/.lastupdate ]] || touch -t 0101010101 "$QTOOLSPATH"/.lastupdate 2> /dev/null
[[ -w "$TOOLSPATH"/.lastupdate ]] || TOOLS_TO_UPDATE=0 [[ -w "$QTOOLSPATH"/.lastupdate ]] || TOOLS_TO_UPDATE=0
if [ $TOOLS_TO_UPDATE -eq 1 ]; then if [ $TOOLS_TO_UPDATE -eq 1 ]; then
TOOLS_LASTUPDATE=$( "$TOOLSPATH"/files/file-age "$TOOLSPATH"/.lastupdate d ) TOOLS_LASTUPDATE=$( "$QTOOLSPATH"/files/file-age "$QTOOLSPATH"/.lastupdate d )
[[ "$TOOLS_LASTUPDATE" -gt 7 ]] && _self_update [[ "$TOOLS_LASTUPDATE" -gt 7 ]] && _self_update
unset TOOLS_LASTUPDATE unset TOOLS_LASTUPDATE
fi fi