惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tenable Blog
H
Heimdal Security Blog
K
Kaspersky official blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
S
Schneier on Security
G
GRAHAM CLULEY
U
Unit 42
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
C
CERT Recently Published Vulnerability Notes
Google DeepMind News
Google DeepMind News
罗磊的独立博客
Stack Overflow Blog
Stack Overflow Blog
阮一峰的网络日志
阮一峰的网络日志
Simon Willison's Weblog
Simon Willison's Weblog
C
Cisco Blogs
Cyberwarzone
Cyberwarzone
T
The Exploit Database - CXSecurity.com
Project Zero
Project Zero
Security Archives - TechRepublic
Security Archives - TechRepublic
www.infosecurity-magazine.com
www.infosecurity-magazine.com
博客园 - 司徒正美
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
V
Visual Studio Blog
博客园 - Franky
Engineering at Meta
Engineering at Meta
WordPress大学
WordPress大学
Jina AI
Jina AI
P
Proofpoint News Feed
P
Proofpoint News Feed
有赞技术团队
有赞技术团队
L
LINUX DO - 最新话题
宝玉的分享
宝玉的分享
N
News and Events Feed by Topic
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
博客园 - 聂微东
T
The Blog of Author Tim Ferriss
Spread Privacy
Spread Privacy
Application and Cybersecurity Blog
Application and Cybersecurity Blog
IT之家
IT之家
S
Security Affairs
博客园 - 叶小钗
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
小众软件
小众软件
N
News | PayPal Newsroom
Cloudbric
Cloudbric
AWS News Blog
AWS News Blog
W
WeLiveSecurity
The Last Watchdog
The Last Watchdog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
NISL@THU
NISL@THU

博客园 - Bob-wei

Visual Studio 配置额外工具 Windows Terminal 等 CMakeList.txt Windows Terminal 配置文件 C# 7.2 中 In参数( in parameter )的性能比较 JavaScript 的 parseInt(x), parseFloat(x), Number(x), +x, ~~x, x>>>0, isNaN(x) 区别和结果 Windows Terminal 配置 git-bash,集成右键菜单,集成VSCode 恢复WIn10 2004的“要使用本计算机,用户必须输入用户名和密码”选项 plantuml server with math docker image aspnetcore singleton service in app.use Chrome 不跟随 macOS 系统主题改变深色模式 VSCode的浅色主题(Default Light+)侧边活动栏改为浅色 VSCode_Extensions C++ in VSCode 用户中心 - 博客园 C# 私有字段前缀 _ 的设置(VS2019, .editorconfig) dotnet 跨平台编译发布 重新调整动态vhdx占用的空间 通过git-bash一句话获得当前目录的全部csproj文件绝对路径 devdocs
[bash] 编写7zz函数替换7z压缩命令
Bob-wei · 2020-05-07 · via 博客园 - Bob-wei

安装 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