diff --git a/.gitignore b/.gitignore index e41a0cd..a1db5fe 100644 --- a/.gitignore +++ b/.gitignore @@ -126,3 +126,5 @@ golang/pkg/ golang/bin/ golang/src/github.com/ golang/src/gopkg.in/ + +site/ diff --git a/AEE5C04E-1C5F-4BBF-982B-B3B051538EEA.png b/AEE5C04E-1C5F-4BBF-982B-B3B051538EEA.png new file mode 100644 index 0000000..7885c19 Binary files /dev/null and b/AEE5C04E-1C5F-4BBF-982B-B3B051538EEA.png differ diff --git a/README.md b/README.md index 21d34e2..60ac368 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ ## 复制常用命令 +[常用命令](https://cmd.wxnacy.com) + ![t34KxS.gif](https://s1.ax1x.com/2020/06/01/t34KxS.gif) @@ -32,3 +34,7 @@ # 查看磁盘使用情况 ![t3WzZR.gif](https://s1.ax1x.com/2020/06/01/t3WzZR.gif) + +# 开启/关闭 WIFI + +![N1SOY9.gif](https://s1.ax1x.com/2020/06/20/N1SOY9.gif) diff --git a/commands/cmd_docker b/commands/cmd_docker index 4bd196a..1943f3a 100644 --- a/commands/cmd_docker +++ b/commands/cmd_docker @@ -22,6 +22,5 @@ docker --version docker version # 查看 docker 详情 docker info - # 重新创建容器,并在后台运行 docker-compose up --force-recreate -d diff --git a/commands/cmd_mac b/commands/cmd_mac index e17549d..86f8c4f 100644 --- a/commands/cmd_mac +++ b/commands/cmd_mac @@ -3,12 +3,23 @@ defaults write com.apple.finder AppleShowAllFiles yes; killall Finder /System/Li # 在文件夹不显示隐藏文件 defaults write com.apple.finder AppleShowAllFiles no; killall Finder /System/Library/CoreServices/Finder.app -# 列出本机所有网络服务 -networksetup -listallnetworkservices +# 清空DNS缓存 +dscacheutil -flushcache # 查看 Mac 系统内网 ip ifconfig | grep en0 -A 3 | grep 'inet ' | awk '{print $2}' - # 系统软件总览 system_profiler SPSoftwareDataType + +# 扫描附近可用 Wifi热点 +/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport scan + +# 列出本机所有网络服务 +networksetup -listallnetworkservices +# 关闭 Wifi +networksetup -setairportpower en0 off +# 启动 WIFI +networksetup -setairportpower en0 on +# 加入 WIFI +networksetup -setairportnetwork en0 diff --git a/common.py b/common.py new file mode 100644 index 0000000..0e7b3dc --- /dev/null +++ b/common.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python +# -*- coding:utf-8 -*- +# Author: wxnacy(wxnacy@gmail.com) +# Description: +import os + + +def read_file(filename): + '''读取文件,并返回列表''' + with open(filename, 'r') as f: + return [o.strip('\n').strip(" ") for o in f.readlines()] + +def read_cmd(filename): + ''' + 读取指令文件 + ''' + lines = read_file(filename) + lines = list(filter(lambda x: x, lines)) + items = [] + num = int(len(lines) / 2) + # 设置 icon + # 查找是否存在如下对应文件 + # ./commands/cmd_{category} + # ./icon/{category}.png + cmd_name = os.path.basename(filename).split("_")[1] + icon = './icon.png' + cmd_icon_path = './icon/{}.png'.format(cmd_name) + if os.path.exists(cmd_icon_path): + icon = cmd_icon_path + for i in range(num): + item = dict( + title = lines[i * 2 + 1], + subtitle = lines[i * 2], + icon = icon, + valid = True, + ) + item['arg'] = item['title'] + items.append(item) + return items + +# def read_json(filename): + # lines = [] + # with open(filename, 'r') as f: + # lines = f.readlines() + # return json.loads(''.join(lines)) + +# def read_csv(filename): + # lines = [] + # with open(filename, 'r') as f: + # lines = f.readlines() + # logging.info(lines) + # items = [] + # for line in lines: + # ls = line.split(',') + # item = dict(title = ls[0].strip(" "), subtitle = ls[1].strip(" ")) + # items.append(item) + # return items diff --git a/convert.py b/convert.py new file mode 100644 index 0000000..40aad32 --- /dev/null +++ b/convert.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python +# -*- coding:utf-8 -*- +# Author: wxnacy(wxnacy@gmail.com) +# Description: + +import os +import shutil +from common import read_cmd + + +YML = ''' +site_name: 常用命令 # 站点名称 +nav: # 文档目录 + - 首页: index.md + {} +theme: readthedocs # 主题 +''' + +SOURCE_DIR = 'commands' +OUTPUT_DIR = 'docs' + +def cmd2md(filename): + filepath = f'{SOURCE_DIR}/{filename}' + outfile = f'{OUTPUT_DIR}/{fmt_name(filename)}.md' + input_lines = read_cmd(filepath) + outlines = [] + input_lines.sort(key = lambda x: x['title']) + title_key = set() + for line in input_lines: + title = line['subtitle'] + cmd = line['title'] + cmd_begin = ' '.join(cmd.split(" ")[:2]) + if cmd_begin not in title_key: + title_key.add(cmd_begin) + outlines.append(f"## {cmd_begin}\n") + + title = f'**{title[2:]}**\n' + cmd = f'```\n{cmd}\n```\n' + + outlines.append(title) + outlines.append(cmd) + with open(outfile, 'w') as out: + out.writelines(outlines) + +def fmt_name(name): + return name[4:] + +def first_upper(name): + return name[0].upper() + name[1:] + +def cmd2mdname(name): + return fmt_name(name) + '.md' + +def main(dirname): + '''转换''' + files = os.listdir(dirname) + files.sort() + navs = [] + for f in files: + if not f.startswith('cmd_'): + continue + cmd2md(f) + navs.append(f'- {first_upper(fmt_name(f))}: {fmt_name(f)}.md') + + # shutil.move(f'{OUTPUT_DIR}/{cmd2mdname(files[0])}', f'{OUTPUT_DIR}/index.md') + nav = '\n '.join(navs) + # nav = nav.replace(cmd2mdname(files[0]), 'index.md') + yml = YML.format(nav) + with open('mkdocs.yml', 'w') as f: + f.write(yml) + + + + + + +if __name__ == "__main__": + main(SOURCE_DIR) diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..825003f --- /dev/null +++ b/deploy.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# Author: wxnacy(wxnacy@gmail.com) +# Description: + +python convert.py + +for file in `find site | grep '\.'` +do + outfile=`python -c "print('${file}'.replace('site/', ''))"` + ossutil cp -u $file oss://cmd-cn/${outfile} +done diff --git a/docs/docker.md b/docs/docker.md new file mode 100644 index 0000000..3ee2f49 --- /dev/null +++ b/docs/docker.md @@ -0,0 +1,63 @@ +## docker --version +**查看版本** +``` +docker --version +``` +## docker build +**在当前目录创建镜像** +``` +docker build -t . +``` +## docker container +**重启容器** +``` +docker container restart +``` +## docker exec +**在交互模式下进入容器,并进入 bash 环境** +``` +docker exec -it /bin/bash +``` +## docker image +**查看镜像列表** +``` +docker image ls +``` +## docker info +**查看 docker 详情** +``` +docker info +``` +## docker logs +**从最后 10 行开始实时查看日志** +``` +docker logs -f --tail 10 +``` +**从最后 10 行开始实时查看日志并过滤信息** +``` +docker logs -f --tail 10 2>&1 | grep +``` +## docker ps +**查看当前运行的进程列表** +``` +docker ps +``` +**查看所有进程列表** +``` +docker ps -a +``` +## docker restart +**重启所有服务** +``` +docker restart `docker ps -a | awk '{print $1}'` +``` +## docker version +**分别查看 client 和 server 的版本** +``` +docker version +``` +## docker-compose up +**重新创建容器,并在后台运行** +``` +docker-compose up --force-recreate -d +``` diff --git a/docs/ffmpeg.md b/docs/ffmpeg.md new file mode 100644 index 0000000..5a61bbb --- /dev/null +++ b/docs/ffmpeg.md @@ -0,0 +1,10 @@ +## ffmpeg -i +**m3u8 转为 mp4** +``` +ffmpeg -i -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 +``` +## ffmpeg -ss +**截取视频** +``` +ffmpeg -ss -t -i -vcodec copy -acodec copy +``` diff --git a/docs/git.md b/docs/git.md new file mode 100644 index 0000000..070bb44 --- /dev/null +++ b/docs/git.md @@ -0,0 +1,94 @@ +## git add +**将所有新增、修改的文件提交到索引中** +``` +git add --ignore-removal . +``` +**将所有新增、修改、删除的文件提交到索引中** +``` +git add -A +``` +**将所有修改、删除的文件提交到索引中** +``` +git add -u +``` +**将所有新增、修改、删除的文件提交到索引中** +``` +git add . +``` +## git blame +**查看文件每行的最后提交人和时间** +``` +git blame +``` +**查看文件某个方法的最后提交人和时间** +``` +git blame -L : +``` +**查看文件行数范围内的最后提交人和时间** +``` +git blame -L , +``` +## git branch +**查看所有分支,并显示版本信息** +``` +git branch -v +``` +## git checkout +**在本地创建远程分支** +``` +git checkout -b origin/ +``` +## git config +**全局模式缓存凭证 15 分钟** +``` +git config --global credential.helper cache +``` +**全局模式储存仓库凭证** +``` +git config --global credential.helper store +``` +**全局配置 git 邮箱** +``` +git config --global user.email "youremail@gmail.com" +``` +**全局配置 git 用户名** +``` +git config --global user.name "your name" +``` +**储存当前仓库凭证** +``` +git config credential.helper store +``` +## git fetch +**把远程分支拉到本地** +``` +git fetch origin +``` +## git init +**初始化当前目录为仓库** +``` +git init +``` +**创建 仓库** +``` +git init +``` +## git log +**查看某人一段时间的提交记录,并显示详情** +``` +git log --stat --author= --after= --before= +``` +## git merge +**撤销所有合并操作** +``` +git merge --abort +``` +## git pull +**拉取远程分支到本地** +``` +git pull origin +``` +**解决拉取项目到本地新仓库 fatal: refusing to merge unrelated histories 的问题** +``` +git pull origin master --allow-unrelated-histories +``` diff --git a/docs/hexo.md b/docs/hexo.md new file mode 100644 index 0000000..069f593 --- /dev/null +++ b/docs/hexo.md @@ -0,0 +1,54 @@ +## hexo clean +**清除缓存文件 (db.json) 和已生成的静态文件 (public)** +``` +hexo clean +``` +## hexo g +**生成静态文件** +``` +hexo g +``` +**强制重新生成静态文件** +``` +hexo g -f +``` +## hexo init +**新建一个网站。如果没有设置 folder ,Hexo 默认在目前的文件夹建立网站。** +``` +hexo init [folder] +``` +## hexo list +**列出网站资料** +``` +hexo list +``` +## hexo new +**新建一篇文章** +``` +hexo new [layout] +``` +## hexo publish +**发布草稿** +``` +hexo publish [layout] <filename> +``` +## hexo server +**启动日志** +``` +hexo server +``` +## hexo version +**显示 Hexo 版本** +``` +hexo version +``` +## https://hexo.io/zh-cn/docs/commands +**命令地址** +``` +https://hexo.io/zh-cn/docs/commands +``` +## npm install +**安装 hexo** +``` +npm install hexo-cli -g +``` diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..4b47b70 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,10 @@ +# 常用命令总结 + +[alfred-commands-workflow](https://github.com/wxnacy/alfred-commands-workflow) +是集合多种命令模式的插件。 + +其中使用到最多的功能就是复制常用命令,效果如下 + +![t34KxS.gif](https://s1.ax1x.com/2020/06/01/t34KxS.gif) + +而这里面使用到的命令库就在这里进行记录 diff --git a/docs/javascript.md b/docs/javascript.md new file mode 100644 index 0000000..ea802a1 --- /dev/null +++ b/docs/javascript.md @@ -0,0 +1,10 @@ +## pm2 resurrect +**恢复上次保存的任务状态** +``` +pm2 resurrect +``` +## pm2 save +**保存当前任务列表** +``` +pm2 save +``` diff --git a/docs/jupyter.md b/docs/jupyter.md new file mode 100644 index 0000000..b5477d5 --- /dev/null +++ b/docs/jupyter.md @@ -0,0 +1,22 @@ +## jupyter nbconvert +**将 ipynb 转为 html 格式** +``` +jupyter nbconvert <filename>.ipynb +``` +**将 ipynb 转为 html 格式,并指定输出目录** +``` +jupyter nbconvert <filename>.ipynb --output-dir=<dirname> +``` +**将 ipynb 转为 html 格式,并指定输出名称** +``` +jupyter nbconvert <filename>.ipynb --output=<filename> +``` +## jupyter notebook +**启动 jupyter notebook 服务** +``` +jupyter notebook +``` +**启动 jupyter notebook 服务,并制定端口号** +``` +jupyter notebook --port <port> +``` diff --git a/docs/mac.md b/docs/mac.md new file mode 100644 index 0000000..a30f979 --- /dev/null +++ b/docs/mac.md @@ -0,0 +1,48 @@ +## /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport scan +**扫描附近可用 Wifi热点** +``` +/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport scan +``` +## defaults write +**在文件夹不显示隐藏文件** +``` +defaults write com.apple.finder AppleShowAllFiles no; killall Finder /System/Library/CoreServices/Finder.app +``` +**在文件夹显示隐藏文件** +``` +defaults write com.apple.finder AppleShowAllFiles yes; killall Finder /System/Library/CoreServices/Finder.app +``` +## dscacheutil -flushcache +**清空DNS缓存** +``` +dscacheutil -flushcache +``` +## ifconfig | +**查看 Mac 系统内网 ip** +``` +ifconfig | grep en0 -A 3 | grep 'inet ' | awk '{print $2}' +``` +## networksetup -listallnetworkservices +**列出本机所有网络服务** +``` +networksetup -listallnetworkservices +``` +## networksetup -setairportnetwork +**加入 WIFI** +``` +networksetup -setairportnetwork en0 <wifiname> <wifipsword> +``` +## networksetup -setairportpower +**关闭 Wifi** +``` +networksetup -setairportpower en0 off +``` +**启动 WIFI** +``` +networksetup -setairportpower en0 on +``` +## system_profiler SPSoftwareDataType +**系统软件总览** +``` +system_profiler SPSoftwareDataType +``` diff --git a/docs/mysql.md b/docs/mysql.md new file mode 100644 index 0000000..67515f7 --- /dev/null +++ b/docs/mysql.md @@ -0,0 +1,24 @@ +## select * +**查看正在执行的线程,并按 Time 倒排序,看看有没有执行时间特别长的线程** +``` +select * from information_schema.processlist where Command != 'Sleep' order by Time desc; +``` +**查询 processlist** +``` +select * from information_schema.processlist; +``` +## select client_ip,count(client_ip) +**按客户端 IP 分组,看哪个客户端的链接数最多** +``` +select client_ip,count(client_ip) as client_num from (select substring_index(host,':' ,1) as client_ip from information_schema.processlist ) as connect_info group by client_ip order by client_num desc; +``` +## select concat('kill +**找出所有执行时间超过 5 分钟的线程,拼凑出 kill 语句** +``` +select concat('kill ', id, ';') from information_schema.processlist where Command != 'Sleep' and Time > 300 order by Time desc; +``` +## show processlist; +**查询 processlist** +``` +show processlist; +``` diff --git a/docs/nginx.md b/docs/nginx.md new file mode 100644 index 0000000..3d53628 --- /dev/null +++ b/docs/nginx.md @@ -0,0 +1,10 @@ +## nginx -s +**重新加载配置文件** +``` +nginx -s reload +``` +## nginx -t +**检测配置文件** +``` +nginx -t +``` diff --git a/docs/oss.md b/docs/oss.md new file mode 100644 index 0000000..cdcce94 --- /dev/null +++ b/docs/oss.md @@ -0,0 +1,68 @@ +## https://help.aliyun.com/document_detail/50452.html?spm=a2c4g.11186623.6.702.11902e69EVPBh9 +**文档地址** +``` +https://help.aliyun.com/document_detail/50452.html?spm=a2c4g.11186623.6.702.11902e69EVPBh9 +``` +## ossutil cp +**上传文件夹** +``` +ossutil cp -r <dirname> oss://<bucketname>/<path> +``` +**上传所有文件格式为txt的文件** +``` +ossutil cp -r <dirname> oss://<bucketname>/<path> --include "*.txt" +``` +**上传所有文件名包含abc且不是jpg和txt格式的文件** +``` +ossutil cp -r <dirname> oss://<bucketname>/<path> --include "*abc*" --exclude "*.jpg" --exclude "*.txt" +``` +**上传文件时启用 100 个并发数** +``` +ossutil cp -r <dirname> oss://<bucketname>/<path> --jobs 100 +``` +**仅上传当前目录下的文件,忽略子目录** +``` +ossutil cp -r <dirname> oss://<bucketname>/<path> --only-current-dir +``` +**上传文件夹并跳过相同文件** +``` +ossutil cp -ru <dirname> oss://<bucketname>/<path> +``` +**上传文件** +``` +ossutil cp <filename> oss://<bucketname>/<path> +``` +**下载文件** +``` +ossutil cp oss://<bucketname>/<path> <filename> +``` +**拷贝文件** +``` +ossutil cp oss://<bucketname>/<path> oss://<bucketname>/<path> +``` +## ossutil ls +**列举 Bucket** +``` +ossutil ls +``` +**列举指定Bucket下所有的Object** +``` +ossutil ls oss://<bucketname> +``` +## ossutil rm +**删除空Bucket** +``` +ossutil rm oss://<bucketname> -b +``` +**清除Bucket数据并删除Bucket** +``` +ossutil rm oss://<bucketname> -bar +``` +**删除单个Object** +``` +ossutil rm oss://<bucketname>/<object> +``` +**删除指定前缀的所有Object** +``` +ossutil rm oss://<bucketname>/<path>/ -r +``` diff --git a/docs/other.md b/docs/other.md new file mode 100644 index 0000000..2f18491 --- /dev/null +++ b/docs/other.md @@ -0,0 +1,44 @@ +## crontab -e +**编辑服务器定时任务** +``` +crontab -e +``` +## crontab -l +**查看服务器定时任务列表** +``` +crontab -l +``` +## df -h +**查看磁盘使用情况,并格式化输出** +``` +df -h +``` +## du -d +**查看第一层目录的文件夹大小,并格式化输出** +``` +du -d 1 -h +``` +## echo -n +**复制当前目录** +``` +echo -n $(echo -n $(pwd) | sed 's/ /\\ /g') | pbcopy +``` +**复制一段文字** +``` +echo -n 'hello world' | pbcopy +``` +## ifconfig | +**查看 Linux 系统内网 ip** +``` +ifconfig | grep 'eth0' -A 1 | grep 'inet ' | awk '{print $2}' | sed 's/addr://g' +``` +## pbpaste +**黏贴** +``` +pbpaste +``` +## ps -ef +**查看进程,并过滤关键字** +``` +ps -ef | grep <pattern> +``` diff --git a/docs/python.md b/docs/python.md new file mode 100644 index 0000000..5389270 --- /dev/null +++ b/docs/python.md @@ -0,0 +1,5 @@ +## python -m +**py3 启动一个默认 8000 端口的服务** +``` +python -m http.server +``` diff --git a/docs/vagrant.md b/docs/vagrant.md new file mode 100644 index 0000000..5341432 --- /dev/null +++ b/docs/vagrant.md @@ -0,0 +1,78 @@ +## vagrant box +**查看所有 box 列表** +``` +vagrant box list +``` +**删除 box** +``` +vagrant box remove <box-name> +``` +**删除 box,并指定版本** +``` +vagrant box remove <box-name> --box-version <version> +``` +**更新 box 版本"** +``` +vagrant box update +``` +**更新指定 box 版本** +``` +vagrant box update --box <box-name> +``` +## vagrant destroy +**销毁虚拟机,并对询问回答 yes"** +``` +vagrant destroy -f +``` +**销毁虚拟机"** +``` +vagrant destroy [name|id] +``` +## vagrant global-status +**查看所有虚拟机状态** +``` +vagrant global-status +``` +## vagrant halt +**登陆虚拟机"** +``` +vagrant halt +``` +## vagrant init +**在当前文件夹初始化 Vagrantfile** +``` +vagrant init [name [url]] +``` +**在当前文件夹初始化 centos7** +``` +vagrant init centos/7 +``` +## vagrant package +**打包 box"** +``` +vagrant package +``` +**打包 box,并指定包名"** +``` +vagrant package --ouput <box-name> +``` +## vagrant reload +**重新加载虚拟机配置** +``` +vagrant reload +``` +## vagrant ssh +**登陆虚拟机"** +``` +vagrant ssh +``` +## vagrant status +**当前虚拟机状态** +``` +vagrant status +``` +## vagrant up +**启动虚拟机"** +``` +vagrant up +``` diff --git a/info.plist b/info.plist index 1456919..167786d 100644 --- a/info.plist +++ b/info.plist @@ -127,6 +127,19 @@ </array> <key>ABFDAC0A-59AC-46FF-8317-30A5EE1E72B4</key> <array/> + <key>AEE5C04E-1C5F-4BBF-982B-B3B051538EEA</key> + <array> + <dict> + <key>destinationuid</key> + <string>B2F96C31-53D7-4372-B4B1-A63242E03685</string> + <key>modifiers</key> + <integer>0</integer> + <key>modifiersubtext</key> + <string></string> + <key>vitoclose</key> + <false/> + </dict> + </array> <key>AEEE997C-352F-4019-BFEF-40480C5770E9</key> <array> <dict> @@ -150,6 +163,19 @@ <false/> </dict> </array> + <key>B2F96C31-53D7-4372-B4B1-A63242E03685</key> + <array> + <dict> + <key>destinationuid</key> + <string>59283810-F7EB-471D-BF42-E310BB651471</string> + <key>modifiers</key> + <integer>0</integer> + <key>modifiersubtext</key> + <string></string> + <key>vitoclose</key> + <false/> + </dict> + </array> <key>F800D030-BFC4-490B-813D-74D375AA6EF0</key> <array> <dict> @@ -525,6 +551,71 @@ done</string> <key>version</key> <integer>1</integer> </dict> + <dict> + <key>config</key> + <dict> + <key>argumenttype</key> + <integer>0</integer> + <key>keyword</key> + <string>wifi</string> + <key>subtext</key> + <string>on 打开 off 关闭</string> + <key>text</key> + <string>打开关闭 WIFI</string> + <key>withspace</key> + <true/> + </dict> + <key>type</key> + <string>alfred.workflow.input.keyword</string> + <key>uid</key> + <string>AEE5C04E-1C5F-4BBF-982B-B3B051538EEA</string> + <key>version</key> + <integer>1</integer> + </dict> + <dict> + <key>config</key> + <dict> + <key>concurrently</key> + <false/> + <key>escaping</key> + <integer>102</integer> + <key>script</key> + <string>networksetup -setairportpower en0 {query}</string> + <key>scriptargtype</key> + <integer>0</integer> + <key>scriptfile</key> + <string></string> + <key>type</key> + <integer>0</integer> + </dict> + <key>type</key> + <string>alfred.workflow.action.script</string> + <key>uid</key> + <string>B2F96C31-53D7-4372-B4B1-A63242E03685</string> + <key>version</key> + <integer>2</integer> + </dict> + <dict> + <key>config</key> + <dict> + <key>lastpathcomponent</key> + <false/> + <key>onlyshowifquerypopulated</key> + <false/> + <key>removeextension</key> + <false/> + <key>text</key> + <string>{query}</string> + <key>title</key> + <string>Successful</string> + </dict> + <key>type</key> + <string>alfred.workflow.output.notification</string> + <key>uid</key> + <string>59283810-F7EB-471D-BF42-E310BB651471</string> + <key>version</key> + <integer>1</integer> + </dict> <dict> <key>config</key> <dict> @@ -692,7 +783,7 @@ echo -n $(nohup curl $1 -O &)</string> <key>xpos</key> <integer>510</integer> <key>ypos</key> - <integer>965</integer> + <integer>1075</integer> </dict> <key>5348461E-968E-4C7D-A961-2C53A47EEB39</key> <dict> @@ -701,6 +792,13 @@ echo -n $(nohup curl $1 -O &)</string> <key>ypos</key> <integer>170</integer> </dict> + <key>59283810-F7EB-471D-BF42-E310BB651471</key> + <dict> + <key>xpos</key> + <integer>565</integer> + <key>ypos</key> + <integer>810</integer> + </dict> <key>679ACFD3-4EFD-4253-8DE7-43596D7AE00B</key> <dict> <key>xpos</key> @@ -713,7 +811,7 @@ echo -n $(nohup curl $1 -O &)</string> <key>xpos</key> <integer>180</integer> <key>ypos</key> - <integer>965</integer> + <integer>1075</integer> </dict> <key>7550C092-A6C8-4BB2-A593-865B5A9F831B</key> <dict> @@ -741,14 +839,21 @@ echo -n $(nohup curl $1 -O &)</string> <key>xpos</key> <integer>180</integer> <key>ypos</key> - <integer>830</integer> + <integer>940</integer> </dict> <key>ABFDAC0A-59AC-46FF-8317-30A5EE1E72B4</key> <dict> <key>xpos</key> <integer>350</integer> <key>ypos</key> - <integer>830</integer> + <integer>940</integer> + </dict> + <key>AEE5C04E-1C5F-4BBF-982B-B3B051538EEA</key> + <dict> + <key>xpos</key> + <integer>180</integer> + <key>ypos</key> + <integer>810</integer> </dict> <key>AEEE997C-352F-4019-BFEF-40480C5770E9</key> <dict> @@ -757,6 +862,13 @@ echo -n $(nohup curl $1 -O &)</string> <key>ypos</key> <integer>685</integer> </dict> + <key>B2F96C31-53D7-4372-B4B1-A63242E03685</key> + <dict> + <key>xpos</key> + <integer>350</integer> + <key>ypos</key> + <integer>810</integer> + </dict> <key>C2C22059-F577-4982-B0BF-665E0E358013</key> <dict> <key>xpos</key> @@ -769,7 +881,7 @@ echo -n $(nohup curl $1 -O &)</string> <key>xpos</key> <integer>350</integer> <key>ypos</key> - <integer>965</integer> + <integer>1075</integer> </dict> </dict> <key>variablesdontexport</key> diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 0000000..b30d6a8 --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,18 @@ + +site_name: 常用命令 # 站点名称 +nav: # 文档目录 + - 首页: index.md + - Docker: docker.md + - Ffmpeg: ffmpeg.md + - Git: git.md + - Hexo: hexo.md + - Javascript: javascript.md + - Jupyter: jupyter.md + - Mac: mac.md + - Mysql: mysql.md + - Nginx: nginx.md + - Oss: oss.md + - Other: other.md + - Python: python.md + - Vagrant: vagrant.md +theme: readthedocs # 主题 diff --git a/publish.sh b/publish.sh new file mode 100755 index 0000000..695cf54 --- /dev/null +++ b/publish.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +# Author: wxnacy(wxnacy@gmail.com) +# Description: + + +rm -rf site + +ws git publish $@ + diff --git a/search_commands.py b/search_commands.py index 40b0d01..157858e 100644 --- a/search_commands.py +++ b/search_commands.py @@ -9,63 +9,13 @@ import timeit from workflow import Workflow3 +from common import read_cmd ABBR = { "py": "python", "vg": "vagrant", } -# def read_json(filename): - # lines = [] - # with open(filename, 'r') as f: - # lines = f.readlines() - # return json.loads(''.join(lines)) - -# def read_csv(filename): - # lines = [] - # with open(filename, 'r') as f: - # lines = f.readlines() - # logging.info(lines) - # items = [] - # for line in lines: - # ls = line.split(',') - # item = dict(title = ls[0].strip(" "), subtitle = ls[1].strip(" ")) - # items.append(item) - # return items - -def read_file(filename): - with open(filename, 'r') as f: - return [o.strip('\n').strip(" ") for o in f.readlines()] - -def read_cmd(filename): - ''' - 读取指令文件 - ''' - lines = read_file(filename) - lines = list(filter(lambda x: x, lines)) - items = [] - num = len(lines) / 2 - # 设置 icon - # 查找是否存在如下对应文件 - # ./commands/cmd_{category} - # ./icon/{category}.png - cmd_name = os.path.basename(filename).split("_")[1] - icon = './icon.png' - cmd_icon_path = './icon/{}.png'.format(cmd_name) - if os.path.exists(cmd_icon_path): - icon = cmd_icon_path - for i in range(num): - item = dict( - title = lines[i * 2 + 1], - subtitle = lines[i * 2], - icon = icon, - valid = True, - ) - item['arg'] = item['title'] - items.append(item) - return items - - def get_all_commands(): '''获取所有的命令''' files = os.listdir('./commands')