mirror of
https://github.com/DictXiong/dotfiles.git
synced 2024-11-24 17:17:01 +08:00
install.sh: -H|--hist|--history
This commit is contained in:
parent
063b15f4d5
commit
a1c5d6deee
13
install.sh
13
install.sh
|
@ -109,6 +109,11 @@ prepare_config()
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
append_hist()
|
||||||
|
{
|
||||||
|
"$DOTFILES/tools/append_zsh_hist.sh" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
install_file_content()
|
install_file_content()
|
||||||
{
|
{
|
||||||
fmt_note "installing file content ..."
|
fmt_note "installing file content ..."
|
||||||
|
@ -275,6 +280,7 @@ install()
|
||||||
# those that won't be uninstalled in the future
|
# those that won't be uninstalled in the future
|
||||||
install_tmux_tpm
|
install_tmux_tpm
|
||||||
install_vim_vundle
|
install_vim_vundle
|
||||||
|
if [[ -n "$DFS_HIST" ]]; then append_hist "$DFS_HIST"; fi
|
||||||
fmt_note "done installing!"
|
fmt_note "done installing!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,18 +302,25 @@ echo "this is the dotfiles installer, version $(cd "$DOTFILES" && git describe -
|
||||||
FUNC=install
|
FUNC=install
|
||||||
INSTALL_DEP=0
|
INSTALL_DEP=0
|
||||||
store_config=0
|
store_config=0
|
||||||
|
store_hist=0
|
||||||
for i in ${GOT_OPTS[@]}; do
|
for i in ${GOT_OPTS[@]}; do
|
||||||
if [[ "$store_config" == "1" ]]; then
|
if [[ "$store_config" == "1" ]]; then
|
||||||
store_config=0
|
store_config=0
|
||||||
DFS_CONFIGS+=("$i")
|
DFS_CONFIGS+=("$i")
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
if [[ "$store_hist" == "1" ]]; then
|
||||||
|
store_hist=0
|
||||||
|
DFS_HIST=$i
|
||||||
|
continue
|
||||||
|
fi
|
||||||
case $i in
|
case $i in
|
||||||
-i ) FUNC=install ;;
|
-i ) FUNC=install ;;
|
||||||
-r ) FUNC=uninstall ;;
|
-r ) FUNC=uninstall ;;
|
||||||
-d|--dev ) export DFS_DEV=1; set -x ;;
|
-d|--dev ) export DFS_DEV=1; set -x ;;
|
||||||
-a|--auto ) INSTALL_DEP=1 ;;
|
-a|--auto ) INSTALL_DEP=1 ;;
|
||||||
-s|--secure ) export DFS_DEV=0 ;;
|
-s|--secure ) export DFS_DEV=0 ;;
|
||||||
|
-H|--hist|--history ) store_hist=1 ;;
|
||||||
-x ) store_config=1 ;;
|
-x ) store_config=1 ;;
|
||||||
* ) fmt_fatal "unknown option \"$i\"" ;;
|
* ) fmt_fatal "unknown option \"$i\"" ;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -41,4 +41,4 @@ route()
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
route "$@"
|
route "${GOT_OPTS[@]}"
|
26
tools/append_zsh_hist.sh
Executable file
26
tools/append_zsh_hist.sh
Executable 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[@]}"
|
|
@ -48,7 +48,8 @@ test `git rev-parse HEAD` = `curl -fsSL https://api.beardic.cn/get-var/dfs-commi
|
||||||
git reset --hard $DFS_VERSION
|
git reset --hard $DFS_VERSION
|
||||||
|
|
||||||
# then check install.sh
|
# 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
|
grep -q "DFS_CI=1" ~/.config/dotfiles/env
|
||||||
./install.sh -l -x DFS_CI=1
|
./install.sh -l -x DFS_CI=1
|
||||||
dfs version
|
dfs version
|
||||||
|
|
Loading…
Reference in New Issue
Block a user