From 891b4a1a6ec8251f45348a7712b51700a9207c24 Mon Sep 17 00:00:00 2001 From: Luk Date: Mon, 24 Jun 2024 09:48:20 +0800 Subject: [PATCH] u --- acme-setup-all.sh => acme-setup.sh | 0 mac-homebrew-setup.sh | 24 +++++++++++++ nixhome/.gitignore.global.txt | 5 +-- ssh-run.sh | 55 ++++++++++++++++++++++++++++++ svn-run.sh => svn-serve.sh | 0 5 files changed, 80 insertions(+), 4 deletions(-) rename acme-setup-all.sh => acme-setup.sh (100%) create mode 100644 mac-homebrew-setup.sh create mode 100644 ssh-run.sh rename svn-run.sh => svn-serve.sh (100%) mode change 100755 => 100644 diff --git a/acme-setup-all.sh b/acme-setup.sh similarity index 100% rename from acme-setup-all.sh rename to acme-setup.sh diff --git a/mac-homebrew-setup.sh b/mac-homebrew-setup.sh new file mode 100644 index 0000000..bdfbb84 --- /dev/null +++ b/mac-homebrew-setup.sh @@ -0,0 +1,24 @@ +echo "=== Install formulaes and casks, enter [y] for Yes, [anything else] for No:" +echo + +formulaeList=(jq openssl pandoc speedtest-cli sqlite yt-dlp) +for APP in "${formulaeList[@]}" +do + echo "--- brew install $APP" + read -p ">>> " YN + if [ "$YN" = 'y' ] + then + echo brew install $APP + fi +done + +caskList=(appcleaner avidemux baidunetdisk cloudflare-warp cursor douyin drawio emacs futubull iina lx-music miniconda obs poe qq seafile-client shotcut spacelauncher sqlitestudio telegram-desktop telegram-lite termius thunder warp wechat) +for APP in "${formulaeList[@]}" +do + echo "--- brew install $APP" + read -p ">>> " YN + if [ "$YN" = 'y' ] + then + echo brew install $APP + fi +done \ No newline at end of file diff --git a/nixhome/.gitignore.global.txt b/nixhome/.gitignore.global.txt index 2c29353..b921cd4 100644 --- a/nixhome/.gitignore.global.txt +++ b/nixhome/.gitignore.global.txt @@ -65,6 +65,7 @@ _desktop.ini # hexo /public/ +/db.json # Hardhat /artifacts/ @@ -72,7 +73,6 @@ _desktop.ini # seafile 临时文件 ._* - .$* # office 暂存文件 @@ -91,9 +91,6 @@ _desktop.ini .env.local .env.*.local -# hexo -/db.json - # wo # 服务端 /_archive/* diff --git a/ssh-run.sh b/ssh-run.sh new file mode 100644 index 0000000..8d9e9c6 --- /dev/null +++ b/ssh-run.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +# Ensure jq is installed +if ! command -v jq &> /dev/null; then + echo "jq is required but not installed. Please install jq and run the script again." + exit 1 +fi + +# Path to the settings.json file +SETTINGS_FILE="$HOME/Library/Application Support/Code/User/settings.json" +if [[ ! -f "$SETTINGS_FILE" ]]; then + echo "settings.json file not found!" + exit 1 +fi + +# 自定义的列表,但是测试有问题,只有第一行被select添加了序号 +# targets=$(jq -r '.["sshfs.configs"][] | "\(.name)"' "$SETTINGS_FILE") +# if [ -z "$targets" ] +# then +# echo "No configurations found in the settings.json file." +# exit 1 +# fi + +# Parse the JSON to get labels and corresponding details +labels=($(jq -r '.["sshfs.configs"][] | .label' "$SETTINGS_FILE")) +hosts=($(jq -r '.["sshfs.configs"][] | .host' "$SETTINGS_FILE")) +names=($(jq -r '.["sshfs.configs"][] | .name' "$SETTINGS_FILE")) +usernames=($(jq -r '.["sshfs.configs"][] | .username' "$SETTINGS_FILE")) +privateKeyPaths=($(jq -r '.["sshfs.configs"][] | .privateKeyPath' "$SETTINGS_FILE")) + +if [ "$1" -ge 0 ] 2>/dev/null && [ "$1" -le ${#hosts[@]} ] 2>/dev/null +then + selected_index=$1 +else + echo "Select a target to connect via SSH:" + select target in "${labels[@]}" + do + if [[ -n "$target" ]]; then + selected_index=$REPLY-1 + break + else + echo "Invalid selection. Try again." + fi + done +fi + +label="${labels[$selected_index]}" +name="${names[$selected_index]}" +host="${hosts[$selected_index]}" +username="${usernames[$selected_index]}" +privateKeyPath="${privateKeyPaths[$selected_index]}" + +echo "=== Coonecting to ${label}" +echo ">>> ssh $username@$host" +ssh "$username@$host" \ No newline at end of file diff --git a/svn-run.sh b/svn-serve.sh old mode 100755 new mode 100644 similarity index 100% rename from svn-run.sh rename to svn-serve.sh