Skip to content

Commit

Permalink
new version
Browse files Browse the repository at this point in the history
  • Loading branch information
wxnacy committed May 21, 2020
1 parent ff90407 commit c13da89
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 131 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

## 查看帮助文档

Expand Down
44 changes: 44 additions & 0 deletions commands/cmd_git
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# 将所有新增、修改、删除的文件提交到索引中
git add .
# 将所有新增、修改的文件提交到索引中
git add --ignore-removal .
# 将所有新增、修改、删除的文件提交到索引中
git add -A
# 将所有修改、删除的文件提交到索引中
git add -u

# 初始化当前目录为仓库
git init
# 创建 <repo_name> 仓库
git init <repo_name>

# 查看文件每行的最后提交人和时间
git blame <file>
# 查看文件行数范围内的最后提交人和时间
git blame <file> -L <start>,<end>
# 查看文件某个方法的最后提交人和时间
git blame <file> -L :<funcname>

# 全局配置 git 用户名
git config --global user.name "your name"
# 全局配置 git 邮箱
git config --global user.email "[email protected]"
# 储存当前仓库凭证
git config credential.helper store
# 全局模式储存仓库凭证
git config --global credential.helper store
# 全局模式缓存凭证 15 分钟
git config --global credential.helper cache

# 在本地创建远程分支
git checkout -b <local-branch-name> origin/<remote-branch-name>
# 把远程分支拉到本地
git fetch origin <branch_name>
# 解决拉取项目到本地新仓库 fatal: refusing to merge unrelated histories 的问题
git pull origin master --allow-unrelated-histories
# 拉取远程分支到本地
git pull origin <branch-name>
# 撤销所有合并操作
git merge --abort
# 查看某人一段时间的提交记录,并显示详情
git log --stat --author=<pattern> --after=<date> --before=<date>
6 changes: 6 additions & 0 deletions commands/cmd_other
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# 查看磁盘使用情况,并格式化输出
df -h
# 查看第一层目录的文件夹大小,并格式化输出
du -d 1 -h
# 恢复上次保存的任务状态
pm2 resurrect
34 changes: 34 additions & 0 deletions commands/cmd_vagrant
Original file line number Diff line number Diff line change
@@ -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 <box-name>
# 当前虚拟机状态
vagrant status
# 重新加载虚拟机配置
vagrant reload
# 查看所有虚拟机状态
vagrant global-status
# 查看所有 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>
9 changes: 6 additions & 3 deletions commands/git.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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 <repo_name>, 创建 <repo_name> 仓库
git init <repo_name>, 创建 <repo_name> 仓库
git config --global user.name "your name", 全局配置 git 用户名
git config --global user.email "[email protected]", 全局配置 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 <local-branch-name> origin/<remote-branch-name>, 在本地创建远程分支
git fetch origin <branch_name>, 把远程分支拉到本地
git pull origin master --allow-unrelated-histories, 解决拉取项目到本地新仓库 fatal: refusing to merge unrelated histories 的问题
git pull origin <branch-name>, 拉取远程分支到本地
git merge --abort, 撤销所有合并操作
git log --stat --author=<pattern> --after=<date> --before=<date>, 查看某人一段时间的提交记录,并显示详情
1 change: 1 addition & 0 deletions commands/other.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
df -h, 查看磁盘使用情况,并格式化输出
du -d 1 -h, 查看第一层目录的文件夹大小,并格式化输出
pm2 resurrect, 恢复上次保存的任务状态
2 changes: 1 addition & 1 deletion deploy/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
125 changes: 2 additions & 123 deletions info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,6 @@
<false/>
</dict>
</array>
<key>1BA1AC7A-FDA1-4796-8291-29891278EA41</key>
<array>
<dict>
<key>destinationuid</key>
<string>15F615E7-C6EB-4E97-8E95-106D5FABAD51</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>1DF4C6B0-EDE0-42C1-B043-302FA3BBEDFA</key>
<array>
<dict>
Expand All @@ -58,19 +45,6 @@
<false/>
</dict>
</array>
<key>31DEFD66-80B8-4E1B-9FF7-0D8D85EB1828</key>
<array>
<dict>
<key>destinationuid</key>
<string>1BA1AC7A-FDA1-4796-8291-29891278EA41</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>7550C092-A6C8-4BB2-A593-865B5A9F831B</key>
<array>
<dict>
Expand Down Expand Up @@ -123,80 +97,6 @@
<string>Commands Help Tools</string>
<key>objects</key>
<array>
<dict>
<key>config</key>
<dict>
<key>concurrently</key>
<false/>
<key>escaping</key>
<integer>102</integer>
<key>script</key>
<string># 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</string>
<key>scriptargtype</key>
<integer>1</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>1BA1AC7A-FDA1-4796-8291-29891278EA41</string>
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>argumenttype</key>
<integer>2</integer>
<key>keyword</key>
<string>cmdr</string>
<key>subtext</key>
<string></string>
<key>text</key>
<string>Refresh commands source</string>
<key>withspace</key>
<false/>
</dict>
<key>type</key>
<string>alfred.workflow.input.keyword</string>
<key>uid</key>
<string>31DEFD66-80B8-4E1B-9FF7-0D8D85EB1828</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>lastpathcomponent</key>
<false/>
<key>onlyshowifquerypopulated</key>
<false/>
<key>removeextension</key>
<false/>
<key>text</key>
<string></string>
<key>title</key>
<string>Refresh successful</string>
</dict>
<key>type</key>
<string>alfred.workflow.output.notification</string>
<key>uid</key>
<string>15F615E7-C6EB-4E97-8E95-106D5FABAD51</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
Expand Down Expand Up @@ -319,7 +219,7 @@ done</string>
<key>scriptfile</key>
<string></string>
<key>type</key>
<integer>0</integer>
<integer>5</integer>
</dict>
<key>type</key>
<string>alfred.workflow.action.script</string>
Expand Down Expand Up @@ -446,20 +346,6 @@ done</string>
<key>ypos</key>
<integer>320</integer>
</dict>
<key>15F615E7-C6EB-4E97-8E95-106D5FABAD51</key>
<dict>
<key>xpos</key>
<integer>510</integer>
<key>ypos</key>
<integer>40</integer>
</dict>
<key>1BA1AC7A-FDA1-4796-8291-29891278EA41</key>
<dict>
<key>xpos</key>
<integer>340</integer>
<key>ypos</key>
<integer>40</integer>
</dict>
<key>1DF4C6B0-EDE0-42C1-B043-302FA3BBEDFA</key>
<dict>
<key>xpos</key>
Expand All @@ -474,13 +360,6 @@ done</string>
<key>ypos</key>
<integer>180</integer>
</dict>
<key>31DEFD66-80B8-4E1B-9FF7-0D8D85EB1828</key>
<dict>
<key>xpos</key>
<integer>170</integer>
<key>ypos</key>
<integer>40</integer>
</dict>
<key>5348461E-968E-4C7D-A961-2C53A47EEB39</key>
<dict>
<key>xpos</key>
Expand Down Expand Up @@ -527,7 +406,7 @@ done</string>
<key>variablesdontexport</key>
<array/>
<key>version</key>
<string>2020.05.13</string>
<string>2020.05.14</string>
<key>webaddress</key>
<string>https://github.com/wxnacy/alfred-commands-workflow</string>
</dict>
Expand Down
23 changes: 20 additions & 3 deletions search_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit c13da89

Please sign in to comment.