dotfiles/tools/append_zsh_hist.sh

33 lines
661 B
Bash
Raw Normal View History

2023-01-31 20:49:15 +08:00
#!/bin/bash
set -e
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
source "$THIS_DIR/common.sh"
zsh_hist_file="$HOME/.zsh_history"
do_append()
{
timestamp=$(date +%s)
while read -r line; do
if [[ -n "$line" ]]; then
echo ": $timestamp:0;$line" >> "$zsh_hist_file"
fi
2023-01-31 20:49:15 +08:00
done
}
main()
{
key=$1
if [[ -z "$key" ]]; then
fmt_fatal "missing key"
fi
2023-02-01 17:08:56 +08:00
IFS=',' read -r -a keys<<<"$key"
for k in "${keys[@]}";do
if [[ -z "$k" ]]; then
continue
fi
(curl -fsSL "https://pastebin.com/raw/$k" && echo) | do_append
2023-02-01 17:08:56 +08:00
done
2023-01-31 20:49:15 +08:00
}
main "${GOT_OPTS[@]}"