python 泰语拼写纠正
We’re used to word processing programs telling us when we’ve misspelled a word, but what about when your fingers are flying through directories on the Linux command line? You can actually have your typos and misspellings automatically corrected, at least when using the cd
command.
我们习惯于使用文字处理程序来告诉我们何时拼错了一个单词,但是当您的手指在Linux命令行上的目录中穿行时呢? 实际上,至少在使用cd
命令时,您实际上可以自动纠正拼写错误和拼写错误。
We’ll show you how to add a simple command to the .bashrc file that will check what you type into the cd command for transposed characters, missing characters, and too many characters.
我们将向您展示如何向.bashrc文件中添加一个简单命令,该命令将检查您在cd命令中键入的内容是否存在转置字符,丢失字符和太多字符。
The .bashrc file is a script that runs every time you open a Terminal window by pressing Ctrl+Alt+T or open a new tab in a Terminal window. You can add commands to the .bashrc file that you want to run automatically every time you open a Terminal window. To add a spell check to the cd command, we’re going to add a command to the .bashrc file.
.bashrc文件是一个脚本,每次您通过按Ctrl + Alt + T或在“终端”窗口中打开新选项卡打开“终端”窗口时运行 。 您可以将命令添加到要在每次打开“终端”窗口时自动运行的.bashrc文件。 要向cd命令添加拼写检查,我们将向.bashrc文件添加命令。
To edit the .bashrc file, we’re going to use gedit. Type the following command at the prompt.
要编辑.bashrc文件,我们将使用gedit。 在提示符下键入以下命令。
gedit ~/.bashrc
You can use any text editor you’re comfortable with, such as vi and nano. Simply replace “gedit” in the above command with the command to run your chosen text editor.
您可以使用任何您喜欢的文本编辑器,例如vi和nano 。 只需将上述命令中的“ gedit”替换为运行所选文本编辑器的命令即可。
Scroll to the bottom of the .bashrc file and add the following line to the end of the file.
滚动到.bashrc文件的底部,并将以下行添加到文件末尾。
shopt -s cdspell
You can add a comment above the command so you remember what the command does. Simply put a number sign (#) at the beginning of the line, and then any description you want to add.
您可以在命令上方添加注释,以便记住命令的作用。 只需在行的开头加上数字符号(#),然后再添加任何要添加的描述。
Click “Save”.
点击“保存”。
Close gedit (or other text editor) by clicking the “X” in the upper-left corner of the window.
单击窗口左上角的“ X”,关闭gedit(或其他文本编辑器)。
The setting you just added to the .bashrc file will not affect the current Terminal window session. You must close the Terminal window and log out and back in for the change to take affect. So, type exit
at the prompt and press Enter or click the “X” button in the upper-left corner of the window. Then, log out and back in.
您刚刚添加到.bashrc文件中的设置不会影响当前的“终端”窗口会话。 您必须关闭“终端”窗口,然后注销并重新登录,以使更改生效。 因此,在提示符下键入exit
,然后按Enter或单击窗口左上角的“ X”按钮。 然后,注销并重新登录。
Now, if you make a small mistake (such as transposed characters) when typing the name of a directory in the cd command, the correct spelling displays on the next line and you are automatically taken to the directory that most closely matches what you typed.
现在,如果您在cd命令中键入目录名称时犯了一个小错误(例如,转置字符),则正确的拼写将显示在下一行,并且您将自动进入与您键入的内容最匹配的目录。
This is a simple solution that makes navigating directories on the command line much easier.
这是一个简单的解决方案,使在命令行上导航目录更加容易。
python 泰语拼写纠正