mirror of
https://github.com/nmasur/dotfiles
synced 2025-04-23 20:22:24 +00:00
Compare commits
No commits in common. "3873ab7296915cc54f8d3689c38b5ad8a16a56dd" and "b7317a721b04ea4adb1b960340c56f52a64e6606" have entirely different histories.
3873ab7296
...
b7317a721b
@ -1,19 +0,0 @@
|
|||||||
{ config, lib, ... }:
|
|
||||||
|
|
||||||
let
|
|
||||||
cfg = config.nmasur.presets.programs.aws-ssh;
|
|
||||||
in
|
|
||||||
|
|
||||||
{
|
|
||||||
options.nmasur.presets.programs.aws-ssh.enable = lib.mkEnableOption "AWS SSH tools";
|
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
|
||||||
|
|
||||||
# Ignore wine directories in searches
|
|
||||||
home.file.".ssh/aws-ssm-ssh-proxy-command.sh" = {
|
|
||||||
text = builtins.readFile ./aws-ssm-ssh-proxy-command.sh;
|
|
||||||
executable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -eu
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
#
|
|
||||||
# For documentation see https://github.com/qoomon/aws-ssm-ssh-proxy-command
|
|
||||||
#
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
getInstanceId() {
|
|
||||||
local instance_name="$1"
|
|
||||||
local instance_id=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=${instance_name}" --query "Reservations[].Instances[?State.Name == 'running'].InstanceId" --output text)
|
|
||||||
|
|
||||||
echo "${instance_id}"
|
|
||||||
}
|
|
||||||
|
|
||||||
instance_name="$1"
|
|
||||||
ssh_user="$2"
|
|
||||||
ssh_port="$3"
|
|
||||||
ssh_public_key_path="$4"
|
|
||||||
|
|
||||||
ec2InstanceIdPattern='^m?i-[0-9a-f]{8,17}$'
|
|
||||||
if [[ $instance_name =~ $ec2InstanceIdPattern ]]; then
|
|
||||||
instance_id=$instance_name
|
|
||||||
else
|
|
||||||
instance_id=$(getInstanceId "$instance_name")
|
|
||||||
|
|
||||||
if [[ -z $instance_id ]]; then
|
|
||||||
echo "Found no running instances with name \"${instance_name}\"."
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "Instance ID for \"${instance_name}\": \"${instance_id}\""
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
REGION_SEPARATOR='--'
|
|
||||||
if echo "$instance_id" | grep -q -e "${REGION_SEPARATOR}"; then
|
|
||||||
export AWS_REGION="${instance_id##*"${REGION_SEPARATOR}"}"
|
|
||||||
instance_id="${instance_id%%"$REGION_SEPARATOR"*}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
>/dev/stderr echo "Add public key ${ssh_public_key_path} for ${ssh_user} at instance ${instance_id} for 10 seconds"
|
|
||||||
ssh_public_key="$(cat "${ssh_public_key_path}")"
|
|
||||||
aws ssm send-command \
|
|
||||||
--instance-ids "${instance_id}" \
|
|
||||||
--document-name 'AWS-RunShellScript' \
|
|
||||||
--comment "Add an SSH public key to authorized_keys for 10 seconds" \
|
|
||||||
--parameters commands="
|
|
||||||
\"
|
|
||||||
set -eu
|
|
||||||
|
|
||||||
mkdir -p ~${ssh_user}/.ssh && cd ~${ssh_user}/.ssh
|
|
||||||
|
|
||||||
authorized_key='${ssh_public_key} ssm-session'
|
|
||||||
|
|
||||||
echo \\\"\${authorized_key}\\\" >> authorized_keys
|
|
||||||
|
|
||||||
sleep 10
|
|
||||||
|
|
||||||
(grep -v -F \\\"\${authorized_key}\\\" authorized_keys || true) > authorized_keys~
|
|
||||||
mv authorized_keys~ authorized_keys
|
|
||||||
\"
|
|
||||||
"
|
|
||||||
|
|
||||||
>/dev/stderr echo "Start ssm session to instance ${instance_id}"
|
|
||||||
aws ssm start-session \
|
|
||||||
--target "${instance_id}" \
|
|
||||||
--document-name 'AWS-StartSSHSession' \
|
|
||||||
--parameters "portNumber=${ssh_port}"
|
|
@ -36,10 +36,6 @@ in
|
|||||||
"super+shift+[=unbind"
|
"super+shift+[=unbind"
|
||||||
"ctrl+tab=unbind"
|
"ctrl+tab=unbind"
|
||||||
"ctrl+shift+tab=unbind"
|
"ctrl+shift+tab=unbind"
|
||||||
"ctrl+tab=text:\\x1b[9;5u"
|
|
||||||
"ctrl+shift+tab=text:\\x1b[9;6u"
|
|
||||||
"super+k=unbind"
|
|
||||||
"super+shift+e=unbind"
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
themes."gruvbox" = {
|
themes."gruvbox" = {
|
||||||
|
@ -22,9 +22,7 @@ in
|
|||||||
# Set Neovim as the default app for text editing and manual pages
|
# Set Neovim as the default app for text editing and manual pages
|
||||||
home.sessionVariables = {
|
home.sessionVariables = {
|
||||||
EDITOR = lib.mkForce "${lib.getExe pkgs.helix}";
|
EDITOR = lib.mkForce "${lib.getExe pkgs.helix}";
|
||||||
MANPAGER = lib.mkForce "sh -c 'col -bx | ${lib.getExe pkgs.helix}'";
|
MANPAGER = lib.mkForce "${lib.getExe pkgs.helix}";
|
||||||
MANWIDTH = 87;
|
|
||||||
MANROFFOPT = "-c";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# Create quick aliases for launching Helix
|
# Create quick aliases for launching Helix
|
||||||
@ -120,21 +118,10 @@ in
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ignores = [
|
|
||||||
"content/.obsidian/**"
|
|
||||||
];
|
|
||||||
|
|
||||||
settings = {
|
settings = {
|
||||||
theme = "base16";
|
theme = "base16";
|
||||||
|
|
||||||
keys.normal = {
|
keys.normal = {
|
||||||
|
|
||||||
# Get out of multiple cursors and selection
|
|
||||||
esc = [
|
|
||||||
"collapse_selection"
|
|
||||||
"keep_primary_selection"
|
|
||||||
];
|
|
||||||
|
|
||||||
# Enable and disable inlay hints
|
# Enable and disable inlay hints
|
||||||
space.H = ":toggle lsp.display-inlay-hints";
|
space.H = ":toggle lsp.display-inlay-hints";
|
||||||
|
|
||||||
@ -224,7 +211,6 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
themes."${config.programs.helix.settings.theme}" = {
|
themes."${config.programs.helix.settings.theme}" = {
|
||||||
|
@ -44,17 +44,16 @@ in
|
|||||||
programs.fish.functions = {
|
programs.fish.functions = {
|
||||||
syncnotes = {
|
syncnotes = {
|
||||||
description = "Full git commit on notes";
|
description = "Full git commit on notes";
|
||||||
body =
|
body = lib.getExe (
|
||||||
let
|
pkgs.writers.writeFishBin "syncnotes" {
|
||||||
git = lib.getExe pkgs.git;
|
makeWrapperArgs = [
|
||||||
in
|
"--prefix"
|
||||||
# fish
|
"PATH"
|
||||||
''
|
":"
|
||||||
${git} -C ${cfg.path} pull
|
"${lib.makeBinPath [ pkgs.git ]}"
|
||||||
${git} -C ${cfg.path} add -A
|
];
|
||||||
${git} -C ${cfg.path} commit -m autosync
|
} (builtins.readFile ./syncnotes.fish)
|
||||||
${git} -C ${cfg.path} push
|
);
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
note = {
|
note = {
|
||||||
description = "Edit or create a note";
|
description = "Edit or create a note";
|
||||||
|
@ -106,7 +106,7 @@ in
|
|||||||
};
|
};
|
||||||
shared = {
|
shared = {
|
||||||
"bind \"Alt Shift p\"" = {
|
"bind \"Alt Shift p\"" = {
|
||||||
Run = {
|
"Run" = {
|
||||||
_args = [
|
_args = [
|
||||||
"${pkgs.fish}/bin/fish"
|
"${pkgs.fish}/bin/fish"
|
||||||
"-c"
|
"-c"
|
||||||
@ -115,32 +115,27 @@ in
|
|||||||
close_on_exit = true;
|
close_on_exit = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
"bind \"Super Shift ]\"" = {
|
"bind \"Alt Shift k\"" = {
|
||||||
GoToNextTab = { };
|
|
||||||
};
|
|
||||||
"bind \"Super Shift [\"" = {
|
|
||||||
GoToPreviousTab = { };
|
|
||||||
};
|
|
||||||
"bind \"Ctrl Tab\"" = {
|
|
||||||
GoToNextTab = { };
|
|
||||||
};
|
|
||||||
"bind \"Ctrl Shift Tab\"" = {
|
|
||||||
GoToPreviousTab = { };
|
|
||||||
};
|
|
||||||
"bind \"Super t\"" = {
|
|
||||||
NewTab = { };
|
|
||||||
};
|
|
||||||
"bind \"Super k\"" = {
|
|
||||||
SwitchToMode = {
|
|
||||||
_args = [ "scroll" ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
"bind \"Super Shift e\"" = {
|
|
||||||
EditScrollback = { };
|
EditScrollback = { };
|
||||||
SwitchToMode = {
|
SwitchToMode = {
|
||||||
_args = [ "locked" ];
|
_args = [ "locked" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
"bind \"Super Shift ]\"" = {
|
||||||
|
"GoToNextTab" = { };
|
||||||
|
};
|
||||||
|
"bind \"Super Shift [\"" = {
|
||||||
|
"GoToPreviousTab" = { };
|
||||||
|
};
|
||||||
|
"bind \"Ctrl Tab\"" = {
|
||||||
|
"GoToNextTab" = { };
|
||||||
|
};
|
||||||
|
"bind \"Ctrl Shift Tab\"" = {
|
||||||
|
"GoToPreviousTab" = { };
|
||||||
|
};
|
||||||
|
"bind \"Super t\"" = {
|
||||||
|
"NewTab" = { };
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -39,14 +39,11 @@ in
|
|||||||
pkgs.nmasur.terraform-init # Quick shortcut for initializing Terraform backend
|
pkgs.nmasur.terraform-init # Quick shortcut for initializing Terraform backend
|
||||||
];
|
];
|
||||||
|
|
||||||
programs.fish.shellAliases.ec2 = "aws-ec2";
|
|
||||||
|
|
||||||
nmasur.presets = {
|
nmasur.presets = {
|
||||||
fonts.enable = lib.mkDefault true;
|
fonts.enable = lib.mkDefault true;
|
||||||
programs = {
|
programs = {
|
||||||
_1password.enable = lib.mkDefault true;
|
_1password.enable = lib.mkDefault true;
|
||||||
atuin.enable = lib.mkDefault true;
|
atuin.enable = lib.mkDefault true;
|
||||||
aws-ssh.enable = lib.mkDefault true;
|
|
||||||
bash.enable = lib.mkDefault true;
|
bash.enable = lib.mkDefault true;
|
||||||
bat.enable = lib.mkDefault true;
|
bat.enable = lib.mkDefault true;
|
||||||
direnv.enable = lib.mkDefault true;
|
direnv.enable = lib.mkDefault true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user