win10管理凌亂桌面
Effective collaboration, especially in open source software development, starts with effective organization. To make sure that nothing gets missed, the general rule, “one issue, one pull request” is a nice rule of thumb.
有效的協作(特別是在開源軟件開發中)始于有效的組織。 為確保不會遺漏任何東西,一般規則“一個問題,一個請求請求”是一個很好的經驗法則。
Instead of opening an issue with a large scope like, “Fix all the broken links in the documentation,” open source projects will have more luck attracting contributors with several smaller and more manageable issues.
開源項目不會像“修復文檔中所有斷開的鏈接”這樣的大問題,而是會吸引更多的貢獻者,幫助他們解決一些更小,更易于管理的問題。
In the preceding example, you might scope broken links by section or by page. This allows more contributors to jump in and dedicate small windows of their time, rather than waiting for one person to take on a larger and more tedious contribution effort.
在前面的示例中,您可以按節或按頁劃分損壞的鏈接的范圍。 這樣一來,更多的貢獻者就可以投入并奉獻自己的時間,而不是等待一個人承擔更大,更乏味的貢獻。
Smaller scoped issues also help project maintainers see where work has been completed and where it hasn’t. This reduces the chances that some part of the issue is missed, assumed to be completed, and later leads to bugs or security vulnerabilities.
范圍較小的問題還可以幫助項目維護人員查看工作已完成和未完成的地方。 這樣可以減少錯過問題的某些部分(假定已完成)的機會,并在以后導致錯誤或安全漏洞。
That’s all well and good. But what if you’ve already opened several massively-scoped issues, some PRs have already been submitted or merged, and you currently have no idea where the work started or stopped?
一切都很好。 但是,如果您已經打開了幾個范圍廣泛的問題,已經提交或合并了一些PR,而您目前不知道工作在哪里開始或停止,該怎么辦?
It’s going to take a little sorting out to get the state of your project back under control. Thankfully, there are a number of command line tools to help you scan, sort, and make sense of a messy repository. Here’s a small selection of ones I use.
需要進行一些整理以使項目狀態重新得到控制。 值得慶幸的是,有許多命令行工具可幫助您掃描,排序和理解混亂的存儲庫。 這是我使用的一小部分。
用vim
交互式搜索和替換 (Interactive search-and-replace with vim
)
You can open a file in Vim, then interactively search and replace with:
您可以在Vim中打開文件,然后以交互方式搜索并替換為:
:%s/\<word\>/newword/gc
The %
indicates to look in all lines of the current file, s
is for substitute, \<word\>
matches the whole word, and the g
for “global” is for every occurrence. The c
at the end will let you view and confirm each change before it’s made. You can run it automatically, and much faster, without c
, but you put yourself at risk of complicating things if you’ve made a pattern-matching error.
%
表示在當前文件的所有行中查找, s
表示替代, \<word\>
匹配整個單詞,而g
表示“ global”,表示每次出現。 最后的c
可以讓您查看并確認每個更改,然后再進行更改。 您可以在沒有c
情況下自動且以更快的速度運行它,但是如果發生模式匹配錯誤,您就有使事情復雜化的風險。
使用節點模塊在Markdown文件中查找無效鏈接 (Find dead links in Markdown files with a node module)
The markdown-link-check node module has a great CLI buddy.
markdown-link-check節點模塊具有出色的CLI伙伴 。
I use this so often I turned it into a Bash alias function. To do the same, add this to your .bashrc
:
我經常使用它,因此將它變成Bash別名函數 。 為此,請將其添加到您的.bashrc
:
# Markdown link check in a folder, recursive
function mlc () {find $1 -name \*.md -exec markdown-link-check -p {} \;
}
Then run with mlc <filename>
.
然后使用mlc <filename>
運行。
列出具有或不具有git存儲庫的子目錄以及find
(List subdirectories with or without a git repository with find
)
Print all subdirectories that are git repositories, or in other words, have a .git
in them:
打印所有屬于git存儲庫的子目錄,或者換句話說,其中包含.git
:
find . -maxdepth 1 -type d -exec test -e '{}/.git' ';' -printf "is git repo: %p\n"
To print all subdirectories that are not git repositories, negate the test with !
:
要打印不是git存儲庫的所有子目錄,請使用!
取消測試!
:
find . -maxdepth 1 -type d -exec test '!' -e '{}/.git' ';' -printf "not git repo: %p\n"
使用xargs
從列表中拉出多個git存儲庫 (Pull multiple git repositories from a list with xargs
)
I initially used this as part of automatically re-creating my laptop with Bash scripts, but it’s pretty handy when you’re working with cloud instances or Dockerfiles.
我最初將其用作使用Bash腳本自動重新創建筆記本電腦的一部分,但是當您使用云實例或Dockerfiles時,它非常方便。
Given a file, repos.txt
with a repository’s SSH link on each line (and your SSH keys set up), run:
給定文件repos.txt
并在每行上包含存儲庫的SSH鏈接(并設置SSH密鑰),運行:
xargs -n1 git clone < repos.txt
If you want to pull and push many repositories, I previously wrote about how to use a Bash one-liner to manage your repositories.
如果您想拉動很多存儲庫,我之前曾寫過關于如何使用Bash一線管理存儲庫的文章 。
用數字表的問題jot
(List issues by number with jot
)
I’m a co-author and maintainer for the OWASP Web Security Testing Guide repository where I recently took one large issue (yup, it was “Fix all the broken links in the documentation” - how’d you guess?) and broke it up into several smaller, more manageable issues. A whole thirty-seven smaller, more manageable issues.
我是OWASP Web安全測試指南存儲庫的合著者和維護者,最近在該存儲庫中遇到了一個大問題(是的,這是“修復文檔中所有斷開的鏈接” –您怎么猜?)并破壞了它分成幾個較小的,更易于管理的問題。 總共37個較小的,更易于管理的問題。
I wanted to enumerate all the issues that the original one became, but the idea of typing out thirty-seven issue numbers (#275 through #312) seemed awfully tedious and time-consuming. So, in natural programmer fashion, I spent the same amount of time I would have used to type out all those numbers and crafted a way to automate it instead.
我想列舉一下原來的所有問題,但是輸入37個問題編號(#275至#312)的想法似乎很繁瑣且耗時。 因此,以自然的程序員方式,我花費了與原本要鍵入所有這些數字相同的時間,并設計了一種自動化的方法。
The jot
utility (apt install athena-jot
) is a tiny tool that’s a big help when you want to print out some numbers. Just tell it how many you want, and where to start and stop.
jot
實用程序( apt install athena-jot
)是一個很小的工具,當您要打印一些數字時, apt install athena-jot
您有很大幫助。 只需告訴它您想要多少,以及在哪里開始和停止。
# jot [ reps [ begin [ end ] ] ]
jot 37 275 312
This prints each number, inclusively, from 275 to 312 on a new line. To make these into issue number notations that GitHub and many other platforms automatically recognize and turn into links, you can pipe the output to awk
.
這會在新行上打印每個數字(包括275至312)。 為了使這些成為GitHub和許多其他平臺自動識別并轉化為鏈接的問題編號符號,您可以將輸出傳遞給awk
。
jot 37 275 312 | awk '{printf "#"$0", "}'#275, #276, #277, #278, #279, #280, #281, #282, #283, #284, #285, #286, #287, #288, #289, #290, #291, #292, #293, #295, #296, #297, #298, #299, #300, #301, #302, #303, #304, #305, #306, #307, #308, #309, #310, #311, #312
You can also use jot
to generate random or redundant data, mainly for development or testing purposes.
您還可以使用jot
生成隨機或冗余數據,主要用于開發或測試目的。
CLI驅動的開源組織 (CLI-powered open source organization)
A well-organized open source repository is a well-maintained open source project. Save this post for handy reference, and use your newfound CLI superpowers for good! 🚀
組織良好的開源資源庫是維護良好的開源項目。 保存此帖子以方便參考,并永久使用您新發現的CLI超級功能! 🚀
翻譯自: https://www.freecodecamp.org/news/command-line-tricks-for-managing-your-messy-open-source-repository/
win10管理凌亂桌面