Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
switch_case_indent = true

[*.{yml,yaml,json,md}]
indent_size = 2
3 changes: 3 additions & 0 deletions .github/linters/.jscpd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"threshold": 5
}
14 changes: 12 additions & 2 deletions .github/workflows/CI-CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,24 @@ name: CI-CD

on: [push]

permissions:
contents: read
packages: read
statuses: write

jobs:
lint:
name: Linters
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Run Super-Linter
uses: github/super-linter@latest
uses: super-linter/super-linter/slim@4ce20838b8ab83717e78138c5b3a1407148e0918 # v8.7.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Biome's JSON formatting conflicts with Prettier's; keep Prettier
VALIDATE_BIOME_FORMAT: false
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
; Secret files are for tokens or other "Secret stuff"
*.secret
.DS_Store

; Machine-local scripts (work-specific etc.), only the README is committed
bin/local/*
!bin/local/README.md
28 changes: 7 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,18 @@
# Scripts

These are some non-secret scripts/configs I use locally to develop. Since I tend to break things, or redo my local setup I place them in version control

## Fair warning
I highly recommend not running other people commands blindly on your machine. So I don't expect others to do the same with mine. Which is why the only documentation included; is meant for myself.

I highly recommend not running other people commands blindly on your machine. So I don't expect others to do the same with mine. Which is why the only documentation included; is meant for myself.

## Setup

### .bashrc
Add the following to your .bashrc
```shell
# Jor bin in PATH
export PATH="$HOME/Projects/Scripts/bin:$PATH"

# Jor .profile
for f in $HOME/Projects/Scripts/profile/*; do
. "$f"
done

# Jor aliasses
for f in $HOME/Projects/Scripts/aliasses/*; do
. "$f"
done
```
Run the install script. It adds bin/ and bin/local/ (gitignored,
machine-local scripts) to PATH and sources every file under profile/ and
aliases/ from your shell rc file (~/.zshrc for Zsh, ~/.bashrc for Bash),
see `./install --help`:

### Config
```shell
mkdir -p ~/.ssh
cp config/ssh/config ~/.ssh/config
chmod 600 ~/.ssh/config
./install
```
3 changes: 3 additions & 0 deletions aliases/git
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

alias grh="git reset --hard"
2 changes: 1 addition & 1 deletion aliasses/kubectl → aliases/kubectl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
#!/bin/sh

alias k8='kubectl'
2 changes: 1 addition & 1 deletion aliasses/minikube → aliases/minikube
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

alias podmani='podman machine init --cpus 4 --memory 4096 --disk-size 100'
alias minikubed='minikube start --driver=podman --container-runtime containerd' #--alsologtostderr
2 changes: 1 addition & 1 deletion aliasses/utils → aliases/utils
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
#!/bin/sh

alias conn='ping 8.8.8.8|grep -ivE "time=[0-9][0-9]\."'
2 changes: 1 addition & 1 deletion aliasses/vim → aliases/vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
#!/bin/sh

alias vi='vim'
4 changes: 0 additions & 4 deletions aliasses/git

This file was deleted.

52 changes: 47 additions & 5 deletions bin/cb
Original file line number Diff line number Diff line change
@@ -1,8 +1,50 @@
#!/bin/bash
#!/bin/sh

if [[ $* == *"--help"* ]]; then
echo "Clean all local git branches except master|development|develop"
exit 0
usage() {
cat <<'EOF'
Usage: cb

Cleans up local git branches: deletes every local branch that has no
branch of the same name on any remote.

Runs 'git fetch --prune' first so the remote state is current. The
currently checked out branch is never deleted, and branches checked out
in other worktrees are skipped.
EOF
}

case "$1" in
-h | --help)
usage
exit 0
;;
esac

if [ -z "$(git remote)" ]; then
echo "No remotes configured, nothing to compare against" >&2
exit 1
fi

git branch | grep -iEv "master|development|develop|\\*" | xargs git branch -D
git fetch --prune

current=$(git rev-parse --abbrev-ref HEAD)

# Branches checked out in a worktree, one refs/heads/... per line.
in_worktrees=$(git worktree list --porcelain | awk '/^branch /{print substr($0, 8)}')

git for-each-ref --format='%(refname:short)' refs/heads | while read -r branch; do
[ "$branch" = "$current" ] && continue

if printf '%s\n' "$in_worktrees" | grep -Fxq "refs/heads/$branch"; then
echo "Skipping '$branch', it is checked out in a worktree"
continue
fi

for remote in $(git remote); do
if git rev-parse --verify --quiet "refs/remotes/$remote/$branch" >/dev/null; then
continue 2
fi
done

git branch -D "$branch"
done
33 changes: 0 additions & 33 deletions bin/crb

This file was deleted.

4 changes: 2 additions & 2 deletions bin/create_base64
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#!/bin/sh

if [ $# -lt 1 ] || [[ $* == *"--help"* ]]; then
if [ $# -lt 1 ] || [ "$1" = "--help" ]; then
echo "_base64.txt copy of file"
echo "\$1 original filename"
exit 0
Expand Down
4 changes: 2 additions & 2 deletions bin/create_certificate_fingerprint
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#!/bin/sh

if [ $# -lt 1 ] || [[ $* == *"--help"* ]]; then
if [ $# -lt 1 ] || [ "$1" = "--help" ]; then
echo "Get SHA1 fingerprint of a .pem file."
echo "\$1 .pem cert"
exit 0
Expand Down
4 changes: 2 additions & 2 deletions bin/create_certkey
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#!/bin/sh

if [ $# -lt 1 ] || [[ $* == *"--help"* ]]; then
if [ $# -lt 1 ] || [ "$1" = "--help" ]; then
echo "Create an RSA key.pem and cert.pem"
echo "\$1 CN for the cert"
exit 0
Expand Down
4 changes: 2 additions & 2 deletions bin/create_csr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#!/bin/sh

if [ $# -lt 2 ] || [[ $* == *"--help"* ]]; then
if [ $# -lt 2 ] || [ "$1" = "--help" ]; then
echo "Create a csr"
echo "\$1 key file .pem"
echo "\$2 CN for the csr"
Expand Down
4 changes: 2 additions & 2 deletions bin/create_csr_cert
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#!/bin/sh

if [ $# -lt 3 ] || [[ $* == *"--help"* ]]; then
if [ $# -lt 3 ] || [ "$1" = "--help" ]; then
echo "Create an validate a CSR en generate valid_cert.pem"
echo "\$1 .csr file"
echo "\$2 CA cert.pem"
Expand Down
4 changes: 2 additions & 2 deletions bin/create_keystore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#!/bin/sh

if [ $# -lt 1 ] || [[ $* == *"--help"* ]]; then
if [ $# -lt 1 ] || [ "$1" = "--help" ]; then
echo "Create a PKCS12 keystore of a .pem"
echo "\$1 .pem file"
exit 0
Expand Down
4 changes: 2 additions & 2 deletions bin/create_keystore_jks
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#!/bin/sh

if [ $# -lt 2 ] || [[ $* == *"--help"* ]]; then
if [ $# -lt 2 ] || [ "$1" = "--help" ]; then
echo "Create a JKS keystore of a PKCS12 keystore"
echo "\$1 .pkcs12 keystore file"
echo "\$2 .jks keystore file"
Expand Down
4 changes: 2 additions & 2 deletions bin/create_truststore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#!/bin/sh

if [ $# -lt 1 ] || [[ $* == *"--help"* ]]; then
if [ $# -lt 1 ] || [ "$1" = "--help" ]; then
echo "Create a PKCS12 (.pfx) truststore of a .pem file"
echo "\$1 .pem file"
exit 0
Expand Down
4 changes: 2 additions & 2 deletions bin/create_truststore_jks
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#!/bin/sh

if [ $# -lt 3 ] || [[ $* == *"--help"* ]]; then
if [ $# -lt 3 ] || [ "$1" = "--help" ]; then
echo "Create a .jks truststore of a .pem file. Or add a pem to a truststore"
echo "\$1 .pem cert"
echo "\$2 alias for the cert in the truststore"
Expand Down
32 changes: 32 additions & 0 deletions bin/ec
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh

usage() {
cat <<'EOF'
Usage: ec

Creates an empty commit with the message 'chore: empty commit' and pushes
it, e.g. to trigger CI.

When the branch has no upstream yet, it is pushed with -u to set one.
EOF
}

case "$1" in
-h | --help)
usage
exit 0
;;
esac

git commit --allow-empty -m "chore: empty commit" || exit 1

if git rev-parse --verify --quiet '@{u}' >/dev/null 2>&1; then
git push
else
remote=$(git remote | head -n 1)
if [ -z "$remote" ]; then
echo "No remote to push to" >&2
exit 1
fi
git push -u "$remote" HEAD
fi
4 changes: 2 additions & 2 deletions bin/gacp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash
#!/bin/sh

set -e

if [ $# -lt 1 ] || [[ $* == *"--help"* ]]; then
if [ $# -lt 1 ] || [ "$1" = "--help" ]; then
echo "git adds, commits and pushes"
echo "\$1 is the commit message"
exit 0
Expand Down
Loading