Compare commits

...

10 Commits

Author SHA1 Message Date
Fabian Schmidt
b5aea3aeed Merge branch 'master' into macos 2020-07-28 07:48:19 +02:00
Fabian Schmidt
6fc84ce7be Added gitignore file 2020-07-28 07:47:57 +02:00
Fabian Schmidt
e085233dcb Merge branch 'master' into macos 2020-07-27 08:49:40 +02:00
Fabian Schmidt
63cd3baffc Add description of basic scripts from my linux machine 2020-07-25 19:36:53 +02:00
Fabian Schmidt
09d839d92a Add basic scripts from my linux machine 2020-07-25 19:21:21 +02:00
Fabian Schmidt
2e70b1e35d Merge branch 'master' of git.fabschmidt.xyz:/srv/git/scripts into macos 2020-07-10 15:01:00 +02:00
Fabian Schmidt
35f09d5871 Added readme description for run, rgit, mcal and displayer 2020-07-10 14:55:33 +02:00
Fabian Schmidt
b3b11e3b0e Show calendar the way gcal is supposed to (does not work great) 2020-07-10 08:10:17 +02:00
Fabian Schmidt
a69b214c91 Set display order with displayplacer (see: https://github.com/jakehilborn/displayplacer) 2020-07-10 08:03:38 +02:00
Fabian Schmidt
2d56e0cbc8 Run programs detached from terminal and without any kind of output 2020-07-10 07:59:31 +02:00
8 changed files with 183 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
.DS_Store
*.app

View File

@@ -0,0 +1,52 @@
# Script collection
This is a collection of scripts I use on different systems
## Unix
#### run
Simple script to run programs detached from terminal.
No nohup.out, no stdout or stderr, don't close program when terminating the terminal.
#### rgit
Utility to remotely work on git repos through ssh.
Create, list or delete bare repos on git server. Edit your config and description locally in your $EDITOR.
***TODO***
- 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
#### mcal
Show a calendar in your terminal the way gcal **should**.
From [this](https://apple.stackexchange.com/questions/93906/cal-command-start-monday) stackexchange post.
This does not work perfectly but **WHOSE** idea was it to display a calendar vertically?!
#### displayer
Reorganize your displays with displayplacer. Documentation on how to properly set this up is [here](https://github.com/jakehilborn/displayplacer).
And again, I just have to ask: **WTF APPLE ?!** How hard is it to not fuck my displays up after every boot?

60
autoscript Executable file
View File

@@ -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

7
displayer Executable file
View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# run displayplacer list and copy last line below
/usr/local/bin/displayplacer "id:49F08A4F-75FC-4C49-1D42-FCAFFAD002D9 res:1440x900 color_depth:8 scaling:on origin:(0,0) degree:0" "id:53E94505-4CEC-6831-DC98-38719471A1A2 res:2560x1440 hz:60 color_depth:8 scaling:off origin:(-2560,-540) degree:0" "id:FC867AA0-A4A6-CD6C-080F-31EFDA5C3F71 res:2560x1440 hz:60 color_depth:8 scaling:off origin:(-5120,-540) degree:0"
exit 0

12
glances Executable file
View File

@@ -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')()
)

43
initializeANSI Executable file
View File

@@ -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 <C-v> 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

4
mcal Executable file
View File

@@ -0,0 +1,4 @@
cal | awk '{ print " "$0; getline; print " Mo Tu We Th Fr Sa Su"; \
getline; if (substr($0,1,2) == " 1") print " 1 "; \
do { prevline=$0; if (getline == 0) exit; print " " \
substr(prevline,4,17) " " substr($0,1,2) " "; } while (1) }'

3
run Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env bash
($1 >/dev/null 2>&1 &)