-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f6c0a6
commit 49e30dd
Showing
45 changed files
with
1,509 additions
and
360 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,8 @@ | ||
#!/usr/bin/env bash | ||
# -*- coding: UTF-8 -*- | ||
# | ||
# author : JV-conseil | ||
# credits : JV-conseil | ||
# copyright : Copyright (c) 2019-2023 JV-conseil | ||
# All rights reserved | ||
#==================================================== |
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,35 @@ | ||
#!/usr/bin/env bash | ||
# -*- coding: UTF-8 -*- | ||
# | ||
# author : JV-conseil | ||
# credits : JV-conseil | ||
# copyright : Copyright (c) 2019-2023 JV-conseil | ||
# All rights reserved | ||
#==================================================== | ||
|
||
export LANG="en_US.UTF-8" | ||
|
||
# export CLICOLOR=1 | ||
# export LSCOLORS=ExFxBxDxCxegedabagacad | ||
|
||
# print environment variables sorted by name | ||
# <https://stackoverflow.com/a/60756021/2477854> | ||
alias env="env -0 | sort -z | tr '\0' '\n'" | ||
|
||
alias ls='ls -FGlAhp --color=auto' | ||
alias mkdir='mkdir -pv' | ||
alias mv='mv -iv' | ||
alias nano="nano --linenumbers" | ||
alias rm='rm -rf' | ||
|
||
if ! [ -x "$(command -v cd_)" ]; then | ||
|
||
# Silent cd with no list directory | ||
cd_() { builtin cd "$@" || exit; } | ||
|
||
# Always list directory contents upon 'cd' | ||
cd() { | ||
builtin cd "$@" || exit | ||
ls | ||
} | ||
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,23 @@ | ||
#!/usr/bin/env bash | ||
# -*- coding: UTF-8 -*- | ||
# | ||
# author : JV-conseil | ||
# credits : JV-conseil | ||
# copyright : Copyright (c) 2019-2023 JV-conseil | ||
# All rights reserved | ||
# | ||
# GNU bash, version 5.2.15(1)-release (aarch64-apple-darwin21.6.0) | ||
# | ||
#==================================================== | ||
|
||
_jvcl_::set_homebrew_bash() { | ||
local _bash="${HOMEBREW_PREFIX}/bin/bash" | ||
if ! grep -F -q "${_bash}" "/etc/shells"; then | ||
echo "${HOMEBREW_PREFIX}/bin/bash" | sudo tee -a "/etc/shells" >/dev/null | ||
fi | ||
chsh -s "${_bash}" | ||
} | ||
|
||
if _jvcl_::is_formula_installed bash _jvcl_::set_homebrew_bash && [ $((${BASH_VERSION:0:1})) -ge 5 ]; then | ||
echo "Bash ${BASH_VERSION}" &>/dev/null # NOTE: no version display at this step | ||
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,81 @@ | ||
#!/usr/bin/env bash | ||
# -*- coding: UTF-8 -*- | ||
# | ||
# author : JV-conseil | ||
# credits : JV-conseil | ||
# copyright : Copyright (c) 2019-2023 JV-conseil | ||
# All rights reserved | ||
# | ||
# shellcheck disable=SC2034 | ||
# | ||
# black='\E[30;40m' | ||
# red='\E[31;40m' | ||
# green='\E[32;40m' | ||
# yellow='\E[33;40m' | ||
# blue='\E[34;40m' | ||
# magenta='\E[35;40m' | ||
# cyan='\E[36;40m' | ||
# white='\E[37;40m' | ||
# | ||
#==================================================== | ||
|
||
declare -A UCLD_COLORS=( | ||
[_reset]=$'\e[0m' | ||
[blue]=$'\e[1;34m' | ||
[cyan]=$'\e[1;36m' | ||
[green]=$'\e[1;32m' | ||
[magenta]=$'\e[1;35m' | ||
[red]=$'\e[1;31m' | ||
[white]=$'\e[1;37m' | ||
[yellow]=$'\e[1;33m' | ||
) | ||
|
||
_jvcl_::alert() { | ||
local _message=${1:-"Error"} _color=${2:-"magenta"} | ||
|
||
echo -e "${UCLD_COLORS["${_color}"]}${1}${UCLD_COLORS[_reset]} 馃洃" | ||
echo | ||
} | ||
|
||
# read | ||
|
||
_jvcl_::ask() { | ||
local _prompt=${1:-"Houston Do You Copy"} _color=${2:-"cyan"} | ||
|
||
read -e -r -p "${UCLD_COLORS["${_color}"]}${_prompt}? [y/N]${UCLD_COLORS["_reset"]} " -n 1 | ||
if [[ "${REPLY}" =~ ^[Yy]$ ]]; then | ||
true | ||
else | ||
false | ||
fi | ||
} | ||
|
||
_jvcl_::ask_2() { | ||
_jvcl_::ask "$1" "green" | ||
} | ||
|
||
# h1, H2, h3... | ||
|
||
_jvcl_::h1() { | ||
local _message _color | ||
|
||
_message=${1:-"Title h1"} | ||
_color=${2:-"magenta"} | ||
|
||
_message="$(echo -e "${UCLD_COLORS["${_color}"]}${_message}${UCLD_COLORS["_reset"]}")" | ||
|
||
cat <<EOF | ||
${_message} | ||
EOF | ||
} | ||
|
||
_jvcl_::h2() { | ||
_jvcl_::h1 "${1}..." "green" | ||
} | ||
|
||
_jvcl_::h3() { | ||
_jvcl_::h1 "${1}..." "blue" | ||
} |
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,56 @@ | ||
#!/usr/bin/env bash | ||
# -*- coding: UTF-8 -*- | ||
# | ||
# author : JV-conseil | ||
# credits : JV-conseil | ||
# copyright : Copyright (c) 2019-2023 JV-conseil | ||
# All rights reserved | ||
#==================================================== | ||
|
||
_jvcl_::debug() { | ||
if [[ "${DEBUG}" -eq 0 ]]; then | ||
return | ||
fi | ||
cat <<EOF | ||
=============== | ||
DEBUG LEVEL ${DEBUG} | ||
=============== | ||
EOF | ||
|
||
cat /proc/version 2>/dev/null || : | ||
cat /etc/issue 2>/dev/null || : | ||
_jvcl_::set_show_options | ||
python --version || : | ||
|
||
if [[ "${DEBUG}" -gt 1 ]]; then | ||
|
||
if [[ "${DEBUG}" -gt 2 ]]; then | ||
|
||
echo "$( | ||
set -o posix | ||
set | sort | ||
)" | ||
|
||
if [[ "${DEBUG}" -gt 3 ]]; then | ||
# exec 2>>.bash/logfile.log | ||
exec {BASH_XTRACEFD}>>.bash/logfile.log | ||
set -x | ||
fi | ||
|
||
else | ||
|
||
echo | ||
env | ||
echo | ||
|
||
fi | ||
|
||
echo | ||
alias | ||
echo | ||
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,84 @@ | ||
#!/usr/bin/env bash | ||
# -*- coding: UTF-8 -*- | ||
# | ||
# author : JV-conseil | ||
# credits : JV-conseil | ||
# copyright : Copyright (c) 2019-2023 JV-conseil | ||
# All rights reserved | ||
#==================================================== | ||
|
||
# Set PATH, MANPATH, etc., for Homebrew for M1 | ||
case $(arch) in | ||
arm64) # M1 | ||
eval "$(/opt/homebrew/bin/brew shellenv)" | ||
|
||
;; | ||
i386) # Intel | ||
# Warning: Homebrew's "sbin" was not found in your PATH but you have installed | ||
# formulae that put executables in /usr/local/sbin. | ||
# Consider setting your PATH for example like so: | ||
export PATH="/usr/local/sbin:$PATH" | ||
export HOMEBREW_PREFIX="/usr/local" | ||
;; | ||
esac | ||
|
||
_jvcl_::brew_install_formula() { | ||
if _jvcl_::is_homebrew_installed; then | ||
_jvcl_::h1 "Checking if ${1} is installed..." | ||
brew ls --versions "${1}" || brew install "${1}" | ||
fi | ||
} | ||
|
||
_jvcl_::is_formula_installed() { | ||
local _formula="${1}" _type | ||
|
||
_type="${_formula}" | ||
|
||
if [[ "${_formula}" == "postgresql@"* ]]; then _type="psql"; fi | ||
if [[ "${_formula}" == "python@"* ]]; then _type="python"; fi | ||
if [[ "${_formula}" == "visual-studio-code"* ]]; then _type="code"; fi | ||
|
||
if type "${_type}" &>/dev/null; then | ||
true | ||
elif _jvcl_::ask "Do you want to install ${_formula}"; then | ||
brew install "${_formula}" | ||
# "${2:-}" # extra func passed as an argument e.g.: _jvcl_::is_formula_installed bash _jvcl_::set_homebrew_bash | ||
if [ -n "${2:-}" ]; then | ||
"${2}" | ||
fi | ||
true | ||
else | ||
false | ||
fi | ||
} | ||
|
||
_jvcl_::is_homebrew_installed() { | ||
if type brew &>/dev/null; then | ||
true | ||
elif _jvcl_::ask "Do you want to install Homebrew"; then | ||
_jvcl_::h3 "Installing Homebrew" | ||
curl -fsSL "https://raw.githubusercontent.com/Homebrew/install/master/install.sh" | ||
true | ||
else | ||
false | ||
fi | ||
} | ||
|
||
_jvcl_::update_mas() { | ||
mas list | ||
mas upgrade | ||
} | ||
|
||
_jvcl_::update_homebrew() { | ||
local _opt | ||
for _opt in "config" "doctor" "update" "upgrade" "autoremove" "cleanup"; do | ||
brew "${_opt}" --verbose || : | ||
done | ||
|
||
# You can dump a Brewfile of your current brew/cask/mas entries into your current directory with | ||
# https://gist.github.com/ChristopherA/a579274536aab36ea9966f301ff14f3f#creating-a-brewfile | ||
brew bundle dump --force --file="${HOME}/Brewfile" | ||
|
||
# Update pip | ||
python3 -m pip install --upgrade pip | ||
} |
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,15 @@ | ||
#!/usr/bin/env bash | ||
# -*- coding: UTF-8 -*- | ||
# | ||
# author : JV-conseil | ||
# credits : JV-conseil | ||
# copyright : Copyright (c) 2019-2023 JV-conseil | ||
# All rights reserved | ||
# | ||
# Helper script for installing poetry on pipeline | ||
# | ||
#==================================================== | ||
|
||
curl -sSL https://install.python-poetry.org | python3 - | ||
|
||
export PATH="/root/.local/bin:${PATH}" |
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,19 @@ | ||
#!/usr/bin/env bash | ||
# -*- coding: UTF-8 -*- | ||
# | ||
# author : JV-conseil | ||
# credits : JV-conseil | ||
# copyright : Copyright (c) 2019-2023 JV-conseil | ||
# All rights reserved | ||
#==================================================== | ||
|
||
alias python=python3 | ||
|
||
if _jvcl_::is_formula_installed "python@${REPO_PARAM[python]}"; then | ||
export PATH="${HOMEBREW_PREFIX}/opt/python@${REPO_PARAM[python]}/libexec/bin:$PATH" | ||
export PYTHONPATH="${HOMEBREW_PREFIX}/bin/python${REPO_PARAM[python]}" | ||
export PATH="${PYTHONPATH}/bin:$PATH" | ||
export LDFLAGS="-L${PYTHONPATH}/lib" | ||
export PKG_CONFIG_PATH="${PYTHONPATH}/lib/pkgconfig" | ||
# python --version | ||
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,55 @@ | ||
#!/usr/bin/env bash | ||
# -*- coding: UTF-8 -*- | ||
# | ||
# author : JV-conseil | ||
# credits : JV-conseil | ||
# copyright : Copyright (c) 2019-2023 JV-conseil | ||
# All rights reserved | ||
# | ||
# settings to write safe scripts | ||
# <https://sipb.mit.edu/doc/safe-shell/> | ||
# | ||
# The Set Builtin allows you to change the values of shell options | ||
# <https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html> | ||
# | ||
# Shopt builtin allows you to change additional shell optional behavior | ||
# <https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html> | ||
# | ||
# The Unofficial Bash Strict Mode | ||
# These lines deliberately cause your script to fail. | ||
# Wait, what? Believe me, this is a good thing. | ||
# <http://redsymbol.net/articles/unofficial-bash-strict-mode/> | ||
# | ||
# Safer bash scripts with 'set -euxo pipefail' | ||
# <https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/> | ||
# | ||
#==================================================== | ||
|
||
_jvcl_::set_show_options() { | ||
bash --version || : | ||
cat <<EOF | ||
Bash $(if [[ "${-}" =~ [eu] ]]; then echo "Strict Mode activated"; else echo "Options"; fi) set ${-} | ||
$(echo ${SHELLOPTS} | tr ':' '\n') | ||
$(shopt -s) | ||
EOF | ||
} | ||
|
||
_jvcl_::set_terminal_mode() { | ||
set +eu | ||
set -E -o pipefail | ||
shopt -s failglob | ||
IFS=$'\n\t' | ||
} | ||
|
||
_jvcl_::set_strict_mode() { | ||
_jvcl_::set_terminal_mode | ||
set -eu | ||
} | ||
|
||
_jvcl_::set_terminal_mode | ||
if [ "${BASH_STRICT_MODE}" -gt 0 ]; then | ||
_jvcl_::set_strict_mode | ||
fi |
Oops, something went wrong.