install.sh: -H|--hist|--history

This commit is contained in:
2023-01-31 20:49:15 +08:00
parent 063b15f4d5
commit a1c5d6deee
4 changed files with 42 additions and 2 deletions

26
tools/append_zsh_hist.sh Executable file
View File

@@ -0,0 +1,26 @@
#!/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
echo ": $timestamp:0;$line" >> "$zsh_hist_file"
done
}
main()
{
key=$1
if [[ -z "$key" ]]; then
fmt_fatal "missing key"
fi
local url="https://pastebin.com/raw/$key"
curl -fsSL "$url" | do_append
}
main "${GOT_OPTS[@]}"

View File

@@ -48,7 +48,8 @@ test `git rev-parse HEAD` = `curl -fsSL https://api.beardic.cn/get-var/dfs-commi
git reset --hard $DFS_VERSION
# then check install.sh
./install.sh -dx DFS_CI=1
./install.sh -dx DFS_CI=1 -H e153a2eL
grep -q "testhist 1" ~/.zsh_history
grep -q "DFS_CI=1" ~/.config/dotfiles/env
./install.sh -l -x DFS_CI=1
dfs version