终端软件升级功能开发_5个很棒的终端技巧可帮助您升级为开发人员

终端软件升级功能开发

There are plenty of beginner tutorials around that help you learn command line basics, such as cd, ls, pwd and so on...but what about that fancy magic you've seen more experienced developers use?

周围有很多初学者教程可以帮助您学习命令行基础知识,例如cdlspwd等。但是,您已经看到更多经验丰富的开发人员使用的那种奇特的魔术怎么办?

Here are my five favourite terminal commands and utilities (in no particular order), to help you feel like the wizard you aspire to be! This is based on Ubuntu, but should be similar across other platforms (with maybe a little Googling).

这是我最喜欢的五个终端命令和实用程序(不分先后顺序),可帮助您感到自己渴望成为向导! 这是基于Ubuntu的,但在其他平台上应该类似(可能会有一点谷歌搜索)。

If you want to mention how to achieve similar results on MacOS or Windows, or there are other terminal tricks you would like to share, let me know in the comments below.

如果您想提一下如何在MacOS或Windows上获得类似的结果,或者想分享其他终端技巧,请在下面的评论中告诉我。

This is adapted from my recent YouTube video, which you can view to see these tricks in action!

这是根据我最近的YouTube视频改编而成的,您可以观看该视频以了解这些技巧!

须藤!! (sudo !!)

sudo !! (or as I like to shout SUDO BANG BANG) will repeat the last command you typed, but with sudo in front of it.

sudo !! (或者我喜欢大喊SUDO BANG BANG)将重复您键入的最后一个命令,但前面要加上sudo

If you have ever forgotten to use your sudo privilege when doing something that needs your administrator credentials (such as apt updatefor example), then sudo !! is a handy way to correct it without having to type the whole command again.

如果您在做一些需要管理员凭据的操作时忘记了使用sudo特权(例如apt update ),那么sudo !! 是纠正它的便捷方法,而无需再次键入整个命令。

蒂格 (tig)

tig and tig status are probably the tools I use most often in my day-to-day work.

tigtig status可能是我在日常工作中最常使用的工具。

The eagle-eyed among you may have noticed that this is git spelled backwards, and indeed tig is an excellent git utility.

你们中间的鹰眼人士可能已经注意到,这是git反向拼写,而tig确实是一个出色的git实用程序。

One of gits shortcomings for me is the lack of interactivity available in some of the basic actions. For example, while git log and git status give me useful information, it requires more manual git commands to do anything useful with that information.

对我来说,git的缺点之一是某些基本操作中缺乏交互性。 例如,虽然git loggit status为我提供了有用的信息,但它需要更多手动git命令才能对该信息执行任何有用的操作。

tig acts like git log, but allows you to navigate up and down the log, and examine the contents of each commit from the command line.

tig行为类似于git log ,但允许您上下浏览日志,并从命令行检查每个提交的内容。

tig status acts like git status except that it also allows for the same navigation as tig, and it also allows you to add files to staging easily from the command line.

tig status行为类似于git status除了它还允许与tig相同的导航之外,它还允许您从命令行轻松地将文件添加到暂存中。

Both commands can be navigated using the j and k keys to move up and down, and pressing enter will open the information about the file (such as the commit diff). q also exits out of each command.

可以使用jk键上下移动两个命令,然后按enter将打开有关文件的信息(例如commit diff)。 q也退出每个命令。

To add or remove specific files from your staging area in git, simply press u.

要在git的暂存区中添加或删除特定文件,只需按u

Now when you go to git commit... as usual, your  files have already been added, so no need to use the git add command.

现在,当您像往常一样转到git commit... ,您的文件已经添加完毕,因此无需使用git add命令。

grep (grep)

This is a very well known 'trick' but it's incredibly useful all the same.

这是一个非常著名的“把戏”,但同样有用。

grep allows you to return the relevant lines from text output that match a particular pattern you pass it.

grep允许您从文本输出中返回与您传递的特定模式匹配的相关行。

For example, if you are looking in a long .log file for an error, it can be hard to see amongst all irrelevant output. Grep can narrow down your search to only the relevant lines.

例如,如果您正在一个长的.log文件中查找错误,则可能很难在所有不相关的输出中看到该错误。 Grep可以将搜索范围缩小到相关行。

E.g. grep error system.log

例如grep error system.log

With other commands that produce lots of terminal output, you can pipe it to grep error to do the same. For example, if you wanted to look at your Rails routes, but you were only interested in those related to admin you could do this:

使用产生大量终端输出的其他命令,您可以将其传递给grep error以执行相同的操作。 例如,如果您想查看Rails路线,但是只对与admin相关的那些感兴趣,则可以执行以下操作:

rake routes | grep admin

rake routes | grep admin

历史 (history)

history simply returns every command you have ever typed into your terminal. Why is this useful? Well, if, like me, you are super forgetful, the history command can show you what you've done before to jog your memory.

history只是返回您曾经在终端中键入的每个命令。 为什么这有用? 好吧,如果像我一样,您超级健忘, history命令可以向您显示您在记忆之前所做的事情。

For example, whenever I have to restore a database back-up, I can never remember the syntax. history | grep pg_restore will show me every time I've used the pg_restore command, with the exact flags and arguments I had to use.

例如,每当我必须还原数据库备份时,我就永远不会记住语法。 history | grep pg_restore 每次使用pg_restore命令时, history | grep pg_restore都会显示给我,并提供我必须使用的确切标志和参数。

Notice the use of grep to narrow down the search? Work smart, not hard!

注意使用grep缩小搜索范围了吗? 聪明地工作,不难!

快速检测 (spd-say)

This one can be achieved a number of ways, and with various tools on each platform. spd-say is the default Ubuntu text-to-speech utility.

可以通过多种方法以及在每个平台上使用各种工具来实现这一目标。 spd-say是默认的Ubuntu文本语音转换实用程序。

Using your terminal's ability to chain commands, you can use your speech utility tool of choice to tell you when a long running process has finished.

利用终端机链接命令的能力,您可以使用自己的语音实用工具来告诉您长时间运行的过程何时结束。

Example: sudo apt update; spd-say done

示例: sudo apt update; spd-say done sudo apt update; spd-say done

Notice the ; between the commands? This will basically run the apt update to completion and then invoke the next command. In this case it will helpfully say 'done' when it's finished.

注意; 命令之间? 基本上,这将使apt update运行完成,然后调用下一个命令。 在这种情况下,完成时会说“完成”。

Feel free to make it say 'booyah!' if you feel like your day needs more celebrations of tiny wins in it.

随意说“嘘!” 如果您觉得自己的一天需要更多庆祝微小胜利的日子。



与我分享你的! (Share yours with me!)

Devs love two things: laptop stickers and snazzy terminal commands. I've run out of room for stickers, but I'd love to hear your favourite terminal commands in the comments below!

开发人员喜欢两件事:笔记本电脑贴纸和时髦的终端命令。 我已经没有足够的空间来放置贴纸了,但是我很想在下面的评论中听到您最喜欢的终端命令!

You can also connect with me on Twitter @JacksonBates

您也可以通过Twitter @JacksonBates与我联系

翻译自: https://www.freecodecamp.org/news/terminal-tricks/

终端软件升级功能开发

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值