{"id":171788,"date":"2020-02-09T08:14:12","date_gmt":"2020-02-09T00:14:12","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=171788"},"modified":"2020-02-07T11:15:12","modified_gmt":"2020-02-07T03:15:12","slug":"bash-commands","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/bash-commands.html","title":{"rendered":"Bash\u79d8\u7c4d\u65e0\u79c1\u5206\u4eab"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u901a\u8fc7\u522b\u540d\u548c\u5176\u4ed6\u6377\u5f84\u6765\u63d0\u9ad8\u4f60\u7ecf\u5e38\u5fd8\u8bb0\u7684\u90a3\u4e9b\u4e8b\u60c5\u7684\u6548\u7387\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5206\u4eab\u4e86\u6211\u6700\u559c\u6b22\u7684\u8fd9\u4e9b\u52a9\u624b\u547d\u4ee4\uff0c\u5bf9\u4e8e\u6211\u7ecf\u5e38\u9057\u5fd8\u7684\u4e8b\u60c5\uff0c\u5b83\u4eec\u5f88\u6709\u7528\uff0c\u4e5f\u5e0c\u671b\u8fd9\u53ef\u4ee5\u5e2e\u52a9\u5230\u4f60\uff0c\u4ee5\u53ca\u4e3a\u4f60\u89e3\u51b3\u4e00\u4e9b\u7ecf\u5e38\u5934\u75bc\u7684\u95ee\u9898\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u8981\u662f\u4f60\u6574\u5929\u4f7f\u7528\u8ba1\u7b97\u673a\uff0c\u5982\u679c\u80fd\u627e\u5230\u9700\u8981\u91cd\u590d\u6267\u884c\u7684\u547d\u4ee4\u5e76\u8bb0\u4e0b\u5b83\u4eec\u4ee5\u4fbf\u4ee5\u540e\u8f7b\u677e\u4f7f\u7528\u90a3\u5c31\u592a\u68d2\u4e86\u3002\u5b83\u4eec\u5168\u90fd\u5446\u5728\u90a3\u91cc\uff0c\u85cf\u5728 ~\/.bashrc \u4e2d\uff08\u6216 zsh \u7528\u6237\u7684 ~\/.zshrc \u4e2d\uff09\uff0c\u7b49\u5f85\u7740\u6539\u5584\u4f60\u7684\u751f\u6d3b\uff01<\/p>\n

\u5b8c\u4e8b\u5431\u4e00\u58f0<\/strong><\/div>\n

\u5f53\u6211\u6267\u884c\u4e00\u4e2a\u9700\u8981\u957f\u65f6\u95f4\u8fd0\u884c\u7684\u547d\u4ee4\u65f6\uff0c\u6211\u7ecf\u5e38\u91c7\u7528\u591a\u4efb\u52a1\u7684\u65b9\u5f0f\uff0c\u7136\u540e\u5c31\u5fc5\u987b\u56de\u5934\u53bb\u68c0\u67e5\u8be5\u64cd\u4f5c\u662f\u5426\u5df2\u5b8c\u6210\u3002\u7136\u800c\u901a\u8fc7\u6709\u7528\u7684 say \u547d\u4ee4\uff0c\u73b0\u5728\u5c31\u4e0d\u7528\u518d\u8fd9\u6837\u4e86\uff08\u8fd9\u662f\u5728 MacOS \u4e0a\uff1b\u8bf7\u6839\u636e\u4f60\u7684\u672c\u5730\u73af\u5883\u66f4\u6539\u4e3a\u7b49\u6548\u7684\u65b9\u5f0f\uff09\uff1a<\/p>\n

function looooooooong {\r\nSTART=$(date +%s.%N)\r\n$*\r\nEXIT_CODE=$?\r\nEND=$(date +%s.%N)\r\nDIFF=$(echo \"$END - $START\" | bc)\r\nRES=$(python -c \"diff = $DIFF; min = int(diff \/ 60); print('%s min' % min)\")\r\nresult=\"$1 completed in $RES, exit code $EXIT_CODE.\"\r\necho -e \"\\n⏰ $result\"\r\n( say -r 250 $result 2>&1 > \/dev\/null & )\r\n}<\/pre>\n

\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u8bb0\u5f55\u547d\u4ee4\u7684\u5f00\u59cb\u548c\u7ed3\u675f\u65f6\u95f4\uff0c\u8ba1\u7b97\u6240\u9700\u7684\u5206\u949f\u6570\uff0c\u5e76\u201c\u8bf4\u201d\u51fa\u8c03\u7528\u7684\u547d\u4ee4\u3001\u82b1\u8d39\u7684\u65f6\u95f4\u548c\u9000\u51fa\u7801\u3002\u5f53\u7b80\u5355\u7684\u63a7\u5236\u53f0\u94c3\u58f0\u65e0\u6cd5\u4f7f\u7528\u65f6\uff0c\u6211\u53d1\u73b0\u8fd9\u4e2a\u8d85\u7ea7\u6709\u7528\u3002<\/p>\n

\u5b89\u88c5\u5c0f\u52a9\u624b<\/strong><\/div>\n

\u6211\u5728\u5c0f\u65f6\u5019\u5c31\u5f00\u59cb\u4f7f\u7528 Ubuntu\uff0c\u800c\u6211\u9700\u8981\u5b66\u4e60\u7684\u7b2c\u4e00\u4ef6\u4e8b\u5c31\u662f\u5982\u4f55\u5b89\u88c5\u8f6f\u4ef6\u5305\u3002\u6211\u66fe\u7ecf\u9996\u5148\u6dfb\u52a0\u7684\u522b\u540d\u4e4b\u4e00\u662f\u5b83\u7684\u52a9\u624b\uff08\u6839\u636e\u5f53\u5929\u7684\u6d41\u884c\u6897\u547d\u540d\u7684\uff09\uff1a<\/p>\n

alias canhas=\"sudo apt-get install -y\"<\/pre>\n
GPG \u7b7e\u540d<\/strong><\/div>\n

\u6709\u65f6\u5019\uff0c\u6211\u5fc5\u987b\u5728\u6ca1\u6709 GPG \u6269\u5c55\u7a0b\u5e8f\u6216\u5e94\u7528\u7a0b\u5e8f\u7684\u60c5\u51b5\u4e0b\u7ed9\u7535\u5b50\u90ae\u4ef6\u7b7e\u7f72\u00a0GPG \u7b7e\u540d\uff0c\u6211\u4f1a\u8df3\u5230\u547d\u4ee4\u884c\u5e76\u4f7f\u7528\u4ee5\u4e0b\u4ee4\u4eba\u8ba8\u538c\u7684\u522b\u540d\uff1a<\/p>\n

alias gibson=\"gpg --encrypt --sign --armor\"\r\nalias ungibson=\"gpg --decrypt\"<\/pre>\n
Docker<\/strong><\/div>\n

Docker \u7684\u5b50\u547d\u4ee4\u5f88\u591a\uff0c\u4f46\u662f Docker compose \u7684\u66f4\u591a\u3002\u6211\u66fe\u7ecf\u4f7f\u7528\u8fd9\u4e9b\u522b\u540d\u6765\u5c06\u00a0--rm<\/code> \u6807\u5fd7\u4e22\u5230\u8111\u540e\uff0c\u4f46\u662f\u73b0\u5728\u4e0d\u518d\u4f7f\u7528\u8fd9\u4e9b\u6709\u7528\u7684\u522b\u540d\u4e86\uff1a<\/p>\n

alias dc=\"docker-compose\"\r\nalias dcr=\"docker-compose run --rm\"\r\nalias dcb=\"docker-compose run --rm --build\"<\/pre>\n
Google Cloud \u7684 gcurl \u52a9\u624b<\/strong><\/div>\n

\u5bf9\u4e8e\u6211\u6765\u8bf4\uff0cGoogle Cloud \u662f\u4e00\u4e2a\u76f8\u5bf9\u8f83\u65b0\u7684\u4e1c\u897f\uff0c\u800c\u5b83\u6709\u6781\u591a\u7684\u6587\u6863\u3002gcurl\u00a0\u662f\u4e00\u4e2a\u522b\u540d\uff0c\u53ef\u786e\u4fdd\u5728\u7528\u5e26\u6709\u8eab\u4efd\u9a8c\u8bc1\u6807\u5934\u7684\u672c\u5730 curl\u00a0\u547d\u4ee4\u8fde\u63a5 Google Cloud API \u65f6\uff0c\u53ef\u4ee5\u83b7\u5f97\u6240\u6709\u6b63\u786e\u7684\u6807\u5934\u3002<\/p>\n

Git \u548c ~\/.gitignore<\/strong><\/div>\n

\u6211\u5de5\u4f5c\u4e2d\u7528 Git \u5f88\u591a\uff0c\u56e0\u6b64\u6211\u6709\u4e00\u4e2a\u4e13\u95e8\u7684\u90e8\u5206\u6765\u4ecb\u7ecd Git \u52a9\u624b\u3002<\/p>\n

\u6211\u6700\u6709\u7528\u7684\u52a9\u624b\u4e4b\u4e00\u662f\u6211\u7528\u6765\u514b\u9686 GitHub \u5b58\u50a8\u5e93\u7684\u3002\u4f60\u4e0d\u5fc5\u8fd0\u884c\uff1a<\/p>\n

git clone git@github.com:org\/repo \/Users\/glasnt\/git\/org\/repo<\/pre>\n

\u6211\u8bbe\u7f6e\u4e86\u4e00\u4e2a\u514b\u9686\u51fd\u6570\uff1a<\/p>\n

clone(){\r\n\u00a0 \u00a0 echo Cloning $1 to ~\/git\/$1\r\n\u00a0 \u00a0 cd ~\/git\r\n\u00a0 \u00a0 git clone git@github.com:$1 $1\r\n\u00a0 \u00a0 cd $1\r\n}<\/pre>\n

\u5373\u4f7f\u6bcf\u6b21\u8fdb\u5165\u00a0~\/.bashrc\u00a0\u6587\u4ef6\u770b\u5230\u8fd9\u4e2a\u65f6\uff0c\u6211\u603b\u662f\u4f1a\u5fd8\u8bb0\u548c\u50bb\u7b11\uff0c\u6211\u4e5f\u6709\u4e00\u4e2a\u201c\u5237\u65b0\u4e0a\u6e38\u201d\u547d\u4ee4\uff1a<\/p>\n

alias yoink=\"git checkout master && git fetch upstream master && git merge upstream\/master\"<\/pre>\n

\u7ed9 Git \u4e00\u65cf\u7684\u53e6\u4e00\u4e2a\u52a9\u624b\u662f\u5168\u5c40\u5ffd\u7565\u6587\u4ef6\u3002\u5728\u4f60\u7684\u00a0git config --global --list\u00a0\u4e2d\uff0c\u4f60\u5e94\u8be5\u770b\u5230\u4e00\u4e2a\u00a0core.excludesfile\u3002\u5982\u679c\u6ca1\u6709\uff0c\u8bf7\u521b\u5efa\u4e00\u4e2a\uff0c\u7136\u540e\u5c06\u4f60\u603b\u662f\u653e\u5230\u5404\u4e2a\u00a0.gitignore\u6587\u4ef6\u4e2d\u7684\u5185\u5bb9\u586b\u6ee1\u5b83\u3002\u4f5c\u4e3a MacOS \u4e0a\u7684 Python \u5f00\u53d1\u4eba\u5458\uff0c\u5bf9\u6211\u6765\u8bf4\uff0c\u8fd9\u4e9b\u5185\u5bb9\u662f\uff1a<\/p>\n

.DS_Store \u00a0 \u00a0 # macOS clutter\r\nvenv\/ \u00a0 \u00a0 \u00a0 \u00a0 # I never want to commit my virtualenv\r\n*.egg-info\/* \u00a0# ... nor any locally compiled packages\r\n__pycache__ \u00a0 # ... or source\r\n*.swp \u00a0 \u00a0 \u00a0 \u00a0 # ... nor any files open in vim<\/pre>\n

\u4f60\u53ef\u4ee5\u5728\u00a0Gitignore.io\u00a0\u6216 GitHub \u4e0a\u7684\u00a0Gitignore \u5b58\u50a8\u5e93\u4e0a\u627e\u5230\u5176\u4ed6\u5efa\u8bae\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u8981\u662f\u4f60\u6574\u5929\u4f7f\u7528\u8ba1\u7b97\u673a\uff0c\u5982\u679c\u80fd\u627e\u5230\u9700\u8981\u91cd\u590d\u6267\u884c\u7684\u547d\u4ee4\u5e76\u8bb0\u4e0b\u5b83\u4eec\u4ee5\u4fbf\u4ee5\u540e\u8f7b\u677e\u4f7f\u7528\u90a3\u5c31\u592a\u68d2\u4e86\u3002\u5b83\u4eec\u5168\u90fd\u5446\u5728\u90a3\u91cc\uff0c\u85cf\u5728 […]<\/p>\n","protected":false},"author":323,"featured_media":163467,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-171788","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/171788","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/323"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=171788"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/171788\/revisions"}],"predecessor-version":[{"id":171791,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/171788\/revisions\/171791"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/163467"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=171788"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=171788"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=171788"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}