Formatting and hammerspoon
This commit is contained in:
parent
c34274413a
commit
b9b62ea3c3
@ -29,7 +29,9 @@
|
|||||||
echo "Commands:"
|
echo "Commands:"
|
||||||
echo -n '${
|
echo -n '${
|
||||||
builtins.toJSON (
|
builtins.toJSON (
|
||||||
builtins.mapAttrs (s: value: value.description) self.devShells.${pkgs.stdenv.hostPlatform.system}.default.config.scripts
|
builtins.mapAttrs (
|
||||||
|
s: value: value.description
|
||||||
|
) self.devShells.${pkgs.stdenv.hostPlatform.system}.default.config.scripts
|
||||||
)
|
)
|
||||||
}' | \
|
}' | \
|
||||||
${pkgs.jq}/bin/jq -r 'to_entries | map(" \(.key)\n" + " - \(if .value == "" then "no description provided" else .value end)") | "" + .[]'
|
${pkgs.jq}/bin/jq -r 'to_entries | map(" \(.key)\n" + " - \(if .value == "" then "no description provided" else .value end)") | "" + .[]'
|
||||||
|
|||||||
@ -21,26 +21,22 @@ return (function()
|
|||||||
screen = "394ACDEE-CA25-43C4-A533-D4EDF4A897AF",
|
screen = "394ACDEE-CA25-43C4-A533-D4EDF4A897AF",
|
||||||
fullscreen = true,
|
fullscreen = true,
|
||||||
},
|
},
|
||||||
Cursor = {
|
Code = {
|
||||||
desktop = 1,
|
desktop = 1,
|
||||||
screen = "B5845603-D54C-44B8-9B55-96F7E5F50646",
|
screen = "D3142823-261D-46EF-B9C2-5181C7FE2CA5",
|
||||||
fullscreen = true,
|
fullscreen = true,
|
||||||
},
|
},
|
||||||
Notes = {
|
|
||||||
desktop = 2,
|
|
||||||
screen = "B5845603-D54C-44B8-9B55-96F7E5F50646"
|
|
||||||
},
|
|
||||||
Spotify = {
|
Spotify = {
|
||||||
desktop = 3,
|
desktop = 3,
|
||||||
screen = "B5845603-D54C-44B8-9B55-96F7E5F50646",
|
screen = "D3142823-261D-46EF-B9C2-5181C7FE2CA5",
|
||||||
fullscreen = true,
|
fullscreen = true,
|
||||||
},
|
},
|
||||||
["zoom.us"] = {
|
["zoom.us"] = {
|
||||||
screen = "B5845603-D54C-44B8-9B55-96F7E5F50646",
|
screen = "D3142823-261D-46EF-B9C2-5181C7FE2CA5",
|
||||||
fullscreen = true,
|
fullscreen = true,
|
||||||
},
|
},
|
||||||
["Microsoft Outlook"] = {
|
["Microsoft Outlook"] = {
|
||||||
desktop = 3,
|
desktop = 2,
|
||||||
screen = "D3142823-261D-46EF-B9C2-5181C7FE2CA5",
|
screen = "D3142823-261D-46EF-B9C2-5181C7FE2CA5",
|
||||||
fullscreen = true,
|
fullscreen = true,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -35,7 +35,7 @@ windowMove = function()
|
|||||||
|
|
||||||
hs.hotkey.bind({ "ctrl", "alt", "cmd" }, "pad1", function()
|
hs.hotkey.bind({ "ctrl", "alt", "cmd" }, "pad1", function()
|
||||||
-- DELL S2722DGM
|
-- DELL S2722DGM
|
||||||
local scr = getScreenById("0F6BDB5B-840D-40BE-AAC9-B467A78E057A")
|
local scr = getScreenById("394ACDEE-CA25-43C4-A533-D4EDF4A897AF")
|
||||||
if scr == nil then
|
if scr == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -79,7 +79,7 @@ windowMove = function()
|
|||||||
|
|
||||||
hs.hotkey.bind({ "ctrl", "alt", "cmd", "shift" }, "pad1", function()
|
hs.hotkey.bind({ "ctrl", "alt", "cmd", "shift" }, "pad1", function()
|
||||||
-- DELL S2722DGM
|
-- DELL S2722DGM
|
||||||
local scr = getScreenById("0F6BDB5B-840D-40BE-AAC9-B467A78E057A")
|
local scr = getScreenById("394ACDEE-CA25-43C4-A533-D4EDF4A897AF")
|
||||||
if scr == nil then
|
if scr == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
@ -21,145 +21,144 @@ in
|
|||||||
size = 10000;
|
size = 10000;
|
||||||
};
|
};
|
||||||
|
|
||||||
shellAliases =
|
shellAliases = {
|
||||||
{
|
# use eval $(aws-export-credentials) to expose them to environment
|
||||||
# use eval $(aws-export-credentials) to expose them to environment
|
aws-export-credentials = lib.mkDefault "${pkgs.awscli2}/bin/aws configure export-credentials --format env --profile";
|
||||||
aws-export-credentials = lib.mkDefault "${pkgs.awscli2}/bin/aws configure export-credentials --format env --profile";
|
|
||||||
|
|
||||||
aws-export-assume-role = lib.mkDefault "${pkgs.writeShellScript "aws-export-assume-role" ''
|
aws-export-assume-role = lib.mkDefault "${pkgs.writeShellScript "aws-export-assume-role" ''
|
||||||
[[ -z "$1" || -z "$2" ]] && echo "Usage: aws-export-assume-role <profile> <role-arn>" && exit 1
|
[[ -z "$1" || -z "$2" ]] && echo "Usage: aws-export-assume-role <profile> <role-arn>" && exit 1
|
||||||
${pkgs.coreutils}/bin/printf 'export AWS_ACCESS_KEY_ID=%s\nexport AWS_SECRET_ACCESS_KEY=%s\nexport AWS_SESSION_TOKEN=%s' $(${pkgs.awscli2}/bin/aws --profile "$1" sts assume-role --role-arn "$2" --role-session-name lcech --query "Credentials.[AccessKeyId,SecretAccessKey,SessionToken]" --output text)
|
${pkgs.coreutils}/bin/printf 'export AWS_ACCESS_KEY_ID=%s\nexport AWS_SECRET_ACCESS_KEY=%s\nexport AWS_SESSION_TOKEN=%s' $(${pkgs.awscli2}/bin/aws --profile "$1" sts assume-role --role-arn "$2" --role-session-name lcech --query "Credentials.[AccessKeyId,SecretAccessKey,SessionToken]" --output text)
|
||||||
''}";
|
''}";
|
||||||
|
|
||||||
# https://docs.aws.amazon.com/singlesignon/latest/userguide/createshortcutlink.html
|
# https://docs.aws.amazon.com/singlesignon/latest/userguide/createshortcutlink.html
|
||||||
aws-sharable-url = lib.mkDefault "${pkgs.writeShellScript "aws-sharable-url" ''
|
aws-sharable-url = lib.mkDefault "${pkgs.writeShellScript "aws-sharable-url" ''
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
URL=$1
|
URL=$1
|
||||||
[[ -z "$URL" ]] && read -p "Enter URL: " URL
|
[[ -z "$URL" ]] && read -p "Enter URL: " URL
|
||||||
|
|
||||||
# Strip schema
|
# Strip schema
|
||||||
URL="''${URL#https://}"
|
URL="''${URL#https://}"
|
||||||
|
|
||||||
# Parse Account ID from multi-session URL
|
# Parse Account ID from multi-session URL
|
||||||
ACCOUNT_ID="''${URL%%-*}"
|
ACCOUNT_ID="''${URL%%-*}"
|
||||||
|
|
||||||
# Strip account ID and hash up to the region part
|
# Strip account ID and hash up to the region part
|
||||||
URL="''${URL#*\.}"
|
URL="''${URL#*\.}"
|
||||||
|
|
||||||
PROFILE=$(${pkgs.gnugrep}/bin/grep "sso_account_id = $ACCOUNT_ID" ~/.aws/config -B 5 | ${pkgs.gnugrep}/bin/grep "\[profile" | ${pkgs.coreutils}/bin/tail -n 1 | ${pkgs.coreutils}/bin/tr -d '[]')
|
PROFILE=$(${pkgs.gnugrep}/bin/grep "sso_account_id = $ACCOUNT_ID" ~/.aws/config -B 5 | ${pkgs.gnugrep}/bin/grep "\[profile" | ${pkgs.coreutils}/bin/tail -n 1 | ${pkgs.coreutils}/bin/tr -d '[]')
|
||||||
PROFILE="''${PROFILE#profile }"
|
PROFILE="''${PROFILE#profile }"
|
||||||
|
|
||||||
ROLE_NAME=$(${pkgs.awscli2}/bin/aws configure get profile.$PROFILE.sso_role_name)
|
ROLE_NAME=$(${pkgs.awscli2}/bin/aws configure get profile.$PROFILE.sso_role_name)
|
||||||
SSO_SESSION=$(${pkgs.awscli2}/bin/aws configure get profile.$PROFILE.sso_session)
|
SSO_SESSION=$(${pkgs.awscli2}/bin/aws configure get profile.$PROFILE.sso_session)
|
||||||
|
|
||||||
SSO_URL=$(${pkgs.gnugrep}/bin/grep "\[sso-session $SSO_SESSION" ~/.aws/config -A5 | ${pkgs.gnugrep}/bin/grep sso_start_url | ${pkgs.coreutils}/bin/head -n 1)
|
SSO_URL=$(${pkgs.gnugrep}/bin/grep "\[sso-session $SSO_SESSION" ~/.aws/config -A5 | ${pkgs.gnugrep}/bin/grep sso_start_url | ${pkgs.coreutils}/bin/head -n 1)
|
||||||
SSO_URL="''${SSO_URL#sso_start_url = }"
|
SSO_URL="''${SSO_URL#sso_start_url = }"
|
||||||
# Strip trailing slash from SSO_URL if present
|
# Strip trailing slash from SSO_URL if present
|
||||||
SSO_URL="''${SSO_URL%/}"
|
SSO_URL="''${SSO_URL%/}"
|
||||||
|
|
||||||
SHARABLE_URL="$SSO_URL/#/console?account_id=$ACCOUNT_ID&role_name=$ROLE_NAME&destination=$(${pkgs.urlencode}/bin/urlencode "https://$URL")"
|
SHARABLE_URL="$SSO_URL/#/console?account_id=$ACCOUNT_ID&role_name=$ROLE_NAME&destination=$(${pkgs.urlencode}/bin/urlencode "https://$URL")"
|
||||||
|
|
||||||
${
|
${
|
||||||
if isDarwin then
|
if isDarwin then
|
||||||
''
|
''
|
||||||
echo -n "$SHARABLE_URL" | pbcopy
|
echo -n "$SHARABLE_URL" | pbcopy
|
||||||
''
|
''
|
||||||
else
|
else
|
||||||
''
|
''
|
||||||
echo -n "$SHARABLE_URL" | ${pkgs.xclip}/bin/xclip -selection clipboard
|
echo -n "$SHARABLE_URL" | ${pkgs.xclip}/bin/xclip -selection clipboard
|
||||||
''
|
''
|
||||||
}
|
}
|
||||||
echo "URL copied to clipboard"
|
echo "URL copied to clipboard"
|
||||||
''}";
|
''}";
|
||||||
|
|
||||||
aws-s3-cp-public = lib.mkDefault ''
|
aws-s3-cp-public = lib.mkDefault ''
|
||||||
${pkgs.awscli2}/bin/aws s3 cp --acl "public-read" --expires "$(${pkgs.coreutils}/bin/date '+%a, %d %b %Y 00:00:00 GMT' -d "$(${pkgs.coreutils}/bin/date +%Y-%m-%d) + 365 day")" --cache-control "max-age=31536000" --metadata-directive REPLACE
|
${pkgs.awscli2}/bin/aws s3 cp --acl "public-read" --expires "$(${pkgs.coreutils}/bin/date '+%a, %d %b %Y 00:00:00 GMT' -d "$(${pkgs.coreutils}/bin/date +%Y-%m-%d) + 365 day")" --cache-control "max-age=31536000" --metadata-directive REPLACE
|
||||||
'';
|
'';
|
||||||
|
|
||||||
bcrypt = lib.mkDefault "${pkgs.writeShellScript "bcrypt" ''
|
bcrypt = lib.mkDefault "${pkgs.writeShellScript "bcrypt" ''
|
||||||
if [[ -z "$1" ]]; then
|
if [[ -z "$1" ]]; then
|
||||||
echo "Usage: bcrypt <password> [cost]"
|
echo "Usage: bcrypt <password> [cost]"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -n "$1" | ${pkgs.apacheHttpd}/bin/htpasswd -i -nB -C ''${2:-12} "" | tr -d ':'
|
echo -n "$1" | ${pkgs.apacheHttpd}/bin/htpasswd -i -nB -C ''${2:-12} "" | tr -d ':'
|
||||||
''}";
|
''}";
|
||||||
|
|
||||||
cat = lib.mkDefault "${pkgs.bat}/bin/bat --paging=never";
|
cat = lib.mkDefault "${pkgs.bat}/bin/bat --paging=never";
|
||||||
|
|
||||||
# use curl-aws --aws-sigv4 "aws:amz:region:service"
|
# use curl-aws --aws-sigv4 "aws:amz:region:service"
|
||||||
curl-aws = lib.mkDefault "${pkgs.curl}/bin/curl -H \"X-Amz-Security-Token: $AWS_SESSION_TOKEN\" --user \"$AWS_ACCESS_KEY_ID:$AWS_SECRET_ACCESS_KEY\"";
|
curl-aws = lib.mkDefault "${pkgs.curl}/bin/curl -H \"X-Amz-Security-Token: $AWS_SESSION_TOKEN\" --user \"$AWS_ACCESS_KEY_ID:$AWS_SECRET_ACCESS_KEY\"";
|
||||||
|
|
||||||
curl-timing = lib.mkDefault "${pkgs.curl}/bin/curl -w \" time_namelookup: %{time_namelookup}s\n time_connect: %{time_connect}s\n time_appconnect: %{time_appconnect}s\n time_pretransfer: %{time_pretransfer}s\n time_redirect: %{time_redirect}s\n time_starttransfer: %{time_starttransfer}s\n ----------\n time_total: %{time_total}s\n\" -o /dev/null";
|
curl-timing = lib.mkDefault "${pkgs.curl}/bin/curl -w \" time_namelookup: %{time_namelookup}s\n time_connect: %{time_connect}s\n time_appconnect: %{time_appconnect}s\n time_pretransfer: %{time_pretransfer}s\n time_redirect: %{time_redirect}s\n time_starttransfer: %{time_starttransfer}s\n ----------\n time_total: %{time_total}s\n\" -o /dev/null";
|
||||||
|
|
||||||
dbase64 = lib.mkDefault "${pkgs.writeShellScript "dbase64" "echo -n \"$1\" | base64 -d"}";
|
dbase64 = lib.mkDefault "${pkgs.writeShellScript "dbase64" "echo -n \"$1\" | base64 -d"}";
|
||||||
|
|
||||||
git-sync-remote = lib.mkDefault "git remote update origin --prune";
|
git-sync-remote = lib.mkDefault "git remote update origin --prune";
|
||||||
|
|
||||||
cleanup-kube-config = "${
|
cleanup-kube-config = "${
|
||||||
pkgs.writeShellApplication {
|
pkgs.writeShellApplication {
|
||||||
name = "app";
|
name = "app";
|
||||||
text = ./zsh/aliases/cleanup-kube-config.sh;
|
text = ./zsh/aliases/cleanup-kube-config.sh;
|
||||||
runtimeInputs = [
|
runtimeInputs = [
|
||||||
pkgs.gnugrep
|
pkgs.gnugrep
|
||||||
pkgs.coreutils
|
pkgs.coreutils
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}/bin/app";
|
}/bin/app";
|
||||||
|
|
||||||
klogs = lib.mkDefault "${pkgs.writeShellScript "klogs" ''
|
klogs = lib.mkDefault "${pkgs.writeShellScript "klogs" ''
|
||||||
ctx="$1"
|
ctx="$1"
|
||||||
shift
|
shift
|
||||||
namespace="$1"
|
namespace="$1"
|
||||||
shift
|
shift
|
||||||
label="$1"
|
label="$1"
|
||||||
shift
|
shift
|
||||||
|
|
||||||
if [[ "$ctx" == "" || "$namespace" == "" || "$label" == "" ]]; then
|
if [[ "$ctx" == "" || "$namespace" == "" || "$label" == "" ]]; then
|
||||||
echo "Usage: klogs context namespace label"
|
echo "Usage: klogs context namespace label"
|
||||||
echo "${"\n"}Contexts:"
|
echo "${"\n"}Contexts:"
|
||||||
kubectl config get-contexts -o name | sed 's/^/\t/g'
|
kubectl config get-contexts -o name | sed 's/^/\t/g'
|
||||||
|
|
||||||
echo "Label examples:"
|
echo "Label examples:"
|
||||||
echo "${"\t"}app.kubernetes.io/name=..."
|
echo "${"\t"}app.kubernetes.io/name=..."
|
||||||
echo "${"\t"}eks.amazonaws.com/component=..."
|
echo "${"\t"}eks.amazonaws.com/component=..."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
kubectl --context "$ctx" logs -f -n "$namespace" -l "$label" $@
|
kubectl --context "$ctx" logs -f -n "$namespace" -l "$label" $@
|
||||||
''}";
|
''}";
|
||||||
|
|
||||||
nixfix = lib.mkDefault "nix fmt ./**/*.nix";
|
nixfix = lib.mkDefault "nix fmt ./**/*.nix";
|
||||||
|
|
||||||
# Git
|
# Git
|
||||||
a = "git add";
|
a = "git add";
|
||||||
c = "git commit -m";
|
c = "git commit -m";
|
||||||
d = "git diff";
|
d = "git diff";
|
||||||
d-s = "git diff --staged";
|
d-s = "git diff --staged";
|
||||||
gtag = "${pkgs.writeShellScript "gtag" "git tag -a $1 -m '$2'"}";
|
gtag = "${pkgs.writeShellScript "gtag" "git tag -a $1 -m '$2'"}";
|
||||||
gtag-replace = "${pkgs.writeShellScript "gtag" ''
|
gtag-replace = "${pkgs.writeShellScript "gtag" ''
|
||||||
msg=$(git tag -l -n9 $1 | sed "s/$1\s\+//g")
|
msg=$(git tag -l -n9 $1 | sed "s/$1\s\+//g")
|
||||||
git tag -d $1 && \
|
git tag -d $1 && \
|
||||||
git push origin :refs/tags/$1 && \
|
git push origin :refs/tags/$1 && \
|
||||||
git tag -a $1 -m "$msg" && \
|
git tag -a $1 -m "$msg" && \
|
||||||
git push origin $1
|
git push origin $1
|
||||||
''}";
|
''}";
|
||||||
gtagl = "git fetch --tags && git tag -l -n9 --sort=-v:refname";
|
gtagl = "git fetch --tags && git tag -l -n9 --sort=-v:refname";
|
||||||
s = "git status";
|
s = "git status";
|
||||||
}
|
}
|
||||||
// (
|
// (
|
||||||
if isDarwin then
|
if isDarwin then
|
||||||
{
|
{
|
||||||
hm-switch = lib.mkDefault "sudo darwin-rebuild switch --flake ~/.config/nix";
|
hm-switch = lib.mkDefault "sudo darwin-rebuild switch --flake ~/.config/nix";
|
||||||
}
|
}
|
||||||
else if isLinux then
|
else if isLinux then
|
||||||
{
|
{
|
||||||
hm-switch = lib.mkDefault "home-manager switch --impure --flake ~/.config/nix";
|
hm-switch = lib.mkDefault "home-manager switch --impure --flake ~/.config/nix";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ }
|
{ }
|
||||||
);
|
);
|
||||||
|
|
||||||
initContent = lib.mkBefore ''
|
initContent = lib.mkBefore ''
|
||||||
for file in ${./zsh}/*.zsh; do
|
for file in ${./zsh}/*.zsh; do
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user