diff --git a/README.md b/README.md index b008b55..bd05c84 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## 复制常用命令 -![cmds](https://github.com/wxnacy/image/blob/master/blog/cmds.gif) +![cmds](https://github.com/wxnacy/image/blob/master/blog/alfred-cp.gif) ## 查看帮助文档 diff --git a/commands/cmd_git b/commands/cmd_git new file mode 100644 index 0000000..8a19978 --- /dev/null +++ b/commands/cmd_git @@ -0,0 +1,44 @@ +# 将所有新增、修改、删除的文件提交到索引中 +git add . +# 将所有新增、修改的文件提交到索引中 +git add --ignore-removal . +# 将所有新增、修改、删除的文件提交到索引中 +git add -A +# 将所有修改、删除的文件提交到索引中 +git add -u + +# 初始化当前目录为仓库 +git init +# 创建 仓库 +git init + +# 查看文件每行的最后提交人和时间 +git blame +# 查看文件行数范围内的最后提交人和时间 +git blame -L , +# 查看文件某个方法的最后提交人和时间 +git blame -L : + +# 全局配置 git 用户名 +git config --global user.name "your name" +# 全局配置 git 邮箱 +git config --global user.email "youremail@gmail.com" +# 储存当前仓库凭证 +git config credential.helper store +# 全局模式储存仓库凭证 +git config --global credential.helper store +# 全局模式缓存凭证 15 分钟 +git config --global credential.helper cache + +# 在本地创建远程分支 +git checkout -b origin/ +# 把远程分支拉到本地 +git fetch origin +# 解决拉取项目到本地新仓库 fatal: refusing to merge unrelated histories 的问题 +git pull origin master --allow-unrelated-histories +# 拉取远程分支到本地 +git pull origin +# 撤销所有合并操作 +git merge --abort +# 查看某人一段时间的提交记录,并显示详情 +git log --stat --author= --after= --before= diff --git a/commands/cmd_other b/commands/cmd_other new file mode 100644 index 0000000..f2cb7e4 --- /dev/null +++ b/commands/cmd_other @@ -0,0 +1,6 @@ +# 查看磁盘使用情况,并格式化输出 +df -h +# 查看第一层目录的文件夹大小,并格式化输出 +du -d 1 -h +# 恢复上次保存的任务状态 +pm2 resurrect diff --git a/commands/cmd_vagrant b/commands/cmd_vagrant new file mode 100644 index 0000000..f9114a4 --- /dev/null +++ b/commands/cmd_vagrant @@ -0,0 +1,34 @@ +# 在当前文件夹初始化 Vagrantfile +vagrant init [name [url]] +# 在当前文件夹初始化 centos7 +vagrant init centos/7 +# 启动虚拟机" +vagrant up +# 登陆虚拟机" +vagrant ssh +# 登陆虚拟机" +vagrant halt +# 销毁虚拟机" +vagrant destroy [name|id] +# 销毁虚拟机,并对询问回答 yes" +vagrant destroy -f +# 打包 box" +vagrant package +# 打包 box,并指定包名" +vagrant package --ouput +# 当前虚拟机状态 +vagrant status +# 重新加载虚拟机配置 +vagrant reload +# 查看所有虚拟机状态 +vagrant global-status +# 查看所有 box 列表 +vagrant box list +# 删除 box +vagrant box remove +# 删除 box,并指定版本 +vagrant box remove --box-version +# 更新 box 版本" +vagrant box update +# 更新指定 box 版本 +vagrant box update --box diff --git a/commands/git.csv b/commands/git.csv index dbda159..2b3d141 100644 --- a/commands/git.csv +++ b/commands/git.csv @@ -3,13 +3,16 @@ git add --ignore-removal ., 将所有新增、修改的文件提交到索引中 git add -A, 将所有新增、修改、删除的文件提交到索引中 git add -u, 将所有修改、删除的文件提交到索引中 git init, 初始化当前目录为仓库 -git init {repo_name}, 创建 {repo_name} 仓库 -git init {repo_name}, 创建 {repo_name} 仓库 +git init , 创建 仓库 +git init , 创建 仓库 git config --global user.name "your name", 全局配置 git 用户名 git config --global user.email "youremail@gmail.com", 全局配置 git 邮箱 git config credential.helper store, 储存当前仓库凭证 git config --global credential.helper store, 全局模式储存仓库凭证 git config --global credential.helper cache, 全局模式缓存凭证 15 分钟 -git fetch origin {branch_name}, 把远程分支拉到本地 +git checkout -b origin/, 在本地创建远程分支 +git fetch origin , 把远程分支拉到本地 git pull origin master --allow-unrelated-histories, 解决拉取项目到本地新仓库 fatal: refusing to merge unrelated histories 的问题 +git pull origin , 拉取远程分支到本地 git merge --abort, 撤销所有合并操作 +git log --stat --author= --after= --before=, 查看某人一段时间的提交记录,并显示详情 diff --git a/commands/other.csv b/commands/other.csv index 9c13cbc..b2ab4e8 100644 --- a/commands/other.csv +++ b/commands/other.csv @@ -1,2 +1,3 @@ df -h, 查看磁盘使用情况,并格式化输出 du -d 1 -h, 查看第一层目录的文件夹大小,并格式化输出 +pm2 resurrect, 恢复上次保存的任务状态 diff --git a/deploy/publish.sh b/deploy/publish.sh index bf37190..a1fa60e 100755 --- a/deploy/publish.sh +++ b/deploy/publish.sh @@ -3,4 +3,4 @@ # Description: -./deploy/push_tag.sh $(date '+%Y.%m.%d') new version +./deploy/push_tag.sh v$(date '+%Y.%m.%d') new version diff --git a/info.plist b/info.plist index 3f4fd6a..c8108aa 100644 --- a/info.plist +++ b/info.plist @@ -19,19 +19,6 @@ - 1BA1AC7A-FDA1-4796-8291-29891278EA41 - - - destinationuid - 15F615E7-C6EB-4E97-8E95-106D5FABAD51 - modifiers - 0 - modifiersubtext - - vitoclose - - - 1DF4C6B0-EDE0-42C1-B043-302FA3BBEDFA @@ -58,19 +45,6 @@ - 31DEFD66-80B8-4E1B-9FF7-0D8D85EB1828 - - - destinationuid - 1BA1AC7A-FDA1-4796-8291-29891278EA41 - modifiers - 0 - modifiersubtext - - vitoclose - - - 7550C092-A6C8-4BB2-A593-865B5A9F831B @@ -123,80 +97,6 @@ Commands Help Tools objects - - config - - concurrently - - escaping - 102 - script - # curl https://raw.githubusercontent.com/wxnacy/test/master/blog/vagrant.json -o commands/vagrant.json - - -URL_HOME=https://raw.githubusercontent.com/wxnacy/alfred-commands-workflow/master/commands/ - -for name in git.json vagrant.json -do - url=$URL_HOME${name} - curl $url -o $name -done - scriptargtype - 1 - scriptfile - - type - 0 - - type - alfred.workflow.action.script - uid - 1BA1AC7A-FDA1-4796-8291-29891278EA41 - version - 2 - - - config - - argumenttype - 2 - keyword - cmdr - subtext - - text - Refresh commands source - withspace - - - type - alfred.workflow.input.keyword - uid - 31DEFD66-80B8-4E1B-9FF7-0D8D85EB1828 - version - 1 - - - config - - lastpathcomponent - - onlyshowifquerypopulated - - removeextension - - text - - title - Refresh successful - - type - alfred.workflow.output.notification - uid - 15F615E7-C6EB-4E97-8E95-106D5FABAD51 - version - 1 - config @@ -319,7 +219,7 @@ done scriptfile type - 0 + 5 type alfred.workflow.action.script @@ -446,20 +346,6 @@ done ypos 320 - 15F615E7-C6EB-4E97-8E95-106D5FABAD51 - - xpos - 510 - ypos - 40 - - 1BA1AC7A-FDA1-4796-8291-29891278EA41 - - xpos - 340 - ypos - 40 - 1DF4C6B0-EDE0-42C1-B043-302FA3BBEDFA xpos @@ -474,13 +360,6 @@ done ypos 180 - 31DEFD66-80B8-4E1B-9FF7-0D8D85EB1828 - - xpos - 170 - ypos - 40 - 5348461E-968E-4C7D-A961-2C53A47EEB39 xpos @@ -527,7 +406,7 @@ done variablesdontexport version - 2020.05.13 + 2020.05.14 webaddress https://github.com/wxnacy/alfred-commands-workflow diff --git a/search_commands.py b/search_commands.py index feccd53..ebab2fb 100644 --- a/search_commands.py +++ b/search_commands.py @@ -30,19 +30,36 @@ def read_csv(filename): for line in lines: ls = line.split(',') item = dict(title = ls[0].strip(" "), subtitle = ls[1].strip(" ")) - # logging.info(item) 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 + for i in range(num): + items.append(dict( + title = lines[i * 2 + 1], + subtitle = lines[i * 2], + )) + return items + + def get_all_commands(): '''获取所有的命令''' files = os.listdir('./commands') commands = [] for f in files: - if f.endswith('.csv'): + # if f.endswith('.csv'): + if f.startswith('cmd_'): filename = './commands/' + f - data = read_csv(filename) + data = read_cmd(filename) commands.extend(data) return commands