【保姆级教程】Windows Terminal设置在当前目录打开

【保姆级教程】Windows Terminal设置在当前目录打开

最近我在研究windows下的命令行工具的多Tab页功能。选择了Windows Terminal自从发布以来备受好评,它的功能简单且具有很强的扩展性,给人一种类似VS Code的感觉。然而,我习惯了使用Shift+右键在当前目录打开命令窗口(通常是PowerShell窗口),我在想是否可以实现类似的效果,即在Windows Terminal中右键菜单中也能够打开命令窗口,并自动切换到当前目录。这样就能更方便地在Windows Terminal中进行命令行操作了。

预览效果

先来看下要达成的效果

在这里插入图片描述

操作步骤

1、win+R 输入 regedit

2、找到 计算机\HKEY_CLASSES_ROOT\Directory\Background\shell

复制路径直达跳转

3、右键 > 新建 > 项,名称填写 “在此处打开 Terminal(窗口)”

好的,下面是一个基于Python的BBS论坛保姆教程,适用于Windows操作系统。 首先,你需要安装Python和一些必要的库。推荐使用Anaconda或Miniconda,因为它们包含了常用的Python库。在命令行中输入以下命令来安装Flask和SQLAlchemy: ``` pip install Flask pip install SQLAlchemy ``` 接下来,你需要创建一个Flask应用程序。在你的工作目录中创建一个名为`app.py`的文件,并输入以下代码: ```python from flask import Flask, render_template, request, redirect, url_for from flask_sqlalchemy import SQLAlchemy app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///bbs.db' db = SQLAlchemy(app) class Post(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(80)) content = db.Column(db.Text) author = db.Column(db.String(50)) def __repr__(self): return '<Post %r>' % self.title @app.route('/') def index(): posts = Post.query.all() return render_template('index.html', posts=posts) @app.route('/post/<int:id>') def post(id): post = Post.query.get(id) return render_template('post.html', post=post) @app.route('/new_post', methods=['GET', 'POST']) def new_post(): if request.method == 'POST': title = request.form['title'] content = request.form['content'] author = request.form['author'] post = Post(title=title, content=content, author=author) db.session.add(post) db.session.commit() return redirect(url_for('index')) return render_template('new_post.html') if __name__ == '__main__': app.run(debug=True) ``` 这个应用程序使用了Flask和SQLAlchemy,定义了一个名为`Post`的数据库模型,并创建了三个路由函数。`index`函数会渲染主页,`post`函数会渲染帖子页面,`new_post`函数会渲染新帖子页面,并将新帖子添加到数据库中。 接下来,你需要创建模板。在你的工作目录中创建一个名为`templates`的文件夹,并在其中创建三个HTML文件:`index.html`、`post.html`和`new_post.html`。 `index.html`模板: ```html <!doctype html> <html> <head> <title>BBS</title> </head> <body> <h1>BBS</h1> <ul> {% for post in posts %} <li><a href="{{ url_for('post', id=post.id) }}">{{ post.title }}</a> by {{ post.author }}</li> {% endfor %} </ul> <a href="{{ url_for('new_post') }}">New Post</a> </body> </html> ``` `post.html`模板: ```html <!doctype html> <html> <head> <title>{{ post.title }}</title> </head> <body> <h1>{{ post.title }}</h1> <p>{{ post.content }}</p> <p>by {{ post.author }}</p> <a href="{{ url_for('index') }}">Back to Index</a> </body> </html> ``` `new_post.html`模板: ```html <!doctype html> <html> <head> <title>New Post</title> </head> <body> <h1>New Post</h1> <form method="post"> <label for="title">Title:</label> <input type="text" id="title" name="title"><br><br> <label for="content">Content:</label> <textarea id="content" name="content"></textarea><br><br> <label for="author">Author:</label> <input type="text" id="author" name="author"><br><br> <input type="submit" value="Submit"> </form> <a href="{{ url_for('index') }}">Back to Index</a> </body> </html> ``` 最后,你需要创建一个SQLite数据库。在命令行中输入以下命令: ``` python from app import db db.create_all() exit() ``` 现在你可以运行应用程序了。在命令行中输入以下命令: ``` python app.py ``` 然后在浏览器中访问`http://localhost:5000`即可。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值