{"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":"
\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 |