// 导入 prompts 模块
constprompt=require('prompts');// 声明一个变量用于存储 interval 定时器
letinterval;// 使用异步自执行函数定义主函数
(asyncfunction(){// 定义一系列问题的数组
constquestions=[// 文本输入问题,用户输入 Twitter 账号,可以在输入前添加 '@' 符号
{type:'text',name:'twitter',message:`What's your twitter handle?`,initial:`terkelg`,format:v=>`@${v}`// 将用户输入格式化为 '@username' 的形式
},// 数字输入问题,询问用户年龄,如果年龄小于 18,则验证失败
{type:'number',name:'age',message:'How old are you?',validate:value=>value<18?`Sorry, you have to be 18`:true// 验证函数,如果返回字符串,表示验证失败,否则验证通过
},// 密码输入问题,用户可以输入密码
{type:'password',name:'secret',message:'Tell me a secret'},// 确认问题,用户需要确认一个问题
{type:'confirm',name:'confirmed',message:'Can you confirm?'},// 切换问题,根据上一个问题的回答来判断是否显示该问题,用户需要切换 'yes' 或 'no'
{type:prev=>prev&&'toggle',name:'confirmtoggle',message:'Can you confirm again?',active:'yes',inactive:'no'},// 列表问题,用户可以输入一个或多个关键词
{type:'list',name:'keywords',message:'Enter keywords'},// 选择问题,用户需要从提供的选项中选择一个颜色
{type:'select',name:'color',message:'Pick a color',choices:[{title:'Red',description:'This option has a description.',value:'#ff0000'},{title:'Green',value:'#00ff00'},{title:'Yellow',value:'#ffff00',disabled:true},{title:'Blue',value:'#0000ff'}]},// 多选问题,用户可以选择多个颜色
{type:'multiselect',name:'multicolor',message:'Pick colors',hint:false,choices:[{title:'Red',description:'This option has a description.',value:'#ff0000'},{title:'Green',value:'#00ff00'},{title:'Yellow',value:'#ffff00',disabled:true},{title:'Blue',value:'#0000ff'}]},// 自动补全问题,用户可以通过输入来选择喜欢的演员
{type:'autocomplete',name:'actor',message:'Pick your favorite actor',initial:1,limit:3,suggest:(input,choices)=>choices.filter(i=>i.title.toLowerCase().includes(input.toLowerCase())),choices:[{title:'Cage'},{title:'Clooney',value:'silver-fox'},{title:'Gyllenhaal'},{title:'Gibson'},{title:'Grant',description:'This option has a description.'},{title:'Hanks'},{title:'Downey Jr.'}],fallback:{title:`This is the fallback. Its value is 'fallback'`,value:'fallback'}},// 日期问题,用户需要输入日期,但不能选择未来的日期
{type:'date',name:'birthday',message:`What's your birthday?`,validate:date=>date>Date.now()?`Your birth day can't be in the future`:true},// 数字输入问题,用于演示 onRender 回调函数
{type:'number',name:'prompt',message:'This will be overridden',onRender(color){this.no=(this.no||1);this.msg=`Enter a number (e.g. ${color.cyan(this.no)})`;if(!interval)interval=setInterval(()=>{this.no+=1;this.render();},1000);}}];// 使用 prompts 函数来显示问题,等待用户回答
constanswers=awaitprompt(questions,{onCancel:cleanup,onSubmit:cleanup});console.log(answers);// 打印用户的回答
})();// 定义一个 cleanup 函数,用于清理资源
functioncleanup(){clearInterval(interval);// 清除定时器
}
constprompt=require("prompts");// npm install prompts
constfs=require("fs");consthttp=require("https");constfilePath=process.argv[2]||"token.txt";lettoken;fs.readFile(filePath,"utf8",(err,data)=>{if(err){console.error(err);process.exit(1);// 1 表示退出代码
}else{token=data;}});(asyncfunction(){constchoice=[{type:"select",name:"create",message:`Do you want to create new repository? `,choices:[{title:"false",description:"no",value:false},{title:"true",description:"yes",value:true},]}];constchoiceAnswers=awaitprompt(choice,{onCancel:cleanup,onSubmit:cleanup});if(choiceAnswers.create){constquestions=[{type:"text",name:"name",message:`What's your repo name?`,initial:`github`},{type:"text",name:"description",message:"What's your repo description?",initial:`this is a demo repo`,},{type:"text",name:"homepage",message:"What's your homepage?",initial:`https://meethigher.top`},{type:"select",name:"private",message:"Is is private?",initial:false,choices:[{title:"false",description:"your repo is public",value:false},{title:"true",description:"your repo is private",value:true},]},{type:"select",name:"echo",message:"Do you want to output git with token?",choices:[{title:"no",description:"no",value:false},{title:"yes",description:"yes",value:true},]}];constanswers=awaitprompt(questions,{onCancel:cleanup,onSubmit:cleanup});constpostData=JSON.stringify(answers);constoptions={hostname:"api.github.com",port:443,path:"/user/repos",method:"POST",headers:{"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 Edg/108.0.100.0","Accept":"application/vnd.github+json","Authorization":`Bearer ${token}`,"X-GitHub-Api-Version":"2022-11-28","Content-Type":"application/json","Content-Length":Buffer.byteLength(postData)}};constreq=http.request(options,(res)=>{console.log(`状态码:${res.statusCode}`);//console.log('响应头:', res.headers);
if(res.statusCode===200||res.statusCode===201){letdata=`https://${token}@github.com/meethigher/${answers.name}.git`;if(answers.echo){console.log(data);}}//res.on('data', (data) => {
// console.log('响应数据:', data.toString());
//});
});req.on("error",(error)=>{console.error("请求错误:",error);});req.write(postData);req.end();}else{console.log(token);}})();functioncleanup(){}
@echo off
cmd /k cd/d "D:\Develop\www\hexoBlog\blog"
@echo off表示不在控制台输出输入内容
然后配置环境变量。
输入win+r,在运行中输入blog,即可直接进入命令行
如果想要打开当前文件夹,输入以下命令
sh
1
start .
创建右键cmd打开
cmd打开指定目录,可以通过shift+鼠标右键,或者文件夹路径上输入cmd即可。
桌面新建一个cmd.reg
powershell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
WindowsRegistryEditorVersion5.00[HKEY_CLASSES_ROOT\Directory\shell\runas]@="Open cmd here as Admin""HasLUAShield"=""[HKEY_CLASSES_ROOT\Directory\shell\runas\command]@="cmd.exe /s /k pushd \"%V\""[-HKEY_CLASSES_ROOT\Directory\Background\shell\runas][HKEY_CLASSES_ROOT\Directory\Background\shell\runas]@="Open cmd here as Admin""HasLUAShield"=""[HKEY_CLASSES_ROOT\Directory\Background\shell\runas\command]@="cmd.exe /s /k pushd \"%V\""[-HKEY_CLASSES_ROOT\Drive\shell\runas][HKEY_CLASSES_ROOT\Drive\shell\runas]@="Open cmd here as Admin""HasLUAShield"=""[HKEY_CLASSES_ROOT\Drive\shell\runas\command]
::@brief Used to delete all 'idea' folder, because it takes up more memory. eg 01idea、.idea等
::@author Create by William
@echo off
for /f "delims=" %%i in ('dir /s/b/ad *idea')do(rd /s/q "%%~i")exit
Win文件链接
创建软硬链接示例
text
1
2
3
4
5
6
7
mklink [[/d] | [/h] | [/j]] link target
/d 创建目录符号链接。默认为文件符号链接。
/h 创建硬链接而非符号链接。
/j 创建目录联接。
link 指定新的符号链接名称。
target 指定新链接引用的路径(相对或绝对)。