Skip to content

Instantly share code, notes, and snippets.

@PrashamTrivedi
Created July 18, 2025 18:01
Show Gist options
  • Save PrashamTrivedi/a239c084b96ae3c05f20ae7334224519 to your computer and use it in GitHub Desktop.
Save PrashamTrivedi/a239c084b96ae3c05f20ae7334224519 to your computer and use it in GitHub Desktop.
Local Setup File
# easy reload config
bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded."
set -g default-terminal "screen-256color"
# set window split
bind-key v split-window -h
bind-key h split-window
bind-key q confirm-before -p "kill-session #S? (y/n)" kill-session
bind-key ! break-pane -d -n _hidden_pane
bind-key @ join-pane -s $.0
set -g mouse on
bind-key C command-prompt -p "Name of new window: " "new-window -n '%%'"
set -g status-position top
set -g set-clipboard on # use system clipboard
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'catppuccin/tmux'
set -g @plugin 'tmux-plugins/tmux-battery'
# Catpuccin Area
set -g pane-active-border-style 'fg=magenta,bg=default'
set -g pane-border-style 'fg=brightblack,bg=default'
set -g @catppuccin_window_status_icon_enable "yes"
set -g @catppuccin_flavour 'macchiato' #
set -g @catppuccin_status_background 'default'
#Catpuccin Config
set -g @catppuccin_window_left_separator ""
set -g @catppuccin_window_right_separator " "
set -g @catppuccin_window_middle_separator " █"
set -g @catppuccin_window_number_position "right"
set -g @catppuccin_window_default_fill "number"
set -g @catppuccin_window_default_text "#W"
set -g @catppuccin_window_current_fill "number"
set -g @catppuccin_window_current_text "#W#{?window_zoomed_flag,(),}"
set -g @catppuccin_status_modules_right "session battery date_time"
set -g @catppuccin_status_left_separator " "
set -g @catppuccin_status_right_separator ""
set -g @catppuccin_status_fill "icon"
set -g @catppuccin_status_connect_separator "no"
set -g @catppuccin_icon_window_last "󰖰"
set -g @catppuccin_icon_window_current "󰖯"
set -g @catppuccin_icon_window_zoom "󰁌"
set -g @catppuccin_icon_window_mark "󰃀"
set -g @catppuccin_icon_window_silent "󰂛"
set -g @catppuccin_icon_window_activity "󱅫"
set -g @catppuccin_icon_window_bell "󰂞"
set -g @catppuccin_directory_text "#{pane_current_path}"
# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'github_username/plugin_name#branch'
# set -g @plugin '[email protected]:user/plugin'
# set -g @plugin '[email protected]:user/plugin'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
#!/bin/bash
# Function to print usage information
usage() {
echo "Usage: $0 <profile>"
exit 1
}
# Check if a profile has been provided
if [ -z "$1" ]; then
usage
fi
PROFILE=$1
# Perform AWS SSO login
echo "Logging into profile $PROFILE..."
aws sso login --sso-session "$PROFILE"
# Check if the login succeeded
if [ $? -ne 0 ]; then
echo "AWS SSO login failed"
exit 1
fi
# Export credentials to environment variables format
echo "Exporting credentials for profile $PROFILE..."
export_output=$(aws configure export-credentials --profile "$PROFILE" --format env-no-export)
# Check if export succeeded
if [ $? -ne 0 ]; then
echo "Failed to export credentials"
exit 1
fi
# Parse the output to extract individual credentials
access_key_id=$(echo "$export_output" | grep 'AWS_ACCESS_KEY_ID' | cut -d '=' -f2 | tr -d ' ')
secret_access_key=$(echo "$export_output" | grep 'AWS_SECRET_ACCESS_KEY' | cut -d '=' -f2 | tr -d ' ')
session_token=$(echo "$export_output" | grep 'AWS_SESSION_TOKEN' | cut -d '=' -f2 | tr -d ' ')
# Backup existing credentials file
cp ~/.aws/credentials ~/.aws/credentials.bak
# Replace profile in ~/.aws/credentials
echo "Updating ~/.aws/credentials with new credentials for profile $PROFILE..."
# Use awk to replace or add the profile
awk -v profile="$PROFILE" -v access_key_id="$access_key_id" -v secret_access_key="$secret_access_key" -v session_token="$session_token" '
BEGIN {
profile_section = "[" profile "]";
in_profile_section = 0;
updated = 0;
}
{
if ($0 ~ /^\[.*\]$/) {
in_profile_section = 0;
}
if ($0 == profile_section) {
in_profile_section = 1;
updated = 1;
print $0;
getline;
print "aws_access_key_id="access_key_id;
getline;
print "aws_secret_access_key="secret_access_key;
getline;
print "aws_session_token="session_token;
} else if (!in_profile_section) {
print $0;
}
}
END {
if (updated == 0) {
print profile_section;
print "aws_access_key_id="access_key_id;
print "aws_secret_access_key="secret_access_key;
print "aws_session_token="session_token;
}
}' ~/.aws/credentials > ~/.aws/credentials.tmp && mv ~/.aws/credentials.tmp ~/.aws/credentials
echo "Profile $PROFILE updated successfully"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment