Compare commits

...

12 Commits

Author SHA1 Message Date
ab34c148a6 feat(bin): age tools (#20)
* wip: ae for encryption, ad for decryption
* feat: finished ad and ae, created a for both uses
2024-12-24 09:31:25 +02:00
github-actions[bot]
910b29ed9f chore: update pre-commit hooks (#56) 2024-12-24 06:50:02 +02:00
3fb0a75a62 feat(asdf): update automation, versions, plugins 2024-12-24 00:59:50 +02:00
github-actions[bot]
f73abb508b chore: update pre-commit hooks (#55)
Co-authored-by: ivuorinen <11024+ivuorinen@users.noreply.github.com>
2024-12-23 13:00:01 +02:00
github-actions[bot]
1dd3d952cf chore: update pre-commit hooks (#54)
Co-authored-by: ivuorinen <11024+ivuorinen@users.noreply.github.com>
2024-12-22 02:07:59 +02:00
1ffd6e1569 feat(nvim): update blink config 2024-12-20 22:54:17 +02:00
a76033a48a chore(deps): update Brewfile 2024-12-20 18:55:14 +02:00
34dc18883e chore(config): aerospace tweaks 2024-12-20 18:14:57 +02:00
832d8b94f3 chore(nvim): add the awesome youtube video to mini 2024-12-20 12:37:00 +02:00
c40eb765f8 chore(config): tweak aerospace config 2024-12-20 12:06:37 +02:00
github-actions[bot]
1bb7e9076b chore: update pre-commit hooks (#53)
Co-authored-by: ivuorinen <11024+ivuorinen@users.noreply.github.com>
2024-12-20 10:11:10 +02:00
ivuorinen
17821dfefa chore(git): Update submodules (automated)
asdf 54d15e3
antidote
dotbot v1.20.4
2024-12-20 03:09:26 +00:00
14 changed files with 620 additions and 109 deletions

View File

@@ -48,7 +48,7 @@ repos:
- id: actionlint
- repo: https://github.com/renovatebot/pre-commit-hooks
rev: 39.74.1
rev: 39.82.3
hooks:
- id: renovate-config-validator

View File

@@ -1,27 +1,21 @@
asdf-plugin-manager 1.4.0
golang 1.23.3
ruby 3.3.4
golang 1.23.4
rust 1.82.0
direnv 2.35.0
fd 10.2.0
1password-cli 2.30.3
age 1.2.0
age 1.2.1
bottom 0.10.2
dotenv-linter 3.3.0
editorconfig-checker 2.8.0
github-cli 2.61.0
github-cli 2.64.0
hadolint 2.12.0
kubectl 1.31.2
kubectl 1.32.0
pre-commit 4.0.1
ripgrep 14.1.1
shellcheck 0.10.0
shfmt 3.10.0
terragrunt 0.68.8
tf-summarize 0.3.13
tf-summarize 0.3.14
yamllint 1.35.1
yq 4.44.3
bats 1.11.0
gitleaks 8.18.4
delta 0.18.1
eza 0.20.8
sops 3.9.1
yq 4.44.6

View File

@@ -40,13 +40,37 @@ automatically-unhide-macos-hidden-apps = true
# run = ['layout floating', 'move-node-to-workspace S'] # The callback itself
[[on-window-detected]]
if.app-name-regex-substring = 'ferdium'
run = 'layout floating'
if.app-id = 'org.ferdium.ferdium-app' # Ferdium, has WhatsApp etc.
run = ['layout floating']
[[on-window-detected]]
if.app-name-regex-substring = 'finder'
run = 'layout floating'
[[on-window-detected]]
if.app-id = 'com.apple.finder' # Finder
run = 'layout floating'
[[on-window-detected]]
if.app-id = 'com.apple.mail' # Mail
run = 'layout floating'
[[on-window-detected]]
if.app-id = 'com.DanPristupov.Fork' # Fork
run = 'layout floating'
[[on-window-detected]]
if.app-id = 'com.flexibits.fantastical2.mac' # Fantastical
run = 'layout floating'
[[on-window-detected]]
if.app-id = 'org.whispersystems.signal-desktop' # Signal
run = 'layout floating'
[[on-window-detected]]
if.app-id = 'com.tidal.desktop'
run = ['layout floating', 'move-node-to-workspace 2']
# Possible values: (qwerty|dvorak)
# See https://nikitabobko.github.io/AeroSpace/guide#key-mapping
[key-mapping]
@@ -62,10 +86,11 @@ preset = 'qwerty'
[gaps]
inner.horizontal = 5
inner.vertical = 5
outer.top = 5
outer.right = 5
outer.bottom = 5
outer.left = 5
# outer.top = 0
outer.top = [{ monitor.'^built-in retina display$' = 20 }, 0]
outer.right = 0
outer.bottom = 0
outer.left = 0
# 'main' binding mode declaration
# See: https://nikitabobko.github.io/AeroSpace/guide#binding-modes
@@ -97,13 +122,13 @@ outer.left = 5
# end tell'
# '''
alt-ctrl-shift-f = 'fullscreen'
alt-ctrl-f = 'layout floating'
alt-cmd-shift-f = 'fullscreen'
alt-cmd-f = 'layout floating'
alt-shift-left = 'join-with left'
alt-shift-down = 'join-with down'
alt-shift-up = 'join-with up'
alt-shift-right = 'join-with right'
alt-cmd-left = 'join-with left'
alt-cmd-down = 'join-with down'
alt-cmd-up = 'join-with up'
alt-cmd-right = 'join-with right'
# See: https://nikitabobko.github.io/AeroSpace/commands#focus
alt-h = 'focus left'
@@ -117,39 +142,32 @@ alt-shift-j = 'move down'
alt-shift-k = 'move up'
alt-shift-l = 'move right'
# See: https://nikitabobko.github.io/AeroSpace/commands#resize
alt-shift-minus = 'resize smart -50'
alt-shift-equal = 'resize smart +50'
# See: https://nikitabobko.github.io/AeroSpace/commands#workspace
alt-cmd-z = 'workspace 1'
alt-cmd-x = 'workspace 2'
# alt-cmd-c = 'workspace 3'
# alt-cmd-v = 'workspace 4'
cmd-shift-1 = 'workspace 1' # Main
cmd-shift-2 = 'workspace 2' # Music
# See: https://nikitabobko.github.io/AeroSpace/commands#move-node-to-workspace
alt-shift-1 = 'move-node-to-workspace 1 --focus-follows-window'
alt-shift-2 = 'move-node-to-workspace 2 --focus-follows-window'
# alt-shift-3 = 'move-node-to-workspace 3 --focus-follows-window'
# alt-shift-4 = 'move-node-to-workspace 4 --focus-follows-window'
alt-cmd-1 = 'move-node-to-workspace 1 --focus-follows-window'
alt-cmd-2 = 'move-node-to-workspace 2 --focus-follows-window'
alt-tab = 'workspace-back-and-forth'
alt-shift-tab = 'move-workspace-to-monitor --wrap-around next'
shift-tab = 'workspace-back-and-forth'
# alt-shift-tab = 'move-workspace-to-monitor --wrap-around next'
# See: https://nikitabobko.github.io/AeroSpace/commands#mode
alt-cmd-s = 'mode service'
alt-cmd-a = 'mode apps'
# Taken:
# - <alt> + hjkl 1234 ,.
# - <alt><shift> + hjkl 1234 -=; <cr> ↑↓←→
alt-c = 'exec-and-forget open -a /Applications/Ferdium.app'
alt-o = 'exec-and-forget open -a /Applications/Obsidian.app'
alt-b = 'exec-and-forget open -a /Applications/Brave Browser.app'
alt-t = 'exec-and-forget open -a /Applications/TIDAL.app'
# 'service' binding mode declaration.
# See: https://nikitabobko.github.io/AeroSpace/guide#binding-modes
alt-a = 'mode apps'
alt-s = 'mode service'
alt-d = 'mode resize'
[mode.apps.binding]
esc = ['reload-config', 'mode main']
alt-b = ['exec-and-forget open -a /Applications/Brave Browser.app', 'mode main']
alt-c = ['exec-and-forget open -a /Applications/Ferdium.app', 'mode main']
alt-o = ['exec-and-forget open -a /Applications/Obsidian.app', 'mode main']
alt-s = ['exec-and-forget open -a /Applications/Slack.app', 'mode main']
alt-t = ['exec-and-forget open -a /Applications/TIDAL.app', 'mode main']
alt-w = ['exec-and-forget open -a /Applications/WezTerm.app', 'mode main']
[mode.service.binding]
esc = ['reload-config', 'mode main']
r = ['flatten-workspace-tree', 'mode main'] # reset layout
@@ -157,5 +175,9 @@ r = ['flatten-workspace-tree', 'mode main'] # reset layout
f = ['layout floating tiling', 'mode main'] # Toggle between floating and tiling layout
backspace = ['close-all-windows-but-current', 'mode main']
[mode.apps.binding]
alt-w = ['exec-and-forget open -a /Applications/WezTerm.app', 'mode main']
[mode.resize.binding]
# See: https://nikitabobko.github.io/AeroSpace/commands#resize
r = ['flatten-workspace-tree', 'mode main'] # reset layout
h = 'resize smart -70'
l = 'resize smart +70'
esc = ['reload-config', 'mode main']

View File

@@ -1,27 +1,20 @@
1password-cli https://github.com/NeoHsu/asdf-1password-cli.git f5d5aab
age https://github.com/threkk/asdf-age.git 396bdf6
asdf-plugin-manager https://github.com/asdf-community/asdf-plugin-manager.git b5862c1
bats https://github.com/timgluz/asdf-bats.git 299551f
bottom https://github.com/carbonteq/asdf-btm.git fd8a55a
delta https://github.com/andweeb/asdf-delta.git 501318b
direnv https://github.com/asdf-community/asdf-direnv.git 6ff3dbe
dotenv-linter https://github.com/wesleimp/asdf-dotenv-linter.git 1369f53
editorconfig-checker https://github.com/gabitchov/asdf-editorconfig-checker.git 585c1d5
eza https://github.com/lwiechec/asdf-eza.git 11f578d
fd https://gitlab.com/wt0f/asdf-fd.git 17d56e0
github-cli https://github.com/bartlomiejdanek/asdf-github-cli.git e0605b7
gitleaks https://github.com/jmcvetta/asdf-gitleaks.git 0cc0d7e
golang https://github.com/asdf-community/asdf-golang.git e2527a3
hadolint https://github.com/devlincashman/asdf-hadolint.git 335e230
hadolint https://github.com/devlincashman/asdf-hadolint.git c8eb88b
kubectl https://github.com/asdf-community/asdf-kubectl.git 2fb3b57
pre-commit https://github.com/jonathanmorley/asdf-pre-commit.git 26bfc42
ripgrep https://gitlab.com/wt0f/asdf-ripgrep.git e836665
ruby https://github.com/asdf-vm/asdf-ruby.git 194fe45
rust https://github.com/code-lever/asdf-rust.git 95acf4f
shellcheck https://github.com/luizm/asdf-shellcheck.git 66200ff
shfmt https://github.com/luizm/asdf-shfmt.git a42c5ff
sops https://github.com/feniix/asdf-sops.git 5c7a2fb
terragrunt https://github.com/ohmer/asdf-terragrunt.git 4a6651a
terragrunt https://github.com/ohmer/asdf-terragrunt.git 29f2935
tf-summarize https://github.com/adamcrews/asdf-tf-summarize.git 880ad26
yamllint https://github.com/ericcornelissen/asdf-yamllint.git bc2813e
yamllint https://github.com/ericcornelissen/asdf-yamllint.git e4cfb17
yq https://github.com/sudermanjr/asdf-yq.git 772992f

View File

@@ -11,3 +11,5 @@
[include]
path = ~/.config/git/overrides/config
[advice]
detachedHead = false

View File

@@ -13,6 +13,7 @@ tap "jesseduffield/lazygit"
tap "k8sgpt-ai/k8sgpt"
tap "keith/formulae"
tap "mongodb/brew"
tap "nikitabobko/tap"
tap "reviewdog/tap"
tap "shivammathur/extensions"
tap "shivammathur/php"
@@ -21,6 +22,20 @@ tap "teamookla/speedtest"
tap "xwmx/taps"
# Run your GitHub Actions locally
brew "act"
# Simple, modern, secure file encryption
brew "age"
# Mozilla CA certificate store
brew "ca-certificates"
# Mozilla CA bundle for Python
brew "certifi"
# Cryptographic recipes and primitives for Python
brew "cryptography"
# YAML Parser
brew "libyaml"
# Automate deployment, configuration, and upgrading
brew "ansible"
# Checks ansible playbooks for practices and behaviour
brew "ansible-lint"
# Generic-purpose lossless compression algorithm by Google
brew "brotli"
# Library and utilities for processing GIFs
@@ -31,6 +46,8 @@ brew "highway"
brew "imath"
# JPEG image codec that aids compression and decompression
brew "jpeg-turbo"
# Library for manipulating PNG images
brew "libpng"
# Zstandard is a real-time compression algorithm
brew "zstd"
# New file format for still image compression
@@ -39,32 +56,38 @@ brew "jpeg-xl"
brew "aom"
# Apache Portable Runtime library
brew "apr"
# Mozilla CA certificate store
brew "ca-certificates"
# Cryptography and SSL/TLS Toolkit
brew "openssl@3"
# Companion library to apr, the Apache Portable Runtime library
brew "apr-util"
# Password hashing library and CLI utility
brew "argon2"
# Spell checker with better logic than ispell
brew "aspell"
# Automatic configure script builder
brew "autoconf"
# Collection of over 500 reusable autoconf macros
brew "autoconf-archive"
# Cryptographic recipes and primitives for Python
brew "cryptography"
# Official Amazon AWS command-line interface
brew "awscli"
# Bourne-Again SHell, a UNIX command interpreter
brew "bash"
# Tool for generating GNU Standards-compliant Makefiles
brew "automake"
# GNU multiple precision arithmetic library
brew "gmp"
# GNU File, Shell, and Text utilities
brew "coreutils"
# Extendable version manager with support for Ruby, Node.js, Erlang & more
brew "asdf"
# Spell checker with better logic than ispell
brew "aspell"
# Collection of over 500 reusable autoconf macros
brew "autoconf-archive"
# Package compiler and linker metadata toolkit
brew "pkgconf"
# Automated text file generator
brew "autogen"
# Official Amazon AWS command-line interface
brew "awscli"
# Bourne-Again SHell, a UNIX command interpreter
brew "bash"
# Clone of cat(1) with syntax highlighting and Git integration
brew "bat"
# Bash Automated Testing System
brew "bats-core"
# Parser generator
brew "bison"
# Software library to render fonts
brew "freetype"
# XML-based font configuration API for X Windows
@@ -73,18 +96,32 @@ brew "fontconfig"
brew "gettext"
# Core application library for C
brew "glib"
# Mozilla CA bundle for Python
brew "certifi"
# Human-friendly and fast alternative to cut and (sometimes) awk
brew "choose-rust"
# Cross-platform make
brew "cmake"
# Get a file from an HTTP, HTTPS or FTP server
brew "curl"
# Lightweight DNS forwarder and DHCP server
brew "dnsmasq"
# Spellchecker wrapping library
brew "enchant"
# Perl lib for reading and writing EXIF metadata
brew "exiftool"
# Banner-like program prints strings as ASCII art
brew "figlet"
# Lock file during command
brew "flock"
# Libraries to talk to Microsoft SQL Server and Sybase databases
brew "freetds"
# Monitor a directory for changes and run a shell command
brew "fswatch"
# Command-line fuzzy finder written in Go
brew "fzf"
# Graphics library to dynamically manipulate images
brew "gd"
# Disk usage analyzer with console interface written in Go
brew "gdu"
# GitHub command-line tool
brew "gh"
# OpenType text shaping engine
@@ -95,22 +132,40 @@ brew "libb2"
brew "pango"
# Distributed revision control system
brew "git"
# Enable transparent encryption/decryption of files in a git repo
brew "git-crypt"
# Small git utilities
brew "git-extras"
# See your latest local git branches, formatted real fancy
brew "git-recent"
# Render markdown on the CLI
brew "glow"
# GNU implementation of the famous stream editor
brew "gnu-sed"
# Validating, recursive, caching DNS resolver
brew "unbound"
# GNU Transport Layer Security (TLS) Library
brew "gnutls"
# GNU Pretty Good Privacy (PGP) package
brew "gnupg"
# Library access to GnuPG
brew "gpgme"
# Open source suite of directory software
brew "openldap"
# Manage your GnuPG keys with ease!
brew "gpg-tui"
# Image manipulation
brew "netpbm"
# Library to render SVG files using Cairo
brew "librsvg"
# Graph visualization software from AT&T and Bell Labs
brew "graphviz"
# GNU grep, egrep and fgrep
brew "grep"
# Popular GNU data compression program
brew "gzip"
# Text-based UI library
brew "ncurses"
# Improved top (interactive process viewer)
brew "htop"
# Portable abstraction of the hierarchical topology of modern architectures
@@ -121,6 +176,8 @@ brew "libheif"
brew "imagemagick"
# Modular IRC client
brew "irssi"
# Image manipulation library
brew "jpeg"
# Lightweight and flexible command-line JSON processor
brew "jq"
# JSON parser for C
@@ -129,40 +186,76 @@ brew "json-c"
brew "krb5"
# Tool to detect/remediate misconfig and security risks of GitHub/GitLab assets
brew "legitify"
# BSD-style licensed readline alternative
brew "libedit"
# Conversion library
brew "libiconv"
# Postgres C API library
brew "libpq"
# Version of the SSL/TLS protocol forked from OpenSSL
brew "libressl"
# Multi-platform support library with a focus on asynchronous I/O
brew "libuv"
# YAML Parser
brew "libyaml"
# GNOME XML library
brew "libxml2"
# C library for reading, creating, and modifying zip archives
brew "libzip"
# Package manager for the Lua programming language
brew "luarocks"
# LZMA-based compression program similar to gzip or bzip2
brew "lzip"
# Swiss Army Knife for macOS
brew "m-cli"
# Collection of tools that nobody wrote when UNIX was young
brew "moreutils"
# NCurses Disk Usage
brew "ncdu"
# HTTP(S) server and reverse proxy, and IMAP/POP3 proxy server
brew "nginx"
# Port scanning utility for large networks
brew "nmap"
# Libraries for security-enabled client and server applications
brew "nss"
# Open source suite of directory software
brew "openldap"
# General-purpose scripting language
brew "php"
# Cryptography and SSL/TLS Toolkit
brew "openssl@1.1"
# ISO-C API and CLI for generating UUIDs
brew "ossp-uuid"
# General-purpose scripting language
brew "php@8.2"
# Manage compile and link flags for libraries
brew "pkg-config"
# General-purpose scripting language
brew "php@8.3", link: true
# Python version management
brew "pyenv"
# Migrate pip packages from one Python version to another
brew "pyenv-pip-migrate"
# Pyenv plugin to manage virtualenv
brew "pyenv-virtualenv"
# Interpreted, interactive, object-oriented programming language
brew "python@3.11"
# Install various Ruby versions and implementations
brew "ruby-build"
# Ruby version manager
brew "rbenv"
# Generate C-based recognizers from regular expressions
brew "re2c"
# Static analysis and lint tool, for (ba)sh scripts
brew "shellcheck"
# Send macOS User Notifications from the command-line
brew "terminal-notifier"
# Tool which checks for the support of TLS/SSL ciphers and flaws
brew "testssl"
# Terraform version manager inspired by rbenv
brew "tfenv"
# Linter for Terraform files
brew "tflint"
# Static analysis security scanner for your terraform code
brew "tfsec"
# Terminal multiplexer
brew "tmux"
# Display directories as trees (with optional color/HTML output)
brew "tree"
# Tool for creating isolated virtual python environments
brew "virtualenv"
# Command-line interface to the WakaTime api
brew "wakatime-cli"
# Executes a program periodically, showing output fullscreen
@@ -171,10 +264,16 @@ brew "watch"
brew "wget"
# Check your $HOME for unwanted files and directories
brew "xdg-ninja", args: ["HEAD"]
# General-purpose lossless data-compression library
brew "zlib"
# Watcher for macOS 10.14+ light/dark mode changes
brew "cormacrelf/tap/dark-notify"
# Igbinary PHP extension
brew "shivammathur/extensions/igbinary@8.3"
# Cleans up your $HOME from those pesky dotfiles
brew "doron-cohen/tap/antidot"
# lets you quickly switch between multiple git user profiles
brew "gesquive/tap/git-user"
# Automated code review tool integrated with any code analysis tools regardless of programming language.
brew "reviewdog/tap/reviewdog"
# Imagick PHP extension
brew "shivammathur/extensions/imagick@8.3"
# Mcrypt PHP extension
@@ -190,9 +289,15 @@ brew "shivammathur/extensions/uuid@8.3"
# Yaml PHP extension
brew "shivammathur/extensions/yaml@8.3"
# General-purpose scripting language
brew "shivammathur/php/php", link: false
# General-purpose scripting language
brew "shivammathur/php/php-debug"
# Find & fix known vulnerabilities in open-source dependencies
brew "snyk/tap/snyk"
# Command-line interface for 1Password
cask "1password-cli"
# AeroSpace is an i3-like tiling window manager for macOS
cask "aerospace"
# Text editor
cask "coda"
# Universal database tool and SQL client
@@ -206,10 +311,7 @@ cask "font-jetbrains-mono-nerd-font"
cask "font-lato"
cask "font-open-sans"
cask "font-roboto"
cask "font-source-code-pro"
cask "font-source-code-pro-for-powerline"
cask "font-source-sans-pro"
cask "font-source-serif-pro"
# GIT client
cask "fork"
# HTTP and GraphQL Client

View File

@@ -91,21 +91,19 @@ return {
-- default list of enabled providers defined so that you can extend it
-- elsewhere in your config, without redefining it, via `opts_extend`
sources = {
default = {
'lsp',
'copilot',
'path',
'snippets',
'buffer',
},
providers = {
copilot = {
name = 'copilot',
module = 'blink-cmp-copilot',
},
},
completion = {
enabled_providers = {
'lsp',
'copilot',
'path',
'snippets',
'buffer',
},
},
},
-- experimental auto-brackets support

View File

@@ -1,8 +1,12 @@
return {
-- Library of 40+ independent Lua modules improving overall Neovim
-- (version 0.8 and higher) experience with minimal effort
--
-- https://github.com/echasnovski/mini.nvim
-- https://github.com/echasnovski/mini.nvim/tree/main?tab=readme-ov-file#modules
--
-- YouTube: Text editing with 'mini.nvim' - Neovimconf 2024 - Evgeni Chasnovski
-- https://www.youtube.com/watch?v=cNK5kYJ7mrs
{
'echasnovski/mini.nvim',
version = '*',

184
local/bin/a Executable file
View File

@@ -0,0 +1,184 @@
#!/usr/bin/env bash
# A script for encrypting and decrypting files or directories with age and SSH keys
VERSION="1.0.0"
# Default ENV values
KEYS_FILE="${AGE_KEYSFILE:-$HOME/.ssh/keys.txt}"
KEYS_SOURCE="${AGE_KEYSSOURCE:-https://github.com/ivuorinen.keys}"
LOG_FILE="${AGE_LOGFILE:-$HOME/.cache/a.log}"
VERBOSE=false
# Parse flags for verbosity
for arg in "$@"; do
if [[ "$arg" == "-v" || "$arg" == "--verbose" ]]; then
VERBOSE=true
break
fi
done
# Ensure log directory and file exist with correct permissions
prepare_log_file() {
local log_dir
log_dir=$(dirname "$LOG_FILE")
# Create log directory if it does not exist
if [[ ! -d "$log_dir" ]]; then
mkdir -p "$log_dir"
fi
# Create log file if it does not exist
if [[ ! -f "$LOG_FILE" ]]; then
touch "$LOG_FILE"
fi
# Set permissions to 0600
chmod 0600 "$LOG_FILE"
}
prepare_log_file
# Logging function
log_message() {
local message="$1"
echo "$(date +'%Y-%m-%d %H:%M:%S') - $message" >> "$LOG_FILE"
# Print to user if verbose flag is set
if [[ "$VERBOSE" == true ]]; then
echo "$message"
fi
}
# Function to print usage
print_help() {
cat <<EOF
Usage: a [command] [file_or_directory] [options]
Commands:
e, enc, encrypt Encrypt the specified file or directory
d, dec, decrypt Decrypt the specified file or directory
help, --help Show this help message
version, --version Show version information
Options:
-v, --verbose Print log messages to console in addition to writing to log file
Environment Variables:
AGE_KEYSFILE Path to the SSH keys file (default: $HOME/.ssh/keys.txt)
AGE_KEYSSOURCE URL to fetch SSH keys if keys file does not exist
AGE_LOGFILE Path to the log file (default: $HOME/.cache/a.log)
Examples:
Encrypt a file:
a e file.txt
Encrypt a directory:
a e /path/to/directory
Decrypt a file:
a d file.txt.age
Specify a custom keys file:
AGE_KEYSFILE=/path/to/keys.txt a e file.txt
Specify a custom keys source and log file:
AGE_KEYSSOURCE=https://example.com/keys.txt AGE_LOGFILE=/tmp/a.log a d file.txt.age
EOF
}
# Function to print version
print_version() {
echo "a version $VERSION"
echo "Created by Ismo Vuorinen <https://github.com/ivuorinen>"
}
# Function to fetch keys if missing
fetch_keys_if_missing() {
if [[ ! -f "$KEYS_FILE" ]]; then
log_message "Keys file '$KEYS_FILE' not found. Attempting to fetch from $KEYS_SOURCE..."
mkdir -p "$(dirname "$KEYS_FILE")"
curl -s "$KEYS_SOURCE" -o "$KEYS_FILE"
if [[ $? -ne 0 || ! -s "$KEYS_FILE" ]]; then
log_message "Error: Failed to fetch keys from $KEYS_SOURCE"
exit 1
fi
chmod 0400 "$KEYS_FILE"
log_message "Keys file fetched and permissions set to 0400."
fi
}
# Function to encrypt files or directories
encrypt_file_or_directory() {
local file="$1"
if [[ -d "$file" ]]; then
for f in "$file"/*; do
encrypt_file_or_directory "$f"
done
elif [[ -f "$file" ]]; then
fetch_keys_if_missing
local output_file="${file}.age"
age -R "$KEYS_FILE" "$file" >"$output_file"
if [[ $? -eq 0 ]]; then
log_message "File encrypted successfully: $output_file"
else
log_message "Error: Failed to encrypt file '$file'."
exit 1
fi
fi
}
# Function to decrypt files or directories
decrypt_file_or_directory() {
local file="$1"
if [[ -d "$file" ]]; then
for f in "$file"/*.age; do
decrypt_file_or_directory "$f"
done
elif [[ -f "$file" ]]; then
fetch_keys_if_missing
local output_file="${file%.age}"
age -d -i "$KEYS_FILE" "$file" >"$output_file"
if [[ $? -eq 0 ]]; then
log_message "File decrypted successfully: $output_file"
else
log_message "Error: Failed to decrypt file '$file'."
exit 1
fi
fi
}
# Main logic
case "$1" in
e|enc|encrypt)
if [[ $# -lt 2 ]]; then
log_message "Error: No file or directory specified for encryption."
print_help
exit 1
fi
encrypt_file_or_directory "$2"
;;
d|dec|decrypt)
if [[ $# -lt 2 ]]; then
log_message "Error: No file or directory specified for decryption."
print_help
exit 1
fi
decrypt_file_or_directory "$2"
;;
help|--help)
print_help
;;
version|--version)
print_version
;;
*)
log_message "Error: Unknown command '$1'"
print_help
exit 1
;;
esac
# vim: ft=bash:syn=sh:ts=2:sw=2:et:ai:nowrap

62
local/bin/ad Executable file
View File

@@ -0,0 +1,62 @@
#!/usr/bin/env bash
# age decrypt file with github keys
# Use ENV or default values for keys file and source
KEYS_FILE="${AGE_KEYSFILE:-$HOME/.ssh/keys.txt}"
KEYS_SOURCE="${AGE_KEYSSOURCE:-https://github.com/ivuorinen.keys}"
# Check for required commands
if ! command -v age &>/dev/null; then
echo "Error: age is not installed. Please install it to continue."
exit 1
fi
if ! command -v curl &>/dev/null; then
echo "Error: curl is not installed. Please install it to continue."
exit 1
fi
# Ensure a file is provided
if [[ $# -lt 1 ]]; then
echo "Usage: $0 <file-to-decrypt>"
exit 1
fi
FILE="$1"
if [[ ! -f "$FILE" ]]; then
echo "Error: File '$FILE' does not exist."
exit 1
fi
# Check if keys file exists, otherwise fetch it
if [[ ! -f "$KEYS_FILE" ]]; then
echo "Keys file '$KEYS_FILE' not found. Attempting to fetch from $KEYS_SOURCE..."
# Create the directory if it doesn't exist
mkdir -p "$(dirname "$KEYS_FILE")"
# Fetch the keys and save to the file
curl -s "$KEYS_SOURCE" -o "$KEYS_FILE"
if [[ $? -ne 0 || ! -s "$KEYS_FILE" ]]; then
echo "Error: Failed to fetch keys from $KEYS_SOURCE"
exit 1
fi
# Set permissions to 0400
chmod 0400 "$KEYS_FILE"
echo "Keys file fetched and permissions set to 0400."
fi
# Decrypt the file
OUTPUT_FILE="${FILE%.age}"
age -d -i "$KEYS_FILE" "$FILE" >"$OUTPUT_FILE"
if [[ $? -eq 0 ]]; then
echo "File decrypted successfully: $OUTPUT_FILE"
else
echo "Error: Failed to decrypt file."
exit 1
fi

60
local/bin/ae Executable file
View File

@@ -0,0 +1,60 @@
#!/usr/bin/env bash
# age encrypt file with github keys
# Use ENV or default values for keys file and source
KEYS_FILE="${AGE_KEYSFILE:-$HOME/.ssh/keys.txt}"
KEYS_SOURCE="${AGE_KEYSSOURCE:-https://github.com/ivuorinen.keys}"
# Check for required commands
if ! command -v age &>/dev/null; then
echo "Error: age is not installed. Please install it to continue."
exit 1
fi
if ! command -v curl &>/dev/null; then
echo "Error: curl is not installed. Please install it to continue."
exit 1
fi
# Ensure a file is provided
if [[ $# -lt 1 ]]; then
echo "Usage: $0 <file-to-encrypt>"
exit 1
fi
FILE="$1"
if [[ ! -f "$FILE" ]]; then
echo "Error: File '$FILE' does not exist."
exit 1
fi
# Check if keys file exists, otherwise fetch it
if [[ ! -f "$KEYS_FILE" ]]; then
echo "Keys file '$KEYS_FILE' not found. Attempting to fetch from $KEYS_SOURCE..."
# Create the directory if it doesn't exist
mkdir -p "$(dirname "$KEYS_FILE")"
# Fetch the keys and save to the file
curl -s "$KEYS_SOURCE" -o "$KEYS_FILE"
if [[ $? -ne 0 || ! -s "$KEYS_FILE" ]]; then
echo "Error: Failed to fetch keys from $KEYS_SOURCE"
exit 1
fi
# Set permissions to 0400
chmod 0400 "$KEYS_FILE"
echo "Keys file fetched and permissions set to 0400."
fi
# Encrypt the file
OUTPUT_FILE="${FILE}.age"
age -R "$KEYS_FILE" "$FILE" >"$OUTPUT_FILE"
if [[ $? -eq 0 ]]; then
echo "File encrypted successfully: $OUTPUT_FILE"
else
echo "Error: Failed to encrypt file."
exit 1
fi

View File

@@ -169,7 +169,7 @@ section_install()
;;
asdf)
msg "Installing asdf..."
bash "$DOTFILES/scripts/install-asdf.sh both" \
$0 asdf plugins-add \
&& msg_yay "asdf installed!"
;;
cargo)
@@ -371,21 +371,111 @@ section_asdf()
{
USAGE_PREFIX="$SCRIPT asdf <command>"
MENU=(
"install:Install asdf"
"current:Show asdf current versions"
"global:Show asdf global versions"
"installed:Show asdf installed versions"
"local:Show asdf local versions"
"plugins-add:Add and update direnv and asdf-plugin-manager, and all other plugins"
"plugins-update:Update all asdf plugins"
"reset:Reset asdf plugins"
"versions:Show asdf versions"
"where:Show asdf where"
"which:Show asdf which"
)
case "$1" in
install)
msg "Installing asdf..."
bash "$DOTFILES/scripts/install-asdf.sh both" \
&& msg_yay "asdf installed!"
plugins-update)
APM_BIN="$(asdf where asdf-plugin-manager)/bin/asdf-plugin-manager"
msgr run "Updating all asdf plugins"
$APM_BIN update-all
$APM_BIN export > "$ASDF_PLUGIN_MANAGER_PLUGIN_VERSIONS_FILENAME"
msgr run_done "Updated all plugins"
;;
plugins-add)
X_GH_BIN="$DOTFILES/local/bin/x-gh-get-latest-version"
LATEST_APM="$($X_GH_BIN asdf-community/asdf-plugin-manager | sed 's/^v//')"
LATEST_DIRENV="$($X_GH_BIN asdf-community/asdf-direnv)"
PLUGIN_VERSIONS="$DOTFILES/config/asdf/plugin-versions"
APM_BIN="$HOME/.local/bin/asdf/shims/asdf-plugin-manager"
msgr run "Adding and updating direnv and asdf-plugin-manager"
asdf plugin add direnv https://github.com/asdf-community/asdf-direnv.git
asdf global direnv "$LATEST_DIRENV"
asdf install direnv "$LATEST_DIRENV"
asdf plugin add asdf-plugin-manager https://github.com/asdf-community/asdf-plugin-manager.git
asdf global asdf-plugin-manager "$LATEST_APM"
asdf install asdf-plugin-manager "$LATEST_APM"
asdf reshim
msgr run_done "direnv and asdf-plugin-manager added and updated"
msgr run "Reset plugin-versions file to the original using git"
if git ls-files --error-unmatch "$PLUGIN_VERSIONS" > /dev/null 2>&1; then
git checkout -- "$PLUGIN_VERSIONS"
fi
msgr run_done "Reset plugin-versions file"
msgr run "Adding all plugins with asdf-plugin-manager"
"$APM_BIN" add-all
msgr run_done "Added all plugins with asdf-plugin-manager"
msgr run "Install all plugins"
PLUGINS=$($APM_BIN list | awk -F ' ' '{print $1}' | sort)
for P in $PLUGINS; do
msgr run "Installing $P"
asdf install "$P" latest
asdf global "$P" latest
done
msgr run_done "Installed all plugins"
msgr run "Reshimming"
asdf reshim
msgr run_done "Reshimmed"
;;
plugins-remove)
PLUGIN_VERSIONS="$DOTFILES/config/asdf/plugin-versions"
msgr run "Remove installed plugins"
INSTALLED_ASDF_PLUGINS=$(asdf list | grep -vE "direnv|asdf-plugin-manager" | grep -v "^ ")
for P in $INSTALLED_ASDF_PLUGINS; do
asdf plugin remove "$P"
msgr nested_done "Removed $P"
done
msgr run "Reset plugin-versions file to the original using git"
if git ls-files --error-unmatch "$PLUGIN_VERSIONS" > /dev/null 2>&1; then
git checkout -- "$PLUGIN_VERSIONS"
fi
msgr run_done "Reset plugin-versions file"
msgr run_done "Remove plugins done!"
;;
reset)
APM_BIN="$(asdf where asdf-plugin-manager)/bin/asdf-plugin-manager"
msgr run "Get currently installed plugins, remove those that are not defined"
$0 asdf plugins-remove
$0 asdf plugins-add
$0 asdf fixtoolversions
asdf reshim
msgr yay "Reset asdf plugins done!"
;;
fixtoolversions)
ASDF_TOOL_VERSIONS_FILE="$DOTFILES/base/tool-versions"
ASDF_TOOL_FILE_PLUGINS=$(awk '{print $1 " " $2}' "$ASDF_TOOL_VERSIONS_FILE")
APM_BIN="$(asdf where asdf-plugin-manager)/bin/asdf-plugin-manager"
msgr run "Loading $ASDF_TOOL_VERSIONS_FILE and collecting installed"
ASDF_PLUGINS_DEFINED=$($APM_BIN list | awk -F ' ' '{print $1}')
echo "$ASDF_TOOL_FILE_PLUGINS" | \
grep -Fxv -f <(echo "$ASDF_PLUGINS_DEFINED") > tmp && \
mv tmp "$ASDF_TOOL_VERSIONS_FILE"
msgr run_done "Fixed $ASDF_TOOL_VERSIONS_FILE"
;;
current)
asdf current