From 09d839d92adc32ae64cc03640ec9eec1adf729a4 Mon Sep 17 00:00:00 2001 From: Fabian Schmidt Date: Sat, 25 Jul 2020 19:21:21 +0200 Subject: [PATCH 1/2] Add basic scripts from my linux machine --- autoscript | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ glances | 12 ++++++++++ initializeANSI | 43 ++++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100755 autoscript create mode 100755 glances create mode 100755 initializeANSI diff --git a/autoscript b/autoscript new file mode 100755 index 0000000..f832fb1 --- /dev/null +++ b/autoscript @@ -0,0 +1,60 @@ +#!/bin/bash + +set -euo pipefail +IFS=$'\n\t' +oldIFS=$IFS + +help() { + echo "Usage: ${0##*/} [-l lang][-h] FILENAME" + echo "Supported languages: python, crystal, bash (default)" +} + +if [ $# -eq 0 ];then + help + exit 0 +fi + +read -d '' bashShebang << 'EOF' || true +#!/bin/bash + +set -euo pipefail +IFS=$'\\n\\t' +EOF + +read -d '' pythonShebang << EOF || true +#!/usr/bin/env python +EOF + +read -d '' crystalShebang << EOF || true +#!/usr/bin/env crystal +EOF + +shebang=$bashShebang + +while getopts ":hl:" opt;do + if [ $opt == "h" ];then + help + exit 0 + else + case $OPTARG in + py | python)shebang=$pythonShebang ;; + cr | crystal)shebang=$crystalShebang ;; + sh | bash | shell | *)shebang=$bashShebang ;; + esac + fi +done +shift $((OPTIND - 1)) + +SCRIPT_FOLDER=$HOME/.local/bin +SCRIPT_FILE=$SCRIPT_FOLDER/$1 + +if [[ -f $SCRIPT_FILE ]]; then + $EDITOR $SCRIPT_FILE +else + touch $SCRIPT_FILE + chmod +x $SCRIPT_FILE + echo "$shebang" >> $SCRIPT_FILE + $EDITOR $SCRIPT_FILE +fi + +exit 0 diff --git a/glances b/glances new file mode 100755 index 0000000..00eb75f --- /dev/null +++ b/glances @@ -0,0 +1,12 @@ +#!/usr/bin/python +# EASY-INSTALL-ENTRY-SCRIPT: 'Glances==3.1.4.1','console_scripts','glances' +__requires__ = 'Glances==3.1.4.1' +import re +import sys +from pkg_resources import load_entry_point + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) + sys.exit( + load_entry_point('Glances==3.1.4.1', 'console_scripts', 'glances')() + ) diff --git a/initializeANSI b/initializeANSI new file mode 100755 index 0000000..b7f1b85 --- /dev/null +++ b/initializeANSI @@ -0,0 +1,43 @@ +#!/bin/bash + +set -euo pipefail +IFS=$'\n\t' + +# ANSI color--Use these variables to make output in different colors +# and formats. Color names that end with 'f' are foreground colors, +# and those ending with 'b' are background colors. + +initializeANSI() +{ + #esc="\033" # If this doesn't work, enter an ESC directly. In insert mode press and Esc (^[) + esc="" + + # Foreground colors (as denoted by the 'f' at the end of the names) + blackf="${esc}[30m"; redf="${esc}[31m"; greenf="${esc}[32m" + yellowf="${esc}[33m" bluef="${esc}[34m"; purplef="${esc}[35m" + cyanf="${esc}[36m"; whitef="${esc}[37m" + + # Background colors + blackb="${esc}[40m"; redb="${esc}[41m"; greenb="${esc}[42m" + yellowb="${esc}[43m" blueb="${esc}[44m"; purpleb="${esc}[45m" + cyanb="${esc}[46m"; whiteb="${esc}[47m" + + # Bold, italic, underline, and inverse style toggles + boldon="${esc}[1m"; boldoff="${esc}[22m" + italicson="${esc}[3m"; italicsoff="${esc}[23m" + ulon="${esc}[4m"; uloff="${esc}[24m" + invon="${esc}[7m"; invoff="${esc}[27m" + + reset="${esc}[0m" +} + +initializeANSI + +cat << EOF +${yellowf}This is a phrase in yellow${redb} and red${reset} +${boldon}This is bold${ulon} this is underlined${reset} bye-bye +${italicson}This is italics${italicsoff} and this is not +${ulon}This is ul${uloff} and this is not +${invon}This is inv${invoff} and this is not +${yellowf}${redb}Warning I ${yellowb}${redf}Warning II${reset} +EOF From 63cd3baffcccd56dc31b8b7568881d05cfebd8d5 Mon Sep 17 00:00:00 2001 From: Fabian Schmidt Date: Sat, 25 Jul 2020 19:36:53 +0200 Subject: [PATCH 2/2] Add description of basic scripts from my linux machine --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 483cb28..c5b7a9b 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,22 @@ Create, list or delete bare repos on git server. Edit your config and descriptio - Create, list, delete, edit hooks +#### autoscript + +Quickly setup the base to start writing scripts. +Supports crystal, python and bash (default) + + +#### initializeANSI + +Initialize a bunch of variables with ANSI colors and co. + + +#### glances + +top alternative + + ## MacOS