From fc87f5e7fce8a33cdd829524bbabf9ed9234fd1a Mon Sep 17 00:00:00 2001 From: Hadeed Ahmad Date: Sun, 14 Apr 2024 08:02:45 +0500 Subject: [PATCH] Modify save-ssh-key function --- zsh/zsh-functions | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/zsh/zsh-functions b/zsh/zsh-functions index 7cb50a3..eb6164c 100644 --- a/zsh/zsh-functions +++ b/zsh/zsh-functions @@ -2,8 +2,14 @@ function cc() python -c "from math import *; print($*)" function mkcd() mkdir -p -- $1 && cd -- $1 function save-ssh-key() { + mkdir -p "$HOME/.ssh" + chmod 700 "$HOME/.ssh" + mv "$1" "$HOME/.ssh/${1}_${2}" - mv "$1.pub" "$HOME/.ssh/${1}_${2}.pub" + + if [ -e "$1.pub" ]; then + mv -n "$1.pub" "$HOME/.ssh/${1}_${2}.pub" + fi } function eik() {