diff --git a/oh-my-cfg/zsh/oh-my-custom-zsh.sh b/oh-my-cfg/zsh/oh-my-custom-zsh.sh index ed0e196..6dfcf65 100755 --- a/oh-my-cfg/zsh/oh-my-custom-zsh.sh +++ b/oh-my-cfg/zsh/oh-my-custom-zsh.sh @@ -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 # @@ -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)/ @@ -81,7 +81,6 @@ OhMyZsh-Config () { if [ -f $aliasFile ]; then rm -f $aliasFile fi - plugins="git" @@ -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 @@ -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 @@ -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 } @@ -212,7 +219,7 @@ Check_Dependencies () { fi fi - ## ZSH ## + ## Zsh ## # Checking binary of the zsh dependency. checkBinary=$(which zsh | wc -l) @@ -231,7 +238,7 @@ Check_Dependencies () { fi fi - ## CURL ## + ## Curl ## # Checking binary of the curl dependency. checkBinary=$(which curl | wc -l) diff --git a/templates/k8s_python_template.py b/templates/k8s_python_template.py new file mode 100755 index 0000000..3c9c293 --- /dev/null +++ b/templates/k8s_python_template.py @@ -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: dev.josemanuelps@gmail.com # +############################################################################### + + + +############################################################################### +## 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() + +