Added a new script

This commit is contained in:
Vlad Doster 2020-04-10 15:23:48 -05:00
parent 08d556cd4b
commit c6eb8546ba
2 changed files with 19 additions and 2 deletions

View File

@ -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"

View File

@ -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/.$//' )"