Wxf`s Fantasy World

share something useful


Windows软件管理

window主要靠两个软件:msys2(类linux环境)、scoop

流程

所有数据都放到u盘了,所以只要恢复软件及其配置
拿到一个新电脑,先安装msys2,然后恢复其配置文件,再安装scoop,完成

msys配置

msys的核心是这些配置文件,把它们上传到github,定期更新,迁移到新电脑时git clone一下就行
然后需要修改注册表,我写了三个脚本,执行一遍,msys配置就完成了!!!
main-init.sh

#!/bin/bash

# change environment variables
. chg-env-var.sh

# change reg
. chg-reg.sh

# install cmd tool 
. command-install.sh

chg-env-var.sh

#!/bin/bash

# Set the system environment variable list
SYS_ENV_VARS=(
	""
)

# Create the system batch file
cat > update_sys_env.bat << EOF
@echo off
REM Update system environment variables
EOF

for env_var in "${SYS_ENV_VARS[@]}"
do
  var_name="${env_var%=*}"
  var_value="${env_var#*=}"
  echo "setx $var_name \"$var_value\" /M" >> update_sys_env.bat
done

# Call the system batch file
cmd /c update_sys_env.bat
# Remove the tmp files
rm update_sys_env.bat




# Set the user environment variable list
USER_ENV_VARS=(
  "MSYS2_PATH_TYPE=inherit"
  "EMACS_SERVER_FILE=C:\msys64\home\dell\.emacs.d\server\server"
)


# Create the batch file
cat > update_user_env.bat << EOF
@echo off

REM Get the user profile path for the main computer user
for /f "tokens=2 delims==" %%a in ('wmic useraccount where name="%username%" get sid /value') do set sid=%%a
set "sid=%sid:~0,-18%"
set "userprofile=C:\Users\%username%"

REM Update environment variables
EOF

for env_var in "${USER_ENV_VARS[@]}"
do
  var_name="${env_var%=*}"
  var_value="${env_var#*=}"
  echo "setx $var_name \"$var_value\"" >> update_user_env.bat
done

# Call the batch file with cmd.exe
cmd.exe /c update_user_env.bat

# Remove the tmp files
rm update_user_env.bat

chg-reg.sh

#!/bin/bash

# 使用 cmd 执行 reg add 命令
cmd /c "reg add HKEY_CLASSES_ROOT\org-protocol\shell\open /v \"command\" /t REG_SZ /d \"\\\"C:\\msys64\\mingw64\\bin\\emacsclientw.exe\\\" \\\"%1\\\"\" /f"

command-install.sh

#!/bin/bash

# 定义软件包名称列表
packages=(
          "vim"
	  "mingw-w64-x86_64-ffmpeg"
	  "dialog"
	  "mingw-w64-x86_64-spdlog"
	  "mingw-w64-x86_64-emacs"
	  "git"
  )

# 循环遍历软件包列表中的每个软件包名称
for package in "${packages[@]}"; do
    # 检查软件包是否已经安装
    if pacman -Qq $package > /dev/null 2>&1; then
        echo "$package is already installed, skipping..."
    else
        # 安装软件包
        echo "Installing $package..."
        pacman -S --noconfirm $package

        # 检查软件包是否成功安装
        if [ $? -ne 0 ]; then
            echo "Error: Failed to install $package"
            exit 1
        fi
    fi
done

scoop

ref scoop blog

卸载:默认在“C:\Users\whens\scoop\",删除该目录即可

- env:powershell

> admin
$env:SCOOP='D:\softwares\scoop'
[environment]::setEnvironmentVariable('USERSCOOP',$env:SCOOP,'User')
$env:SCOOP_GLOBAL='D:\softwares\scoop\globalApps'
[environment]::setEnvironmentVariable('SCOOP_GLOBAL',$env:SCOOP_GLOBAL,'Machine')

> user
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
iwr -useb get.scoop.sh | iex

scoop uninstall scoop

-------------------------------------

> proxy
scoop install git
scoop config proxy socks5://127.0.0.1:1081
scoop config rm proxy

> add buckets
scoop bucket add extras
#scoop bucket add apps https://github.com/kkzzhizhou/scoop-apps
scoop bucket add dorado https://github.com/h404bi/dorado

>install tools
scoop install yt-dlp ffmpeg
miniconda

scoop install 7zip curl sudo git openssh coreutils grep sed gawk less innounp 
scoop install python ruby go nodejs


> manage 
scoop list xxx
scoop update xxx

scoop search xxx
scoop info xxx
scoop install spc/<app_name>

scoop bucket list
scoop bucket known
scoop update
scoop bucket add

scoop reset xx

[[https://www.junmajinlong.com/others/scoop/]]       

常用软件

flomo、logseq、chrome、clash