Added zshrc and update-pkg

This commit is contained in:
Marcin Woźniak 2024-10-30 21:22:52 +01:00 committed by Marcin Woźniak
parent 50f025d579
commit 54a3a20434
2 changed files with 72 additions and 22 deletions

View File

@ -63,8 +63,10 @@ function err() {
function command_start() { function command_start() {
timestamp "Command $* has been started." timestamp "Command $* has been started."
if ! "$*"; then if ! "$*"; then
err "---------"
err "Command $* went wrong." err "Command $* went wrong."
exit err "---------"
# exit
fi fi
timestamp "Command $* has been ended." timestamp "Command $* has been ended."
} }
@ -83,7 +85,7 @@ function command_exists() {
function update_pip() { function update_pip() {
# Update the pip # Update the pip
if [[ "$(uname)" == "Darwin" ]]; then if [[ "$(uname)" == "Darwin" ]]; then
$python -m pip install --upgrade pip --user --break-system-packages $python -m pip install --upgrade pip --user --no-warn-script-location --break
elif [[ -f $GENTOO ]]; then elif [[ -f $GENTOO ]]; then
$install dev-python/pip $install dev-python/pip
fi fi
@ -94,6 +96,20 @@ function install_neovim_module_for_python() {
$pip install pynvim neovim imps $PIPEXTPRE $pip install pynvim neovim imps $PIPEXTPRE
} }
function install_node(){
if command_exists npm; then
timestamp "Node has been found"
else
if [[ "$(uname)" == "Darwin" ]]; then
sudo brew uninstall node
sudo rm -rf /opt/homebrew/lib/node_modules/npm/
$install node
elif [[ -f $GENTOO ]]; then
$install dev-lang/nodejs
fi
fi
}
function install_pyright() { function install_pyright() {
# Install pyright # Install pyright
sudo npm -s -g i pyright --force sudo npm -s -g i pyright --force
@ -326,13 +342,26 @@ function install_gh_cli() {
function install_kubernetes() { function install_kubernetes() {
# Install kubectl # Install kubectl
if [[ "$(uname)" == "Darwin" ]]; then LINK=""
wget "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/arm64/kubectl" -O $HOME/.local/bin/kubectl CURRENT_VERSION=""
chmod +x $HOME/.local/bin/kubectl REMOTE_VERSION=$(curl -L -s https://dl.k8s.io/release/stable.txt)
else KUBECTL_LOCATION="$HOME/.local/bin/kubectl"
wget "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" -O $HOME/.local/bin/kubectl
chmod +x $HOME/.local/bin/kubectl [ -f $HOME/.local/bin/kubectl ] && CURRENT_VERSION=$($KUBECTL_LOCATION version --client | grep --color=no -iEo 'Client Version: v[0-9\.]+' | grep -ioE --color=no 'v[0-9\.]+')
if [ "$REMOTE_VERSION" == "$CURRENT_VERSION" ]; then
timestamp "The current version of the kubectl is the same as the newest version"
return 0
fi fi
if [[ "$(uname)" == "Darwin" ]]; then
LINK="http://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/amd64/kubectl"
else
LINK="http://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
fi
wget "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" -O $KUBECTL_LOCATION
chmod +x $KUBECTL_LOCATION
} }
function install_rust() { function install_rust() {
@ -347,25 +376,42 @@ function install_rust() {
function install_tss_client() { function install_tss_client() {
# Install tss # Install tss
CURRENT_VERSION="1.0.0" CURRENT_VERSION="1.5.7"
# Example link: https://downloads.ss.thycotic.com/secretserversdk/1.5.7/secretserver-sdk-1.5.7-linux-x64.zip # Example link: https://downloads.ss.thycotic.com/secretserversdk/1.5.7/secretserver-sdk-1.5.7-linux-x64.zip
LINK=$(curl -s -L https://docs.delinea.com/online-help/secret-server/api-scripting/sdk-devops/sdk-downloads/index.htm | grep -iEo 'href=".*-linux-x64.zip"' | sed 's/href\=//g;s/"//g' | sort -r | head -n1) TSSDOCS="https://docs.delinea.com/online-help/secret-server/api-scripting/sdk-devops/sdk-downloads/index.htm"
REMOTE_VERSION=$(echo $LINK | grep -iEo '[0-9.]+-linux' | sed 's/-linux//g') LINK=""
REMOTE_VERSION=""
[ -f /usr/bin/tss ] && CURRENT_VERSION=$(/usr/bin/tss version) if [ "$(uname)" == "Darwin" ]; then
LINK=$(curl -s -L $TSSDOCS | grep -iEo 'href=".*-osx-x64.zip"' | sed 's/href\=//g;s/"//g' | sort -r | head -n1)
REMOTE_VERSION=$(echo $LINK | grep -iEo '[0-9.]+-osx' | sed 's/-osx//g')
else
LINK=$(curl -s -L $TSSDOCS | grep -iEo 'href=".*-linux-x64.zip"' | sed 's/href\=//g;s/"//g' | sort -r | head -n1)
REMOTE_VERSION=$(echo $LINK | grep -iEo '[0-9.]+-linux' | sed 's/-linux//g')
fi
TSSFOLDER="$HOME/.local/tss-sdk"
TSSLINK="$HOME/.local/bin/tss"
[ -f $TSSLINK ] && CURRENT_VERSION=$($TSSLINK version)
timestamp "Current version of the TSS-SDK: $CURRENT_VERSION"
timestamp "Remote version of the TSS-SDK: $REMOTE_VERSION"
if [ "$REMOTE_VERSION" == "$CURRENT_VERSION" ]; then if [ "$REMOTE_VERSION" == "$CURRENT_VERSION" ]; then
timestamp "The current version of the TSS-SDK is the same as the newest version" timestamp "The current version of the TSS-SDK is the same as the newest version"
return 0 return 0
else else
sudo rm -rfv /usr/bin/tss-sdk /usr/bin/tss rm -rfv $TSSFOLDER $TSSLINK
sudo mkdir /usr/bin/tss-sdk mkdir $TSSFOLDER
sudo wget $LINK -P /usr/bin/tss-sdk timestamp "Downloading the newest version of the TSS-SDK"
sudo unzip secretserver-sdk-*.zip -d /usr/bin/tss-sdk > /dev/null timestamp "Link: $LINK"
sudo rm -rfv /usr/bin/tss-sdk/secretserver-sdk-*.zip wget $LINK -P $TSSFOLDER
sudo ln -s /usr/bin/tss-sdk/tss /usr/bin/tss unzip $TSSFOLDER/secretserver-sdk-*.zip -d $TSSFOLDER
sudo chmod +x /usr/bin/tss rm -rfv $TSSFOLDER/secretserver-sdk-*.zip
ln -s $TSSFOLDER/tss $TSSLINK
chmod +x $TSSLINK
fi fi
} }
@ -373,13 +419,13 @@ function install_tss_client() {
function main() { function main() {
command_start update_pip command_start update_pip
command_start install_neovim_module_for_python command_start install_neovim_module_for_python
command_start install_node
command_start install_go command_start install_go
command_start install_pyright command_start install_pyright
command_start install_lazy command_start install_lazy
command_start install_dlv command_start install_dlv
command_start install_bash-language-server command_start install_bash-language-server
command_start install_yaml-language-server command_start install_yaml-language-server
command_start install_ansible-language-server
command_start install_marksman command_start install_marksman
command_start install_shfmt command_start install_shfmt
command_start install_shellcheck command_start install_shellcheck
@ -391,6 +437,7 @@ function main() {
command_start install_black command_start install_black
command_start install_ansible command_start install_ansible
command_start install_meraki_ansible command_start install_meraki_ansible
command_start install_ansible-language-server
command_start install_ytdlp command_start install_ytdlp
command_start install_spotifydl command_start install_spotifydl
command_start install_awscli command_start install_awscli
@ -399,7 +446,7 @@ function main() {
command_start install_gh_cli command_start install_gh_cli
command_start install_kubernetes command_start install_kubernetes
command_start install_rust command_start install_rust
# command_start install_tss_client command_start install_tss_client
command_start update command_start update
} }

5
.zshrc
View File

@ -156,7 +156,7 @@ if [[ "$(uname)" == "Darwin" ]]; then
alias date='gdate' alias date='gdate'
alias lsblk="diskutil list" alias lsblk="diskutil list"
alias Update="~/.local/bin/Update-pkg; brew update; brew upgrade" alias Update="$HOME/.local/bin/Update-pkg; brew update; brew upgrade; sudo softwareupdate -i -a -R"
alias ls="ls -Gh" alias ls="ls -Gh"
alias mpv="mpv --ytdl-raw-options="yes-playlist=" --no-resume-playback --ytdl-format='bestvideo[height<=?1080]+bestaudio/best'" alias mpv="mpv --ytdl-raw-options="yes-playlist=" --no-resume-playback --ytdl-format='bestvideo[height<=?1080]+bestaudio/best'"
alias code="open -a 'Visual Studio Code'" alias code="open -a 'Visual Studio Code'"
@ -225,5 +225,8 @@ setopt +o nomatch
# Error with icu # Error with icu
export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
# Security changes made in High Sierra that are breaking lots of Python things that use fork()
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
# Error with Delinea - Linux # Error with Delinea - Linux
[ -f "/etc/ssl/certs/ca-certificates.crt" ] && export REQUESTS_CA_BUNDLE='/etc/ssl/certs/ca-certificates.crt' [ -f "/etc/ssl/certs/ca-certificates.crt" ] && export REQUESTS_CA_BUNDLE='/etc/ssl/certs/ca-certificates.crt'