{"id":2444,"date":"2015-12-20T23:26:48","date_gmt":"2015-12-20T15:26:48","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=2444"},"modified":"2015-12-20T23:26:48","modified_gmt":"2015-12-20T15:26:48","slug":"%e6%88%91%e7%9a%84%e4%b8%80%e4%ba%9b-bashrc%e6%8a%80%e5%b7%a7","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/2444.html","title":{"rendered":"\u6211\u7684\u4e00\u4e9b.bashrc\u6280\u5de7"},"content":{"rendered":"<p>=Start=<\/p>\n<pre class=\"lang:default decode:true \">#urldecode\/urlencode\nalias urldecode='python -c \"import sys, urllib as ul; \\\n    print ul.unquote_plus(sys.argv[1])\"'\n\nalias urlencode='python -c \"import sys, urllib as ul; \\\n    print ul.quote_plus(sys.argv[1])\"'\n\n#rot13 encode\nalias rot13=\"tr 'a-zA-Z' 'n-za-mN-ZA-M'\"<\/pre>\n<pre class=\"lang:default decode:true \">#Bash history\nexport HISTFILESIZE=999999\nexport HISTSIZE=999999\nshopt -s histappend\nHISTTIMEFORMAT=\"@%F_%T \"\nexport HISTTIMEFORMAT\n\n#MySQL\nexport MYSQL_PS1=\"\\u@\\h [\\d]&gt; \"<\/pre>\n<pre class=\"lang:default decode:true \">mcd() { mkdir -p \"$1\"; cd \"$1\"; }\nmtoday() { mkdir -p \"$HOME\/$(date +%Y_%B)\/$(date +%Y-%-m-%-d)\"; cd \"$HOME\/$(date +%Y_%B)\/$(date +%Y-%-m-%-d)\"; }\nbackup() { cp \"$1\"{,.bak}; }\nmd5check() { md5sum \"$1\" | grep \"$2\"; }\nsha1check() { sha1sum \"$1\" | grep \"$2\"; }\n\nmd5dir() {\n    if [ -d \"$1\" ]; then\n        path=$(readlink -f \"$1\")\n        save_name=$(date +%Y%m%d)$(echo \"$path\" | tr '\/' '_')\n        find \"$path\" -type f -print0 | xargs -0 md5sum &gt; \"$save_name\".md5\n    else\n        echo \"'$1' is not a directory !!!\"\n    fi\n}\n\nextract() {\n    if [ -f $1 ] ; then\n      case $1 in\n        *.tar.bz2)   tar xjf $1     ;;\n        *.tar.gz)    tar xzf $1     ;;\n        *.bz2)       bunzip2 $1     ;;\n        *.rar)       unrar e $1     ;;\n        *.gz)        gunzip $1      ;;\n        *.tar)       tar xf $1      ;;\n        *.tbz2)      tar xjf $1     ;;\n        *.tgz)       tar xzf $1     ;;\n        *.zip)       unzip $1       ;;\n        *.Z)         uncompress $1  ;;\n        *.7z)        7z x $1        ;;\n        *) echo \"'$1' cannot be extracted via extract()\" ;;\n      esac\n    else\n        echo \"'$1' is not a valid file\"\n    fi\n}<\/pre>\n<pre class=\"lang:default decode:true \">alias genpasswd=\"strings \/dev\/urandom | grep -o '[[:alnum:]]' | head -n 30 | tr -d '\\n'; echo\"\nalias genpasswd2=\"uuidgen\"\n\nalias listen='netstat -lntp'\nalias listen2='sudo lsof -P -i -n'\nalias wuliao='man $(ls \/bin | shuf | head -1)'\nalias dirtree=\"ls -R | grep \":$\" | sed -e 's\/:$\/\/' -e 's\/[^-][^\\\/]*\\\/\/--\/g' -e 's\/^\/   \/' -e 's\/-\/|\/'\"<\/pre>\n<p>=EOF=<\/p>\n","protected":false},"excerpt":{"rendered":"<p>=Start= #urldecode\/urlencode alias urldecode=&#8217;python -c [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,11,12],"tags":[83],"class_list":["post-2444","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-linux","category-tools","tag-bash"],"views":5240,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2444","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=2444"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2444\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=2444"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=2444"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=2444"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}