大家好,欢迎来到IT知识分享网。
安装 p7zip 然后将下面内容放到 ~/.zshrc 或者 ~/.bashrc
function 7zz() { # compress a direcotry to directory.7z # usage: 7zz path/to/directory [7z options] # returns: 0 - successful, 1 - argument error, 2 - not found 7z command local ok=$(command -v 7z >/dev/null 2>/dev/null && echo 'ok' || echo '') if [ "$ok" != "ok" ]; then echo 'not found 7z command, please install p7zip' return 2 fi local dir="$1" local target="$(basename ${dir%/}.7z)" if [ ! -d "$dir" ]; then echo 'argument error\nusage: 7zz path/to/directory [7z options]' return 1 fi if [ -f "$target" ]; then while true; do printf "Are you sure overwrite file \"$target\"? [y/N] " read yn case $yn in [yY][eE][sS] | [yY]) break ;; [nN][oO] | [nN] | "") return 0 ;; *) ;; esac done rm -f "$target" fi shift 7z a -mx=9 -xr\!.DS_Store "$@" "$target" "$dir" }
然后打开新会话或者重新载入配置文件
source ~/.zshrc
或者
source ~/.bashrc
命令格式:
7zz 目录 [7z的参数]
例子1:压缩 abc 目录为 abc.7z
7zz abc
例子2: 压缩vscode的扩展目录,并且排除cocos扩展,重命名为vscode_extensions.7z
7zz ~/.vscode/extensions -xr\!cocos-creator -xr\!cocos-debug && mv {,vscode_}extensions.7z
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/30409.html