mirror of
https://github.com/nikdoof/dotfiles.git
synced 2025-12-13 09:42:27 +00:00
Compare commits
8 Commits
3620c5cf4d
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
04206a5471
|
|||
|
|
4115692e51 | ||
|
|
d27de08a5c | ||
|
|
7b493cbfde | ||
|
b66a25ef26
|
|||
| 8ca8ea5a41 | |||
| 08dde00b3a | |||
| 633203a69c |
@@ -1,5 +0,0 @@
|
||||
[user]
|
||||
signingkey = 86DAB9F71FF20A3A
|
||||
|
||||
[commit]
|
||||
gpgsign = true
|
||||
@@ -20,9 +20,12 @@ brew "poetry"
|
||||
brew "sass/sass/sass"
|
||||
brew "smartmontools"
|
||||
brew "hashicorp/tap/terraform"
|
||||
brew "terraform-local"
|
||||
brew "tz"
|
||||
brew "uv"
|
||||
brew "yazi"
|
||||
brew "jq"
|
||||
brew "fzf"
|
||||
|
||||
cask "appcleaner"
|
||||
cask "balenaetcher"
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
# Tag the file as OK to run
|
||||
# macOS tags downloads with "com.apple.quarantine" attribute to prevent execution of downloaded files until the user explicitly allows it.
|
||||
# This function removes that attribute, allowing the file to be opened without warning.
|
||||
# Usage: itsok <file_path>
|
||||
function itsok() {
|
||||
if [[ $(uname) == "Darwin" ]]; then
|
||||
xattr -d com.apple.quarantine $1
|
||||
@@ -7,12 +9,17 @@ function itsok() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Updates Homebrew installation from the Brewfile
|
||||
# Runs a brew bundle check and installs missing packages
|
||||
# Usage: update-brewfile
|
||||
function update-brewfile() {
|
||||
brew bundle check --file "$HOME/.config/Brewfile" || brew bundle --cleanup -f --file "$HOME/.config/Brewfile"
|
||||
}
|
||||
|
||||
# Updates the dock
|
||||
# Updates the macOS Dock based on a configuration file
|
||||
# The configuration file should be in the format:
|
||||
# app_name<TAB>app_path<TAB>app_type
|
||||
# where app_type can be "persisentApps" or "other"
|
||||
# Usage: update-dock
|
||||
function update-dock() {
|
||||
idx=1
|
||||
while read entry; do
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
# Get the list of AWS profiles
|
||||
function awsprofiles() {
|
||||
profiles=$(aws --no-cli-pager configure list-profiles 2> /dev/null)
|
||||
@@ -28,19 +27,47 @@ function awslogin() {
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1"
|
||||
echo "Usage: awslogin --profile prof [--region region]"
|
||||
echo "Usage: awslogin [--profile prof] [--region region]"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Check if profile is provided
|
||||
if [[ -z "$profile" ]]; then
|
||||
echo "Error: --profile parameter is required."
|
||||
echo "Usage: awslogin --profile prof [--region region]"
|
||||
# Get available profiles
|
||||
local available_profiles
|
||||
available_profiles=$(aws --no-cli-pager configure list-profiles 2> /dev/null)
|
||||
if [[ -z "$available_profiles" ]]; then
|
||||
echo "No AWS profiles found in ~/.aws/config"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# If no profile provided, use fzf to select one
|
||||
if [[ -z "$profile" ]]; then
|
||||
profile=$(echo "$available_profiles" | fzf --header "Select AWS profile" --height 40%)
|
||||
if [[ -z "$profile" ]]; then
|
||||
echo "No profile selected."
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
# Check if provided profile exists
|
||||
if ! echo "$available_profiles" | grep -qx "$profile"; then
|
||||
echo "Profile '$profile' not found. Searching for matches..."
|
||||
local matched_profiles
|
||||
matched_profiles=$(echo "$available_profiles" | grep -i "$profile")
|
||||
|
||||
if [[ -z "$matched_profiles" ]]; then
|
||||
echo "No matching profiles found."
|
||||
return 1
|
||||
fi
|
||||
|
||||
profile=$(echo "$matched_profiles" | fzf --header "Select AWS profile" --height 40%)
|
||||
if [[ -z "$profile" ]]; then
|
||||
echo "No profile selected."
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Build AWS CLI options
|
||||
local aws_opts=()
|
||||
[[ -n "$profile" ]] && aws_opts+=(--profile "$profile")
|
||||
@@ -71,10 +98,36 @@ function awslogout() {
|
||||
unset AWS_ACCESS_KEY_ID
|
||||
unset AWS_SECRET_ACCESS_KEY
|
||||
unset AWS_SESSION_TOKEN
|
||||
unset AWS_CREDENTIAL_EXPIRATION
|
||||
export AWS_PROFILE_DISPLAY=""
|
||||
echo "AWS profile and credentials cleared."
|
||||
}
|
||||
|
||||
function _aws_creds_expiration_check() {
|
||||
if [[ -n "$AWS_CREDENTIAL_EXPIRATION" ]]; then
|
||||
local expiration_epoch
|
||||
local current_epoch
|
||||
|
||||
# Convert expiration time to epoch (handles ISO 8601 format)
|
||||
if command -v gdate &> /dev/null; then
|
||||
# macOS with GNU coreutils installed
|
||||
expiration_epoch=$(gdate -d "$AWS_CREDENTIAL_EXPIRATION" +%s 2>/dev/null)
|
||||
current_epoch=$(gdate +%s)
|
||||
else
|
||||
# macOS with BSD date
|
||||
expiration_epoch=$(date -j -f "%Y-%m-%dT%H:%M:%S%z" "$AWS_CREDENTIAL_EXPIRATION" +%s 2>/dev/null)
|
||||
current_epoch=$(date +%s)
|
||||
fi
|
||||
|
||||
if [[ $? -eq 0 && -n "$expiration_epoch" ]]; then
|
||||
if [[ $current_epoch -ge $expiration_epoch ]]; then
|
||||
echo "AWS credentials have expired. Logging out..."
|
||||
awslogout
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# easy access to SSH
|
||||
function awsssh() {
|
||||
local profile=""
|
||||
|
||||
@@ -32,14 +32,14 @@ if [ -f $HOME/.cargo/env ]; then
|
||||
source $HOME/.cargo/env
|
||||
fi
|
||||
|
||||
# https://github.com/oz/tz
|
||||
if [ -x "$(command -v tz)" ]; then
|
||||
export TZ_LIST="Europe/Dublin,Portwest HQ;America/New_York,WDW;America/Los_Angeles,DLR;Europe/Paris,DLP"
|
||||
fi
|
||||
|
||||
# macOS Specific envs
|
||||
if [[ $(uname) == "Darwin" ]]; then
|
||||
# Homebrew
|
||||
export HOMEBREW_NO_ENV_HINTS=1
|
||||
[ -d /opt/homebrew ] && eval $(/opt/homebrew/bin/brew shellenv)
|
||||
[ -d /opt/homebrew ] && eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||
fi
|
||||
|
||||
# https://github.com/oz/tz
|
||||
if [ -x "$(command -v tz)" ]; then
|
||||
export TZ_LIST="Europe/Dublin,Portwest HQ;America/New_York,WDW;America/Los_Angeles,DLR;Europe/Paris,DLP"
|
||||
fi
|
||||
|
||||
@@ -10,7 +10,8 @@ function update-dotfiles() {
|
||||
cd "$prevdir"
|
||||
}
|
||||
|
||||
# Wrapper around ssh-add to ease usage and also ensure basic timeouts
|
||||
# Wrapper around ssh-add to easily add SSH keys with a timeout
|
||||
# Usage: add-sshkey [key_name]
|
||||
function add-sshkey() {
|
||||
TIMEOUT="2h"
|
||||
NAME=$1
|
||||
|
||||
Reference in New Issue
Block a user