Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu Wang 2020-12-05 11:15:33 +08:00
commit 7461e20818
6 changed files with 683 additions and 288 deletions

View File

@ -1,8 +1,8 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-12886-1.html)
[#]: subject: (scanimage: scan from the command line!)
[#]: via: (https://jvns.ca/blog/2020/07/11/scanimage--scan-from-the-command-line/)
[#]: author: (Julia Evans https://jvns.ca/)
@ -10,15 +10,17 @@
scanimage从命令行扫描!
======
![](https://img.linux.net.cn/data/attachment/album/202012/05/105822m30t6x66hz3hx6x3.jpg)
这又是一篇关于我很喜欢的一个命令行工具的文章。
昨晚,出于官僚原因,我需要扫描一些文档。我以前从来没有在 Linux 上使用过扫描仪,我担心会花上好几个小时才弄明白。我从使用 `gscan2pdf` 开始,但在用户界面上遇到了麻烦。我想同时扫描两面(我知道我们的扫描仪支持),但无法使它工作。
### 遇到 scanimage
`scanimage` 是一个命令行工具,在 `sane-utils` Debian 软件包中。我想所有的 Linux 扫描工具都使用 `sane` ”scanner access now easy“ 库,所以我猜测它和其他扫描软件有类似的能力。在这里,我不需要 OCR所以我不打算谈论 OCR。
`scanimage` 是一个命令行工具,在 `sane-utils` Debian 软件包中。我想所有的 Linux 扫描工具都使用 `sane` “scanner access now easy” 库,所以我猜测它和其他扫描软件有类似的能力。在这里,我不需要 OCR所以我不打算谈论 OCR。
### 用 `scanimage -L` 得到你的扫描仪的名字
### 用 scanimage -L 得到你的扫描仪的名字
`scanimage -L` 列出了你所有的扫描设备。
@ -26,7 +28,7 @@ scanimage从命令行扫描!
插上后,它马上就能工作了。显然我们的扫描仪叫 `fujitsu:ScanSnap S1500:2314`。万岁!
### 用 `--help` 列出你的扫描仪选项
### 用 --help 列出你的扫描仪选项
显然每个扫描仪有不同的选项(有道理!),所以我运行这个命令来获取我的扫描仪的选项:
@ -60,6 +62,7 @@ convert *.png $CUR/$1
### 这真是太简单了!
我一直以为在 Linux 上使用打印机/扫描仪是一个噩梦,我真的很惊讶 `scanimage` 可以工作。我可以直接运行我的脚本 `scan-single-sided receipts.pdf`,它将扫描文档并将其保存到 `receipts.pdf`
--------------------------------------------------------------------------------
via: https://jvns.ca/blog/2020/07/11/scanimage--scan-from-the-command-line/
@ -67,7 +70,7 @@ via: https://jvns.ca/blog/2020/07/11/scanimage--scan-from-the-command-line/
作者:[Julia Evans][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -0,0 +1,203 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (7 Git tricks that changed my life)
[#]: via: (https://opensource.com/article/20/10/advanced-git-tips)
[#]: author: (Rajeev Bera https://opensource.com/users/acompiler)
7 Git tricks that changed my life
======
These helpful tips will change the way you work with the popular version
control system.
![Computer screen with files or windows open][1]
Git is one of the most common version control systems available, and it's used on private systems and publicly hosted websites for all kinds of development work. Regardless of how proficient with Git I become, it seems there are always features left to discover. Here are seven tricks that have changed the way I work with Git.
### 1\. Autocorrection in Git
We all make typos sometimes, but if you have Git's auto-correct feature enabled, you can let Git automatically fix a mistyped subcommand.
Suppose you want to check the status with `git status` but you type `git stats` by accident. Under normal circumstances, Git tells you that 'stats' is not a valid command:
```
$ git stats
git: stats is not a git command. See git --help.
The most similar command is
status
```
To avoid similar scenarios, enable Git autocorrection in your Git configuration:
```
`$ git config --global help.autocorrect 1`
```
If you want this to apply only to your current repository, omit the `--global` option.
This command enables the autocorrection feature. An in-depth tutorial is available at [Git Docs][2], but trying the same errant command as above gives you a good idea of what this configuration does:
```
$ git stats
git: stats is not a git command. See git --help.
On branch master
Your branch is up to date with origin/master.
nothing to commit, working tree clean
```
Instead of suggesting an alternative subcommand, Git now just runs the top suggestion, which in this case was **git status**.
### 2\. Count your commits
There are many reasons you might need to count your commits. Many developers count the number of commits to judge when to increment the build number, for instance, or just to get a feel for how the project is progressing.
To count your commits is really easy and straightforward; here is the Git command:
```
`$ git rev-list --count`
```
In the above command, the **branch-name** should be a valid branch name in your current repository.
```
$ git rev-list count master
32
$ git rev-list count dev
34
```
### 3\. Optimize your repo
Your code repository is valuable not only for you but also for your organization. You can keep your repository clean and up to date with a few simple practices. One of the best practices is to [use the .gitignore file][3]. By using this file, you are telling Git not to store many unwanted files like binaries, temporary files, and so on.
To optimize your repository further, you can use Git garbage collection.
```
`$ git gc --prune=now --aggressive`
```
This command helps when you or your team heavily uses **pull** or **push** commands.
This command is an internal utility that cleans up unreachable or "orphaned" Git objects in your repository.
### 4\. Take a backup of untracked files
Most of the time, it's safe to delete all the untracked files. But many times, there is a situation wherein you want to delete, but also to create a backup of your untracked files just in case you need them later.
Git, along with some Bash command piping, makes it easy to create a zip archive for your untracked files.
```
$ git ls-files --others --exclude-standard -z |\
xargs -0 tar rvf ~/backup-untracked.zip
```
The above command makes an archive (and excludes files listed in .gitignore) with the name backup-untracked.zip
### 5\. Know your .git folder
Every repository has a .git folder. It is a special hidden folder.
```
$ ls -a
. … .git
```
Git mainly works with two things:
1. The working tree (the state of files in your current checkout)
2. The path of your Git repository (specifically, the location of the .git folder, which contains the versioning information)
This folder stores all references and other important details like configurations, repository data, the state of HEAD, logs, and much more.
If you delete this folder, the current state of your source code is not deleted, but your remote information, such as your project history, is. Deleting this folder means your project (at least, the local copy) isn't under version control anymore. It means you cannot track your changes; you cannot pull or push from a remote.
Generally, there's not much you need to do, or should do, in your .git folder. It's managed by Git and is considered mostly off-limits. However, there are some interesting artifacts in this directory, including the current state of HEAD:
```
$ cat .git/HEAD
ref: refs/heads/master
```
It also contains, potentially, a description of your repository:
```
`$ cat .git/description`
```
This is an unnamed repository; edit this file 'description' to name the repository.
The Git hooks folder is also here, complete with example hook files. You can read these samples to get an idea of what's possible through Git hooks, and you can also [read this Git hook introduction by Seth Kenlon][4].
### 6\. View a file of another branch
Sometimes you want to view the content of the file from another branch. It's possible with a simple Git command, and without actually switching your branch.
Suppose you have a file called [README.md][5], and it's in the **main** branch. You're working on a branch called **dev**.
With the following Git command, you can do it from the terminal.
```
`$ git show main:README.md`
```
Once you execute this command, you can view the content of the file in your terminal.
### 7\. Search in Git
You can search in Git like a pro with one simple command. Better still, you can search in Git even if you aren't sure which commit—or even branch—you made your changes.
```
`$ git rev-list --all | xargs git grep -F `
```
For example, suppose you want to search for the string "font-size: 52 px;" in your repository:
```
$ git rev-list all | xargs git grep -F font-size: 52 px;
F3022…9e12:HtmlTemplate/style.css: font-size: 52 px;
E9211…8244:RR.Web/Content/style/style.css: font-size: 52 px;
```
### Try these tips
I hope these advanced tips are useful and boost your productivity, saving you lots of time.
Do you have [Git tips][6] you love? Share them in the comments.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/10/advanced-git-tips
作者:[Rajeev Bera][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/acompiler
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_screen_windows_files.png?itok=kLTeQUbY (Computer screen with files or windows open)
[2]: https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_code_help_autocorrect_code
[3]: https://opensource.com/article/20/8/dont-ignore-gitignore
[4]: https://opensource.com/life/16/8/how-construct-your-own-git-server-part-6
[5]: http://README.md
[6]: https://acompiler.com/git-tips/

View File

@ -1,281 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (8 Git aliases that make me more efficient)
[#]: via: (https://opensource.com/article/20/11/git-aliases)
[#]: author: (Ricardo Gerardi https://opensource.com/users/rgerardi)
8 Git aliases that make me more efficient
======
Use aliases to create shortcuts for your most-used or complex Git
commands.
![Terminal command prompt on orange background][1]
The excellent article _[7 Git tricks that changed my life][2]_ inspired me to write about another Git feature that's had a major impact on my experience using Git on the command line: aliases.
Defining Git aliases to serve as substitutes for commands provides two major benefits:
* It simplifies long commands that have many options, making them shorter and easier to remember.
* It shortens frequently used commands so that you can work more efficiently.
### How to define and use aliases
To define a Git alias, use the `git config` command with the alias and the command you want to substitute. For example, to create the alias `p` for `git push`:
```
$ git config --global alias.p 'push'
```
You can use an alias by providing it as an argument to `git`, just like any other command:
```
$ git p
```
To see all your aliases, list your configuration with `git config`:
```
$ git config --global -l
user.name=ricardo
user.email=[ricardo@example.com][3]
alias.p=push
```
You can also define aliases with your favorite shell, such as Bash or Zsh. However, defining aliases using Git offers several features that you don't get using the shell. First, it allows you to use aliases across different shells with no additional configuration. It also integrates with Git's autocorrect feature, so Git can suggest aliases as alternatives when you mistype a command. Finally, Git saves your aliases in the user configuration file, allowing you to transfer them to other machines by copying a single file.
Regardless of the method you use, defining aliases improves your overall experience with Git. For more information about defining Git aliases, take a look at the [Git Book][4].
### 8 useful Git aliases
Now that you know how to create and use an alias, take a look at some useful ones.
#### 1\. Git status
Git command line users often use the `status` command to see changed or untracked files. By default, this command provides verbose output with many lines, which you may not want or need. You can use a single alias to address both of these components: Define the alias `st` to shorten the command with the option `-sb` to output a less verbose status with branch information:
```
$ git config --global alias.st 'status -sb'
```
If you use this alias on a clean branch, your output looks like this:
```
$  git st
## master
```
Using it on a branch with changed and untracked files produces this output:
```
$ git st
## master
 M test2
?? test3
```
#### 2\. Git log --oneline
Create an alias to display your commits as single lines for more compact output:
```
$ git config --global alias.ll 'log --oneline'
```
Using this alias provides a short list of all commits:
```
$ git ll
33559c5 (HEAD -> master) Another commit
17646c1 test1
```
#### 3\. Git last commit
This shows details about the most recent commit you made. This extends an example in the Git Book's chapter on [Aliases][4]:
```
$ git config --global alias.last 'log -1 HEAD --stat'
```
Use it to see the last commit:
```
$ git last
commit f3dddcbaabb928f84f45131ea5be88dcf0692783 (HEAD -> branch1)
Author: ricardo <[ricardo@example.com][3]>
Date:   Tue Nov 3 00:19:52 2020 +0000
    Commit to branch1
 test2 | 1 +
 test3 | 0
 2 files changed, 1 insertion(+)
```
#### 4\. Git commit
You use `git commit` a lot when you're making changes to a Git repository. Make the `git commit -m` command more efficient with the `cm` alias:
```
$ git config --global alias.cm 'commit -m'
```
Because Git aliases expand commands, you can provide additional parameters during their execution:
```
$ git cm "A nice commit message"
[branch1 0baa729] A nice commit message
 1 file changed, 2 insertions(+)
```
#### 5\. Git remote
The `git remote -v` command lists all configured remote repositories. Shorten it with the alias `rv`:
```
$ git config --global alias.rv 'remote -v'
```
#### 6\. Git diff
The `git diff` command displays differences between files in different commits or between a commit and the working tree. Simplify it with the `d` alias:
```
$ git config --global alias.d 'diff'
```
The standard `git diff` command works fine for small changes. But for more complex ones, an external tool such as `vimdiff` makes it more useful. Create the alias `dv` to display diffs using `vimdiff` and use the `-y` parameter to skip the confirmation prompt:
```
$ git config --global alias.dv 'difftool -t vimdiff -y'
```
Use this alias to display `file1` differences between two commits:
```
$ git dv 33559c5 ca1494d file1
```
![vim-diff results][5]
(Ricardo Gerardi, [CC BY-SA 4.0][6])
#### 7\. Git config list
The `gl` alias makes it easier to list all user configurations:
```
$ git config --global alias.gl 'config --global -l'
```
Now you can see all defined aliases (and other configuration options):
```
$ git gl
user.name=ricardo
user.email=[ricardo@example.com][3]
alias.p=push
alias.st=status -sb
alias.ll=log --oneline
alias.last=log -1 HEAD --stat
alias.cm=commit -m
alias.rv=remote -v
alias.d=diff
alias.dv=difftool -t vimdiff -y
alias.gl=config --global -l
alias.se=!git rev-list --all | xargs git grep -F
```
#### 8\. Git search commit
Git alias allows you to define more complex aliases, such as executing external shell commands, by prefixing them with the `!` character. You can use this to execute custom scripts or more complex commands, including shell pipes.
For example, define the `se` alias to search within your commits:
```
$ git config --global alias.se '!git rev-list --all | xargs git grep -F'
```
Use this alias to search for specific strings in your commits:
```
$ git se test2
0baa729c1d683201d0500b0e2f9c408df8f9a366:file1:test2
ca1494dd06633f08519ec43b57e25c30b1c78b32:file1:test2
```
### Autocorrect your aliases
A cool benefit of using Git aliases is its native integration with the autocorrect feature. If you make a mistake, by default Git suggests commands that are similar to what you typed, including aliases. For example, if you type `ts` instead of `st` for `status`, Git will suggest the correct alias:
```
$ git ts
git: 'ts' is not a git command. See 'git --help'.
The most similar command is
        st
```
If you have autocorrect enabled, Git will automatically execute the correct command:
```
$ git config --global help.autocorrect 20
$ git ts
WARNING: You called a Git command named 'ts', which does not exist.
Continuing in 2.0 seconds, assuming that you meant 'st'.
## branch1
?? test4
```
### Optimize Git commands
Git alias is a useful feature that improves your efficiency by optimizing the execution of common and repetitive commands. Git allows you to define as many aliases as you want, and some users define many. I prefer to define aliases for just my most used commands—defining too many makes it harder to memorize them and may require me to look them up to use them.
For more about aliases, including other useful ones, see the [Git Wiki's Aliases page][7].
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/11/git-aliases
作者:[Ricardo Gerardi][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/rgerardi
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/terminal_command_linux_desktop_code.jpg?itok=p5sQ6ODE (Terminal command prompt on orange background)
[2]: https://opensource.com/article/20/10/advanced-git-tips
[3]: mailto:ricardo@example.com
[4]: https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases
[5]: https://opensource.com/sites/default/files/uploads/vimdiff.png (vim-diff results)
[6]: https://creativecommons.org/licenses/by-sa/4.0/
[7]: https://git.wiki.kernel.org/index.php/Aliases

View File

@ -0,0 +1,124 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Setting a standard for digital public goods)
[#]: via: (https://opensource.com/article/20/12/digital-public-goods)
[#]: author: (Lucy https://opensource.com/users/lucyeoh)
Setting a standard for digital public goods
======
Nine-indicator standard aims to promote open source software, data, AI
models, standards, and content for a more equitable world.
![Two diverse hands holding a globe][1]
In June 2020, the Secretary-General of the United Nations published a "[Roadmap for Digital Cooperation][2]." In this report, he expanded on recommendations made a year before, calling on all actors, including the Member States, the United Nations system, the private sector, and others, to promote digital public goods. He says to realize the benefits of increased internet connectivity, open source projects in the form of digital public goods must be at the center.
While the term "digital public good" appears as early as April 2017, this report offers the first broadly accepted definition of digital public goods:
> "Open source software, open data, open AI models, open standards, and open content that adhere to privacy and other applicable international and domestic laws, standards and best practices, and do no harm."
The Digital Public Goods Alliance (DGPA) translated that definition into a [nine-indicator open standard][3] that we hope will serve as a comprehensive, shared definition to promote the discovery, development, use of, and investment in digital public goods for a more equitable world.
The DPG standard was developed from the original 51-indicator standard used by the DPGA in the preliminary review of [Early Grade Reading][4] projects and refined through contributions from many experts. The standard is itself an open source project. The core version [lives on GitHub][5] and is open to contributions, revisions, and suggestions from anyone. Proposed revisions are regularly reviewed in alignment with the standard's [governance principles][6], and we invite anyone who uses and benefits from the standard to join our growing [list of endorsers][7].
The Digital Public Goods Alliance envisions engaging a growing community of contributors and stakeholders around the [Digital Public Goods Standard][3]. Our ambition is to balance responsiveness to feedback with stability and predictability for the standard so that it can be a reliable framework that supports development, recognition, and advocacy for digital public goods.
### Digital Public Goods Standard
Below is the DPG Standard's full list of indicators and requirements in v.1.1.2. These must be met in order for a nominated project (software, data, AI model, standard, and/or piece of content) to be considered a digital public good.
**Indicator**
**Requirement**
1\. Relevance to Sustainable Development Goals
All projects must indicate the [Sustainable Development Goals][8] (SDGs) that they are relevant to and provide supporting links/documentation to support this relevance.
2\. Use of approved open source license
Projects must demonstrate the use of an approved open source license. For open source software, we only accept [OSI approved licenses][9]. For open content, we require the use of a [Creative Commons license][10], while we encourage projects to use a license which allows for both derivatives and commercial reuse ([CC-BY][11] and [CC-BY-SA][12]), or dedicate content to the public domain ([CC0][13]); we also accept licenses which do not allow for commercial reuse ([CC BY-NC][14] and [CC BY-NC-SA][15]). For data, we require an [Open Data Commons approved license][16]. You can find [the full license list here][17].
3\. Documentation of ownership
Ownership of everything that the project produces must be clearly defined and documented, i.e., through copyright, trademark, or other publicly available information.
4\. Mandatory dependencies
If the open source project has mandatory dependencies that create more restrictions than the original license, the projects must be able to demonstrate independence from the closed component and/or indicate the existence of functional, open alternatives.
5\. Documentation
The project must have some documentation of the source code, use cases, and/or functional requirements. For content, this should indicate any relevant compatible apps, software, hardware required to access the content, and instructions about how to use it. For software projects, this should be present as technical documentation that would allow a technical person unfamiliar with the project to launch and run the software. For data projects, this should be present as documentation that describes all the fields in the set and provides context on how the data was collected and how it should be interpreted.
6\. Mechanism for extracting data
If this project has non personally identifiable information, there must be a mechanism for extracting or importing non personally identifiable information (PII) data from the system in a non-proprietary format.
_Note that evidence for requirements 7 through 9 can only be given by someone authorized to speak on behalf of the project. We collect title, name, and contact information to confirm this authority._
7\. Adherence to privacy and applicable laws
The project must state that, to the best of its knowledge, it complies with relevant privacy laws and all applicable international and domestic laws.
8\. Adherence to standards and best practices
Projects must demonstrate some adherence to standards, best practices, and/or principles, i.e., the principles for digital development.
9\. Do no harm
All projects must demonstrate that they have taken steps to ensure that the project anticipates, prevents, and does no harm.
9a. Data privacy and security
Projects that collect data must identify the types of data collected and stored and demonstrate that the project ensures the privacy and security of this data and has taken steps to prevent adverse impacts resulting from its collection, storage, and distribution.
9b. Inappropriate and illegal content
Projects that collect, store, or distribute content must have policies identifying inappropriate and illegal content such as child sexual abuse materials and mechanisms for detecting, moderating, and removing inappropriate/illegal content.
9c. Protection from harassment
If the project facilitates interactions with or between users or contributors, there must be a mechanism for users and contributors to protect themselves against grief, abuse, and harassment. The project must have a mechanism to address the safety and security of underage users.
If you know of a project that you believe meets these standards and should be considered a digital public good, please [submit it][18]. We also welcome your feedback on the standard in the comments below.
* * *
_This article is adapted with permission from the post "Setting a standard for digital public goods," which originally appeared on the Digital Public Goods Alliance_ [_blog_][19] _and_ [_Medium_][20] _channel._
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/12/digital-public-goods
作者:[Lucy][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/lucyeoh
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/world_hands_diversity.png?itok=zm4EDxgE (Two diverse hands holding a globe)
[2]: https://www.un.org/en/content/digital-cooperation-roadmap/
[3]: https://digitalpublicgoods.net/standard/
[4]: https://medium.com/digital-public-goods/announcing-the-first-vetted-digital-public-goods-for-foundational-literacy-and-early-grade-reading-1f5c371a50d3
[5]: https://github.com/DPGAlliance/DPG-Standard/blob/master/standard.md
[6]: https://github.com/DPGAlliance/DPG-Standard/blob/master/governance.md
[7]: https://github.com/DPGAlliance/DPG-Standard/blob/master/endorsement.md
[8]: https://sdgs.un.org/goals
[9]: https://opensource.org/licenses
[10]: https://creativecommons.org/licenses/
[11]: https://creativecommons.org/licenses/by/4.0/
[12]: https://creativecommons.org/licenses/by-sa/4.0/
[13]: https://creativecommons.org/choose/zero/
[14]: https://creativecommons.org/licenses/by-nc/4.0/
[15]: https://creativecommons.org/licenses/by-nc-sa/4.0/
[16]: https://opendefinition.org/licenses/
[17]: https://github.com/unicef/publicgoods-candidates/blob/master/docs/licenses.md
[18]: https://forms.gle/8w4pXRUqUV2oKAHi9
[19]: https://digitalpublicgoods.net/blog/setting-a-standard-for-digital-public-goods/
[20]: https://medium.com/digital-public-goods/setting-a-standard-for-digital-public-goods-a1f28b3d1ed5

View File

@ -0,0 +1,90 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Try this Linux text editor for Emacs fans)
[#]: via: (https://opensource.com/article/20/12/jove-emacs)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
Try this Linux text editor for Emacs fans
======
If you're looking for a fast, easy Emacs editor without a long list of
dependencies, give Jove a try.
![Text editor on a browser, in blue][1]
GNU Emacs is a very famous editor, but not everyone knows that emacs is a _tradition_ of text editors rather than just one specific application.
The term "emacs" is actually a portmanteau of "Editor Macros," and the first one was programmed in 1976 as a set of macros for the TECO editor. GNU Emacs was developed as an interpretation of this style of visual text editor, and it was notably released as free, hackable, and redistributable software (called "free software" by the [Free Software Foundation][2], although the term "free" in this context means "liberated" rather than "gratis").
Other versions have been developed over the years, including [Jove][3], an acronym for "Jonathan Payne's Own Version of Emacs." Jove is a small (it's only 250K) and minimalistic version of Emacs that can prove useful when you find GNU Emacs too bloated for what you need.
### Install Jove
Fedora and Debian both have packages available for Jove, so it's easy to install on Linux. For instance, on Fedora:
```
`$ sudo dnf install jove`
```
You can also compile it yourself from [its source code][3]. You must have development tools and libraries installed (such as LLVM on macOS or [MinGW][4] on Windows).
```
$ wget <ftp://ftp.cs.toronto.edu/pub/moraes/jove/jove-X.Y.Z.tgz>
$ tar xvf jove*z
$ make
$ sudo make install
```
### Launch Jove
Jove is a terminal-based application (there is legacy code to provide a rudimentary GUI, but the library it's based on isn't 64-bit capable). If you're new to Jove or emacs, then you can learn about both from the `teachjove` tutorial. Start the tutorial by typing `teachjove` into a terminal:
```
`$ teachjove`
```
The tutorial is an interactive and guided tour introducing you to the _emacs way_ of entering and manipulating text. This is the easiest way to get started with Jove—and with emacs in general.
After you've done the tutorial, you can launch Jove by just typing `jove` into a terminal.
![Jove][5]
(Seth Kenlon, [CC BY-SA 4.0][6])
### Use Jove
As you might expect, most of what you do in Jove is type text. That's essentially the same regardless of what editor you're using. Working with that text, though, is where things get interesting. For instance, you might find that navigation in Jove feels integrated with other actions you perform because they're built around the **Ctrl** and **Alt** keys, like Copy, Paste, or Select. You can use the **Arrow** keys if you prefer, but try navigating with key combinations like **Ctrl**+**F** (forward) and **Ctrl**+**B** (back), or **Ctrl**+**P** (previous line) and **Ctrl**+**N** (next line). You might find that the unfamiliarity of these key combos is offset by how useful it is to be able to move your cursor around the same way you move text. It's a unified user experience that can help you optimize the way you work with text, whether you deal in prose or code.
Key combinations in Jove, as in GNU Emacs, invoke functions or commands. You can list all available commands with **Alt**+**?**, and you can press the **Space bar** to scroll through the list. This gives you some idea of what you can make your cursor do in the application or how you can make the application behave.
To get more information about any command, type **Alt**+**X** and **describe-command** followed by a command's name, and then press **Enter**. At the top of the Jove screen, you get basic information about the command and any key combinations assigned to it.
For a list of all key combinations, type **Alt**+**X**, then **describe-bindings**, and press **Enter**.
### Simple Emacs
Jove is a small, almost minimal emacs. It doesn't have all the functions and modes that GNU Emacs has, but in a way, that's its strength. Jove is a fast, easy editor to compile, start, and use, without a long list of dependencies. Thanks to Jove, you can set `EDITOR` and `VISUAL` to something in the emacs tradition and still get the responsiveness and speed of something like Vi or Nano.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/12/jove-emacs
作者:[Seth Kenlon][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/seth
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_blue_text_editor_web.png?itok=lcf-m6N7 (Text editor on a browser, in blue)
[2]: http://fsf.org
[3]: ftp://ftp.cs.toronto.edu/pub/moraes/jove
[4]: https://opensource.com/article/20/8/gnu-windows-mingw
[5]: https://opensource.com/sites/default/files/uploads/jove.jpg (Jove)
[6]: https://creativecommons.org/licenses/by-sa/4.0/

View File

@ -0,0 +1,256 @@
[#]: collector: (lujun9972)
[#]: translator: (wxy)
[#]: reviewer: (wxy)
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (8 Git aliases that make me more efficient)
[#]: via: (https://opensource.com/article/20/11/git-aliases)
[#]: author: (Ricardo Gerardi https://opensource.com/users/rgerardi)
8 个让我更有效率的 Git 别名
======
> 使用别名为你最常用或复杂的 Git 命令创建快捷方式。
![橙色背景的终端命令提示][1]
这篇出色的文章《[改变我生活的 7 个 Git 技巧][2]》启发了我写下另一个对我在命令行上使用 Git 的经验有重大影响的 Git 特性:别名。
定义 Git 的别名来替代命令有两大好处。
* 它简化了有许多选项的长命令,使它们更短,更容易记住。
* 缩短了经常使用的命令,使你的工作更有效率。
### 如何定义和使用别名
要定义 Git 的别名,请使用 `git config` 命令,加上别名和要替换的命令。例如,要为 `git push` 创建别名 `p`
```
$ git config --global alias.p 'push'
```
你可以通过将别名作为 `git` 的参数来使用别名,就像其他命令一样:
```
$ git p
```
要查看所有的别名,用 `git config` 列出你的配置:
```
$ git config --global -l
user.name=ricardo
user.email=ricardo@example.com
alias.p=push
```
你也可以用你喜欢的 shell 来定义别名,比如 Bash 或 Zsh。不过用 Git 定义别名有几个功能是用 shell 无法实现的。首先,它允许你在不同的 shell 中使用别名,而无需额外配置。此外,它还集成了 Git 的自动更正功能所以当你输入错误的命令时Git 可以建议你正确的别名。最后Git 还会将别名保存在用户配置文件中,你可以通过复制一个文件将别名转移到其他机器上。
无论使用哪种方法,定义别名都能改善你使用 Git 的整体体验。更多关于定义 Git 别名的信息,请看《[Git Book][4]》。
### 8 个有用的 Git 别名
现在你知道如何创建和使用别名了,来看看一些有用的别名。
#### 1、Git 状态
Git 命令行用户经常使用 `status` 命令来查看已更改或未跟踪的文件。默认情况下,这个命令提供了很多行的冗长输出,你可能不想要或不需要。你可以使用一个别名来处理这两个组件。定义别名 `st` 来缩短命令,并使用选项 `-sb` 来输出一个不那么啰嗦的状态和分支信息。
```
$ git config --global alias.st 'status -sb'
```
如果你在一个干净的分支上使用这个别名,你的输出就像这样:
```
$  git st
## master
```
在一个带有已更改和未跟踪文件的分支上使用它,会产生这样的输出:
```
$ git st
## master
 M test2
?? test3
```
#### 2、Git 单行日志
创建一个别名,以单行方式显示你的提交,使输出更紧凑:
```
$ git config --global alias.ll 'log --oneline'
```
使用这个别名可以提供所有提交的简短列表:
```
$ git ll
33559c5 (HEAD -> master) Another commit
17646c1 test1
```
#### 3、Git 的最近一次提交
这将显示你最近一次提交的详细信息。这是扩展了《Git Book》中 [别名][4] 一章的例子:
```
$ git config --global alias.last 'log -1 HEAD --stat'
```
用它来查看最后的提交:
```
$ git last
commit f3dddcbaabb928f84f45131ea5be88dcf0692783 (HEAD -> branch1)
Author: ricardo <ricardo@example.com>
Date:   Tue Nov 3 00:19:52 2020 +0000
    Commit to branch1
 test2 | 1 +
 test3 | 0
 2 files changed, 1 insertion(+)
```
#### 4、Git 提交
当你对 Git 仓库进行修改时,你会经常使用 `git commit`。使用 `cm` 别名使 `git commit -m` 命令更有效率:
```
$ git config --global alias.cm 'commit -m'
```
因为 Git 别名扩展了命令,所以你可以在执行过程中提供额外的参数:
```
$ git cm "A nice commit message"
[branch1 0baa729] A nice commit message
 1 file changed, 2 insertions(+)
```
#### 5、Git 远程仓库
`git remote -v` 命令列出了所有配置的远程仓库。用别名 `rv` 将其缩短:
```
$ git config --global alias.rv 'remote -v'
```
#### 6、Git 差异
`git diff` 命令可以显示不同提交的文件之间的差异,或者提交和工作树之间的差异。用 `d` 别名来简化它:
```
$ git config --global alias.d 'diff'
```
标准的 `git diff` 命令对小的改动很好用,但对于比较复杂的改动,外部工具如 `vimdiff` 就更有用。创建别名 `dv` 来使用 `vimdiff` 显示差异,并使用 `y` 参数跳过确认提示:
```
$ git config --global alias.dv 'difftool -t vimdiff -y'
```
使用这个别名来显示两个提交之间的 `file1` 差异:
```
$ git dv 33559c5 ca1494d file1
```
![vim-diff results][5]
#### 7、Git 配置列表
`gl` 别名可以更方便地列出所有用户配置:
```
$ git config --global alias.gl 'config --global -l'
```
现在你可以看到所有定义的别名(和其他配置选项):
```
$ git gl
user.name=ricardo
user.email=ricardo@example.com
alias.p=push
alias.st=status -sb
alias.ll=log --oneline
alias.last=log -1 HEAD --stat
alias.cm=commit -m
alias.rv=remote -v
alias.d=diff
alias.dv=difftool -t vimdiff -y
alias.gl=config --global -l
alias.se=!git rev-list --all | xargs git grep -F
```
#### 8、搜索提交
Git 别名允许你定义更复杂的别名,比如执行外部 shell 命令,可以在别名前加上 `!` 字符。你可以用它来执行自定义脚本或更复杂的命令,包括 shell 管道。
例如,定义 `se` 别名来搜索你的提交:
```
$ git config --global alias.se '!git rev-list --all | xargs git grep -F'
```
使用这个别名来搜索提交中的特定字符串:
```
$ git se test2
0baa729c1d683201d0500b0e2f9c408df8f9a366:file1:test2
ca1494dd06633f08519ec43b57e25c30b1c78b32:file1:test2
```
### 自动更正你的别名
使用 Git 别名的一个很酷的好处是它与自动更正功能的原生集成。如果你犯了错误默认情况下Git 会建议使用与你输入的命令相似的命令,包括别名。例如,如果你把 `status` 打成了 `ts`,而不是 `st`Git 会推荐正确的别名:
```
$ git ts
git: 'ts' is not a git command. See 'git --help'.
The most similar command is
        st
```
如果你启用了自动更正功能Git 会自动执行正确的命令:
```
$ git config --global help.autocorrect 20
$ git ts
WARNING: You called a Git command named 'ts', which does not exist.
Continuing in 2.0 seconds, assuming that you meant 'st'.
## branch1
?? test4
```
### 优化 Git 命令
Git 别名是一个很有用的功能它可以优化常见的重复性命令的执行从而提高你的效率。Git 允许你定义任意数量的别名,有些用户会定义很多别名。我更喜欢只为最常用的命令定义别名 —— 定义太多别名会让人难以记忆,而且可能需要查找才能使用。
更多关于别名的内容,包括其他有用的内容,请参见 [Git 维基的别名页面][7]。
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/11/git-aliases
作者:[Ricardo Gerardi][a]
选题:[lujun9972][b]
译者:[wxy](https://github.com/wxy)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/rgerardi
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/terminal_command_linux_desktop_code.jpg?itok=p5sQ6ODE (Terminal command prompt on orange background)
[2]: https://opensource.com/article/20/10/advanced-git-tips
[3]: mailto:ricardo@example.com
[4]: https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases
[5]: https://opensource.com/sites/default/files/uploads/vimdiff.png (vim-diff results)
[6]: https://creativecommons.org/licenses/by-sa/4.0/
[7]: https://git.wiki.kernel.org/index.php/Aliases