Add -F, --firstrun

This commit is contained in:
clsty
2025-11-14 09:09:58 +08:00
parent 323b0bc257
commit 45a78c383b
2 changed files with 18 additions and 8 deletions
+14 -6
View File
@@ -8,7 +8,7 @@ function copy_file_s_t(){
local t=$2
if [ -f $t ];then
echo -e "${STY_YELLOW}[$0]: \"$t\" already exists.${STY_RST}"
if $firstrun;then
if ${INSTALL_FIRSTRUN};then
echo -e "${STY_BLUE}[$0]: It seems to be the firstrun.${STY_RST}"
v mv $t $t.old
v cp -f $s $t
@@ -35,11 +35,19 @@ function copy_dir_s_t(){
#####################################################################################
# In case some dirs does not exists
v mkdir -p $XDG_BIN_HOME $XDG_CACHE_HOME $XDG_CONFIG_HOME $XDG_DATA_HOME/icons
if test -f "${FIRSTRUN_FILE}"; then
firstrun=false
else
firstrun=true
fi
case ${INSTALL_FIRSTRUN} in
# When specify --firstrun
true) sleep 0 ;;
# When not specify --firstrun
*)
if test -f "${FIRSTRUN_FILE}"; then
${INSTALL_FIRSTRUN}=false
else
${INSTALL_FIRSTRUN}=true
fi
;;
esac
# `--delete' for rsync to make sure that
# original dotfiles and new ones in the SAME DIRECTORY
+4 -2
View File
@@ -8,6 +8,7 @@ Idempotent installation for dotfiles.
Options for install:
-h, --help Print this help message and exit
-f, --force (Dangerous) Force mode without any confirm
-F, --fisrtrun Act like it is the first run
-c, --clean Clean the build cache first
--skip-allgreeting Skip the whole process greeting
--skip-alldeps Skip the whole process installing dependency
@@ -43,8 +44,8 @@ cleancache(){
# `man getopt` to see more
para=$(getopt \
-o hfk:cs \
-l help,force,fontset:,clean,skip-allgreeting,skip-alldeps,skip-allsetups,skip-allfiles,skip-sysupdate,skip-plasmaintg,skip-backup,skip-quickshell,skip-fish,skip-hyprland,skip-fontconfig,skip-miscconf,core,exp-files,via-nix \
-o hfFk:cs \
-l help,force,firstrun,fontset:,clean,skip-allgreeting,skip-alldeps,skip-allsetups,skip-allfiles,skip-sysupdate,skip-plasmaintg,skip-backup,skip-quickshell,skip-fish,skip-hyprland,skip-fontconfig,skip-miscconf,core,exp-files,via-nix \
-n "$0" -- "$@")
[ $? != 0 ] && echo "$0: Error when getopt, please recheck parameters." && exit 1
#####################################################################################
@@ -69,6 +70,7 @@ while true ; do
-c|--clean) shift;;
## Ones without parameter
-f|--force) ask=false;shift;;
-F|--firstrun) INSTALL_FIRSTRUN=true;shift;;
--skip-allgreeting) SKIP_ALLGREETING=true;shift;;
--skip-alldeps) SKIP_ALLDEPS=true;shift;;
--skip-allsetups) SKIP_ALLSETUPS=true;shift;;