use sd for managin scripts
This commit is contained in:
parent
fcda7ed476
commit
df5c4def7e
|
@ -33,3 +33,6 @@ zsh-users/zsh-autosuggestions
|
||||||
zsh-users/zsh-completions
|
zsh-users/zsh-completions
|
||||||
zdharma-continuum/fast-syntax-highlighting kind:defer
|
zdharma-continuum/fast-syntax-highlighting kind:defer
|
||||||
zsh-users/zsh-history-substring-search
|
zsh-users/zsh-history-substring-search
|
||||||
|
|
||||||
|
# Managing Personal Scripts
|
||||||
|
ianthehenry/sd
|
||||||
|
|
|
@ -42,3 +42,5 @@ fpath+=( /home/alhassan/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLA
|
||||||
zsh-defer source /home/alhassan/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zdharma-continuum-SLASH-fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh
|
zsh-defer source /home/alhassan/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zdharma-continuum-SLASH-fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh
|
||||||
fpath+=( /home/alhassan/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-history-substring-search )
|
fpath+=( /home/alhassan/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-history-substring-search )
|
||||||
source /home/alhassan/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-history-substring-search/zsh-history-substring-search.plugin.zsh
|
source /home/alhassan/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-history-substring-search/zsh-history-substring-search.plugin.zsh
|
||||||
|
fpath+=( /home/alhassan/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-ianthehenry-SLASH-sd )
|
||||||
|
source /home/alhassan/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-ianthehenry-SLASH-sd/sd.plugin.zsh
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
|
|
||||||
value=$(<./adblock-list)
|
|
||||||
|
|
||||||
echo $value
|
|
||||||
|
|
||||||
for entry in $value
|
|
||||||
do
|
|
||||||
./adblock-update.sh $entry
|
|
||||||
done
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
#!/bin/bash
|
||||||
|
parent_path=$(
|
||||||
|
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||||
|
pwd -P
|
||||||
|
)
|
||||||
|
|
||||||
|
cd "$parent_path"
|
||||||
|
|
||||||
|
value=$(<./adblock-list)
|
||||||
|
|
||||||
|
echo $value
|
||||||
|
|
||||||
|
for entry in $value; do
|
||||||
|
./adblock-update.sh $entry
|
||||||
|
done
|
|
@ -7,10 +7,16 @@
|
||||||
# URL URL of the filterlist to download
|
# URL URL of the filterlist to download
|
||||||
# -h, --help Display this help-message and exit
|
# -h, --help Display this help-message and exit
|
||||||
|
|
||||||
|
parent_path=$(
|
||||||
|
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||||
|
pwd -P
|
||||||
|
)
|
||||||
|
|
||||||
|
cd "$parent_path"
|
||||||
|
|
||||||
# help message
|
# help message
|
||||||
function usage ()
|
function usage() {
|
||||||
{
|
cat <<EOF
|
||||||
cat << EOF
|
|
||||||
Usage: $0 [-h] [URL]
|
Usage: $0 [-h] [URL]
|
||||||
This script can be used to download/update filterlists for the luakit adblock-module.
|
This script can be used to download/update filterlists for the luakit adblock-module.
|
||||||
It will only update the file if the server-side version is newer.
|
It will only update the file if the server-side version is newer.
|
||||||
|
@ -21,14 +27,13 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
# check for $XDG_DATA_HOME or fallback
|
# check for $XDG_DATA_HOME or fallback
|
||||||
[[ -z "$XDG_DATA_HOME" ]] && DATADIR="$HOME/.local/share" || DATADIR="$XDG_DATA_HOME"
|
[[ -z $XDG_DATA_HOME ]] && DATADIR="$HOME/.local/share" || DATADIR="$XDG_DATA_HOME"
|
||||||
|
|
||||||
|
|
||||||
# use URL if given
|
# use URL if given
|
||||||
if (( $# == 1 )) || (( $# == 0 )); then
|
if (($# == 1)) || (($# == 0)); then
|
||||||
[[ -z $1 ]] || [[ $1 == "-h" ]] || [[ $1 == "--help" ]] && usage && exit 0 # check for -h flag
|
[[ -z $1 ]] || [[ $1 == "-h" ]] || [[ $1 == "--help" ]] && usage && exit 0 # check for -h flag
|
||||||
listname="${1}"
|
listname="${1}"
|
||||||
elif (( $# > 1 ));then
|
elif (($# > 1)); then
|
||||||
usage
|
usage
|
||||||
exit 11
|
exit 11
|
||||||
fi
|
fi
|
||||||
|
@ -43,7 +48,7 @@ fi
|
||||||
wget -N --connect-timeout=10 --tries=20 --retry-connrefused --waitretry=5 ${listname}
|
wget -N --connect-timeout=10 --tries=20 --retry-connrefused --waitretry=5 ${listname}
|
||||||
|
|
||||||
# if download failed move old file back in place
|
# if download failed move old file back in place
|
||||||
if (( $? != 0 )); then
|
if (($? != 0)); then
|
||||||
[[ -f ${listname}.b ]] && cp -p ${listname}.b ${listname} && rm ${listname}.b
|
[[ -f ${listname}.b ]] && cp -p ${listname}.b ${listname} && rm ${listname}.b
|
||||||
echo "Error: List Download Failed!"
|
echo "Error: List Download Failed!"
|
||||||
exit 11
|
exit 11
|
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/sh
|
||||||
|
[ "$#" -lt "1" ] && {
|
||||||
|
echo "Configure current shell to use a specific major PHP version.
|
||||||
|
|
||||||
|
Usage: usephp 7"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
binary="php${1}"
|
||||||
|
wanted="/usr/bin/${binary}"
|
||||||
|
[ ! -f "${wanted}" ] && {
|
||||||
|
echo "'${binary}' not found. Using 'php'."
|
||||||
|
wanted="/usr/bin/php"
|
||||||
|
}
|
||||||
|
ln -sf "${wanted}" "${HOME}/bin/php"
|
||||||
|
inUse=$(php -nr "echo phpversion();")
|
||||||
|
echo "Shell configured to use PHP ${inUse}."
|
Loading…
Reference in New Issue