diff --git a/config/clink/starship.lua b/config/clink/starship.lua index 34df967..c263c39 100644 --- a/config/clink/starship.lua +++ b/config/clink/starship.lua @@ -1,3 +1,6 @@ --- Load starship +-- Set config location to be in %APPDATA% rather than the default %USERPROFILE%\.config +local appdata = os.getenv("APPDATA") +os.setenv("STARSHIP_CONFIG", appdata .. "\\starship.toml") +-- Load starship load(io.popen('starship init cmd'):read("*a"))() diff --git a/config/starship.toml b/config/starship.toml index d0d39f9..85c2f95 100644 --- a/config/starship.toml +++ b/config/starship.toml @@ -1,6 +1,6 @@ -add_newline = false +add_newline = false scan_timeout = 10 -format = "\\[$username$hostname\\] :: $directory $cmd_duration$character" +format = "\\[$username$hostname\\] :: $directory $cmd_duration$character" [line_break] disabled = true diff --git a/dots.bat b/dots.bat index 708f525..c4ca6e8 100644 --- a/dots.bat +++ b/dots.bat @@ -1,5 +1,5 @@ @ECHO OFF -SETLOCAL ENABLEDELAYEDEXPANSION +SETLOCAL DISABLEDELAYEDEXPANSION IF "%1" == "install" ( CALL :Install @@ -7,30 +7,52 @@ IF "%1" == "install" ( IF "%1" == "pull" ( CALL :Pull ) ELSE ( - echo usage: %0 ^ + ECHO usage: %0 ^ ) ) GOTO :EOF :Install - echo [Info] :: Installing dotfiles + ECHO [Info] :: Installing dotfiles - xcopy /E /I /Y /Q "config\nvim" "%LOCALAPPDATA%\nvim" > NUL - copy /Y "config\starship.toml" "%APPDATA%\" > NUL - copy /Y "config\clink\inputrc" "%LOCALAPPDATA%\.inputrc" > NUL + XCOPY /E /I /Y /Q "config\nvim" "%LOCALAPPDATA%\nvim" > NUL + COPY /Y "config\starship.toml" "%APPDATA%\" > NUL + COPY /Y "config\clink\inputrc" "%LOCALAPPDATA%\.inputrc" > NUL + + CALL :Patch %APPDATA%\starship.toml WHERE /q "starship" IF %ERRORLEVEL% equ 0 ( IF NOT EXIST "%LOCALAPPDATA%\clink" ( MKDIR "%LOCALAPPDATA%\clink" ) - copy "config\clink\starship.lua" "%LOCALAPPDATA%\clink\" > NUL + COPY "config\clink\starship.lua" "%LOCALAPPDATA%\clink\" > NUL ) GOTO :EOF :Pull - echo [Info] :: Pulling dotfile changes + ECHO [Info] :: Pulling dotfile changes - xcopy /E /I /Y "%LOCALAPPDATA%\nvim" "config\nvim" - copy /Y "%APPDATA%\starship.toml" "config\" - copy /Y "%LOCALAPPDATA%\.inputrc" "config\clink\inputrc" + XCOPY /E /I /Y "%LOCALAPPDATA%\nvim" "config\nvim" + COPY /Y "%LOCALAPPDATA%\.inputrc" "config\clink\inputrc" +GOTO :EOF + +:Patch + SET "PREFIX=#%COMPUTERNAME% " + SET "REPLACEMENT=" + + SET "TEMPFILE=%TEMP%\tmpdots%RANDOM%" + + FOR /f "DELIMS=" %%A in ('FINDSTR /N "^" "%1"') DO ( + SET "LINE=%%A" + + SETLOCAL ENABLEDELAYEDEXPANSION + SET "LINE=!LINE:%PREFIX%=%REPLACEMENT%!" + SET "LINE=!LINE:*:=!" + + ECHO:!LINE!>> %TEMPFILE% + + ENDLOCAL + ) + + MOVE /Y %TEMPFILE% %1 > NUL GOTO :EOF