diff --git a/home-manager/becky-dingleberry.nix b/home-manager/becky-dingleberry.nix index c359c6b..2e20ee2 100644 --- a/home-manager/becky-dingleberry.nix +++ b/home-manager/becky-dingleberry.nix @@ -225,13 +225,12 @@ in enable = true; shellAliases = { - hm-switch = "home-manager switch --impure --flake ~/.config/nix"; configure-ssh-terminfo = "f(){ infocmp -x | ssh \"$@\" -- tic -x -; unset -f f; }; f"; - aws-ecr-login-skoda="aws --profile skoda-prod --region eu-central-1 ecr get-login-password | sudo docker login 943160431142.dkr.ecr.eu-central-1.amazonaws.com -u AWS --password-stdin"; + aws-ecr-login-skoda = "aws --profile skoda-prod --region eu-central-1 ecr get-login-password | sudo docker login 943160431142.dkr.ecr.eu-central-1.amazonaws.com -u AWS --password-stdin"; aws-ecr-login-scholaris = "aws --profile skoda-sch-dev --region eu-central-1 ecr get-login-password | sudo docker login 442913623981.dkr.ecr.eu-central-1.amazonaws.com -u AWS --password-stdin"; - aws-ecr-login-yp="aws-vault exec yp aws --region eu-central-1 ecr get-login-password | sudo docker login 060714730522.dkr.ecr.eu-central-1.amazonaws.com -u AWS --password-stdin"; - aws-ecr-login-investbay="aws-vault exec InvestBay-AccountManagement aws --region eu-central-1 ecr get-login-password | sudo docker login 297503416491.dkr.ecr.eu-central-1.amazonaws.com -u AWS --password-stdin"; + aws-ecr-login-yp = "aws-vault exec yp aws --region eu-central-1 ecr get-login-password | sudo docker login 060714730522.dkr.ecr.eu-central-1.amazonaws.com -u AWS --password-stdin"; + aws-ecr-login-investbay = "aws-vault exec InvestBay-AccountManagement aws --region eu-central-1 ecr get-login-password | sudo docker login 297503416491.dkr.ecr.eu-central-1.amazonaws.com -u AWS --password-stdin"; }; dirHashes = { diff --git a/home-manager/common.nix b/home-manager/common.nix index 17cea61..49d6fd7 100644 --- a/home-manager/common.nix +++ b/home-manager/common.nix @@ -113,18 +113,58 @@ in # 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-s3-cp-public = '' + 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 ''; cat = lib.mkDefault "${pkgs.bat}/bin/bat --paging=never"; - nixfix = lib.mkDefault "nix fmt ./**/*.nix"; - # 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-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"}"; + git-sync-remote = lib.mkDefault "git remote update origin --prune"; + + klogs = lib.mkDefault "${pkgs.writeShellScript "klogs" '' + local ctx="$1" + local namespace="$2" + local label="$3" + + if [[ "$ctx" == "" || "$namespace" == "" || "$label" == "" ]]; then + echo "Usage: klogs context namespace label" + echo "\nContexts:" + kubectl config get-contexts -o name | sed 's/^/\t/g' + + echo "Label examples:" + echo "\tapp.kubernetes.io/name=..." + echo "\teks.amazonaws.com/component=..." + return 1 + fi + + kubectl --context "$ctx" logs -f -n "$namespace" -l "$label" + ''} + "; + + nixfix = lib.mkDefault "nix fmt ./**/*.nix"; + + # Git + a = "git add"; + c = "git commit -m"; + d = "git diff"; + d-s = "git diff --staged"; + gtag = "${pkgs.writeShellScript "gtag" "git tag -a $1 -m '$2'"}"; + gtag-replace = "${pkgs.writeShellScript "gtag" '' + msg=$(git tag -l -n9 $1 | sed "s/$1\s\+//g") + git tag -d $1 && \ + git push origin :refs/tags/$1 && \ + git tag -a $1 -m "$msg" && \ + git push origin $1 + ''}"; + gtagl = "git fetch --tags && git tag -l -n9 --sort=-v:refname"; + s = "git status"; } // ( if isDarwin then @@ -133,7 +173,7 @@ in } else if isLinux then { - hm-switch = lib.mkDefault "home-manager switch --flake ~/.config/nix"; + hm-switch = lib.mkDefault "home-manager switch --impure --flake ~/.config/nix"; } else { } diff --git a/home-manager/zsh/common/05-home-manager.zsh b/home-manager/zsh/common/05-home-manager.zsh deleted file mode 100644 index 00f0bdd..0000000 --- a/home-manager/zsh/common/05-home-manager.zsh +++ /dev/null @@ -1 +0,0 @@ -alias hm-switch="home-manager switch --flake ~/.config/nix" diff --git a/home-manager/zsh/common/09-zsh_aliases.zsh b/home-manager/zsh/common/09-zsh_aliases.zsh index f58cdf1..d614a60 100755 --- a/home-manager/zsh/common/09-zsh_aliases.zsh +++ b/home-manager/zsh/common/09-zsh_aliases.zsh @@ -1,11 +1,4 @@ -# Allow usage of aliases when using sudo alias less='less -R' -alias curlTiming="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_starttransfe -r: %{time_starttransfer}s\n ----------\n time_total: %{time_total}s\n\" -o /dev/null" - -dbase64() { - echo -n "${1}" | base64 -d -} function appConnections() { diff --git a/home-manager/zsh/common/10-docker_aliases.zsh b/home-manager/zsh/common/10-docker_aliases.zsh deleted file mode 100755 index 3ecd784..0000000 --- a/home-manager/zsh/common/10-docker_aliases.zsh +++ /dev/null @@ -1,9 +0,0 @@ -alias dockerVolumeSizes="for vol in \$(docker volume ls -q); do sudo du -hs \$(docker volume inspect --format \"{{.Mountpoint}}\" \$vol); done" - -alias dockerstats="docker stats \$(docker ps --format \"{{.Names}}\")" - -alias dockerRemove="docker rmi -f \$(docker images | grep none | awk '{print \$3}')" - -function bcrypt() { - nix-shell -p apacheHttpd --run "echo -n '${1}' | htpasswd -i -nB -C ${2:-12} '' | tr -d ':'" -} diff --git a/home-manager/zsh/common/10-git_aliases.zsh b/home-manager/zsh/common/10-git_aliases.zsh deleted file mode 100755 index 34a3b1a..0000000 --- a/home-manager/zsh/common/10-git_aliases.zsh +++ /dev/null @@ -1,71 +0,0 @@ -# Git - -alias c="git commit -m" -alias s="git status" -alias gtagl="git fetch --tags && git tag -l -n9 --sort=-v:refname" -alias d="git diff" -alias d-s="git diff --staged" -alias a="git add" -alias n="git checkout -b" -alias m="git merge --no-ff" -alias gitSquash="git rebase --root -i" - -gtag() { - git tag -a $1 -m "$2" -} - -gtagReplace() { - local msg - msg=$(git tag -l -n9 $1 | sed "s/$1\s\+//g") - git tag -d $1 && \ - git push origin :refs/tags/$1 && \ - git tag -a $1 -m "${msg}" && \ - git push origin $1 -} - -gtagRemoveMinor() { - if [[ $1 = "" ]]; then - echo "How does the tag begin?" - fi - - local remove - - local tags=$(git tag -l | grep "^${1}\.") - - echo "${tags}" - - echo -n "Remove these tags? (y/n) " - - read remove - - if [[ ${remove} != "y" ]] && [[ ${remove} != "yes" ]]; then - echo "Ok then!" - return 2 - fi - - while read -r tag; do - git tag -d ${tag} - git push origin :refs/tags/${tag} - done <<< "${tags}" -} - -gdiff() { - local awkFormat='{ $2=on $2 off }; 1' - local masterDiff=$(git cherry -v develop master | awk -v on="\033[31;33m" -v off="\033[0m" ${awkFormat}) - local develDiff=$(git cherry -v master develop | awk -v on="\033[31;33m" -v off="\033[0m" ${awkFormat}) - - if [[ "${masterDiff}" != "" ]]; then - echo "\033[1;31;32mOnly in master:\033[0m" - echo - echo "${masterDiff}" - fi - - if [[ "${develDiff}" != "" ]]; then - echo "\033[1;31;33mOnly in develop:\033[0m" - echo - echo "${develDiff}" - fi - -} - -alias gitRemoveMerged="git branch --merged origin/master | grep -v '* master' | xargs git branch -d" diff --git a/home-manager/zsh/common/10-kubernetes_aliases.zsh b/home-manager/zsh/common/10-kubernetes_aliases.zsh deleted file mode 100755 index 6627968..0000000 --- a/home-manager/zsh/common/10-kubernetes_aliases.zsh +++ /dev/null @@ -1,18 +0,0 @@ -function klogs() { - local ctx="$1" - local namespace="$2" - local label="$3" - - if [[ "$ctx" == "" || "$namespace" == "" || "$label" == "" ]]; then - echo "Usage: klogs context namespace label" - echo "\nContexts:" - kubectl config get-contexts -o name | sed 's/^/\t/g' - - echo "Label examples:" - echo "\tapp.kubernetes.io/name=..." - echo "\teks.amazonaws.com/component=..." - return 1 - fi - - kubectl --context "$context" logs -f -n "$namespace" -l "$label" -}