Skip to content

Commit

Permalink
[oh-my-cfg/zsh] Pre-Release v1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
José Manuel Plana Santos committed Dec 28, 2022
1 parent a44aa34 commit 0971a9a
Show file tree
Hide file tree
Showing 2 changed files with 157 additions and 11 deletions.
29 changes: 18 additions & 11 deletions oh-my-cfg/zsh/oh-my-custom-zsh.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
###############################################################################
## Name: oh-my-custom-zsh.sh #
## Date: 04/10/2022 #
## Date: 28/12/2022 #
## Description: Custom configuration of oh-my-zsh. #
##----------------------------------------------------------------------------#
## Editor: José Manuel Plana Santos #
Expand All @@ -12,7 +12,7 @@

# Script information.
scriptName="oh-my-custom-zsh"
scriptVersion="v1.2"
scriptVersion="v1.3"

# Script directories.
scriptPath=$(cd $(dirname $0) ; pwd -P)/
Expand Down Expand Up @@ -81,7 +81,6 @@ OhMyZsh-Config () {
if [ -f $aliasFile ]; then
rm -f $aliasFile
fi

plugins="git"


Expand Down Expand Up @@ -114,7 +113,7 @@ OhMyZsh-Config () {
# Helm
echo ""; read -p "Do you want to autocomplete helm command? [y/n]: " selectedOption
if [ "$selectedOption" == "y" ]; then
echo "source <(helm completion zsh)" >> ~/.zshrc
echo "source <(helm completion zsh); compdef _helm helm" >> ~/.zshrc
fi

# K
Expand All @@ -128,19 +127,25 @@ OhMyZsh-Config () {
# Kubectl
echo ""; read -p "Do you want to install kubectl plugin? [y/n]: " selectedOption
if [ "$selectedOption" == "y" ]; then
plugins=$plugins" kubectl"
echo "source <(kubectl completion zsh); compdef _kubectl kubectl" >> ~/.zshrc
fi

# Minikube
echo ""; read -p "Do you want to install minikube plugin? [y/n]: " selectedOption
if [ "$selectedOption" == "y" ]; then
plugins=$plugins" minikube"
echo "source <(minikube completion zsh); compdef _minikube minikube" >> ~/.zshrc
fi

# Oc
echo ""; read -p "Do you want to install oc plugin? [y/n]: " selectedOption
if [ "$selectedOption" == "y" ]; then
plugins=$plugins" oc"
echo "source <(oc completion zsh); compdef _oc oc" >> ~/.zshrc
fi

# Tridentctl
echo ""; read -p "Do you want to autocomplete tridentctl command? [y/n]: " selectedOption
if [ "$selectedOption" == "y" ]; then
echo "source <(tridentctl completion zsh); compdef _tridentctl tridentctl" >> ~/.zshrc
fi

# zsh-autosuggestions
Expand All @@ -164,10 +169,12 @@ OhMyZsh-Config () {
plugins=$plugins" zsh-syntax-highlighting"
fi

sed -i "s|plugins.*|plugins=($plugins)|" $execUser_Home/.zshrc
if [ "$plugins" != "git" ]; then
sed -i "s|plugins.*|plugins=($plugins)|" $execUser_Home/.zshrc
fi

cat $aliasFile >> $execUser_Home/.zshrc
if [ -f $aliasFile ]; then
cat $aliasFile >> $execUser_Home/.zshrc
rm -f $aliasFile
fi
}
Expand Down Expand Up @@ -212,7 +219,7 @@ Check_Dependencies () {
fi
fi

## ZSH ##
## Zsh ##
# Checking binary of the zsh dependency.
checkBinary=$(which zsh | wc -l)

Expand All @@ -231,7 +238,7 @@ Check_Dependencies () {
fi
fi

## CURL ##
## Curl ##
# Checking binary of the curl dependency.
checkBinary=$(which curl | wc -l)

Expand Down
139 changes: 139 additions & 0 deletions templates/k8s_python_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
###############################################################################
## Name: <(script_name)> #
## Date: <(script_date)> #
## Description: <(script_description)> #
##----------------------------------------------------------------------------#
## Editor: José Manuel Plana Santos #
## Contact: [email protected] #
###############################################################################



###############################################################################
## Imports. ###################################################################
###############################################################################

#from <(package)> import <(module)>
from rich import print
from rich.progress import Progress
from rich.prompt import Prompt
from rich.table import Table
# import <(package)>
import argparse as argp
import os
import subprocess as sp
import time



###############################################################################
## Args. ######################################################################
###############################################################################

# parser = argp.ArgumentParser(description = '<(script_description)>')
# parser.add_argument('<(arg | --arg)>', metavar = '<(ARG)>', type = <(bool | int | str)>, help = '<(arg_description)>', default = <(True or False | some_number | some_text)>)
# args = parser.parse_args()



###############################################################################
## Main code. #################################################################
###############################################################################

class Main:

def __init__(self):

some_custom_var = some_custom_method('some_custom_var')
print(some_custom_var)
exit(0)

def some_custom_method(self, some_custom_var):

some_custom_var = some_custom_var + ' plus some_text'
return some_custom_var



###############################################################################
## Auxiliary methods. #########################################################
###############################################################################


def execCommand_local(self, command):
command_exec = sp.run([command], shell=True, universal_newlines=True, stdout=sp.PIPE, stderr=sp.PIPE)
return command_exec


def execCommand_remote(self, command, node_connection):
command_format = 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ' + args.ssh_key + ' ' + node_connection + ' ' + command
command_exec = sp.run([command_format], shell=True, universal_newlines=True, stdout=sp.PIPE, stderr=sp.PIPE)
return command_exec


def getNodesInfo_names(self):

get_nodes_exec = self.execCommand_local('kubectl get nodes')
get_nodes_exec_split_row = get_nodes_exec.stdout.splitlines()

nodes_info_names = []
for x in range(1, len(get_nodes_exec_split_row)):
if args.node_group == 'all':
get_nodes_exec_split_colum = get_nodes_exec_split_row[x].split()
nodes_info_names.append(get_nodes_exec_split_colum[0])
else:
get_nodes_exec_split_colum = get_nodes_exec_split_row[x].split()
if args.node_group in get_nodes_exec_split_colum[0]:
nodes_info_names.append(get_nodes_exec_split_colum[0])

return nodes_info_names


def getNodesInfo_ips(self):

get_nodes_exec = self.execCommand_local('kubectl get nodes -o wide')
get_nodes_exec_split_row = get_nodes_exec.stdout.splitlines()

nodes_info_ips = []
for x in range(1, len(get_nodes_exec_split_row)):
if args.node_group == 'all':
get_nodes_exec_split_colum = get_nodes_exec_split_row[x].split()
nodes_info_ips.append(get_nodes_exec_split_colum[5])
else:
get_nodes_exec_split_colum = get_nodes_exec_split_row[x].split()
if args.node_group in get_nodes_exec_split_colum[0]:
nodes_info_ips.append(get_nodes_exec_split_colum[5])

return nodes_info_ips



###############################################################################
## Verbose & UI. ##############################################################
###############################################################################

## Colors:
### [green] Oks, Nodes_ips, Network_interfaces_names, Network_interfaces_ips, systemservices
### [red] Errors,
### [yellow] Warnings,
### [blue] Nodes_names,
### [magent] Paths

## Emojis:
### :white_heavy_check_mark: Checks, Oks,
### :heavy_exclamation_mark: Errors,
### :warning: Warnings,
### :person_running: Skips,
### :grey_question: Asks, Questions,



###############################################################################
## Execution. #################################################################
###############################################################################

Main()


0 comments on commit 0971a9a

Please sign in to comment.