From f01868e2465addb3d207906f39883b88808bb63c Mon Sep 17 00:00:00 2001 From: luk Date: Sun, 1 Feb 2026 19:12:37 +0800 Subject: [PATCH] u --- git-ignore-find2merge.bat | 16 +++--- git-ignore-find2merge.sh | 24 ++++----- nixhome/.bashrc | 19 ++++--- nixhome/seafile-ignore.global.txt | 8 +++ seafile-ignore-find2merge.sh | 28 +++++------ seafile-ignore.txt | 84 +++++++++++++++++++++++++++++++ ssh.sh | 4 +- 7 files changed, 137 insertions(+), 46 deletions(-) create mode 100644 seafile-ignore.txt diff --git a/git-ignore-find2merge.bat b/git-ignore-find2merge.bat index 4caff6e..83a6360 100644 --- a/git-ignore-find2merge.bat +++ b/git-ignore-find2merge.bat @@ -24,17 +24,17 @@ if not exist "%ROOTPATH%" ( ) echo ::*** Enter [path to .gitignore_global] or [leave blank] for default [[https://git.tic.cc/npm/sysconfig/raw/branch/main/nixhome/.gitignore_global]] -set /p IGNOREPATH=">>> " +set /p GLOBALPATH=">>> " echo; -if "" == "%IGNOREPATH%" ( - set IGNOREPATH=https://git.tic.cc/npm/sysconfig/raw/branch/main/nixhome/.gitignore_global +if "" == "%GLOBALPATH%" ( + set GLOBALPATH=https://git.tic.cc/npm/sysconfig/raw/branch/main/nixhome/.gitignore_global ) else ( - for %P in (%IGNOREPATH%) do set "IGNOREPATH=%~dpnxP/.gitignore_global" - if not exist "%IGNOREPATH%" ( - echo ××× [[%IGNOREPATH%]] not exist! Exit now. *** + for %P in (%GLOBALPATH%) do set "GLOBALPATH=%~dpnxP/.gitignore_global" + if not exist "%GLOBALPATH%" ( + echo ××× [[%GLOBALPATH%]] not exist! Exit now. *** @ GOTO END ) else ( - echo √√√ IGNOREPATH = [[%IGNOREPATH%]] + echo √√√ GLOBALPATH = [[%GLOBALPATH%]] ) ) @@ -48,7 +48,7 @@ for /d /r %%r in (*) do ( if exist "%%r\.git" ( pushd "%%r" echo ---- updating .gitignore in [[%%r]] ---- - cat %IGNOREPATH%\.gitignore %%r\.gitignore.local.txt > %%r\.gitignore + cat %GLOBALPATH%\.gitignore %%r\.gitignore.local.txt > %%r\.gitignore echo; popd ) diff --git a/git-ignore-find2merge.sh b/git-ignore-find2merge.sh index 1dac158..40a2ca9 100755 --- a/git-ignore-find2merge.sh +++ b/git-ignore-find2merge.sh @@ -1,7 +1,7 @@ #!/bin/bash echo "" -echo "Search in [ROOTPATH], merge [IGNOREPATH/.gitignore_global] and [ROOTPATH/*/.gitignore.local.txt] files to [seafile-ignore.txt]" +echo "Search in [ROOTPATH], merge [GLOBALPATH/.gitignore_global] and [ROOTPATH/*/.gitignore.local.txt] files to .gitignore" echo "" if [ -d "$1" ] @@ -27,22 +27,22 @@ fi echo "" echo "::*** Enter [path to .gitignore_global] or [leave blank] for default [[https://git.tic.cc/npm/sysconfig/raw/branch/main/nixhome/.gitignore_global]]" -read -p "***:: " IGNOREPATH -if [ "$IGNOREPATH" ] +read -p "***:: " GLOBALPATH +if [ "$GLOBALPATH" ] then - if [ -d "$IGNOREPATH" ] + if [ -d "$GLOBALPATH" ] then - IGNOREPATH=$(realpath $IGNOREPATH)/.gitignore_global + GLOBALPATH=$(realpath $GLOBALPATH)/.gitignore_global fi - if [ ! -f "$IGNOREPATH" ] + if [ ! -f "$GLOBALPATH" ] then - echo "××× Not found [[$IGNOREPATH]]. Exit now..." + echo "××× Not found [[$GLOBALPATH]]. Exit now..." exit else - echo "√√√ IGNOREPATH = [[$IGNOREPATH]]" + echo "√√√ GLOBALPATH = [[$GLOBALPATH]]" fi else - IGNOREPATH=https://git.tic.cc/npm/sysconfig/raw/branch/main/nixhome/.gitignore_global + GLOBALPATH=https://git.tic.cc/npm/sysconfig/raw/branch/main/nixhome/.gitignore_global fi echo "" @@ -62,11 +62,11 @@ do if [ -f "$repo/.gitignore" ] # some git repo need to keep privacy, therefore judge from .gitignore, not from .git then echo "---- updating [[$repo/.gitignore]] ----" - if [ -f "$IGNOREPATH" ] + if [ -f "$GLOBALPATH" ] then - cat $IGNOREPATH > $repo/.gitignore + cat $GLOBALPATH > $repo/.gitignore else - curl -sSL $IGNOREPATH | cat > $repo/.gitignore + curl -sSL $GLOBALPATH | cat > $repo/.gitignore fi cat $repo/.gitignore.local.txt 2>/dev/null >> $repo/.gitignore echo "" diff --git a/nixhome/.bashrc b/nixhome/.bashrc index b88be51..02985b6 100644 --- a/nixhome/.bashrc +++ b/nixhome/.bashrc @@ -132,29 +132,28 @@ elif [ -f /etc/debian_version ]; then elif [ -f /etc/ubuntu_version ]; then MYOSVERSION=Ubt`cat /etc/ubuntu_version 2>/dev/null` fi +if [[ -n "$SSH_CONNECTION" ]]; then + IN_SSH="[ssh]" +fi if [ "$color_prompt" = yes ]; then - PS1='<\[\033[07;32m\]\t\[\033[00m\]#\[\033[07;35m\]\u\[\033[00m\]@\[\033[07;31m\]\h\[\033[00m\]^\[\033[07;34m\]$(uname -m),$(uname),$MYOSVERSION\[\033[00m\]::\[\033[07;36m\]\w\[\033[00m\]> ' + PS1='<\[\033[07;32m\]\t\[\033[00m\]#\[\033[07;35m\]\u\[\033[00m\]@\[\033[07;31m\]\h\[\033[00m\]^\[\033[07;34m\]$(uname -m),$(uname),$MYOSVERSION\[\033[00m\]::\[\033[07;36m\]\w\[\033[00m\]$IN_SSH> ' else - PS1='[\t#\u@\h^$(uname -m),$(uname),$MYOSVERSION::\w] ' # \w shows absolute path, \W shows current folder. + PS1='<\t#\u@\h^$(uname -m),$(uname),$MYOSVERSION::\w$IN_SSH> ' # \w shows absolute path, \W shows current folder. fi unset color_prompt force_color_prompt ############## above settings copied from amazon's debian #################### -if [ "$(uname)" = "Darwin" ] -then - if [ "$(uname -m)" = "arm64" ] && [ -f /opt/homebrew/bin/brew ] - then +if [ "$(uname)" = "Darwin" ]; then + if [ "$(uname -m)" = "arm64" ] && [ -f /opt/homebrew/bin/brew ]; then eval "$(/opt/homebrew/bin/brew shellenv)" - elif [ "$(uname -m)" = "x86_64" ] && [ -f /usr/local/homebrew/bin/brew ] - then + elif [ "$(uname -m)" = "x86_64" ] && [ -f /usr/local/homebrew/bin/brew ]; then eval "$(echo $(/usr/local/homebrew/bin/brew shellenv) | sed 's#HOMEBREW_CELLAR=.*$#HOMEBREW_CELLAR=/usr/local/Cellar#')" fi fi # nvm settings -if [ -d $HOME/.nvm ] -then +if [ -d $HOME/.nvm ]; then # 注意,这句 export 导致 `su` 会继承原用户的环境变量 NVM_DIR=/home/原用户/.nvm,可能导致不符合预期的行为。因此要 `su -` 更安全。 export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm diff --git a/nixhome/seafile-ignore.global.txt b/nixhome/seafile-ignore.global.txt index c76ac0f..25b55a0 100644 --- a/nixhome/seafile-ignore.global.txt +++ b/nixhome/seafile-ignore.global.txt @@ -22,10 +22,15 @@ *.nosf/ *.nosf.*/ +## everything 'git pull or fetch' will update `.git/FETCH_HEAD`, even if the content doesn't change. To avoid too many useless updates of this file in Seafile history: +FETCH_HEAD +*/FETCH_HEAD + .Trash/ .DS_Store */.DS_Store +*.aae # AAE 文件主要在苹果的照片应用程序中使用,保存对原始照片所做的编辑,比如,裁剪、旋转或调整亮度等操作的信息。 .thumbnails */.thumbnails @@ -50,14 +55,17 @@ _desktop.ini node_modules/ */node_modules/ package-lock.json +*/package-lock.json pages4loader.json5 +*/pages4loader.json5 .deploy_git/ */.deploy_git/ # next.js 项目 .next/ +*/.next/ # HBuilder 目录 unpackage/ diff --git a/seafile-ignore-find2merge.sh b/seafile-ignore-find2merge.sh index 7449b52..5ccbfdf 100755 --- a/seafile-ignore-find2merge.sh +++ b/seafile-ignore-find2merge.sh @@ -1,7 +1,7 @@ #!/bin/bash echo "" -echo "Search in [ROOTPATH], Merge [IGNOREPATH/seafile-ignore.global.txt] and [ROOTPATH/*/seafile-ignore.local.txt] files to [seafile-ignore.txt]" +echo "Search in [ROOTPATH], Merge [GLOBALPATH/seafile-ignore.global.txt] and [ROOTPATH/*/seafile-ignore.local.txt] files to [seafile-ignore.txt]" echo "" if [ -d "$1" ] @@ -27,22 +27,22 @@ fi echo "" echo "::*** Enter [path to seafile-ignore.global.txt] or [leave blank] for default [[https://git.tic.cc/npm/sysconfig/raw/branch/main/nixhome/seafile-ignore.global.txt]]" -read -p "***:: " IGNOREPATH -if [ "$IGNOREPATH" ] +read -p "***:: " GLOBALPATH +if [ "$GLOBALPATH" ] then - if [ -d "$IGNOREPATH" ] + if [ -d "$GLOBALPATH" ] then - IGNOREPATH=$(realpath $IGNOREPATH)/seafile-ignore.global.txt + GLOBALPATH=$(realpath $GLOBALPATH)/seafile-ignore.global.txt fi - if [ ! -f "$IGNOREPATH" ] + if [ ! -f "$GLOBALPATH" ] then - echo "××× Not found [[$IGNOREPATH]]. Exit now..." + echo "××× Not found [[$GLOBALPATH]]. Exit now..." exit else - echo "√√√ IGNOREPATH = [[$IGNOREPATH]]" + echo "√√√ GLOBALPATH = [[$GLOBALPATH]]" fi else - IGNOREPATH=https://git.tic.cc/npm/sysconfig/raw/branch/main/nixhome/seafile-ignore.global.txt + GLOBALPATH=https://git.tic.cc/npm/sysconfig/raw/branch/main/nixhome/seafile-ignore.global.txt fi echo "" @@ -57,16 +57,16 @@ cd $ROOTPATH echo "*** Starting from [[`pwd`]] ***" echo "" -find . -mindepth 1 -maxdepth 3 -type d -name '[^.]*' | grep -E -v 'node_modules|uni_modules|\.deploy_git|\.git|.svn|\.vscode|\.wrangler|unpackage|_webroot|_logstore|_datasotre|_archive|_filestore|_ssl' | while read repo +find . -mindepth 0 -maxdepth 3 -type d -name '[^.]*' | grep -E -v 'node_modules|uni_modules|\.deploy_git|\.git|.svn|\.vscode|\.wrangler|unpackage|_webroot|_logstore|_datasotre|_archive|_filestore|_ssl' | while read repo do - if [ -f "$repo/seafile-ignore.txt" ] + if [ -f "$repo/seafile-ignore.txt" ] || [ -d "$repo/.git" ] then echo "---- updating [[$repo/seafile-ignore.txt]] ----" - if [ -f "$IGNOREPATH" ] + if [ -f "$GLOBALPATH" ] then - cat $IGNOREPATH > $repo/seafile-ignore.txt + cat $GLOBALPATH > $repo/seafile-ignore.txt else - curl -sSL $IGNOREPATH | cat > $repo/seafile-ignore.txt + curl -sSL $GLOBALPATH | cat > $repo/seafile-ignore.txt fi cat $repo/seafile-ignore.local.txt 2>/dev/null >> $repo/seafile-ignore.txt echo "" diff --git a/seafile-ignore.txt b/seafile-ignore.txt new file mode 100644 index 0000000..d0a7486 --- /dev/null +++ b/seafile-ignore.txt @@ -0,0 +1,84 @@ +# https://help.seafile.com/syncing_client/excluding_files/ +# 注释。通配符:* 匹配0到若干个字符,包括代表目录的/。? 匹配1个字符,包括/。 +# seafile-ignore.txt 只能控制在客户端需要忽略哪些文件。你依然可以在 seahub 的 web 界面创建这些被客户端忽略的文件。 +# 在这种情况下, +# 这些文件会被同步到客户端,但是用户在客户端对这些文件的后续修改会被忽略,不会被同步回服务器。 +# 文件在服务器端的后续更改会被同步到客户端,如果客户端也同时修改了这些文件,系统会生成冲突文件。 +# seafile-ignore.txt 只能忽略还没有被同步的文件。对于已经被同步的文件,如果后来把它添加到 seafile-ignore.txt 中,系统只会忽略后续更改,已经上传的版本不会受影响。 + +### seafile-ignore.global.txt ### + +# 自定义的后缀名,凡有 sfignore 后缀的都不进行同步 +*.sfignore +*.sfignore/ +*.sfignore.* +*.sfignore.*/ +*.sfomit +*.sfomit.* +*.sfomit/ +*.sfomit.*/ +*.nosf +*.nosf.* +*.nosf/ +*.nosf.*/ + +## everything 'git pull or fetch' will update `.git/FETCH_HEAD`, even if the content doesn't change. To avoid too many useless updates of this file in Seafile history: +FETCH_HEAD +*/FETCH_HEAD + +.Trash/ + +.DS_Store +*/.DS_Store + +.thumbnails +*/.thumbnails + +Thumbs.db +*/Thumbs.db +thumbs.db +*/thumbs.db + +_desktop.ini +*/_desktop.ini + +._* +*/._* + +.$* +*/.$* + +~$* +*/~$* + +node_modules/ +*/node_modules/ +package-lock.json +*/package-lock.json + +pages4loader.json5 +*/pages4loader.json5 + +.deploy_git/ +*/.deploy_git/ + +# next.js 项目 +.next/ +*/.next/ + +# HBuilder 目录 +unpackage/ +*/unpackage/ + +Icon +OneDrive/Icon + +# wrangler project + +.dev.vars* +*/.dev.vars* +.wrangler/ +*/.wrangler/ + +### seafile-ignore.local.txt ### + diff --git a/ssh.sh b/ssh.sh index df2d0a4..52f9e72 100755 --- a/ssh.sh +++ b/ssh.sh @@ -66,7 +66,7 @@ then port=22 fi -echo "::*** Coonecting to ${label}" +echo "::*** Connecting to ${label}" if [ "$password" != "null" ] then if [ "$(which sshpass)" ] @@ -75,7 +75,7 @@ then sshpass -p $password ssh -X -p $port "$username@$host" $2 else echo "::*** ssh -X -p $port $username@$host" - ssh -X -p $port "$username@$host" $2 + ssh -X -p $port "$username@$host" $2 # -X 在 linux 安装 xrdp 后连接时报错,改 -Y 就可。 fi else echo "::*** ssh -X -p $port $username@$host"