Backed up pre-existing configs to local branch

This commit is contained in:
janolehuebner 2025-04-05 02:52:47 +02:00
parent 8cd9134e10
commit 873bfc08be
39 changed files with 15 additions and 781 deletions

View file

@ -1,28 +0,0 @@
# Basic safe boolean evaluation. See this Gist for details:
# https://gist.github.com/gliech/184dc7566821442202f21dfe15e2b7ff
function truthy {
if [[ "${1,,}" == @(y|yes|on|true|1) ]]; then
return 0
fi
return 1
}
function falsy {
if [[ "${1,,}" == @(n|no|off|false|0) ]]; then
return 0
fi
return 1
}
function true_false_default {
case "${1,,}" in
y | yes | on | true | 1)
return 0 ;;
n | no | off | false | 0)
return 1 ;;
esac
shift
eval "$@"
return 1
}

View file

@ -1,29 +0,0 @@
# .bash_profile
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
# Export environment variables found in ~/.environment.d/ . Adding files in a
# directory makes it easier to supply environment variables that are either
# specific to a machine or can not be included in the dotfiles repository for
# security or privacy reasons.
set -a
for file in ~/.environment.d/*.env; do
. "$file"
done
set +a
unset -v file
# Source the .bashrc if the file descriptor for stdin is opened. This is a very
# simple test to determine if the .bash_profile was sourced from VT or SSH-login
# where the .bashrc has to be sourced to provide a similar environment to a
# terminal emulator. Found here:
# https://eklitzke.org/effectively-using-bash-profile
# I had to move the actual test '-t 0' over to the bashrc. More information as
# to why can be found there.
if [[ -r ~/.bashrc ]]; then
. ~/.bashrc
fi

51
.bashrc
View file

@ -1,51 +0,0 @@
# .bashrc
# Don't load the bashrc if the terminal is not interactive. More information
# on how this test works can be found at the end of the bash_profile. I had to
# move this test here, because in remote shells the bashrc is sourced directly,
# wether the shell is really interactive or not. A brief explanation of this
# behaviour can be found here:
# https://unix.stackexchange.com/questions/257571
if ! [[ -t 0 ]]; then
return 0
fi
# Source global definitions
if [[ -r /etc/bashrc ]]; then
. /etc/bashrc
fi
# Bash 4 or bust
if (( BASH_VERSINFO[0] < 4 )); then
echo "Please get a newer version of Bash." >&2
echo "Your bashrc won't work otherwise." >&2
return 1
fi
# Determine if the rest of the configuration should be loaded. DOTFILES_ACTIVE
# is a environment variable that can be set in ~/.environment.d/dotfiles.env
if [[ "${DOTFILES_ACTIVE,,}" == @(y|yes|on|true|1) ]]; then
# Load a function that allows us to import other function definitions from
# the BASH_FUNC_PATH without providing their exact location and export it
. "$DOTFILES_DIR/bash_functions/autosource.sh"
export -f autosource
# Load utilty functions that may be used by other configurations
autosource bool_eval
autosource dot_utility
# Load the rest of the bash configs in ~/.basrc.d
for file in ~/.bashrc.d/*.sh; do
. "$file"
done
unset -v file
# If the DOTFILES_ACTIVE is not set at all, assume that the dotfiles repo was
# cloned very recently and print a friendly reminder.
elif [[ ! -v DOTFILES_ACTIVE ]]; then
echo "Dotfiles environment not found." >&2
echo "You should probably reload your login session before proceeding." >&2
return 1
fi

View file

@ -1,15 +0,0 @@
# If aws-azure-login is not installed do nothing
if ! command -v aws-azure-login >/dev/null 2>&1; then
return
fi
# In WSL the no-sandbox parameter is mandatory for aws-azure-login to function
# correctly
if truthy $DOTFILES_WSL; then
alias aws-azure-login="aws-azure-login --no-sandbox"
fi
# Make it so I just have to type a command and the (optionally) a profile
function aws-auth {
aws-azure-login --no-prompt ${1:+--profile $1}
}

View file

@ -1,17 +0,0 @@
# Save other operating systems some work
if [[ $OSTYPE != darwin* ]] || ! command -v brew >/dev/null 2>&1; then
return
fi
BREW_DIR=$(brew --prefix)
# for brew formula bash-completion@2
if [[ -r ${BREW_DIR}/etc/profile.d/bash_completion.sh ]]; then
export BASH_COMPLETION_COMPAT_DIR=${BREW_DIR}/etc/bash_completion.d
. ${BREW_DIR}/etc/profile.d/bash_completion.sh
fi
# for brew formula python
if [[ -d ${BREW_DIR}/opt/python/libexec/bin ]]; then
export PATH=${BREW_DIR}/opt/python/libexec/bin:$PATH
fi

View file

@ -1 +0,0 @@
alias diff="diff --color=auto --unified"

View file

@ -1,39 +0,0 @@
# Alias dotfiles to the custom git command required for the functioning of the
# dotfiles utility
alias dotfiles="git \
-c include.path=$DOTFILES_DIR/dotgit_config \
--git-dir=$DOTFILES_GITDIR \
--work-tree=$HOME"
# Shorten the dotfiles command to dot if possible
if ! command -v dot >/dev/null 2>&1
then
alias dot="dotfiles"
dot_aliased="yes"
fi
# Add bash completion to the aliases if possible
possible_locations=(
"/usr/share/doc/git/contrib/completion/git-completion.bash"
"/usr/share/git/completion/git-completion.bash"
"/usr/share/bash-completion/completions/git"
"/usr/local/etc/bash_completion.d/git-completion.bash"
"/opt/homebrew/etc/bash_completion.d/git-completion.bash"
)
for completion_file in "${possible_locations[@]}"
do
if [[ -r "$completion_file" ]]
then
. $completion_file
__git_complete dotfiles __git_main
if [[ $dot_aliased == yes ]]
then
__git_complete dot __git_main
fi
break
fi
done
unset -v dot_aliased possible_locations completion_file

View file

@ -1,64 +0,0 @@
# This is the first-run installation of the dotfiles utility. Although I have
# been trying to avoid the need of executing additional code to put my config
# files into place, that is not always possible or practical. The following
# script is my attempt to make this as painless as possible.
# Get the checksum of this very file.
read -r checksum _ <<< $(sha256sum "${BASH_SOURCE[0]}")
# Compare the computed checksum to a cached version from the environment. This
# is done instead of a boolean token, so that the installation will run again
# automatically, should this file change after an update.
if [[ $checksum != $DOTFILES_INSTALL_CHECKSUM ]]; then
# If the checksum differed, source the file that contains the cached checksum
# and compare again to make sure that an update has not occured and already
# been processed since the environment has last been sourced at the beginning
# of the login session. Testing twice is a trade-off because most of the time
# the first test will fail and no file has to be sourced.
if [[ -r ~/.environment.d/dotfiles_install.env ]]; then
. ~/.environment.d/dotfiles_install.env
fi
if [[ $checksum != $DOTFILES_INSTALL_CHECKSUM ]]; then
# Installation starts here. Sections should still be designed in a way that
# they won't run twice if possible.
############################################################################
echo "Dotfiles: Starting automatic installation routines"
dotfiles_install_error="no"
# vim-plug
if ! [[ -f ~/.local/share/nvim/site/autoload/plug.vim ]]; then
echo "Dotfiles: Downloading vim-plug..."
if curl \
--fail \
--location \
--retry 5 \
--retry-delay 1 \
--create-dirs \
--progress-bar \
--output ~/.local/share/nvim/site/autoload/plug.vim \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
then
echo "Dotfiles: Done"
else
echo "Dotfiles: Error downloading vim-plug"
dotfiles_install_error="yes"
fi
fi
############################################################################
# Installation ends here. If we have come this far the installation should
# have been successful. Write the current checksum of this file to
# dotfiles_install.env and export the variable for good measure.
if [[ $dotfiles_install_error == "no" ]]; then
echo "Dotfiles: Automatic installation successful. Setting new checksum..."
echo "DOTFILES_INSTALL_CHECKSUM=$checksum" > ~/.environment.d/dotfiles_install.env
export DOTFILES_INSTALL_CHECKSUM=$checksum
else
echo "Dotfiles: Errors were encountered during automatic installation"
echo "Dotfiles: Installation can be re-run by opening a new shell"
fi
fi
fi

View file

@ -1,12 +0,0 @@
# https://twitter.com/liamosaur/status/506975850596536320
function fuck {
local nth_last=${1:-1}
if [[ "$nth_last" =~ ^[0-9]+$ ]]; then
sudo $(fc -ln -$nth_last -$nth_last)
else
echo "Usage: fuck [offset]"
return 1
fi
}
alias please='fuck'

View file

@ -1,12 +0,0 @@
# On BSD-based operating systems the GNU coreutils version of ls may be
# installed as gls. I prefer a consistent ls to one that actually integrates
# well with MacOS, so here we are.
if command -v gls >/dev/null 2>&1; then
alias ls="gls --color=auto"
else
alias ls="ls --color=auto"
fi
alias ll="ls --human-readable --color=auto -l"
alias la="ls --human-readable --all --color=auto -l"
alias lA="ls --human-readable --almost-all --color=auto -l"

View file

@ -1,6 +0,0 @@
# Use neovim instead of vim if it is present
if command -v nvim >/dev/null 2>&1; then
alias vim="nvim"
fi

View file

@ -1,6 +0,0 @@
if ! command -v open >/dev/null 2>&1
then
function open {
gio open ${@:-.}
}
fi

View file

@ -1,28 +0,0 @@
[color]
diff = auto
status = auto
branch = auto
interactive = auto
ui = true
pager = true
submodule = true
fetch = true
pull = true
[push]
default = simple
[pull]
ff = only
[core]
excludesfile = ~/.gitignore
autocrlf = input
[status]
submoduleSummary = true
[pager]
log = less --chop-long-lines --shift 3
[alias]
graph = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
chronograph = graph --date-order
ff = merge --ff-only
amend = commit --amend --reuse-message=HEAD
[init]
defaultBranch = main

View file

@ -1,190 +0,0 @@
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see https://i3wm.org/docs/userguide.html for a complete reference!
set $mod Mod4
# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
font pango:monospace 8
# This font is widely installed, provides lots of unicode glyphs, right-to-left
# text rendering and scalability on retina/hidpi displays (thanks to pango).
#font pango:DejaVu Sans Mono 8
# Start XDG autostart .desktop files using dex. See also
# https://wiki.archlinux.org/index.php/XDG_Autostart
exec --no-startup-id dex --autostart --environment i3
# The combination of xss-lock, nm-applet and pactl is a popular choice, so
# they are included here as an example. Modify as you see fit.
# xss-lock grabs a logind suspend inhibit lock and will use i3lock to lock the
# screen before suspend. Use loginctl lock-session to lock your screen.
exec --no-startup-id xss-lock --transfer-sleep-lock -- i3lock --nofork
# NetworkManager is the most popular way to manage wireless networks on Linux,
# and nm-applet is a desktop environment-independent system tray GUI for it.
exec --no-startup-id nm-applet
# Use pactl to adjust volume in PulseAudio.
set $refresh_i3status killall -SIGUSR1 i3status
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10% && $refresh_i3status
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10% && $refresh_i3status
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status
bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status
# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod
# start a terminal
bindsym $mod+Return exec i3-sensible-terminal
# kill focused window
bindsym $mod+Shift+q kill
# start dmenu (a program launcher)
bindsym $mod+space exec --no-startup-id dmenu_run
# A more modern dmenu replacement is rofi:
# bindcode $mod+40 exec "rofi -modi drun,run -show drun"
# There also is i3-dmenu-desktop which only displays applications shipping a
# .desktop file. It is a wrapper around dmenu, so you need that installed.
# bindcode $mod+40 exec --no-startup-id i3-dmenu-desktop
# change focus
bindsym $mod+j focus left
bindsym $mod+k focus down
bindsym $mod+l focus up
bindsym $mod+semicolon focus right
# alternatively, you can use the cursor keys:
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right
# move focused window
bindsym $mod+Shift+j move left
bindsym $mod+Shift+k move down
bindsym $mod+Shift+l move up
bindsym $mod+Shift+semicolon move right
# alternatively, you can use the cursor keys:
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right
# split in horizontal orientation
bindsym $mod+h split h
# split in vertical orientation
bindsym $mod+v split v
# enter fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle
# change container layout (stacked, tabbed, toggle split)
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split
# toggle tiling / floating
bindsym $mod+Shift+d floating toggle
# change focus between tiling / floating windows
bindsym $mod+d focus mode_toggle
# focus the parent container
bindsym $mod+a focus parent
# focus the child container
#bindsym $mod+d focus child
# Define names for default workspaces for which we configure key bindings later on.
# We use variables to avoid repeating the names in multiple places.
set $ws1 "1"
set $ws2 "2"
set $ws3 "3"
set $ws4 "4"
set $ws5 "5"
set $ws6 "6"
set $ws7 "7"
set $ws8 "8"
set $ws9 "9"
set $ws10 "10"
# switch to workspace
bindsym $mod+1 workspace number $ws1
bindsym $mod+2 workspace number $ws2
bindsym $mod+3 workspace number $ws3
bindsym $mod+4 workspace number $ws4
bindsym $mod+5 workspace number $ws5
bindsym $mod+6 workspace number $ws6
bindsym $mod+7 workspace number $ws7
bindsym $mod+8 workspace number $ws8
bindsym $mod+9 workspace number $ws9
bindsym $mod+0 workspace number $ws10
# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace number $ws1
bindsym $mod+Shift+2 move container to workspace number $ws2
bindsym $mod+Shift+3 move container to workspace number $ws3
bindsym $mod+Shift+4 move container to workspace number $ws4
bindsym $mod+Shift+5 move container to workspace number $ws5
bindsym $mod+Shift+6 move container to workspace number $ws6
bindsym $mod+Shift+7 move container to workspace number $ws7
bindsym $mod+Shift+8 move container to workspace number $ws8
bindsym $mod+Shift+9 move container to workspace number $ws9
bindsym $mod+Shift+0 move container to workspace number $ws10
# reload the configuration file
bindsym $mod+Shift+c reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+r restart
# exit i3 (logs you out of your X session)
bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"
# resize window (you can also use the mouse for that)
mode "resize" {
# These bindings trigger as soon as you enter the resize mode
# Pressing left will shrink the windows width.
# Pressing right will grow the windows width.
# Pressing up will shrink the windows height.
# Pressing down will grow the windows height.
bindsym j resize shrink width 10 px or 10 ppt
bindsym k resize grow height 10 px or 10 ppt
bindsym l resize shrink height 10 px or 10 ppt
bindsym semicolon resize grow width 10 px or 10 ppt
# same bindings, but for the arrow keys
bindsym Left resize shrink width 10 px or 10 ppt
bindsym Down resize grow height 10 px or 10 ppt
bindsym Up resize shrink height 10 px or 10 ppt
bindsym Right resize grow width 10 px or 10 ppt
# back to normal: Enter or Escape or $mod+r
bindsym Return mode "default"
bindsym Escape mode "default"
bindsym $mod+r mode "default"
}
bindsym $mod+r mode "resize"
for_window [class="steam_app_40800" instance="steam_app_40800"] floating enable
# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
bar {
position top
status_command i3status
tray_output primary
}

View file

@ -1 +0,0 @@
prefix=${HOME}/.local

9
.config/nvim/init.vim Normal file → Executable file
View file

@ -1,18 +1,23 @@
call plug#begin()
" Display if updates for plugins are available
Plug 'semanser/vim-outdated-plugins'
" Show trailing whitespaces (this could also easily be achieved by settings,
" but the plugin is very neat)
Plug 'ntpeters/vim-better-whitespace'
Plug 'vim-airline/vim-airline'
Plug 'w0rp/ale'
Plug 'sirtaj/vim-openscad'
Plug 'AndrewRadev/bufferize.vim'
Plug 'airblade/vim-gitgutter'
Plug 'hashivim/vim-terraform'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
"Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
call plug#end()
"lua require'nvim-treesitter.configs'.setup{highlight={enable=true}}
" Explicitely set legacy colorscheme to overwrite the new neovim default
" colorscheme until I find the time to configure colors properly

View file

@ -1,30 +0,0 @@
#!/usr/bin/env bash
function autosource {
local bash_function_dirs bash_function_dir
# Test if 1 argument was given
if (( $# == 0 )); then
echo "autosource: basename of a file in BASH_FUNC_PATH required"
echo "autosource: usage: autosource basename [arguments]"
return 1
fi
# Split the BASH_FUNC_PATH into an array of directory names
IFS=: read -ra bash_function_dirs <<< "${BASH_FUNC_PATH}"
# Look for a .sh file with the basename given as first argument in each direc-
# tory in each directory in turn
for bash_function_dir in "${bash_function_dirs[@]}"; do
if [[ -r "${bash_function_dir}/${1}.sh" ]]; then
# If we find a matching file, source it and skip the rest of this function
. "${bash_function_dir}/${1}.sh" ${@:2}
return
fi
done
# If the loop completes no matching file is in BASH_FUNC_PATH
echo "autosource: no ${1} in (${BASH_FUNC_PATH})"
return 1
}

View file

@ -1,3 +0,0 @@
function dot_msg {
echo "$@"
}

View file

@ -1,2 +0,0 @@
[status]
showUntrackedFiles = no

View file

@ -1,5 +0,0 @@
AWS_DEFAULT_REGION=eu-central-1
AWS_DEFAULT_OUTPUT=yaml
AZURE_APP_ID_URI=https://signin.aws.amazon.com/saml
AZURE_DEFAULT_DURATION_HOURS=12

View file

@ -1,2 +0,0 @@
AZURE_TENANT_ID=
AZURE_DEFAULT_USERNAME=

View file

@ -1,4 +0,0 @@
DOTFILES_ACTIVE=true
DOTFILES_DIR="${HOME}/.dotfiles"
DOTFILES_GITDIR="${HOME}/.dotgit"
BASH_FUNC_PATH="${HOME}/.bash_functions:${DOTFILES_DIR}/bash_functions"

View file

@ -1,7 +0,0 @@
# Fixes scrolling bug for G502 mice, where the first scroll step after a
# direction change is not registered sometimes. Also enables gestures and
# pixel-perfect trackpad scrolling apperantly:
# https://wiki.archlinux.org/title/Firefox#Touchscreen_gestures_and_pixel-perfect_trackpad_scrolling
if [ "$XDG_SESSION_TYPE" == "x11" ]; then
MOZ_USE_XINPUT2=1
fi

View file

@ -1,5 +0,0 @@
GIT_AUTHOR_NAME=""
GIT_AUTHOR_EMAIL=""
GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL

View file

@ -1,2 +0,0 @@
HISTSIZE=-1
HISTFILESIZE=-1

View file

@ -1,6 +0,0 @@
# Set neovim as default editor if it is installed
if command -v nvim >/dev/null 2>&1; then
EDITOR=nvim
fi

View file

@ -1 +0,0 @@
NPM_CONFIG_USERCONFIG=$HOME/.config/npm/npmrc

View file

@ -1,4 +0,0 @@
if [[ -e ${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/default.target.wants/ssh-agent.service ]]
then
SSH_AUTH_SOCK=$XDG_RUNTIME_DIR/ssh-agent.socket
fi

View file

@ -1,6 +0,0 @@
if [[ $OSTYPE == linux-gnu && $(< /proc/sys/kernel/osrelease) == *Microsoft ]]
then
DOTFILES_WSL=true
else
DOTFILES_WSL=false
fi

47
.github/README.md vendored
View file

@ -1,47 +0,0 @@
# Gliech Dotfiles
## Replication
```bash
git clone -n --config core.bare=true --separate-git-dir=$HOME/.dotgit git@github.com:gliech/dotfiles.git $(mktemp -d)
git --work-tree=$HOME --git-dir=$HOME/.dotgit reset HEAD
git --work-tree=$HOME --git-dir=$HOME/.dotgit checkout -b $HOSTNAME
git --work-tree=$HOME --git-dir=$HOME/.dotgit -c user.name="$USER" -c user.email="${USER}@${HOSTNAME}" commit -am "Backed up pre-existing configs to local branch"
git --work-tree=$HOME --git-dir=$HOME/.dotgit checkout master
```
## Untracked Configurations (TODO)
- Firefox profile
- Addons (uBlockOrigin, PrivacyBadger)
- about:config keys (Turn off Pocket)
- Gnome3 integration (https://github.com/kurogetsusai/firefox-gnome-theme)
- userChrome.css
- control profiles.ini
- Gnome Extensions
- AWS EC2 SSH helper
- Battery Status
- Disable workspace switcher popup
- Gsconnect (Warning für die ganzen optionalen Pakete, die das braucht)
- Launch new instance
- No topleft hot corner
- Status area horizonzal spacing
- Vitals
## Missing Features (TODO)
- Vim relative line numbering
- unset all variables
- Initial Setup
- do the eye candy messaging stuff
- restructure setup
- add proper status messages to vim-plug install
- install vim plugins
- missing executables warnings
- environment templates? (git.env!)
- fix the umask
- Vim put the Yaml indent Stuff in a proper filetype detection script (ftplugin?)
- Vim also add cfn filetype for cfn-lint
- enable user systemd units during install (for example the sysd ssh-agent)
## Echos to be replaced by msg()
- fuck error msg
- initial setup

View file

@ -1,103 +0,0 @@
#!/usr/bin/env python3
"""
Parse the HTML of https://signin.aws.amazon.com/saml to extract all assumable
roles for use in .aws/config
Usage:
aws-config-gen [--print-default-profile] [--default-role=<name>]
[--region=<name>] [--suffix=<name>] <file>
aws-config-gen -h | --help
aws-config-gen --version
Arguments:
file Downloaded HTML File of the AWS SAML login page
Options:
-d, --print-default-profile Begin output with an empty [default] profile.
--default-role=<name> If more than one role can be assumed in the
same account, this option determines which one
will get the shorthand profile name without an
additional suffix. [default: developer-admin]
-r, --region=<name> Add the specified aws region to each profile's
properties.
-s, --suffix=<name> Append a suffix to each profile name.
--version Show version info.
-h --help Show this help screen.
Examples:
aws-config-gen -d aws-signin.html > ~/.aws/config
aws-config-gen -r eu-central-1 -s -fra aws-signin.html >> ~/.aws/config
"""
import sys
import re
from docopt import docopt
from bs4 import BeautifulSoup
from pathlib import Path
from configparser import ConfigParser
from itertools import starmap, chain
from functools import partial
def get_account_roles (soup):
for saml_account in soup.fieldset(class_='saml-account', recursive=False):
account_title = saml_account.find(class_='saml-account-name').string
account_alias = account_title.split()[1]
account_roles = map(get_saml_role_arn, saml_account(class_='saml-role'))
yield account_alias, list(account_roles)
def get_saml_role_arn (saml_role_tag):
saml_radio_tag = saml_role_tag.find(class_='saml-radio')
saml_role_arn = saml_radio_tag['value']
return saml_role_arn
def seperate_account_roles (alias, roles, role_type_pattern):
if len(roles) == 1:
yield alias, roles[0]
else:
for role in roles:
role_type = role_type_pattern.fullmatch(role).group('type')
role_alias = f'{alias}{"-" if role_type else ""}{role_type or ""}'
yield role_alias, role
def assemble_profile(name, role_arn, suffix=None, region=None):
section = f'profile {name}{suffix or ""}'
properties = {'azure_default_role_arn': role_arn}
if region is not None:
properties['region'] = region
return section, properties
def print_config(profiles, print_default=False):
config = ConfigParser()
if print_default:
config.add_section('default')
config.read_dict(dict(profiles))
config.write(sys.stdout)
if __name__ == '__main__':
# Parse CLI arguments
arguments = docopt(__doc__, version='AWS Config Generator 1.0')
# Prepare some objects for later use
baked_profile = partial(assemble_profile, suffix=arguments['--suffix'],
region=arguments['--region'])
default_role_type=arguments['--default-role']
role_type_pattern = re.compile(
r'(?:arn\:aws\:iam\:\:\d+\:role/)'
r'(?:netrtl\.com-)?'
f'((?:{default_role_type})|(?P<type>.*?))'
r'(?:-access-role)?')
baked_role_seperator = partial(seperate_account_roles,
role_type_pattern=role_type_pattern)
# Read the document
html_location = Path(arguments['<file>']).resolve()
with open(html_location) as document:
page = BeautifulSoup(document, 'html.parser')
# Mangle the data
accounts = get_account_roles(page)
roles = chain.from_iterable( starmap( baked_role_seperator, accounts ) )
profiles = starmap(baked_profile, roles)
# Output the config
print_config(profiles, arguments['--print-default-profile'])

View file

@ -1,15 +0,0 @@
#!/usr/bin/env bash
# This should have been a make script. But apperantly the linux shebang is
# defeated by commands with more than 1 argument (#!/usr/bin/env make -f).
# ^^
# Soo...
make -f - <<'EOF'
SHELL=/usr/bin/env bash
~/.aws/config: ~/.aws/profiles.html
aws-config-gen -d --default-role admin $< > $@
# aws-config-gen -r eu-central-1 --suffix -🍺 --default-role admin $< >> $@
# aws-config-gen -r eu-west-1 --suffix -🍀 --default-role admin $< >> $@
# aws-config-gen -r us-east-1 --suffix -🍔 --default-role admin $< >> $@
EOF

View file

@ -1 +0,0 @@
complete -C aws_completer aws

View file

@ -1,10 +0,0 @@
function _aws-auth {
if [ "${#COMP_WORDS[@]}" != "2" ]; then
return
fi
local aws_profiles
aws_profiles="$(pcre2grep -O '$1' '(?>\[\s*profile )(\S+)(?>\s*\])' ~/.aws/config)"
COMPREPLY=($(compgen -W "$aws_profiles" "${COMP_WORDS[$COMP_CWORD]}" ))
}
complete -F _aws-auth aws-auth

View file

@ -1,4 +0,0 @@
#!/bin/sh
xrandr --newmode "3840x1440_120.00" 993.50 3840 4176 4600 5360 1440 1443 1453 1545 -hsync +vsync
xrandr --addmode DisplayPort-2 3840x1440_120.00
xrandr --output DisplayPort-0 --mode 2560x1440 --pos 0x0 --rotate left --output DisplayPort-1 --off --output DisplayPort-2 --primary --mode 5120x1440 --pos 1440x227 --rotate normal --output HDMI-A-0 --off

View file

@ -1,4 +1,8 @@
AddKeysToAgent yes
ForwardAgent no
IdentitiesOnly yes
Include ~/.ssh/config.d/*
Host mi.lan
HostName 192.168.178.115
User jhuebner
ProxyJump 192.168.84.2
Host 192.168.84.2
HostName 192.168.84.2
User janolehuebner

View file

@ -1,4 +0,0 @@
Host github.com
HostName ssh.github.com
User git
Port 443

View file

@ -1,15 +0,0 @@
#!/bin/sh
udiskie &
xscreensaver --no-splash &
blueman-applet &
if [ -f ~/.screenlayout/${HOSTNAME}.sh ]; then
. ~/.screenlayout/${HOSTNAME}.sh
fi
# Some distros (like archlinux) link /bin/sh to bash. It is safe to load the
# .bash_profile in that case.
if [ $BASH_VERSION ]; then
. ~/.bash_profile
fi