diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index c64c8e52..54039885 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -1,4 +1,4 @@ -# Config for the Zoomer Shell +#Config for the Zoomer Shell # Enable colors and change prompt: autoload -U colors && colors # Load colors @@ -9,7 +9,7 @@ stty stop undef # Disable ctrl-s to freeze terminal. # History in cache directory: HISTSIZE=10000 SAVEHIST=10000 -HISTFILE=~/.cache/zsh/history +HISTFILE=${XDG_CONFIG_HOME:-$HOME/.config}/zsh/history # Load aliases and shortcuts if existent. [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shortcutrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shortcutrc" diff --git a/.local/bin/delete_certain_known_hosts b/.local/bin/delete_certain_known_hosts new file mode 100755 index 00000000..a92c2409 --- /dev/null +++ b/.local/bin/delete_certain_known_hosts @@ -0,0 +1,17 @@ +#!/bin/bash +# Deletes certain lines of ~/.ssh/known_hosts +known_hosts_path=~/.ssh/known_hosts +lines_in_known_hosts=$(wc -l "$known_hosts_path" | awk '{print $1}') +IFS=' ' +deduped_args=$(echo "$@" | xargs -n1 | sort -nu | xargs) +read -r -a delete_these_lines <<< "$deduped_args" +lines_to_delete="" +for var in "${delete_these_lines[@]}"; do +if [[ "$var" -gt "$lines_in_known_hosts" ]]; then + echo "$var isnt valid line in $lines_in_known_hosts line $known_hosts_path" +else + lines_to_delete+="${var}d;" +fi +done +sed -i "$lines_to_delete" "$known_hosts_path" +echo "Deleted lines $(echo $(echo $lines_to_delete | sed 's/d;/, /g') | sed 's/.$//' )"