kingToolbox / kingToolbox/WindTerm
批量导入会话的脚本:Script for bulk import session
- Dominant language
- C
- Stars
- 32.3k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
可以批量导入windeterm的会话,从 csv文件中
You can batch import windeterm sessions from the csv file
### 他在MacOS上工作良好,Linux未测试,windows我想无法运行,但是您可以在linux生成配置文件后,导入到windows使用!
如果你需要,请将脚本中第三行 变量`file_path`替换为您的windterm会话文件路径
If you need, please change the variable in the third line of the script ` file_ Path ` Replace with your windterm session file path
```shell
file_path="/Users/junbys/.wind/profiles/default.v10/terminal/user.sessions"
```
然后在您首次执行此脚本时,会生成模板文件到当前目录!
Then when you execute this script for the first time, the template file will be generated to the current directory!
就像下面这样!
It's like this!

但值得注意的是:password选项并不是明文密码,而是需要您手动创建会话在windterm中,然后从其配置文件获取相同的密码内容粘贴给其他会话使用,windterm密码存储在文件中是加密的,我并没能破解他的加密算法,如果你的大部分会话密码相同,那么很幸运!因为你可以复制他到这里
But it is worth noting that the password option is not a plaintext password, but requires you to manually create a session in the windterm, and then obtain the same password content from its configuration file and paste it to other sessions for use. The windterm password is encrypted when stored in the file. I can't break its encryption algorithm. If most of your session passwords are the same, you are lucky! Because you can copy him here
当你修改好csv文件后,在此执行脚本,会将会话自动为您创建到windter,需要重启windterm
After you modify the csv file, execute the script here, and the session will be automatically created to the winder for you. You need to restart the windterm
祝好运!
Good luck!
脚本文件:
Script file:
``` shell
#!/bin/bash
#20220904
file_path="/Users/junbys/.wind/profiles/default.v10/terminal/user.sessions"
if [ ! -f './sessions.csv' ]; then
echo "已经为你创建模版文件: ./sessions.csv 请编辑"
echo "密码不要输明文密码,需要手动添加后从配置文件中获得session.autoLogin的值"
echo "~/.wind/profiles/default.v10/terminal/user.sessions"
echo "groups,host,port,user,password,labe,logo(centos\debain\ubuntu\suse\linux\macos\windows\cali\git)" > ./sessions.csv
exit 0
fi
#测试文件是否存在
nu=`cat $file_path 2>/dev/null | wc -l | sed 's/ //g'`
if [ "$nu" -lt 4 ]; then
echo -e '[' > $file_path
else
#删除配置文件空行
sed -ie '/^$/d' $file_path
#对最后两行进行重写,去除多余逗号
sed -ie '$d' $file_path
sed -ie '$d' $file_path
echo '},' >> $file_path
fi
for i in `cat sessions.csv | grep -v "groups,host,port"`; do
group=`echo $i | awk -F',' '{print $1}'`
host=`echo $i | awk -F',' '{print $2}'`
port=`echo $i | awk -F',' '{print $3}'`
user=`echo $i | awk -F',' '{print $4}'`
passwd=`echo $i | awk -F',' '{print $5}'`
label=`echo $i | awk -F',' '{print $6}'`
logo=`echo $i | awk -F',' '{print $7}' | tr -cd "[:print:]\n" `
ha=`openssl rand -hex 6`
echo "create host: $host, Label: $label"
conflict=`cat $file_path | grep $ha`
while [ "$conflict" != '' ]; do
ha=`openssl rand -hex 6`
conflict=`cat $file_path | grep $ha`
done
echo '
{
"process.arguments" : "-i -l",
"process.workingDirectory" : "$(HomeDir)",
"session.autoLogin" : "'${passwd}'",
"session.dataType" : "binary",
"session.group" : "'${group}'",
"session.icon" : "session::'${logo}'",
"session.keepAlive" : 30,
"session.label" : "'${label}'",
"session.logFilePath" : "/Users/junbys/Documents/WindTermLogs/%n_%Y-%m-%d_%H-%M-%S.log",
"session.logType" : 14,
"session.port" : '${port}',
"session.protocol" : "SSH",
"session.system" : "Linux",
"session.target" : "'${user}@${host}'",
"session.tcpKeepAlive" : true,
"session.uuid" : "44550de3-ade3-411a-b85f-'${ha}'",
"terminal.autoWrapMode" : true,
"terminal.bellStyle" : 0,
"terminal.eraseWithBackground" : true,
"terminal.newLineMode" : false,
"terminal.reverseScreenMode" : false
},' >> $file_path
done
# 收尾
#删除配置文件空行
sed -ie '/^$/d' $file_path
#对最后两行进行重写,去除多余逗号
sed -ie '$d' $file_path
echo '}' >> $file_path
echo ']' >> $file_path
```
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue provides an embedded Bash script but names no repository file or test. Review the script's CSV parsing and WindTerm user.sessions output first, then determine where a bulk-import utility belongs. Done should include an agreed integration location and verification of session import on the supported platforms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100