使用命令行进行组织:命令库

发布于 2024-07-28 00:08:34 字数 187 浏览 3 评论 0原文

我们每天都会创建/发现新的有用的命令(我确实......),但第二天我就忘记了它们,最重要的是那些复杂的命令管道......我使用历史| grep 但这还不够。

我想要一个程序来保存和分类我最喜欢的命令,以便您轻松搜索并执行它们。

如果你知道的话那就太好了 如果没有,我正在写一个..你不认为这是一个好主意吗?

we all create/discover new and useful commands every day (I do...) but I forget them the day after, above all those complicated command pipes.. I use history | grep but that's not enough.

I'd like a program to save and categorize my favorite commands, that lets you search them and execute them easily.

If you know any, that'd be cool
if not, I'm writing one.. don't you thing this is a good idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

紫轩蝶泪 2024-08-04 00:08:36

在 Windows 上:Slickrun 可以提供帮助。 我将所有快捷方式和命令都放在这里,并将其附加到 WIN-R 键,这样我就可以轻松访问它们! 请参阅此处:http://www.bayden.com/SlickRun/

On windows: Slickrun helps here. I put all my shorcuts and commands in here and I attach it to the WIN-R key so I can get to them easily! See here : http://www.bayden.com/SlickRun/

明月夜 2024-08-04 00:08:36

好的,我正在写一篇!

这是一个简单的 ruby​​ 脚本,命令保存在 yaml 文件中,每个命令都有标题、描述和实际命令。

如果它可用的话,也许我会把它发布到某个地方。 最大的问题是执行命令:我想在当前 shell 中执行它们,并且也许能够在执行之前编辑它们,所以唯一的方法是将它们复制并粘贴到同一个终端中。

我正在使用 osascript (applescript) 自动执行此操作,因此它只能在 OS X 上运行。

谢谢大家

OK, I'm writing one!

It's a simple ruby script, commands are saved in a yaml file, each one with a title, description and the actual command.

maybe I'll post it somewhere if it gets usable. The biggest problem is executing commands: I want to execute them in the current shell, and maybe be able to edit them before executing, so only way is to copy and paste them in the same terminal.

I'm automating that with osascript (applescript) therefore it'll work only on OS X.

thanks to you all

清泪尽 2024-08-04 00:08:36

我只需使用 alias 并将它们存储在 ~/.bashrc~/.bash_profile 中。

如果您需要记住别名,您可以使用 # 注释别名条目,并使用 alias 命令来列出它们。

# list my aliases
alias lscmds='grep alias ~/.bashrc'

I'd just use alias and store them in ~/.bashrc or ~/.bash_profile.

If you need to remember your aliases you could comment the alias entries with # and alias a command to list them.

# list my aliases
alias lscmds='grep alias ~/.bashrc'
猫腻 2024-08-04 00:08:35

将以下行添加到您的 .bashrc:

export HISTFILESIZE=100000
export HISTSIZE=100000

现在您可以使用 CTRL+R 或打开 ~/.bash_history 找到所有旧命令。

如果您想记录一些更复杂的组合,请将它们作为函数添加到 .bashrc 中:

# find uncommitted files which have TODO in them, but not in html files
uncommitted_todo_not_html() {
    grep -n TODO $(hg st -n | grep -v '\.html')
}

Add the following lines to your .bashrc:

export HISTFILESIZE=100000
export HISTSIZE=100000

Now you can find all your old commands using CTRL+R, or by opening ~/.bash_history.

If you want to document some more complex combinations, add them as functions in your .bashrc:

# find uncommitted files which have TODO in them, but not in html files
uncommitted_todo_not_html() {
    grep -n TODO $(hg st -n | grep -v '\.html')
}
素手挽清风 2024-08-04 00:08:35

我个人会获得一份数字格式的基本快速参考表,并在进行时添加我自己的参考表(如果适合的话,可以在他们拥有的分组下或创建一个新组)。 如果使用 GUI shell,我会将其作为我的桌面,否则我会定期将其打印出来。

创建和使用更加简单,并且浪费的时间也少得多。

I personally would get a basic quick reference sheet in digital format and add my own to it as I go (under the groupings they have if it fits or creating a new group). If using a GUI shell I would make it my desktop, otherwise I'd periodically print it out.

Much simpler to create and use, and wastes a lot less time.

玩套路吗 2024-08-04 00:08:35

在 Bash 中按 Ctrl + R 可以向后搜索命令历史记录并执行匹配的命令。

Pressing Ctrl + R in Bash lets you search command history backwards and execute matching commands.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文