mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-03-22 12:07:34 +00:00
Compare commits
1 Commits
26.2.6
...
7cfafbfa87
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7cfafbfa87 |
@@ -1 +1 @@
|
|||||||
3.14.2
|
3.14.3
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
|
|
||||||
export DOTFILES="$HOME/.dotfiles"
|
export DOTFILES="$HOME/.dotfiles"
|
||||||
# Minimal PATH for x-have and utilities; full PATH set in shared.sh/exports
|
|
||||||
export PATH="$HOME/.local/bin:$DOTFILES/local/bin:$PATH"
|
export PATH="$HOME/.local/bin:$DOTFILES/local/bin:$PATH"
|
||||||
export SHARED_SCRIPTS_SOURCED=0
|
export SHARED_SCRIPTS_SOURCED=0
|
||||||
|
|
||||||
@@ -12,7 +11,7 @@ source "$DOTFILES/config/shared.sh"
|
|||||||
[ -f "${DOTFILES}/config/fzf/fzf.bash" ] &&
|
[ -f "${DOTFILES}/config/fzf/fzf.bash" ] &&
|
||||||
source "${DOTFILES}/config/fzf/fzf.bash"
|
source "${DOTFILES}/config/fzf/fzf.bash"
|
||||||
|
|
||||||
# Import ssh keys in keychain (macOS-specific -A flag, silently fails on Linux)
|
# Import ssh keys in keychain
|
||||||
ssh-add -A 2>/dev/null
|
ssh-add -A 2>/dev/null
|
||||||
|
|
||||||
x-have antidot && {
|
x-have antidot && {
|
||||||
@@ -23,3 +22,5 @@ PROMPT_DIRTRIM=3
|
|||||||
PROMPT_COMMAND='PS1_CMD1=$(git branch --show-current 2>/dev/null)'
|
PROMPT_COMMAND='PS1_CMD1=$(git branch --show-current 2>/dev/null)'
|
||||||
PS1='\[\e[95m\]\u\[\e[0m\]@\[\e[38;5;22;2m\]\h\[\e[0m\] \[\e[38;5;33m\]\w\[\e[0m\] \[\e[92;2m\]${PS1_CMD1}\n\[\e[39m\]➜\[\e[0m\] '
|
PS1='\[\e[95m\]\u\[\e[0m\]@\[\e[38;5;22;2m\]\h\[\e[0m\] \[\e[38;5;33m\]\w\[\e[0m\] \[\e[92;2m\]${PS1_CMD1}\n\[\e[39m\]➜\[\e[0m\] '
|
||||||
|
|
||||||
|
# Added by LM Studio CLI (lms)
|
||||||
|
export PATH="$PATH:$HOME/.lmstudio/bin"
|
||||||
|
|||||||
1010
base/hammerspoon/generate-hammerspoon-types.py
Executable file
1010
base/hammerspoon/generate-hammerspoon-types.py
Executable file
File diff suppressed because it is too large
Load Diff
17863
base/hammerspoon/hammerspoon.types.lua
Normal file
17863
base/hammerspoon/hammerspoon.types.lua
Normal file
File diff suppressed because it is too large
Load Diff
15
base/zshrc
15
base/zshrc
@@ -7,13 +7,18 @@
|
|||||||
autoload -U promptinit; promptinit
|
autoload -U promptinit; promptinit
|
||||||
|
|
||||||
export DOTFILES="$HOME/.dotfiles"
|
export DOTFILES="$HOME/.dotfiles"
|
||||||
# Minimal PATH for x-have and utilities; full PATH set in shared.sh/exports
|
LOCAL_SHARE="$HOME/.local/share"
|
||||||
export PATH="$HOME/.local/bin:$DOTFILES/local/bin:$PATH"
|
export PATH="$HOME/.local/bin:$DOTFILES/local/bin:$LOCAL_SHARE/nvim/mason/bin:$LOCAL_SHARE/bob/nvim-bin:$LOCAL_SHARE/cargo/bin:/opt/homebrew/bin:/usr/local/bin:$PATH"
|
||||||
export SHARED_SCRIPTS_SOURCED=0
|
export SHARED_SCRIPTS_SOURCED=0
|
||||||
|
|
||||||
source "$DOTFILES/config/shared.sh"
|
source "$DOTFILES/config/shared.sh"
|
||||||
|
|
||||||
# zsh completions directory (ZSH_CUSTOM_COMPLETION_PATH set in shared.sh)
|
# zsh completions directory
|
||||||
|
[ -z "$ZSH_COMPLETIONS" ] && export ZSH_COMPLETIONS="$XDG_CONFIG_HOME/zsh/completion"
|
||||||
|
|
||||||
|
# Add zsh completions to FPATH, compinit will be called later
|
||||||
|
FPATH="$ZSH_COMPLETIONS:$FPATH"
|
||||||
|
|
||||||
ZSH_COMPDUMP="$XDG_CACHE_HOME/zsh/zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
|
ZSH_COMPDUMP="$XDG_CACHE_HOME/zsh/zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
|
||||||
|
|
||||||
source "$DOTFILES/config/zsh/antidote.zsh"
|
source "$DOTFILES/config/zsh/antidote.zsh"
|
||||||
@@ -32,10 +37,12 @@ source_fzf_config
|
|||||||
x-have antidot && eval "$(antidot init)"
|
x-have antidot && eval "$(antidot init)"
|
||||||
|
|
||||||
autoload -Uz compinit bashcompinit
|
autoload -Uz compinit bashcompinit
|
||||||
compinit -d "$ZSH_COMPDUMP"
|
compinit -d $ZSH_COMPDUMP
|
||||||
bashcompinit
|
bashcompinit
|
||||||
|
|
||||||
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
|
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
|
||||||
export P10K_CONFIG="$DOTFILES/config/zsh/p10k.zsh"
|
export P10K_CONFIG="$DOTFILES/config/zsh/p10k.zsh"
|
||||||
[[ ! -f "$P10K_CONFIG" ]] || source "$P10K_CONFIG"
|
[[ ! -f "$P10K_CONFIG" ]] || source "$P10K_CONFIG"
|
||||||
|
|
||||||
|
# Added by LM Studio CLI (lms)
|
||||||
|
export PATH="$PATH:$HOME/.lmstudio/bin"
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ x-have eza && {
|
|||||||
alias ls="eza -h -s=type --git --icons --group-directories-first"
|
alias ls="eza -h -s=type --git --icons --group-directories-first"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
alias vim='vim -u "$XDG_CONFIG_HOME/vim/vimrc"'
|
||||||
|
|
||||||
# Easier navigation: .., ..., ....
|
# Easier navigation: .., ..., ....
|
||||||
alias ..="cd .."
|
alias ..="cd .."
|
||||||
alias ...="cd ../.."
|
alias ...="cd ../.."
|
||||||
|
|||||||
@@ -282,8 +282,7 @@ export LESSHISTFILE="$XDG_STATE_HOME"/less/history
|
|||||||
export MANPAGER="less -X"
|
export MANPAGER="less -X"
|
||||||
|
|
||||||
# Always enable colored `grep` output
|
# Always enable colored `grep` output
|
||||||
# Note: GREP_OPTIONS is deprecated since GNU grep 2.21
|
export GREP_OPTIONS="--color=auto"
|
||||||
# Color is handled via alias in config/alias
|
|
||||||
|
|
||||||
# check the window size after each command and, if necessary,
|
# check the window size after each command and, if necessary,
|
||||||
# update the values of LINES and COLUMNS.
|
# update the values of LINES and COLUMNS.
|
||||||
@@ -437,10 +436,6 @@ msg "Setting up Wakatime configuration"
|
|||||||
export WAKATIME_HOME="$XDG_STATE_HOME/wakatime"
|
export WAKATIME_HOME="$XDG_STATE_HOME/wakatime"
|
||||||
x-dc "$WAKATIME_HOME"
|
x-dc "$WAKATIME_HOME"
|
||||||
|
|
||||||
# LM Studio CLI
|
|
||||||
msg "Setting up LM Studio configuration"
|
|
||||||
export PATH="$PATH:$HOME/.lmstudio/bin"
|
|
||||||
|
|
||||||
# Misc
|
# Misc
|
||||||
msg "Setting up miscellaneous configuration"
|
msg "Setting up miscellaneous configuration"
|
||||||
export ZSHZ_DATA="$XDG_STATE_HOME/z"
|
export ZSHZ_DATA="$XDG_STATE_HOME/z"
|
||||||
|
|||||||
274
local/bin/a
274
local/bin/a
@@ -1,9 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# A script for encrypting and decrypting files or directories with age and SSH keys
|
# A script for encrypting and decrypting files or directories with age and SSH keys
|
||||||
|
|
||||||
set -euo pipefail
|
VERSION="1.0.0"
|
||||||
|
|
||||||
VERSION="1.1.0"
|
|
||||||
|
|
||||||
# Default ENV values
|
# Default ENV values
|
||||||
KEYS_FILE="${AGE_KEYSFILE:-$HOME/.ssh/keys.txt}"
|
KEYS_FILE="${AGE_KEYSFILE:-$HOME/.ssh/keys.txt}"
|
||||||
@@ -11,49 +9,14 @@ KEYS_SOURCE="${AGE_KEYSSOURCE:-https://github.com/ivuorinen.keys}"
|
|||||||
LOG_FILE="${AGE_LOGFILE:-$HOME/.cache/a.log}"
|
LOG_FILE="${AGE_LOGFILE:-$HOME/.cache/a.log}"
|
||||||
|
|
||||||
VERBOSE=false
|
VERBOSE=false
|
||||||
DELETE_ORIGINAL=false
|
|
||||||
FORCE=false
|
|
||||||
|
|
||||||
# Check for required dependencies
|
# Parse flags for verbosity
|
||||||
check_dependencies()
|
for arg in "$@"; do
|
||||||
{
|
if [[ "$arg" == "-v" || "$arg" == "--verbose" ]]; then
|
||||||
if ! command -v age &> /dev/null; then
|
VERBOSE=true
|
||||||
echo "Error: 'age' is not installed. Please install it first." >&2
|
break
|
||||||
echo " brew install age # macOS" >&2
|
|
||||||
echo " apt install age # Debian/Ubuntu" >&2
|
|
||||||
echo " dnf install age # Fedora" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
if ! command -v curl &> /dev/null; then
|
|
||||||
echo "Error: 'curl' is not installed." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Parse flags
|
|
||||||
parse_flags()
|
|
||||||
{
|
|
||||||
local args=()
|
|
||||||
for arg in "$@"; do
|
|
||||||
case "$arg" in
|
|
||||||
-v | --verbose)
|
|
||||||
VERBOSE=true
|
|
||||||
;;
|
|
||||||
--delete)
|
|
||||||
DELETE_ORIGINAL=true
|
|
||||||
;;
|
|
||||||
-f | --force)
|
|
||||||
FORCE=true
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
args+=("$arg")
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
# Return remaining arguments
|
|
||||||
printf '%s\n' "${args[@]}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Ensure log directory and file exist with correct permissions
|
# Ensure log directory and file exist with correct permissions
|
||||||
prepare_log_file()
|
prepare_log_file()
|
||||||
@@ -75,6 +38,8 @@ prepare_log_file()
|
|||||||
chmod 0600 "$LOG_FILE"
|
chmod 0600 "$LOG_FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prepare_log_file
|
||||||
|
|
||||||
# Logging function
|
# Logging function
|
||||||
log_message()
|
log_message()
|
||||||
{
|
{
|
||||||
@@ -91,7 +56,7 @@ log_message()
|
|||||||
print_help()
|
print_help()
|
||||||
{
|
{
|
||||||
cat << EOF
|
cat << EOF
|
||||||
Usage: a [options] [command] [file_or_directory]
|
Usage: a [command] [file_or_directory] [options]
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
e, enc, encrypt Encrypt the specified file or directory
|
e, enc, encrypt Encrypt the specified file or directory
|
||||||
@@ -100,14 +65,12 @@ Commands:
|
|||||||
version, --version Show version information
|
version, --version Show version information
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-v, --verbose Print log messages to console
|
-v, --verbose Print log messages to console in addition to writing to log file
|
||||||
--delete Delete original files after successful encryption
|
|
||||||
-f, --force Overwrite existing output files without prompting
|
|
||||||
|
|
||||||
Environment Variables:
|
Environment Variables:
|
||||||
AGE_KEYSFILE Path to the SSH keys file (default: \$HOME/.ssh/keys.txt)
|
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_KEYSSOURCE URL to fetch SSH keys if keys file does not exist
|
||||||
AGE_LOGFILE Path to the log file (default: \$HOME/.cache/a.log)
|
AGE_LOGFILE Path to the log file (default: $HOME/.cache/a.log)
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
Encrypt a file:
|
Encrypt a file:
|
||||||
@@ -116,21 +79,14 @@ Examples:
|
|||||||
Encrypt a directory:
|
Encrypt a directory:
|
||||||
a e /path/to/directory
|
a e /path/to/directory
|
||||||
|
|
||||||
Encrypt and delete originals:
|
|
||||||
a --delete e file.txt
|
|
||||||
|
|
||||||
Decrypt a file:
|
Decrypt a file:
|
||||||
a d file.txt.age
|
a d file.txt.age
|
||||||
|
|
||||||
Force overwrite existing files:
|
|
||||||
a -f e file.txt
|
|
||||||
|
|
||||||
Specify a custom keys file:
|
Specify a custom keys file:
|
||||||
AGE_KEYSFILE=/path/to/keys.txt a e file.txt
|
AGE_KEYSFILE=/path/to/keys.txt a e file.txt
|
||||||
|
|
||||||
Requirements:
|
Specify a custom keys source and log file:
|
||||||
- age (encryption tool): https://github.com/FiloSottile/age
|
AGE_KEYSSOURCE=https://example.com/keys.txt AGE_LOGFILE=/tmp/a.log a d file.txt.age
|
||||||
- curl (for fetching keys)
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,104 +115,26 @@ fetch_keys_if_missing()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to encrypt a single file
|
|
||||||
encrypt_single_file()
|
|
||||||
{
|
|
||||||
local file="$1"
|
|
||||||
|
|
||||||
# Skip already encrypted files
|
|
||||||
if [[ "$file" == *.age ]]; then
|
|
||||||
log_message "Skipping already encrypted file: $file"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
local output_file="${file}.age"
|
|
||||||
|
|
||||||
# Check if output file exists
|
|
||||||
if [[ -f "$output_file" && "$FORCE" != true ]]; then
|
|
||||||
log_message "Error: Output file '$output_file' already exists. Use --force to overwrite."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
fetch_keys_if_missing
|
|
||||||
|
|
||||||
local temp_file
|
|
||||||
temp_file="$(mktemp -p "$(dirname "$file")")"
|
|
||||||
|
|
||||||
if age -R "$KEYS_FILE" "$file" > "$temp_file" && mv "$temp_file" "$output_file"; then
|
|
||||||
log_message "File encrypted successfully: $output_file"
|
|
||||||
|
|
||||||
if [[ "$DELETE_ORIGINAL" == true ]]; then
|
|
||||||
rm -f "$file"
|
|
||||||
log_message "Original file deleted: $file"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
rm -f "$temp_file"
|
|
||||||
log_message "Error: Failed to encrypt file '$file'."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to encrypt files or directories
|
# Function to encrypt files or directories
|
||||||
encrypt_file_or_directory()
|
encrypt_file_or_directory()
|
||||||
{
|
{
|
||||||
local file="$1"
|
local file="$1"
|
||||||
|
|
||||||
if [[ -d "$file" ]]; then
|
if [[ -d "$file" ]]; then
|
||||||
# Enable dotglob to include hidden files
|
for f in "$file"/*; do
|
||||||
shopt -s dotglob nullglob
|
|
||||||
local files=("$file"/*)
|
|
||||||
shopt -u dotglob nullglob
|
|
||||||
|
|
||||||
if [[ ${#files[@]} -eq 0 ]]; then
|
|
||||||
log_message "Warning: Directory '$file' is empty."
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
for f in "${files[@]}"; do
|
|
||||||
encrypt_file_or_directory "$f"
|
encrypt_file_or_directory "$f"
|
||||||
done
|
done
|
||||||
elif [[ -f "$file" ]]; then
|
elif [[ -f "$file" ]]; then
|
||||||
encrypt_single_file "$file"
|
fetch_keys_if_missing
|
||||||
else
|
local output_file="${file}.age"
|
||||||
log_message "Warning: '$file' is not a file or directory, skipping."
|
local temp_file
|
||||||
fi
|
temp_file="$(mktemp -p "$(dirname "$file")")"
|
||||||
}
|
if age -R "$KEYS_FILE" "$file" > "$temp_file" && mv "$temp_file" "$output_file"; then
|
||||||
|
log_message "File encrypted successfully: $output_file"
|
||||||
# Function to decrypt a single file
|
else
|
||||||
decrypt_single_file()
|
rm -f "$temp_file"
|
||||||
{
|
log_message "Error: Failed to encrypt file '$file'."
|
||||||
local file="$1"
|
exit 1
|
||||||
|
|
||||||
if [[ ! "$file" == *.age ]]; then
|
|
||||||
log_message "Skipping non-.age file: $file"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
local output_file="${file%.age}"
|
|
||||||
|
|
||||||
# Check if output file exists
|
|
||||||
if [[ -f "$output_file" && "$FORCE" != true ]]; then
|
|
||||||
log_message "Error: Output file '$output_file' already exists. Use --force to overwrite."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
fetch_keys_if_missing
|
|
||||||
|
|
||||||
local temp_file
|
|
||||||
temp_file="$(mktemp -p "$(dirname "$file")")"
|
|
||||||
|
|
||||||
if age -d -i "$KEYS_FILE" "$file" > "$temp_file" && mv "$temp_file" "$output_file"; then
|
|
||||||
log_message "File decrypted successfully: $output_file"
|
|
||||||
|
|
||||||
if [[ "$DELETE_ORIGINAL" == true ]]; then
|
|
||||||
rm -f "$file"
|
|
||||||
log_message "Encrypted file deleted: $file"
|
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
rm -f "$temp_file"
|
|
||||||
log_message "Error: Failed to decrypt file '$file'."
|
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,76 +142,54 @@ decrypt_single_file()
|
|||||||
decrypt_file_or_directory()
|
decrypt_file_or_directory()
|
||||||
{
|
{
|
||||||
local file="$1"
|
local file="$1"
|
||||||
|
|
||||||
if [[ -d "$file" ]]; then
|
if [[ -d "$file" ]]; then
|
||||||
# Enable nullglob to handle no matches gracefully
|
for f in "$file"/*.age; do
|
||||||
shopt -s nullglob
|
decrypt_file_or_directory "$f"
|
||||||
local files=("$file"/*.age)
|
|
||||||
shopt -u nullglob
|
|
||||||
|
|
||||||
if [[ ${#files[@]} -eq 0 ]]; then
|
|
||||||
log_message "Warning: No .age files found in directory '$file'."
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
for f in "${files[@]}"; do
|
|
||||||
decrypt_single_file "$f"
|
|
||||||
done
|
done
|
||||||
elif [[ -f "$file" ]]; then
|
elif [[ -f "$file" ]]; then
|
||||||
decrypt_single_file "$file"
|
fetch_keys_if_missing
|
||||||
else
|
local output_file="${file%.age}"
|
||||||
log_message "Warning: '$file' is not a file or directory, skipping."
|
local temp_file
|
||||||
|
temp_file="$(mktemp -p "$(dirname "$file")")"
|
||||||
|
if age -d -i "$KEYS_FILE" "$file" > "$temp_file" && mv "$temp_file" "$output_file"; then
|
||||||
|
log_message "File decrypted successfully: $output_file"
|
||||||
|
else
|
||||||
|
rm -f "$temp_file"
|
||||||
|
log_message "Error: Failed to decrypt file '$file'."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Main entry point
|
# Main logic
|
||||||
main()
|
case "$1" in
|
||||||
{
|
e | enc | encrypt)
|
||||||
check_dependencies
|
if [[ $# -lt 2 ]]; then
|
||||||
|
log_message "Error: No file or directory specified for encryption."
|
||||||
# Parse flags and get remaining arguments
|
|
||||||
mapfile -t ARGS < <(parse_flags "$@")
|
|
||||||
|
|
||||||
prepare_log_file
|
|
||||||
|
|
||||||
local command="${ARGS[0]:-}"
|
|
||||||
local target="${ARGS[1]:-}"
|
|
||||||
|
|
||||||
case "$command" in
|
|
||||||
e | enc | encrypt)
|
|
||||||
if [[ -z "$target" ]]; then
|
|
||||||
log_message "Error: No file or directory specified for encryption."
|
|
||||||
print_help
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
encrypt_file_or_directory "$target"
|
|
||||||
;;
|
|
||||||
d | dec | decrypt)
|
|
||||||
if [[ -z "$target" ]]; then
|
|
||||||
log_message "Error: No file or directory specified for decryption."
|
|
||||||
print_help
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
decrypt_file_or_directory "$target"
|
|
||||||
;;
|
|
||||||
help | --help | -h)
|
|
||||||
print_help
|
|
||||||
;;
|
|
||||||
version | --version)
|
|
||||||
print_version
|
|
||||||
;;
|
|
||||||
"")
|
|
||||||
print_help
|
print_help
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
fi
|
||||||
*)
|
encrypt_file_or_directory "$2"
|
||||||
log_message "Error: Unknown command '$command'"
|
;;
|
||||||
|
d | dec | decrypt)
|
||||||
|
if [[ $# -lt 2 ]]; then
|
||||||
|
log_message "Error: No file or directory specified for decryption."
|
||||||
print_help
|
print_help
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
fi
|
||||||
esac
|
decrypt_file_or_directory "$2"
|
||||||
}
|
;;
|
||||||
|
help | --help)
|
||||||
main "$@"
|
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
|
# vim: ft=bash:syn=sh:ts=2:sw=2:et:ai:nowrap
|
||||||
|
|||||||
@@ -2,76 +2,28 @@
|
|||||||
|
|
||||||
Encrypt or decrypt files and directories using `age` and your GitHub SSH keys.
|
Encrypt or decrypt files and directories using `age` and your GitHub SSH keys.
|
||||||
|
|
||||||
## Requirements
|
|
||||||
|
|
||||||
- [age](https://github.com/FiloSottile/age) - encryption tool
|
|
||||||
- curl - for fetching SSH keys
|
|
||||||
|
|
||||||
Install age:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
brew install age # macOS
|
|
||||||
apt install age # Debian/Ubuntu
|
|
||||||
dnf install age # Fedora
|
|
||||||
```
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
a [options] <command> <file|directory>
|
a encrypt <file|dir>
|
||||||
|
a decrypt <file.age|dir>
|
||||||
```
|
```
|
||||||
|
|
||||||
Commands:
|
|
||||||
|
|
||||||
- `e`, `enc`, `encrypt` - encrypt files
|
|
||||||
- `d`, `dec`, `decrypt` - decrypt files
|
|
||||||
- `help`, `--help`, `-h` - show help
|
|
||||||
- `version`, `--version` - show version
|
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
|
||||||
- `-v`, `--verbose` - show log output
|
- `-v`, `--verbose` – show log output
|
||||||
- `--delete` - delete original files after successful operation
|
|
||||||
- `-f`, `--force` - overwrite existing output files
|
|
||||||
|
|
||||||
Environment variables:
|
Environment variables:
|
||||||
|
|
||||||
- `AGE_KEYSFILE` - location of the keys file (default: `~/.ssh/keys.txt`)
|
- `AGE_KEYSFILE` – location of the keys file
|
||||||
- `AGE_KEYSSOURCE` - URL to fetch keys if missing (default: GitHub keys)
|
- `AGE_KEYSSOURCE` – URL to fetch keys if missing
|
||||||
- `AGE_LOGFILE` - log file path (default: `~/.cache/a.log`)
|
- `AGE_LOGFILE` – log file path
|
||||||
|
|
||||||
## Examples
|
## Example
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Encrypt a file
|
|
||||||
a encrypt secret.txt
|
a encrypt secret.txt
|
||||||
|
|
||||||
# Encrypt with short command
|
|
||||||
a e secret.txt
|
|
||||||
|
|
||||||
# Decrypt a file
|
|
||||||
a decrypt secret.txt.age
|
a decrypt secret.txt.age
|
||||||
a d secret.txt.age
|
|
||||||
|
|
||||||
# Encrypt a directory (includes hidden files)
|
|
||||||
a e /path/to/secrets/
|
|
||||||
|
|
||||||
# Encrypt and delete originals
|
|
||||||
a --delete e secret.txt
|
|
||||||
|
|
||||||
# Force overwrite existing .age file
|
|
||||||
a -f e secret.txt
|
|
||||||
|
|
||||||
# Verbose output
|
|
||||||
a -v e secret.txt
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Behavior
|
|
||||||
|
|
||||||
- Encrypting a directory processes all files recursively, including hidden files
|
|
||||||
- Already encrypted files (`.age`) are skipped during encryption
|
|
||||||
- Only `.age` files are processed during directory decryption
|
|
||||||
- Original files are preserved by default (use `--delete` to remove them)
|
|
||||||
- Output files are not overwritten by default (use `--force` to overwrite)
|
|
||||||
|
|
||||||
<!-- vim: set ft=markdown spell spelllang=en_us cc=80 : -->
|
<!-- vim: set ft=markdown spell spelllang=en_us cc=80 : -->
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
|
||||||
# @description Create file containing key mappings for Neovim
|
# @description Create file containing key mappings for Neovim
|
||||||
# Usage: ./create-nvim-keymaps.sh
|
# Usage: ./create-nvim-keymaps.sh
|
||||||
#
|
#
|
||||||
@@ -16,7 +15,7 @@ main()
|
|||||||
printf "\`\`\`txt"
|
printf "\`\`\`txt"
|
||||||
} > "$DEST"
|
} > "$DEST"
|
||||||
|
|
||||||
nvim -c "redir! >> \"$DEST\"" -c 'silent verbose map' -c 'redir END' -c 'q'
|
nvim -c "redir! >> $DEST" -c 'silent verbose map' -c 'redir END' -c 'q'
|
||||||
|
|
||||||
printf "\n\`\`\`\n\n- Generated on %s\n" "$(date)" >> "$DEST"
|
printf "\n\`\`\`\n\n- Generated on %s\n" "$(date)" >> "$DEST"
|
||||||
|
|
||||||
|
|||||||
@@ -1,75 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
# @description Install essential apt packages for development.
|
|
||||||
#
|
|
||||||
# shellcheck source=shared.sh
|
|
||||||
source "$DOTFILES/config/shared.sh"
|
|
||||||
|
|
||||||
msgr run "Starting to install apt packages"
|
|
||||||
|
|
||||||
if ! command -v apt &> /dev/null; then
|
|
||||||
msgr warn "apt not found (not a Debian-based system)"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
packages=(
|
|
||||||
# Build essentials
|
|
||||||
build-essential # gcc, g++, make
|
|
||||||
cmake # Cross-platform build system
|
|
||||||
pkg-config # Helper for compiling against libraries
|
|
||||||
autoconf # Automatic configure script builder
|
|
||||||
automake # Makefile generator
|
|
||||||
libtool # Generic library support script
|
|
||||||
|
|
||||||
# Libraries for compiling languages
|
|
||||||
libssl-dev # SSL development headers
|
|
||||||
libffi-dev # Foreign function interface
|
|
||||||
zlib1g-dev # Compression library
|
|
||||||
libreadline-dev # Command-line editing
|
|
||||||
libbz2-dev # Bzip2 compression
|
|
||||||
libsqlite3-dev # SQLite database
|
|
||||||
libncurses-dev # Terminal UI library
|
|
||||||
|
|
||||||
# CLI utilities (not in cargo/go/npm)
|
|
||||||
jq # JSON processor
|
|
||||||
tmux # Terminal multiplexer
|
|
||||||
tree # Directory listing
|
|
||||||
unzip # Archive extraction
|
|
||||||
shellcheck # Shell script linter
|
|
||||||
socat # Multipurpose network relay
|
|
||||||
gnupg # GPG encryption/signing
|
|
||||||
software-properties-common # add-apt-repository command
|
|
||||||
)
|
|
||||||
|
|
||||||
install_packages()
|
|
||||||
{
|
|
||||||
local to_install=()
|
|
||||||
|
|
||||||
for pkg in "${packages[@]}"; do
|
|
||||||
pkg="${pkg%%#*}"
|
|
||||||
pkg="${pkg// /}"
|
|
||||||
[[ -z "$pkg" ]] && continue
|
|
||||||
|
|
||||||
if dpkg -s "$pkg" &> /dev/null; then
|
|
||||||
msgr ok "$pkg already installed"
|
|
||||||
else
|
|
||||||
to_install+=("$pkg")
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ ${#to_install[@]} -gt 0 ]]; then
|
|
||||||
msgr run "Installing ${#to_install[@]} packages: ${to_install[*]}"
|
|
||||||
sudo apt update
|
|
||||||
sudo apt install -y "${to_install[@]}"
|
|
||||||
else
|
|
||||||
msgr ok "All packages already installed"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
install_packages
|
|
||||||
msgr yay "apt package installations complete"
|
|
||||||
}
|
|
||||||
|
|
||||||
main "$@"
|
|
||||||
@@ -1,9 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
|
||||||
# @description Install cargo/rust packages.
|
# @description Install cargo/rust packages.
|
||||||
#
|
|
||||||
# shellcheck source=shared.sh
|
|
||||||
source "$DOTFILES/config/shared.sh"
|
|
||||||
|
|
||||||
msgr run "Starting to install rust/cargo packages"
|
msgr run "Starting to install rust/cargo packages"
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
|
||||||
# @description Update pure-bash-bible cheatsheets
|
# @description Update pure-bash-bible cheatsheets
|
||||||
# shellcheck disable=SC2231,SC2034,SC2181,SC2068
|
# shellcheck disable=SC2231,SC2034,SC2181,SC2068
|
||||||
# shellcheck source=shared.sh
|
# shellcheck source=shared.sh
|
||||||
@@ -86,7 +85,7 @@ process_chapters()
|
|||||||
if [ '---' != "$(head -1 < "$cheat_file")" ]; then
|
if [ '---' != "$(head -1 < "$cheat_file")" ]; then
|
||||||
local metadata
|
local metadata
|
||||||
metadata="$PBB_SYNTAX\n$PBB_TAGS\n$PBB_SOURCE\n"
|
metadata="$PBB_SYNTAX\n$PBB_TAGS\n$PBB_SOURCE\n"
|
||||||
printf '%s\n%b%s\n%s' "---" "$metadata" "---" "$(cat "$cheat_file")" > "$cheat_file"
|
echo -e "---\n$metadata---\n$(cat "$cheat_file")" > "$cheat_file"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
|
||||||
# @description Install PHP Package Manager Composer
|
# @description Install PHP Package Manager Composer
|
||||||
#
|
#
|
||||||
# shellcheck source="shared.sh"
|
# shellcheck source="shared.sh"
|
||||||
source "$DOTFILES/config/shared.sh"
|
source "$HOME/.dotfiles/config/shared.sh"
|
||||||
|
|
||||||
if ! command -v php &> /dev/null; then
|
if ! command -v php &> /dev/null; then
|
||||||
msg_err "PHP Not Available, cannot install composer"
|
msg_err "PHP Not Available, cannot install composer"
|
||||||
@@ -23,7 +22,5 @@ fi
|
|||||||
php composer-setup.php --quiet
|
php composer-setup.php --quiet
|
||||||
RESULT=$?
|
RESULT=$?
|
||||||
rm composer-setup.php
|
rm composer-setup.php
|
||||||
if [ $RESULT -eq 0 ]; then
|
mv composer.phar ~/.local/bin/composer
|
||||||
mv composer.phar ~/.local/bin/composer
|
|
||||||
fi
|
|
||||||
exit $RESULT
|
exit $RESULT
|
||||||
|
|||||||
@@ -1,83 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
# @description Install essential dnf packages for development.
|
|
||||||
#
|
|
||||||
# shellcheck source=shared.sh
|
|
||||||
source "$DOTFILES/config/shared.sh"
|
|
||||||
|
|
||||||
msgr run "Starting to install dnf packages"
|
|
||||||
|
|
||||||
if ! command -v dnf &> /dev/null; then
|
|
||||||
msgr warn "dnf not found (not a Fedora/RHEL-based system)"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
packages=(
|
|
||||||
# Build essentials (individual packages, group handled separately)
|
|
||||||
cmake # Cross-platform build system
|
|
||||||
pkgconfig # Helper for compiling against libraries
|
|
||||||
autoconf # Automatic configure script builder
|
|
||||||
automake # Makefile generator
|
|
||||||
libtool # Generic library support script
|
|
||||||
|
|
||||||
# Libraries for compiling languages
|
|
||||||
openssl-devel # SSL development headers
|
|
||||||
libffi-devel # Foreign function interface
|
|
||||||
zlib-devel # Compression library
|
|
||||||
readline-devel # Command-line editing
|
|
||||||
bzip2-devel # Bzip2 compression
|
|
||||||
sqlite-devel # SQLite database
|
|
||||||
ncurses-devel # Terminal UI library
|
|
||||||
|
|
||||||
# CLI utilities (not in cargo/go/npm)
|
|
||||||
jq # JSON processor
|
|
||||||
tmux # Terminal multiplexer
|
|
||||||
tree # Directory listing
|
|
||||||
unzip # Archive extraction
|
|
||||||
ShellCheck # Shell script linter
|
|
||||||
socat # Multipurpose network relay
|
|
||||||
gnupg2 # GPG encryption/signing
|
|
||||||
)
|
|
||||||
|
|
||||||
install_dev_tools_group()
|
|
||||||
{
|
|
||||||
if dnf group list installed 2>/dev/null | grep -q "Development Tools"; then
|
|
||||||
msgr ok "@development-tools group already installed"
|
|
||||||
else
|
|
||||||
msgr run "Installing @development-tools group"
|
|
||||||
sudo dnf group install -y "Development Tools"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
install_packages()
|
|
||||||
{
|
|
||||||
local to_install=()
|
|
||||||
|
|
||||||
for pkg in "${packages[@]}"; do
|
|
||||||
pkg="${pkg%%#*}"
|
|
||||||
pkg="${pkg// /}"
|
|
||||||
[[ -z "$pkg" ]] && continue
|
|
||||||
|
|
||||||
if rpm -q "$pkg" &> /dev/null; then
|
|
||||||
msgr ok "$pkg already installed"
|
|
||||||
else
|
|
||||||
to_install+=("$pkg")
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ ${#to_install[@]} -gt 0 ]]; then
|
|
||||||
msgr run "Installing ${#to_install[@]} packages: ${to_install[*]}"
|
|
||||||
sudo dnf install -y "${to_install[@]}"
|
|
||||||
else
|
|
||||||
msgr ok "All packages already installed"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
install_dev_tools_group
|
|
||||||
install_packages
|
|
||||||
msgr yay "dnf package installations complete"
|
|
||||||
}
|
|
||||||
|
|
||||||
main "$@"
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
|
||||||
# @description Install NerdFonts
|
# @description Install NerdFonts
|
||||||
#
|
#
|
||||||
# shellcheck source="shared.sh"
|
# shellcheck source="shared.sh"
|
||||||
@@ -22,7 +21,7 @@ clone_or_update_repo()
|
|||||||
git clone --quiet --filter=blob:none --sparse --depth=1 "$GIT_REPO" "$TMP_PATH"
|
git clone --quiet --filter=blob:none --sparse --depth=1 "$GIT_REPO" "$TMP_PATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "$TMP_PATH" || { msgr err "No such folder $TMP_PATH"; exit 1; }
|
cd "$TMP_PATH" || msgr err "No such folder $TMP_PATH"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to add fonts to sparse-checkout
|
# Function to add fonts to sparse-checkout
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
|
||||||
# @description Install GitHub CLI extensions
|
# @description Install GitHub CLI extensions
|
||||||
#
|
#
|
||||||
# shellcheck source="shared.sh"
|
# shellcheck source="shared.sh"
|
||||||
source "${DOTFILES}/config/shared.sh"
|
source "${DOTFILES}/config/shared.sh"
|
||||||
|
|
||||||
|
# Enable verbosity with VERBOSE=1
|
||||||
|
VERBOSE="${VERBOSE:-0}"
|
||||||
|
|
||||||
msgr run "Installing gh (GitHub Client) extensions"
|
msgr run "Installing gh (GitHub Client) extensions"
|
||||||
|
|
||||||
if ! command -v gh &> /dev/null; then
|
if ! command -v gh &> /dev/null; then
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
|
||||||
# @description Install git-crypt
|
# @description Install git-crypt
|
||||||
#
|
#
|
||||||
# NOTE: Experimental, wip
|
# NOTE: Experimental, wip
|
||||||
@@ -7,17 +6,21 @@ set -euo pipefail
|
|||||||
# shellcheck source=shared.sh
|
# shellcheck source=shared.sh
|
||||||
source "${DOTFILES}/config/shared.sh"
|
source "${DOTFILES}/config/shared.sh"
|
||||||
|
|
||||||
|
# Enable verbosity with VERBOSE=1
|
||||||
|
VERBOSE="${VERBOSE:-0}"
|
||||||
|
|
||||||
msgr run "Installing git-crypt"
|
msgr run "Installing git-crypt"
|
||||||
|
|
||||||
if ! command -v git-crypt &> /dev/null; then
|
if ! command -v git-crypt &> /dev/null; then
|
||||||
REPO_URL="https://github.com/AGWA/git-crypt.git"
|
REPO_URL="https://github.com/AGWA/git-crypt.git"
|
||||||
CHECK_PATH="${XDG_BIN_HOME}/git-crypt"
|
CHECK_PATH="${XDG_BIN_HOME}/git-crypt"
|
||||||
BUILD_PATH="$(mktemp -d)"
|
BUILD_PATH="/tmp/git-crypt"
|
||||||
trap 'rm -rf "$BUILD_PATH"' EXIT
|
|
||||||
|
|
||||||
if [ ! -f "$CHECK_PATH" ]; then
|
rm -rf "$BUILD_PATH"
|
||||||
git clone --depth 1 "$REPO_URL" "$BUILD_PATH" || { msgr err "Failed to clone $REPO_URL"; exit 1; }
|
|
||||||
cd "$BUILD_PATH" || { msgr err "$BUILD_PATH not found"; exit 1; }
|
if [ ! -d "$CHECK_PATH" ]; then
|
||||||
|
git clone --depth 1 "$REPO_URL" "$BUILD_PATH" || true
|
||||||
|
cd "$BUILD_PATH" || msg_err "$BUILD_PATH not found"
|
||||||
make && make install PREFIX="$HOME/.local"
|
make && make install PREFIX="$HOME/.local"
|
||||||
else
|
else
|
||||||
msgr run_done "git-crypt ($CHECK_PATH) already installed"
|
msgr run_done "git-crypt ($CHECK_PATH) already installed"
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
|
||||||
# @description Install Go packages
|
# @description Install Go packages
|
||||||
#
|
#
|
||||||
# shellcheck source=shared.sh
|
# shellcheck source=shared.sh
|
||||||
source "$DOTFILES/config/shared.sh"
|
source "$DOTFILES/config/shared.sh"
|
||||||
|
|
||||||
|
# Enable verbosity with VERBOSE=1
|
||||||
|
VERBOSE="${VERBOSE:-0}"
|
||||||
|
|
||||||
msgr run "Installing go packages"
|
msgr run "Installing go packages"
|
||||||
|
|
||||||
! x-have "go" && msgr err "go hasn't been installed yet." && exit 0
|
! x-have "go" && msgr err "go hasn't been installed yet." && exit 0
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -uo pipefail
|
|
||||||
# @description Sets macOS Defaults that I like
|
# @description Sets macOS Defaults that I like
|
||||||
#
|
#
|
||||||
# This script contains large portions from following scripts:
|
# This script contains large portions from following scripts:
|
||||||
@@ -8,7 +7,7 @@ set -uo pipefail
|
|||||||
[ "$(uname)" != "Darwin" ] && echo "Not a macOS system" && exit 0
|
[ "$(uname)" != "Darwin" ] && echo "Not a macOS system" && exit 0
|
||||||
|
|
||||||
# shellcheck source=shared.sh
|
# shellcheck source=shared.sh
|
||||||
source "$DOTFILES/config/shared.sh"
|
source "$HOME/.dotfiles/config/shared.sh"
|
||||||
|
|
||||||
msgr run "Starting to set macOS defaults, these require sudo privileges:"
|
msgr run "Starting to set macOS defaults, these require sudo privileges:"
|
||||||
|
|
||||||
@@ -24,12 +23,12 @@ while true; do
|
|||||||
done 2> /dev/null &
|
done 2> /dev/null &
|
||||||
|
|
||||||
# Skip when shell is fish
|
# Skip when shell is fish
|
||||||
if [[ $SHELL != "$(command -v fish)" ]]; then
|
if [[ $SHELL != $(which fish) ]]; then
|
||||||
msgr nested "Change user shell to zsh if it is available and not the current"
|
msgr nested "Change user shell to zsh if it is available and not the current"
|
||||||
|
|
||||||
# Change user shell to zsh if not that already.
|
# Change user shell to zsh if not that already.
|
||||||
if hash zsh 2> /dev/null; then
|
if hash zsh 2> /dev/null; then
|
||||||
[[ $SHELL != "$(command -v zsh)" ]] && chsh -s "$(command -v zsh)"
|
[[ $SHELL != $(which zsh) ]] && chsh -s "$(which zsh)"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
|
||||||
# @description Install npm packages globally.
|
# @description Install npm packages globally.
|
||||||
#
|
#
|
||||||
# shellcheck source=shared.sh
|
# shellcheck source=shared.sh
|
||||||
source "$DOTFILES/config/shared.sh"
|
source "$DOTFILES/config/shared.sh"
|
||||||
|
|
||||||
|
# Enable verbosity with VERBOSE=1
|
||||||
|
VERBOSE="${VERBOSE:-0}"
|
||||||
|
|
||||||
msgr msg "Starting to install npm packages"
|
msgr msg "Starting to install npm packages"
|
||||||
|
|
||||||
if ! command -v npm &> /dev/null; then
|
if ! command -v npm &> /dev/null; then
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
|
||||||
# @description Install ntfy
|
# @description Install ntfy
|
||||||
#
|
#
|
||||||
# shellcheck source=shared.sh
|
# shellcheck source=shared.sh
|
||||||
source "$DOTFILES/config/shared.sh"
|
source "$DOTFILES/config/shared.sh"
|
||||||
|
|
||||||
|
# Enable verbosity with VERBOSE=1
|
||||||
|
VERBOSE="${VERBOSE:-0}"
|
||||||
|
|
||||||
# Check if ntfy is already installed
|
# Check if ntfy is already installed
|
||||||
if x-have "ntfy"; then
|
if x-have "ntfy"; then
|
||||||
msgr "done" "ntfy already installed"
|
msgr "done" "ntfy already installed"
|
||||||
@@ -21,31 +23,28 @@ case $(dfm check arch) in
|
|||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
msgr err "Unsupported OS"
|
msgr err "Unsupported OS"
|
||||||
exit 1
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
NTFY_VERSION="$(x-gh-get-latest-version binwiederhier/ntfy)"
|
NTFY_VERSION="$(x-gh-get-latest-version binwiederhier/ntfy)"
|
||||||
NTFY_URL="https://github.com/binwiederhier/ntfy"
|
NTFY_URL="https://github.com/binwiederhier/ntfy"
|
||||||
NTFY_TARBALL="ntfy_${NTFY_VERSION}_${NTFY_ARCH}.tar.gz"
|
NTFY_DEST="/tmp/ntfy_${NTFY_VERSION}_${NTFY_ARCH}"
|
||||||
NTFY_DIR="ntfy_${NTFY_VERSION}_${NTFY_ARCH}"
|
|
||||||
|
|
||||||
# Download and extract ntfy
|
# Download and extract ntfy
|
||||||
install_ntfy()
|
install_ntfy()
|
||||||
{
|
{
|
||||||
local tmpdir
|
curl -L "$NTFY_URL/releases/download/v${NTFY_VERSION}/${NTFY_DEST}.tar.gz" -o "${NTFY_DEST}.tar.gz"
|
||||||
tmpdir="$(mktemp -d)"
|
tar zxvf "${NTFY_DEST}.tar.gz"
|
||||||
trap 'rm -rf "$tmpdir"' EXIT
|
cp -a "${NTFY_DEST}/ntfy" ~/.local/bin/ntfy
|
||||||
|
|
||||||
curl -L "$NTFY_URL/releases/download/v${NTFY_VERSION}/${NTFY_TARBALL}" -o "$tmpdir/${NTFY_TARBALL}"
|
|
||||||
tar zxvf "$tmpdir/${NTFY_TARBALL}" -C "$tmpdir"
|
|
||||||
cp -a "$tmpdir/${NTFY_DIR}/ntfy" ~/.local/bin/ntfy
|
|
||||||
mkdir -p ~/.config/ntfy
|
mkdir -p ~/.config/ntfy
|
||||||
|
|
||||||
# Copy config only if it does not exist
|
# Copy config only if it does not exist
|
||||||
if [ ! -f "$HOME/.config/ntfy/client.yml" ]; then
|
if [ ! -f "$HOME/.config/ntfy/client.yml" ]; then
|
||||||
cp "$tmpdir/${NTFY_DIR}/client/client.yml" ~/.config/ntfy/client.yml
|
cp "${NTFY_DEST}/client/client.yml" ~/.config/ntfy/client.yml
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
rm -rf "${NTFY_DEST}" "${NTFY_DEST}.tar.gz"
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
|
||||||
# @description Install Python packages using uv.
|
# @description Install Python packages using uv.
|
||||||
#
|
#
|
||||||
# shellcheck source=shared.sh
|
# shellcheck source=shared.sh
|
||||||
source "$DOTFILES/config/shared.sh"
|
source "$DOTFILES/config/shared.sh"
|
||||||
|
|
||||||
|
# Enable verbosity with VERBOSE=1
|
||||||
|
VERBOSE="${VERBOSE:-0}"
|
||||||
|
|
||||||
msgr run "Starting to install Python packages"
|
msgr run "Starting to install Python packages"
|
||||||
|
|
||||||
# Ensure uv is available
|
# Ensure uv is available
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
|
||||||
# @description Install XCode CLI Tools with osascript magic.
|
# @description Install XCode CLI Tools with osascript magic.
|
||||||
# Ismo Vuorinen <https://github.com/ivuorinen> 2018
|
# Ismo Vuorinen <https://github.com/ivuorinen> 2018
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Enable verbosity with VERBOSE=1
|
||||||
|
VERBOSE="${VERBOSE:-0}"
|
||||||
|
|
||||||
# Check if the script is running on macOS
|
# Check if the script is running on macOS
|
||||||
if [ "$(uname)" != "Darwin" ]; then
|
if [ "$(uname)" != "Darwin" ]; then
|
||||||
msgr warn "Not a macOS system"
|
msgr warn "Not a macOS system"
|
||||||
@@ -29,7 +31,7 @@ keep_alive_sudo()
|
|||||||
done 2> /dev/null &
|
done 2> /dev/null &
|
||||||
}
|
}
|
||||||
|
|
||||||
XCODE_TOOLS_PATH="$(xcode-select -p)"
|
XCODE_TOOLS_PATH=$(xcode-select -p)
|
||||||
XCODE_SWIFT_PATH="$XCODE_TOOLS_PATH/usr/bin/swift"
|
XCODE_SWIFT_PATH="$XCODE_TOOLS_PATH/usr/bin/swift"
|
||||||
|
|
||||||
# Function to prompt for XCode CLI Tools installation
|
# Function to prompt for XCode CLI Tools installation
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
|
||||||
# @description Install z
|
# @description Install z
|
||||||
#
|
#
|
||||||
# shellcheck source=shared.sh
|
# shellcheck source=shared.sh
|
||||||
|
|||||||
@@ -4,8 +4,17 @@
|
|||||||
# Helper env variables. Use like this: VERBOSE=1 ./script.sh
|
# Helper env variables. Use like this: VERBOSE=1 ./script.sh
|
||||||
: "${VERBOSE:=0}"
|
: "${VERBOSE:=0}"
|
||||||
|
|
||||||
# Source the main shared config if not already loaded
|
# Set variable that checks if the shared.sh script has been
|
||||||
if [ -z "${SHARED_SCRIPTS_SOURCED:-}" ]; then
|
# sourced only once If the script has been sourced more than once,
|
||||||
|
# the script not be sourced again.
|
||||||
|
[ -z "$SHARED_SCRIPTS_SOURCED" ] && {
|
||||||
|
|
||||||
source "${DOTFILES}/config/shared.sh"
|
source "${DOTFILES}/config/shared.sh"
|
||||||
|
# Warn the user if the shared configuration hasn't been loaded yet
|
||||||
|
msgr warn "(!) shared.sh not sourced"
|
||||||
|
|
||||||
|
# Set variable that checks if the shared.sh script has been
|
||||||
|
# sourced only once.
|
||||||
|
# shellcheck disable=SC2034
|
||||||
export SHARED_SCRIPTS_SOURCED=1
|
export SHARED_SCRIPTS_SOURCED=1
|
||||||
fi
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user