-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: fast-forward to 2023 for daily use: .bscripts, .bash_stuff, .c…
…onfig
- Loading branch information
1 parent
6974999
commit 2cba38b
Showing
57 changed files
with
4,834 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
OLD_HOME | ||
*~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
export USE_CCACHE=1 | ||
export CCACHE_DIR=/home/phonz | ||
export CCACHE_DIR=/home/${USER} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
### SHLVL ? | ||
|
||
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ] && [ -z "$BASH_STUFF_FIRST_SHELL_LOGIN" ]; then | ||
export IGNOREEOF=30 | ||
export BASH_STUFF_FIRST_SHELL_LOGIN=$(date +%s) | ||
else | ||
unset IGNOREEOF | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
|
||
eval "$(direnv hook bash)" | ||
|
||
#eval "$(direnv hook bash)" | ||
#eval "$(direnv hook zsh)" | ||
#eval (direnv hook fish) | ||
#eval `direnv hook tcsh` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
|
||
DOCKER=/usr/bin/docker | ||
|
||
docker () { | ||
sudo "${DOCKER}" "$@" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
|
||
#alias fehS='feh -dZ.Y --min-dimension 1x768 -B black' | ||
alias fehS='feh -dZ.Y -B black; echo feh -dZ.Y -B black $1' | ||
|
||
alias feh1='feh -dZ.Y -B black ' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,217 @@ | ||
#!/usr/bin/env bash | ||
|
||
## https://raw.githubusercontent.com/albfan/bash-ini-parser/master/bash-ini-parser | ||
## https://github.com/albfan/bash-ini-parser/blob/master/bash-ini-parser | ||
|
||
# | ||
# based on http://theoldschooldevops.com/2008/02/09/bash-ini-parser/ | ||
# | ||
|
||
PREFIX="cfg_section_" | ||
|
||
function debug { | ||
if ! [ "x$BASH_INI_PARSER_DEBUG" == "x" ] | ||
then | ||
echo $* | ||
echo --start-- | ||
echo "${ini[*]}" | ||
echo --end-- | ||
echo | ||
fi | ||
} | ||
|
||
function cfg_parser { | ||
shopt -p extglob &> /dev/null | ||
CHANGE_EXTGLOB=$? | ||
if [ $CHANGE_EXTGLOB = 1 ] | ||
then | ||
shopt -s extglob | ||
fi | ||
ini="$(<$1)" # read the file | ||
ini=${ini//$'\r'/} # remove linefeed i.e dos2unix | ||
|
||
ini="${ini//[/\\[}" | ||
debug "escaped [" | ||
ini="${ini//]/\\]}" | ||
debug "escaped ]" | ||
IFS=$'\n' && ini=( ${ini} ) # convert to line-array | ||
debug | ||
ini=( ${ini[*]/#*([[:space:]]);*/} ) | ||
debug "remove ; comments" | ||
ini=( ${ini[*]/#*([[:space:]])\#*/} ) | ||
debug "remove # comments" | ||
ini=( ${ini[*]/#+([[:space:]])/} ) # remove init whitespace | ||
debug | ||
ini=( ${ini[*]/%+([[:space:]])/} ) # remove ending whitespace | ||
debug "whitespace around =" | ||
ini=( ${ini[*]/*([[:space:]])=*([[:space:]])/=} ) # remove whitespace around = | ||
debug | ||
ini=( ${ini[*]/#\\[/\}$'\n'"$PREFIX"} ) # set section prefix | ||
debug | ||
ini=( ${ini[*]/%\\]/ \(} ) # convert text2function (1) | ||
debug | ||
ini=( ${ini[*]/=/=\( } ) # convert item to array | ||
debug | ||
ini=( ${ini[*]/%/ \)} ) # close array parenthesis | ||
debug | ||
ini=( ${ini[*]/%\\ \)/ \\} ) # the multiline trick | ||
debug | ||
ini=( ${ini[*]/%\( \)/\(\) \{} ) # convert text2function (2) | ||
debug | ||
ini=( ${ini[*]/%\} \)/\}} ) # remove extra parenthesis | ||
ini=( ${ini[*]/%\{/\{$'\n''cfg_unset ${FUNCNAME/#'$PREFIX'}'$'\n'} ) # clean previous definition of section | ||
debug | ||
ini[0]="" # remove first element | ||
debug | ||
ini[${#ini[*]} + 1]='}' # add the last brace | ||
debug | ||
eval "$(echo "${ini[*]}")" # eval the result | ||
EVAL_STATUS=$? | ||
if [ $CHANGE_EXTGLOB = 1 ] | ||
then | ||
shopt -u extglob | ||
fi | ||
return $EVAL_STATUS | ||
} | ||
|
||
function cfg_writer { | ||
SECTION=$1 | ||
OLDIFS="$IFS" | ||
IFS=' '$'\n' | ||
if [ -z "$SECTION" ] | ||
then | ||
fun="$(declare -F)" | ||
else | ||
fun="$(declare -F $PREFIX$SECTION)" | ||
if [ -z "$fun" ] | ||
then | ||
echo "section $SECTION not found" 1>&2 | ||
exit 1 | ||
fi | ||
fi | ||
fun="${fun//declare -f/}" | ||
for f in $fun; do | ||
[ "${f#$PREFIX}" == "${f}" ] && continue | ||
item="$(declare -f ${f})" | ||
item="${item##*\{}" # remove function definition | ||
item="${item##*FUNCNAME*$PREFIX\};}" # remove clear section | ||
item="${item/FUNCNAME\/#$PREFIX;}" # remove line | ||
item="${item/\}}" # remove function close | ||
item="${item%)*}" # remove everything after parenthesis | ||
item="${item});" # add close parenthesis | ||
vars="" | ||
while [ "$item" != "" ] | ||
do | ||
newvar="${item%%=*}" # get item name | ||
vars="$vars$newvar" # add name to collection | ||
item="${item#*;}" # remove readed line | ||
done | ||
vars=$(echo "$vars" | sort -u) # remove duplication | ||
eval $f | ||
echo "[${f#$PREFIX}]" # output section | ||
for var in $vars; do | ||
eval 'local length=${#'$var'[*]}' # test if var is an array | ||
if [ $length == 1 ] | ||
then | ||
echo $var=\"${!var}\" #output var | ||
else | ||
echo ";$var is an array" # add comment denoting var is an array | ||
eval 'echo $var=\"${'$var'[*]}\"' # output array var | ||
fi | ||
done | ||
done | ||
IFS="$OLDIFS" | ||
} | ||
|
||
function cfg_unset { | ||
SECTION=$1 | ||
OLDIFS="$IFS" | ||
IFS=' '$'\n' | ||
if [ -z "$SECTION" ] | ||
then | ||
fun="$(declare -F)" | ||
else | ||
fun="$(declare -F $PREFIX$SECTION)" | ||
if [ -z "$fun" ] | ||
then | ||
echo "section $SECTION not found" 1>&2 | ||
return | ||
fi | ||
fi | ||
fun="${fun//declare -f/}" | ||
for f in $fun; do | ||
[ "${f#$PREFIX}" == "${f}" ] && continue | ||
item="$(declare -f ${f})" | ||
item="${item##*\{}" # remove function definition | ||
item="${item##*FUNCNAME*$PREFIX\};}" # remove clear section | ||
item="${item/\}}" # remove function close | ||
item="${item%)*}" # remove everything after parenthesis | ||
item="${item});" # add close parenthesis | ||
vars="" | ||
while [ "$item" != "" ] | ||
do | ||
newvar="${item%%=*}" # get item name | ||
vars="$vars $newvar" # add name to collection | ||
item="${item#*;}" # remove readed line | ||
done | ||
for var in $vars; do | ||
unset $var | ||
done | ||
done | ||
IFS="$OLDIFS" | ||
} | ||
|
||
function cfg_clear { | ||
SECTION=$1 | ||
OLDIFS="$IFS" | ||
IFS=' '$'\n' | ||
if [ -z "$SECTION" ] | ||
then | ||
fun="$(declare -F)" | ||
else | ||
fun="$(declare -F $PREFIX$SECTION)" | ||
if [ -z "$fun" ] | ||
then | ||
echo "section $SECTION not found" 1>&2 | ||
exit 1 | ||
fi | ||
fi | ||
fun="${fun//declare -f/}" | ||
for f in $fun; do | ||
[ "${f#$PREFIX}" == "${f}" ] && continue | ||
unset -f ${f} | ||
done | ||
IFS="$OLDIFS" | ||
} | ||
|
||
function cfg_update { | ||
SECTION=$1 | ||
VAR=$2 | ||
OLDIFS="$IFS" | ||
IFS=' '$'\n' | ||
fun="$(declare -F $PREFIX$SECTION)" | ||
if [ -z "$fun" ] | ||
then | ||
echo "section $SECTION not found" 1>&2 | ||
exit 1 | ||
fi | ||
fun="${fun//declare -f/}" | ||
item="$(declare -f ${fun})" | ||
#item="${item##* $VAR=*}" # remove var declaration | ||
item="${item/\}}" # remove function close | ||
item="${item} | ||
$VAR=(${!VAR}) | ||
" | ||
item="${item} | ||
}" # close function again | ||
|
||
eval "function $item" | ||
} | ||
|
||
#Test harness | ||
if [ $# != 0 ] | ||
then | ||
$@ | ||
fi | ||
# vim: filetype=sh | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/usr/bin/env bash | ||
|
||
# https://stackoverflow.com/questions/6318809/how-do-i-grab-an-ini-value-within-a-shell-script | ||
|
||
cfg_parser () | ||
{ | ||
ini="$(<$1)" # read the file | ||
ini="${ini//[/\[}" # escape [ | ||
ini="${ini//]/\]}" # escape ] | ||
IFS=$'\n' && ini=( ${ini} ) # convert to line-array | ||
ini=( ${ini[*]//;*/} ) # remove comments with ; | ||
ini=( ${ini[*]/\ =/=} ) # remove tabs before = | ||
ini=( ${ini[*]/=\ /=} ) # remove tabs be = | ||
ini=( ${ini[*]/\ =\ /=} ) # remove anything with a space around = | ||
ini=( ${ini[*]/#\\[/\}$'\n'cfg.section.} ) # set section prefix | ||
ini=( ${ini[*]/%\\]/ \(} ) # convert text2function (1) | ||
ini=( ${ini[*]/=/=\( } ) # convert item to array | ||
ini=( ${ini[*]/%/ \)} ) # close array parenthesis | ||
ini=( ${ini[*]/%\\ \)/ \\} ) # the multiline trick | ||
ini=( ${ini[*]/%\( \)/\(\) \{} ) # convert text2function (2) | ||
ini=( ${ini[*]/%\} \)/\}} ) # remove extra parenthesis | ||
ini[0]="" # remove first element | ||
ini[${#ini[*]} + 1]='}' # add the last brace | ||
eval "$(echo "${ini[*]}")" # eval the result | ||
} | ||
|
||
cfg_writer () | ||
{ | ||
IFS=' '$'\n' | ||
fun="$(declare -F)" | ||
fun="${fun//declare -f/}" | ||
for f in $fun; do | ||
[ "${f#cfg.section}" == "${f}" ] && continue | ||
item="$(declare -f ${f})" | ||
item="${item##*\{}" | ||
item="${item%\}}" | ||
item="${item//=*;/}" | ||
vars="${item//=*/}" | ||
eval $f | ||
echo "[${f#cfg.section.}]" | ||
for var in $vars; do | ||
echo $var=\"${!var}\" | ||
done | ||
done | ||
} | ||
|
||
|
||
## usage: | ||
#_USE_# # parse the config file called 'myfile.ini', with the following | ||
#_USE_# # contents:: | ||
#_USE_# # [sec2] | ||
#_USE_# # var2='something' | ||
#_USE_# cfg.parser 'myfile.ini' | ||
#_USE_# | ||
#_USE_# # enable section called 'sec2' (in the file [sec2]) for reading | ||
#_USE_# cfg.section.sec2 | ||
#_USE_# | ||
#_USE_# # read the content of the variable called 'var2' (in the file | ||
#_USE_# # var2=XXX). If your var2 is an array, then you can use | ||
#_USE_# # ${var[index]} | ||
#_USE_# echo "$var2" | ||
#_USE_# | ||
|
||
## http://theoldschooldevops.com/2008/02/09/bash-ini-parser/ | ||
|
||
|
||
# https://github.com/albfan/bash-ini-parser/blob/master/bash-ini-parser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
RES=$(amixer -q -c 0 set Beep mute 2>&1) | ||
if [[ $DEBUG -ne 0 && $? -ne 0 ]]; then | ||
echo -e "$RES" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
|
||
|
||
|
||
function reminder-audio-streaming () { | ||
|
||
cat <<EOF | ||
paprefs (requires) gschema: | ||
su - | ||
cd /usr/share/glib-2.0/schemas/ | ||
wget https://cgit.freedesktop.org/pulseaudio/pulseaudio/plain/src/modules/gsettings/org.freedesktop.pulseaudio.gschema.xml | ||
glib-compile-schemas /usr/share/glib-2.0/schemas/ | ||
EOF | ||
|
||
} |
Oops, something went wrong.