├── .gitignore
├── .travis.yml
├── LICENCE
├── README.md
├── accessories
├── arc-darker-theme for Google Chrome.crx
├── cows.txt
└── cursors.tar.xz
├── charles
├── bin
│ ├── add-ppa
│ ├── apt-unlock
│ ├── apt-upgrade
│ ├── aria2c-daemon
│ ├── cdar
│ ├── charles-update
│ ├── copy-path
│ ├── ef
│ ├── fifo
│ ├── follow
│ ├── get-path
│ ├── gh-md-toc
│ ├── gnome-shell-extensions-backup
│ ├── gnome-shell-extensions-restore
│ ├── gojuon
│ ├── inst
│ ├── itunes2rhythmbox
│ ├── mac-addr-flush
│ ├── omf-backup
│ ├── omf-restore
│ ├── pacman-disowned
│ ├── prj-sync
│ ├── ssr
│ ├── thunderdecode
│ ├── tomato
│ ├── wallpaper-earthview
│ ├── wallpaper-random
│ └── yao
├── installation.d
│ ├── conf.d
│ │ ├── .config-powerline-tmux
│ │ ├── config-aria2
│ │ ├── config-bash
│ │ ├── config-conda
│ │ ├── config-cron
│ │ ├── config-fcitx-on-wayland
│ │ ├── config-fish
│ │ ├── config-git
│ │ ├── config-gnome
│ │ ├── config-homebrew
│ │ ├── config-kitty
│ │ ├── config-pip
│ │ ├── config-powerline-bash
│ │ ├── config-powerline-ipython
│ │ ├── config-tlp
│ │ └── config-tmux
│ └── get.d
│ │ ├── get-albert
│ │ ├── get-aur
│ │ ├── get-calibre
│ │ ├── get-docker
│ │ ├── get-duck-cowsay
│ │ ├── get-fasd
│ │ ├── get-homebrew-command-not-found
│ │ ├── get-oh-my-fish
│ │ ├── get-playdeb
│ │ ├── get-powerline
│ │ ├── get-spacemacs
│ │ ├── get-spacevim
│ │ ├── get-sublime-text-3
│ │ ├── get-thefuck
│ │ ├── get-tldr-cheat
│ │ ├── get-typora
│ │ ├── get-up
│ │ └── get-xsh
└── shell.rc.d
│ ├── init.fish
│ └── init.shell
├── figs
├── 1.png
├── 2.png
└── 3.png
├── install.sh
├── test
└── install.sh
└── tools
├── README.md
├── auto_hosts_updater
├── README.md
├── linux
│ ├── install.sh
│ └── uninst.sh
└── windows
│ ├── README.md
│ ├── install.bat
│ └── uninst.bat
└── codecombine
/.gitignore:
--------------------------------------------------------------------------------
1 | *~
2 | *.swp
3 | *.save
4 | *.bak
5 | .git
6 | anacron
7 | .placeholder
8 | 0anacron
9 |
10 | # Created by https://www.gitignore.io/api/visualstudiocode
11 | # Edit at https://www.gitignore.io/?templates=visualstudiocode
12 |
13 | ### VisualStudioCode ###
14 | .vscode/*
15 | !.vscode/settings.json
16 | !.vscode/tasks.json
17 | !.vscode/launch.json
18 | !.vscode/extensions.json
19 |
20 | ### VisualStudioCode Patch ###
21 | # Ignore all local history of files
22 | .history
23 |
24 | # End of https://www.gitignore.io/api/visualstudiocode
25 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: required
2 | script:
3 | - 'yes|bash test/install.sh debug'
4 |
--------------------------------------------------------------------------------
/LICENCE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Chalres Xu
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the \"Software\"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 | ----------
24 | Copyright (c) 2020 Charles Xu
25 |
26 | "Anti 996" License Version 1.0 (Draft)
27 |
28 | Permission is hereby granted to any individual or legal entity
29 | obtaining a copy of this licensed work (including the source code,
30 | documentation and/or related items, hereinafter collectively referred
31 | to as the "licensed work"), free of charge, to deal with the licensed
32 | work for any purpose, including without limitation, the rights to use,
33 | reproduce, modify, prepare derivative works of, distribute, publish
34 | and sublicense the licensed work, subject to the following conditions:
35 |
36 | 1. The individual or the legal entity must conspicuously display,
37 | without modification, this License and the notice on each redistributed
38 | or derivative copy of the Licensed Work.
39 |
40 | 2. The individual or the legal entity must strictly comply with all
41 | applicable laws, regulations, rules and standards of the jurisdiction
42 | relating to labor and employment where the individual is physically
43 | located or where the individual was born or naturalized; or where the
44 | legal entity is registered or is operating (whichever is stricter). In
45 | case that the jurisdiction has no such laws, regulations, rules and
46 | standards or its laws, regulations, rules and standards are
47 | unenforceable, the individual or the legal entity are required to
48 | comply with Core International Labor Standards.
49 |
50 | 3. The individual or the legal entity shall not induce, suggest or force
51 | its employee(s), whether full-time or part-time, or its independent
52 | contractor(s), in any methods, to agree in oral or written form, to
53 | directly or indirectly restrict, weaken or relinquish his or her
54 | rights or remedies under such laws, regulations, rules and standards
55 | relating to labor and employment as mentioned above, no matter whether
56 | such written or oral agreements are enforceable under the laws of the
57 | said jurisdiction, nor shall such individual or the legal entity
58 | limit, in any methods, the rights of its employee(s) or independent
59 | contractor(s) from reporting or complaining to the copyright holder or
60 | relevant authorities monitoring the compliance of the license about
61 | its violation(s) of the said license.
62 |
63 | THE LICENSED WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
64 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
65 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
66 | IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM,
67 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
68 | OTHERWISE, ARISING FROM, OUT OF OR IN ANY WAY CONNECTION WITH THE
69 | LICENSED WORK OR THE USE OR OTHER DEALINGS IN THE LICENSED WORK.
70 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
CharlesScripts
2 | 可以配合我的博客:Ubuntu Gnome 酷炫完整指南系列 使用。
3 |
4 |
5 |
6 | [](https://travis-ci.org/the0demiurge/CharlesScripts)
7 |
8 |
9 | ## 你为什么要安装本项目? ##
10 |
11 | 凡是喜欢折腾的朋友肯定经常会遇到下面几个困扰:
12 |
13 | 1. 操作系统被自己搞烂,需要重装,难受!
14 | 2. 换了新电脑 / 工作环境,一切常用工具又需要重新部署,麻烦!
15 | 3. 许多插件配置起来太复杂了,缺少自动或版自动化的工具
16 | 4. 常用的命令就那么几个,还又长又复杂(说的就是你!`apt`和`git`)
17 |
18 |
19 | ## 内容介绍 ##
20 |
21 | 最初因为我经常会因为愚蠢的操作把操作系统搞得崩溃,写下了本项目以便减轻重装系统之痛。后来我写了许多方便的小工具和脚本,把它们整合起来就变成了本项目:
22 |
23 | #### 1. 备份/恢复 ####
24 |
25 | 本项目会将所有资料备份到 `$CHARLES_BACKUP` 即 `~/.config/CharlesBackup`,可以使用网盘或git自动上传备份(git备份已经集成在`charles-update`命令中)
26 |
27 | 下面是是相关命令介绍:
28 |
29 | - `add-ppa`: 添加 `ppa` 的时候同时备份 `ppa` 列表,在`fish-shell`中运行 `add-ppa (add-ppa)` 可以自动添加列表中全部 ppa
30 | - `inst`: 使用 `apt` 安装软件的时候同时备份软件名,在`fish-shell`中运行 `inst (inst)` 可以自动安装列表中全部软件
31 | - `gnome-shell-extensions-backup` 和 `gnome-shell-extensions-restore`: 备份和恢复 `Gnome` 桌面的插件
32 | - `omf-backup` 和 `omf-restore`: 备份和恢复 `oh-my-fish`(`fish-shell` 的包管理器)的插件列表
33 | - `charles-backup`: 调用上述部分命令备份各种插件(可以放到 `cronjob` 里面实现自动备份)
34 | - `charles-update`: 更新本项目及相关依赖;自动使用git上传备份
35 |
36 | #### 2. 小工具 ####
37 |
38 | 通知类:
39 |
40 | - `ef` `fifo`: `ef` 相当于一个短时备忘录,可以用来记录笔记,相当于编辑 `fifo` 命令;输入`fifo`即可运行之前写入的内容。
41 | - `notify`: 提醒你一定时间之后做某事
42 | - `tomato`: 简单的蕃茄钟,定时运行 `fifo` 命令
43 |
44 | 系统操作:
45 |
46 | - `update`: 相当于 `pacman -Syyu`,更新所有软件
47 | - `apt-unlock`: 删除 `apt` 因为异常退出而没有删掉的文件锁
48 | - `get-path`: 获得选定的文件绝对路径,并放到剪贴板内
49 | - `mac-addr-flush`: 重置 MAC 地址(重启失效)
50 | - `wallpaper-earthview`: 更新桌面壁纸(需要先设置好桌面壁纸位置为 `~/.cache/wallpaper/background-image.jpg`)
51 |
52 | 其他:
53 |
54 | - `ssr`: ShadowSocksR 的一键安装、配置、使用客户端
55 | - `aria2c-daemon-start`: 启动 `aria2` 的下载服务
56 | - `gh-md-toc`: Forked from [gh-md-toc](https://github.com/ekalinin/github-markdown-toc), 为 GitHub 的 Markdown 文件加入目录
57 | - `gojuon`: 日语五十音学习小工具
58 | - `ipgw` `ipgw_py`: 命令行版的东北大学校园网登录器
59 |
60 |
61 | 网页相关:
62 |
63 | - `wechat`: 打开微信
64 | - `pocket`: 打开 Pocket
65 | - `shanbay`: 打开扇贝单词
66 |
67 | 包含在 `.bashrc` 或 `fish-shell config.fish` 中的简便操作:
68 |
69 | 写在`CharlesScripts/charles/shell.rc.d`中的脚本函数:
70 |
71 | - `backup`: 将文件备份(复制一份并添加`.bak`后缀)
72 | - `cls`: `cd` 到指定文件夹然后`ls`
73 | - `dict`: 将 `dict` 查到的单词输出到`less`内,以免单词解释过长显示不完还要再翻回去看
74 | - `g`: 使用`git`一条龙地执行 `git add -A`,`git diff --cached`,`git status`,`git commit -m `,`git push`,并检查 push 是否成功,若失败则提醒你检查一下
75 | - `mcd`: 先`mkdir`再`cd`到刚刚创建的文件夹内
76 | - `md5check`: `md5check `,用`grep`检查md5是否一样
77 | - `viz`: 使用`graphviz`编译为指定格式的图片,用法为`viz source.dot png`
78 |
79 | 在`CharlesScripts/charles/installation.d/conf.d/config-fish`配置好的命令缩写
80 |
81 | - `...` -> `cd ...`
82 | - `c` -> `clear; cd`
83 | - `cl` -> `cd ..;ls`
84 | - `eg` -> `grep -E`
85 | - `ftps` -> `python3 -m http.server 8080`: 快速开启一个简易 ftp 服务器
86 | - `gaa` -> `git add -A`
87 | - `gb` -> `git branch -c`
88 | - `gck` -> `git checkout`
89 | - `gcm` -> `git commit -m`
90 | - `gl` -> `git l`: 显示结构化的 git 日志
91 | - `gm` -> `git merge --no-ff`
92 | - `gp` -> `git push`
93 | - `gpl` -> `git pull`
94 | - `gst` -> `git status`
95 | - `histg` -> `history | grep`
96 | - `i` -> `ipython --no-confirm-exit --no-banner --pprint -i --pylab=auto`
97 | - `l` -> `ls --color=auto`
98 | - `la` -> `ls --almost-all --color=auto`
99 | - `le` -> `ls --almost-all --color=auto|egrep`
100 | - `lg` -> `ls --almost-all --color=auto|grep`
101 | - `ll` -> `ls --almost-all -lh --color=auto`
102 | - `n` -> `xdg-open .`
103 | - `o` -> `xdg-open`
104 | - `p` -> `python`
105 | - `pdb` -> `python -mpowerline.bindings.pdb`
106 | - `su` -> `sudo su`
107 | - `u` -> `update`
108 |
109 |
110 |
111 | #### 3. 安装软件 ####
112 |
113 | 脚本在 `CharlesScripts/charles/installation.d/get.d`
114 |
115 | 标 `*` 的是推荐安装的
116 |
117 | ```
118 | get.d/
119 | ├── get-calibre
120 | ├── get-docker
121 | ├──*get-fasd
122 | ├──*get-oh-my-fish
123 | ├──*get-powerline
124 | ├── get-spacemacs
125 | ├── get-spacevim
126 | ├── get-sublime-text-3
127 | ├──*get-thefuck
128 | └── get-xsh
129 |
130 | ```
131 |
132 | #### 4. 配置软件 ####
133 |
134 | 脚本在 `CharlesScripts/charles/installation.d/conf.d`
135 |
136 | 标 `*` 的是推荐安装的
137 |
138 | ```
139 | conf.d/
140 | ├──*config-bash
141 | ├──*config-fish
142 | ├──*config-git
143 | ├──*config-gnome
144 | ├──*config-powerline-bash
145 | ├── config-powerline-ipython
146 | └──*config-tmux
147 |
148 | ```
149 |
150 | # 安装指南 #
151 | 装前必读:
152 |
153 | - 本项目并未经过大量测试,需要读者有基本的 Linux 问题处理能力
154 | - 支持的操作系统:Arch Linux 或 Ubuntu Gnome 最新LTS版
155 | - 依赖项(需要用户自行安装): Nerd Fonts, Google Chrome, curl
156 | - 可选项:Anaconda, ipython (>=5.0), fortune-zh
157 |
158 | 逐步安装:
159 |
160 | 1. 安装依赖
161 | 2. 下载本项目:`git clone https://github.com/the0demiurge/CharlesScripts.git ~/.local/share/CharlesScripts`
162 | 3. `cd ~/.local/share/CharlesScripts/charles/installation.d`
163 | 4. 阅读并运行相关软件安装脚本和配置脚本。
164 |
165 | 安装脚本(测试中):
166 |
167 | `bash <(curl -L https://git.io/get-charles)`
168 |
169 | # 效果图: #
170 |
171 | 按照[**Ubuntu Gnome 酷炫完整指南系列**](https://the0demiurge.blogspot.jp/2017/02/ubuntu-gnome.html)介绍的内容配置后如下图所示。
172 |
173 | 
174 | 
175 | 
176 |
--------------------------------------------------------------------------------
/accessories/arc-darker-theme for Google Chrome.crx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/the0demiurge/CharlesScripts/c567d210b482383a638717906cdd5be24a451e77/accessories/arc-darker-theme for Google Chrome.crx
--------------------------------------------------------------------------------
/accessories/cows.txt:
--------------------------------------------------------------------------------
1 | _____
2 | < apt >
3 | -----
4 | \ (__)
5 | (oo)
6 | /------\/
7 | / | ||
8 | * /\---/\
9 | ~~ ~~
10 | ____________
11 | < beavis.zen >
12 | ------------
13 | \ __------~~-,
14 | \ ,' ,
15 | / \
16 | / :
17 | | '
18 | | |
19 | | |
20 | | _-- |
21 | _| =-. .-. ||
22 | o|/o/ _. |
23 | / ~ \ |
24 | (____@) ___~ |
25 | |_===~~~.` |
26 | _______.--~ |
27 | \________ |
28 | \ |
29 | __/-___-- -__
30 | / _ \
31 | ______
32 | < bong >
33 | ------
34 | \
35 | \
36 | ^__^
37 | _______/(oo)
38 | /\/( /(__)
39 | | W----|| |~|
40 | || || |~| ~~
41 | |~| ~
42 | |_| o
43 | |#|/
44 | _+#+_
45 | ___________
46 | < bud-frogs >
47 | -----------
48 | \
49 | \
50 | oO)-. .-(Oo
51 | /__ _\ /_ __\
52 | \ \( | ()~() | )/ /
53 | \__|\ | (-___-) | /|__/
54 | ' '--' ==`-'== '--' '
55 | _______
56 | < bunny >
57 | -------
58 | \
59 | \ \
60 | \ /\
61 | ( )
62 | .( o ).
63 | ________
64 | < calvin >
65 | --------
66 | \ .,
67 | \ . .TR d'
68 | \ k,l .R.b .t .Je
69 | \ .P q. a|.b .f .Z%
70 | .b .h .E` # J: 2` .
71 | .,.a .E ,L.M' ?:b `| ..J9!`.,
72 | q,.h.M` `.., ..,""` ..2"`
73 | .M, J8` `: ` 3;
74 | . Jk ..., `^7"90c.
75 | j, ,! .7"'`j,.| .n. ...
76 | j, 7' .r` 4: L `...
77 | ..,m. J` ..,|.. J` 7TWi
78 | ..JJ,.: % oo ,. ....,
79 | .,E 3 7`g.M: P 41
80 | JT7"' O. .J,; `` V"7N.
81 | G. ""Q+ .Zu.,!` Z`
82 | .9.. . J&..J! . ,:
83 | 7"9a JM"!
84 | .5J. .. ..F`
85 | 78a.. ` ..2'
86 | J9Ksaw0"'
87 | .EJ?A...a.
88 | q...g...gi
89 | .m...qa..,y:
90 | .HQFNB&...mm
91 | ,Z|,m.a.,dp
92 | .,?f` ,E?:"^7b
93 | `A| . .F^^7'^4,
94 | .MMMMMMMMMMMQzna,
95 | ...f"A.JdT J: Jp,
96 | `JNa..........A....af`
97 | `^^^^^'`
98 | ________
99 | < cheese >
100 | --------
101 | \
102 | \
103 | _____ _________
104 | / \_/ |
105 | | ||
106 | | ||
107 | | ###\ /### | |
108 | | 0 \/ 0 | |
109 | /| | |
110 | / | < |\ \
111 | | /| | | |
112 | | | \_______/ | | |
113 | | | | / /
114 | /|| /|||
115 | ----------------|
116 | | | | |
117 | *** ***
118 | /___\ /___\
119 | ______
120 | < cock >
121 | ------
122 | \
123 | \ /\/\
124 | \ /
125 | | 0 >>
126 | |___|
127 | __((_<| |
128 | ( |
129 | (__________)
130 | | |
131 | | |
132 | /\ /\
133 | _______
134 | < cower >
135 | -------
136 | \
137 | \
138 | ,__, | |
139 | (oo)\| |___
140 | (__)\| | )\_
141 | | |_w | \
142 | | | || *
143 |
144 | Cower....
145 | ________
146 | < daemon >
147 | --------
148 | \ , ,
149 | \ /( )`
150 | \ \ \___ / |
151 | /- _ `-/ '
152 | (/\/ \ \ /\
153 | / / | ` \
154 | O O ) / |
155 | `-^--'`< '
156 | (_.) _ ) /
157 | `.___/` /
158 | `-----' /
159 | <----. __ / __ \
160 | <----|====O)))==) \) /====
161 | <----' `--' `.__,' \
162 | | |
163 | \ /
164 | ______( (_ / \______
165 | ,' ,-----' | \
166 | `--{__________) \/
167 | _________
168 | < default >
169 | ---------
170 | \ ^__^
171 | \ (oo)\_______
172 | (__)\ )\/\
173 | ||----w |
174 | || ||
175 | ________________
176 | < dragon-and-cow >
177 | ----------------
178 | \ ^ /^
179 | \ / \ // \
180 | \ |\___/| / \// .\
181 | \ /O O \__ / // | \ \ *----*
182 | / / \/_/ // | \ \ \ |
183 | @___@` \/_ // | \ \ \/\ \
184 | 0/0/| \/_ // | \ \ \ \
185 | 0/0/0/0/| \/// | \ \ | |
186 | 0/0/0/0/0/_|_ / ( // | \ _\ | /
187 | 0/0/0/0/0/0/`/,_ _ _/ ) ; -. | _ _\.-~ / /
188 | ,-} _ *-.|.-~-. .~ ~
189 | \ \__/ `/\ / ~-. _ .-~ /
190 | \____(oo) *. } { /
191 | ( (--) .----~-.\ \-` .~
192 | //__\\ \__ Ack! ///.----..< \ _ -~
193 | // \\ ///-._ _ _ _ _ _ _{^ - - - - ~
194 | ________
195 | < dragon >
196 | --------
197 | \ / \ //\
198 | \ |\___/| / \// \\
199 | /0 0 \__ / // | \ \
200 | / / \/_/ // | \ \
201 | @_^_@'/ \/_ // | \ \
202 | //_^_/ \/_ // | \ \
203 | ( //) | \/// | \ \
204 | ( / /) _|_ / ) // | \ _\
205 | ( // /) '/,_ _ _/ ( ; -. | _ _\.-~ .-~~~^-.
206 | (( / / )) ,-{ _ `-.|.-~-. .~ `.
207 | (( // / )) '/\ / ~-. _ .-~ .-~^-. \
208 | (( /// )) `. { } / \ \
209 | (( / )) .----~-.\ \-' .~ \ `. \^-.
210 | ///.----..> \ _ -~ `. ^-` ^-_
211 | ///-._ _ _ _ _ _ _}^ - - - - ~ ~-- ,.-~
212 | /.-~
213 | ______
214 | < duck >
215 | ------
216 | \
217 | \
218 | \ >()_
219 | (__)__ _
220 | __________
221 | < elephant >
222 | ----------
223 | \ /\ ___ /\
224 | \ // \/ \/ \\
225 | (( O O ))
226 | \\ / \ //
227 | \/ | | \/
228 | | | | |
229 | | | | |
230 | | o |
231 | | | | |
232 | |m| |m|
233 | ___________________
234 | < elephant-in-snake >
235 | -------------------
236 | \
237 | \ ....
238 | . ........
239 | . .
240 | . .
241 | ....... .........
242 | ..............................
243 | Elephant inside ASCII snake
244 | ______
245 | < eyes >
246 | ------
247 | \
248 | \
249 | .::!!!!!!!:.
250 | .!!!!!:. .:!!!!!!!!!!!!
251 | ~~~~!!!!!!. .:!!!!!!!!!UWWW$$$
252 | :$$NWX!!: .:!!!!!!XUWW$$$$$$$$$P
253 | $$$$$##WX!: .
260 | ---------------
261 | \ . . .
262 | \ . . . ` ,
263 | \ .; . : .' : : : .
264 | \ i..`: i` i.i.,i i .
265 | \ `,--.|i |i|ii|ii|i:
266 | UooU\.'@@@@@@`.||'
267 | \__/(@@@@@@@@@@)'
268 | (@@@@@@@@)
269 | `YY~~~~YY'
270 | || ||
271 | ______________
272 | < ghostbusters >
273 | --------------
274 | \
275 | \
276 | \ __---__
277 | _- /--______
278 | __--( / \ )XXXXXXXXXXX\v.
279 | .-XXX( O O )XXXXXXXXXXXXXXX-
280 | /XXX( U ) XXXXXXX\
281 | /XXXXX( )--_ XXXXXXXXXXX\
282 | /XXXXX/ ( O ) XXXXXX \XXXXX\
283 | XXXXX/ / XXXXXX \__ \XXXXX
284 | XXXXXX__/ XXXXXX \__---->
285 | ---___ XXX__/ XXXXXX \__ /
286 | \- --__/ ___/\ XXXXXX / ___--/=
287 | \-\ ___/ XXXXXX '--- XXXXXX
288 | \-\/XXX\ XXXXXX /XXXXX
289 | \XXXXXXXXX \ /XXXXX/
290 | \XXXXXX > _/XXXXX/
291 | \XXXXX--__/ __-- XXXX/
292 | -XXXXXXXX--------------- XXXXXX-
293 | \XXXXXXXXXXXXXXXXXXXXXXXXXX/
294 | ""VXXXXXXXXXXXXXXXXXXV""
295 | _____
296 | < gnu >
297 | -----
298 | \ ,-----._
299 | . \ . ,' `-.__,------._
300 | // \ __\\' `-.
301 | (( _____-'___)) |
302 | `:='/ (alf_/ |
303 | `.=| |=' |
304 | |) O | \
305 | | | /\ \
306 | | / . / \ \
307 | | .-..__ ___ .--' \ |\ \ |
308 | |o o | ``--.___. / `-' \ \\ \ |
309 | `--'' ' .' / / | | | | \
310 | | | / / | | | mmm
311 | | || | | /| |
312 | ( .' \ \ || | |
313 | | | \ \ // / /
314 | | | \ \ || |_|
315 | / | |_/ /_|
316 | /__/
317 | _________
318 | < head-in >
319 | ---------
320 | \
321 | \
322 | ^__^ /
323 | (oo)\_______/ _________
324 | (__)\ )=( ____|_ \_____
325 | ||----w | \ \ \_____ |
326 | || || || ||
327 | ____________
328 | < hellokitty >
329 | ------------
330 | \
331 | \
332 | /\_)o<
333 | | \
334 | | O . O|
335 | \_____/
336 | ______
337 | < kiss >
338 | ------
339 | \
340 | \
341 | ,;;;;;;;,
342 | ;;;;;;;;;;;,
343 | ;;;;;'_____;'
344 | ;;;(/))))|((\
345 | _;;((((((|))))
346 | / |_\\\\\\\\\\\\
347 | .--~( \ ~))))))))))))
348 | / \ `\-(((((((((((\\
349 | | | `\ ) |\ /|)
350 | | | `. _/ \_____/ |
351 | | , `\~ /
352 | | \ \ /
353 | | `. `\| /
354 | | ~- `\ /
355 | \____~._/~ -_, (\
356 | |-----|\ \ ';;
357 | | | :;;;' \
358 | | / | |
359 | | | |
360 | _______
361 | < kitty >
362 | -------
363 | \
364 | \
365 | ("`-' '-/") .___..--' ' "`-._
366 | ` *_ * ) `-. ( ) .`-.__. `)
367 | (_Y_.) ' ._ ) `._` ; `` -. .-'
368 | _.. `--'_..-_/ /--' _ .' ,4
369 | ( i l ),-'' ( l i),' ( ( ! .-'
370 | _______
371 | < koala >
372 | -------
373 | \
374 | \
375 | ___
376 | {~._.~}
377 | ( Y )
378 | ()~*~()
379 | (_)-(_)
380 | ______
381 | < kosh >
382 | ------
383 | \
384 | \
385 | \
386 | ___ _____ ___
387 | / \ / /| / \
388 | | | / / | | |
389 | | | /____/ | | |
390 | | | | | | | |
391 | | | | {} | / | |
392 | | | |____|/ | |
393 | | | |==| | |
394 | | \___________/ |
395 | | |
396 | | |
397 | ____________
398 | < luke-koala >
399 | ------------
400 | \
401 | \ .
402 | ___ //
403 | {~._.~}//
404 | ( Y )K/
405 | ()~*~()
406 | (_)-(_)
407 | Luke
408 | Skywalker
409 | koala
410 | ______________
411 | < mech-and-cow >
412 | --------------
413 | ,-----.
414 | | |
415 | ,--| |-.
416 | __,----| | | |
417 | ,;:: | `_____' |
418 | `._______| i^i |
419 | `----| |---'| .
420 | ,-------._| |== ||//
421 | | |_|P`. /'/
422 | `-------' 'Y Y/'/'
423 | .== /_
424 | ^__^ / /'| `i
425 | (oo)_______ /' / | |
426 | (__) )/ /' / | `i
427 | ||----w | ___,;`----'.___L_,-'`__
428 | || || i_____;----.____i""____
429 |
430 | ______
431 | < meow >
432 | ------
433 | \
434 | \ , _ ___.--'''`--''//-,-_--_.
435 | \`"' ` || \\ \ \\/ / // / ,-\\`,_
436 | /'` \ \ || Y | \|/ / // / - |__ `-,
437 | /@"\ ` \ `\ | | ||/ // | \/ \ `-._`-,_.,
438 | / _.-. `.-\,___/\ _/|_/_\_\/|_/ | `-._._)
439 | `-'``/ / | // \__/\__ / \__/ \
440 | `-' /-\/ | -| \__ \ |-' |
441 | __/\ / _/ \/ __,-' ) ,' _|'
442 | (((__/(((_.' ((___..-'((__,'
443 | ______
444 | < milk >
445 | ------
446 | \ ____________
447 | \ |__________|
448 | / /\
449 | / / \
450 | /___________/___/|
451 | | | |
452 | | ==\ /== | |
453 | | O O | \ \ |
454 | | < | \ \|
455 | /| | \ \
456 | / | \_____/ | / /
457 | / /| | / /|
458 | /||\| | /||\/
459 | -------------|
460 | | | | |
461 | <__/ \__>
462 | _________
463 | < moofasa >
464 | ---------
465 | \ ____
466 | \ / \
467 | | ^__^ |
468 | | (oo) |______
469 | | (__) | )\/\
470 | \____/|----w |
471 | || ||
472 |
473 | Moofasa
474 | _______
475 | < moose >
476 | -------
477 | \
478 | \ \_\_ _/_/
479 | \ \__/
480 | (oo)\_______
481 | (__)\ )\/\
482 | ||----w |
483 | || ||
484 | ___________
485 | < mutilated >
486 | -----------
487 | \ \_______
488 | v__v \ \ O )
489 | (oo) ||----w |
490 | (__) || || \/\
491 |
492 | ______
493 | < pony >
494 | ------
495 | \ /\/\
496 | \ \/\/
497 | \ / -\
498 | \ / oo -\
499 | \ / \
500 | | ---\ -\
501 | \--/ \ \
502 | | -\
503 | \ -\ -------------\ /-\
504 | \ \-------/ ---/ \
505 | \ |\ \
506 | | / | |
507 | \ | \ |
508 | | / \ |
509 | | / \ |
510 | \ \ \|
511 | - /--------\ | o
512 | \+ +--------- \ |
513 | | | | \
514 | | | \ |
515 | | | | \
516 | | | \ |
517 | \ | | |
518 | | | \ \
519 | | | | |
520 | +--+ ---+
521 | ______________
522 | < pony-smaller >
523 | --------------
524 | \ _^^
525 | \ _- oo\
526 | \----- \______
527 | \ )\
528 | ||-----|| \
529 | || ||
530 | _____
531 | < ren >
532 | -----
533 | \
534 | \
535 | ____
536 | /# /_\_
537 | | |/o\o\
538 | | \\_/_/
539 | / |_ |
540 | | ||\_ ~|
541 | | ||| \/
542 | | |||_
543 | \// |
544 | || |
545 | ||_ \
546 | \_| o|
547 | /\___/
548 | / ||||__
549 | (___)_)
550 | _______
551 | < sheep >
552 | -------
553 | \
554 | \
555 | __
556 | UooU\.'@@@@@@`.
557 | \__/(@@@@@@@@@@)
558 | (@@@@@@@@)
559 | `YY~~~~YY'
560 | || ||
561 | __________
562 | < skeleton >
563 | ----------
564 | \ (__)
565 | \ /oo|
566 | \ (_"_)*+++++++++*
567 | //I#\\\\\\\\I\
568 | I[I|I|||||I I `
569 | I`I'///'' I I
570 | I I I I
571 | ~ ~ ~ ~
572 | Scowleton
573 | _________
574 | < snowman >
575 | ---------
576 | \
577 | ___###
578 | /oo\ |||
579 | \ / \|/
580 | /""\ I
581 | ()| |(I)
582 | \ / I
583 | /""""\ I
584 | | |I
585 | | |I
586 | \____/ I
587 | _________________
588 | < sodomized-sheep >
589 | -----------------
590 | \ __
591 | \ (oo)
592 | \ ( )
593 | \ /--\
594 | __ / \ \
595 | UooU\.'@@@@@@`.\ )
596 | \__/(@@@@@@@@@@) /
597 | (@@@@@@@@)((
598 | `YY~~~~YY' \\
599 | || || >>
600 | _____________
601 | < stegosaurus >
602 | -------------
603 | \ . .
604 | \ / `. .' "
605 | \ .---. < > < > .---.
606 | \ | \ \ - ~ ~ - / / |
607 | _____ ..-~ ~-..-~
608 | | | \~~~\.' `./~~~/
609 | --------- \__/ \__/
610 | .' O \ / / \ "
611 | (_____, `._.' | } \/~~~/
612 | `----. / } | / \__/
613 | `-. | / | / `. ,~~|
614 | ~-.__| /_ - ~ ^| /- _ `..-'
615 | | / | / ~-. `-. _ _ _
616 | |_____| |_____| ~ - . _ _ _ _ _>
617 | ________
618 | < stimpy >
619 | --------
620 | \ . _ .
621 | \ |\_|/__/|
622 | / / \/ \ \
623 | /__|O||O|__ \
624 | |/_ \_/\_/ _\ |
625 | | | (____) | ||
626 | \/\___/\__/ //
627 | (_/ ||
628 | | ||
629 | | ||\
630 | \ //_/
631 | \______//
632 | __ || __||
633 | (____(____)
634 | ______
635 | < suse >
636 | ------
637 | \
638 | \____
639 | /@ ~-.
640 | \/ __ .- |
641 | // // @
642 | ____________
643 | < three-eyes >
644 | ------------
645 | \ ^___^
646 | \ (ooo)\_______
647 | (___)\ )\/\
648 | ||----w |
649 | || ||
650 | ________
651 | < turkey >
652 | --------
653 | \ ,+*^^*+___+++_
654 | \ ,*^^^^ )
655 | \ _+* ^**+_
656 | \ +^ _ _++*+_+++_, )
657 | _+^^*+_ ( ,+*^ ^ \+_ )
658 | { ) ( ,( ,_+--+--, ^) ^\
659 | { (@) } f ,( ,+-^ __*_*_ ^^\_ ^\ )
660 | {:;-/ (_+*-+^^^^^+*+*<_ _++_)_ ) ) /
661 | ( / ( ( ,___ ^*+_+* ) < < \
662 | U _/ ) *--< ) ^\-----++__) ) ) )
663 | ( ) _(^)^^)) ) )\^^^^^))^*+/ / /
664 | ( / (_))_^)) ) ) ))^^^^^))^^^)__/ +^^
665 | ( ,/ (^))^)) ) ) ))^^^^^^^))^^) _)
666 | *+__+* (_))^) ) ) ))^^^^^^))^^^^^)____*^
667 | \ \_)^)_)) ))^^^^^^^^^^))^^^^)
668 | (_ ^\__^^^^^^^^^^^^))^^^^^^^)
669 | ^\___ ^\__^^^^^^))^^^^^^^^)\\
670 | ^^^^^\uuu/^^\uuu/^^^^\^\^\^\^\^\^\^\
671 | ___) >____) >___ ^\_\_\_\_\_\_\)
672 | ^^^//\\_^^//\\_^ ^(\_\_\_\)
673 | ^^^ ^^ ^^^ ^
674 | ________
675 | < turtle >
676 | --------
677 | \ ___-------___
678 | \ _-~~ ~~-_
679 | \ _-~ /~-_
680 | /^\__/^\ /~ \ / \
681 | /| O|| O| / \_______________/ \
682 | | |___||__| / / \ \
683 | | \ / / \ \
684 | | (_______) /______/ \_________ \
685 | | / / \ / \
686 | \ \^\\ \ / \ /
687 | \ || \______________/ _-_ //\__//
688 | \ ||------_-~~-_ ------------- \ --/~ ~\ || __/
689 | ~-----||====/~ |==================| |/~~~~~
690 | (_(__/ ./ / \_\ \.
691 | (_(___/ \_____)_)
692 | _____
693 | < tux >
694 | -----
695 | \
696 | \
697 | .--.
698 | |o_o |
699 | |:_/ |
700 | // \ \
701 | (| | )
702 | /'\_ _/`\
703 | \___)=(___/
704 |
705 | _________
706 | < unipony >
707 | ---------
708 | \ \
709 | \ \_
710 | \ \\
711 | \ \\/\
712 | \ _\\/
713 | \ / -\
714 | \ / oo -\
715 | \ / \
716 | | ---\ -\
717 | \--/ \ \
718 | | -\
719 | \ -\ -------------\ /-\
720 | \ \-------/ ---/ \
721 | \ |\ \
722 | | / | |
723 | \ | \ |
724 | | / \ |
725 | | / \ |
726 | \ \ \|
727 | - /--------\ | o
728 | \+ +--------- \ |
729 | | | | \
730 | | | \ |
731 | | | | \
732 | | | \ |
733 | \ | | |
734 | | | \ \
735 | | | | |
736 | +--+ ---+
737 | _________________
738 | < unipony-smaller >
739 | -----------------
740 | \ \
741 | \ \
742 | \ _\^
743 | \ _- oo\
744 | \---- \______
745 | \ )\
746 | ||-----|| \
747 | || ||
748 | _______
749 | < vader >
750 | -------
751 | \ ,-^-.
752 | \ !oYo!
753 | \ /./=\.\______
754 | ## )\/\
755 | ||-----w||
756 | || ||
757 |
758 | Cowth Vader
759 | _____________
760 | < vader-koala >
761 | -------------
762 | \
763 | \ .
764 | .---. //
765 | Y|o o|Y//
766 | /_(i=i)K/
767 | ~()~*~()~
768 | (_)-(_)
769 |
770 | Darth
771 | Vader
772 | koala
773 | _____
774 | < www >
775 | -----
776 | \ ^__^
777 | \ (oo)\_______
778 | (__)\ )\/\
779 | ||--WWW |
780 | || ||
781 |
--------------------------------------------------------------------------------
/accessories/cursors.tar.xz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/the0demiurge/CharlesScripts/c567d210b482383a638717906cdd5be24a451e77/accessories/cursors.tar.xz
--------------------------------------------------------------------------------
/charles/bin/add-ppa:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # This script adds ppa and backup the ppa list automatically to ~/.backup
3 | OS=$(cat /etc/issue | cut -f 1 -d ' ')
4 | if [[ $OS == 'Ubuntu' ]]; then
5 | PPA_BACKUP_PATH=~/.config/CharlesBackup/Packages/ppa
6 | mkdir -p ~/.config/CharlesBackup
7 |
8 | for ppa in $@; do
9 | if [ $ppa ]; then
10 | sudo apt-add-repository -y $ppa
11 | if [ $? = 0 ]; then
12 | echo $ppa >>$PPA_BACKUP_PATH
13 | fi
14 | fi
15 | done
16 |
17 | sort -su $PPA_BACKUP_PATH -o $PPA_BACKUP_PATH >~/.cache/backup4ppa
18 | rm ~/.cache/backup4ppa
19 |
20 | if [ $(ls /etc/apt/sources.list.d/ | grep .save$ | wc -l) -gt 0 ]; then
21 | sudo rm /etc/apt/sources.list.d/*.save
22 | fi
23 | cat $PPA_BACKUP_PATH
24 | else
25 | echo 'Your distribution has not implementd yet, please modify this command'
26 | fi
27 |
--------------------------------------------------------------------------------
/charles/bin/apt-unlock:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #sudo rm /var/lib/apt/lists/lock
3 | sudo rm /var/lib/dpkg/lock
4 | sudo dpkg --configure -a
5 | sudo rm /var/cache/apt/archives/lock
6 | sudo fuser /var/cache/debconf/config.dat
7 | sudo rm /var/lib/apt/lists/lock
8 |
--------------------------------------------------------------------------------
/charles/bin/apt-upgrade:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 | help='using apt to update/upgrade/autoremove packages in one command\n
4 | Usage:\n
5 | \tapt-upgrade help: show help message\n
6 | \tapt-upgrade apt: update using normal apt\n
7 | \tapt-upgrade fast: update using apt-fast\n
8 | \tapt-upgrade socks: update using apt and socks proxy by tsocks\n
9 | '
10 |
11 | if [ $# == 1 ]; then
12 | if [ $1 == 'help' ]; then
13 | echo -e $help
14 | elif [ $1 == 'socks' ]; then
15 | echo "running with ShadowSocks"
16 | echo 'updating sources'
17 | sudo tsocks apt update #> /dev/null
18 | if [ $(apt list --upgradable | wc -l) -gt 1 ]; then
19 | apt list --upgradable
20 | echo 'upgrading'
21 | sleep 1
22 | sudo tsocks apt -y upgrade
23 | fi
24 | echo 'autoremoving'
25 | sleep 1
26 | sudo apt-fast -y autoremove
27 |
28 | elif [ $1 == "fast" ]; then
29 | echo "running with apt-fast"
30 | echo 'updating sources'
31 | sudo apt-fast update #> /dev/null
32 | if [ $(apt list --upgradable | wc -l) -gt 1 ]; then
33 | apt list --upgradable
34 | echo 'upgrading'
35 | sleep 1
36 | sudo apt-fast -y upgrade
37 | fi
38 | echo 'autoremoving'
39 | sleep 1
40 | sudo apt-fast -y autoremove
41 |
42 | else
43 | echo "running with normal apt"
44 | echo 'updating sources'
45 | sudo apt update #> /dev/null
46 | if [ $(apt list --upgradable | wc -l) -gt 1 ]; then
47 | apt list --upgradable
48 | echo 'upgrading'
49 | sleep 1
50 | sudo apt -y upgrade
51 |
52 | fi
53 | echo 'autoremoving'
54 | sleep 1
55 | sudo apt-fast -y autoremove
56 | fi
57 | else
58 | echo -e $help
59 | fi
60 |
--------------------------------------------------------------------------------
/charles/bin/aria2c-daemon:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env fish
2 | echo "download into $HOME/Downloads/"
3 | set config_path $HOME/.config/aria2c.conf
4 |
5 | cd $HOME
6 | touch $HOME/.cache/aria2.session
7 | switch $argv
8 | case start
9 | aria2c --conf-path=$config_path -D
10 | echo 'started' $config_path
11 | case stop
12 | killall aria2c
13 | case run
14 | echo "press Ctrl+C to stop"
15 | sleep 1
16 | aria2c --conf-path=$config_path
17 | end
18 |
19 | echo "Usage: aria2c-daemon [start/stop/run]"
20 |
--------------------------------------------------------------------------------
/charles/bin/cdar:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | if [ -z "$(which mountavfs)" ];then
3 | echo Please install avfs first
4 | exit
5 | fi
6 |
7 | if [ -z "$IN_AVFS" ];then
8 | export IN_AVFS=yes
9 | mountavfs
10 | if [ -z "$AVFSBASE" ];then
11 | AVFS_PWD="$HOME""/.avfs/$PWD"
12 | else
13 | AVFS_PWD="$AVFSBASE""$PWD"
14 | fi
15 |
16 | if [ -z "$1" ];then
17 | cd "$AVFS_PWD"
18 | elif [ -f "$1" ];then
19 | cd "$AVFS_PWD"/"$1""#"||exit
20 | elif [ -d "$1" ];then
21 | cd "$AVFS_PWD"/"$1"
22 | else
23 | cd "$AVFS_PWD"
24 | fi
25 | "$SHELL"
26 | umountavfs
27 | else
28 | echo Already in AVFS, skipping...
29 | fi
30 |
--------------------------------------------------------------------------------
/charles/bin/charles-update:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PUSH_DIR=(~/.config/CharlesBackup
3 | )
4 | PULL_DIR=(~/.local/share/CharlesScripts
5 | ~/.config/CharlesBackup
6 | # ~/.emacs.d
7 | # ~/.SpaceVim
8 | ~/.tmux
9 | )
10 | msg="$@"
11 |
12 | echo 'Updating CharlesScripts and dependencies...'
13 | for i in ${PULL_DIR[@]}; do
14 | cd $i
15 | echo Pulling $i
16 | git pull
17 | done
18 |
19 | echo 'Uploading Backups'
20 | for i in ${PUSH_DIR[@]}; do
21 | cd $i
22 | echo Pushing $i
23 | git add -A
24 | git status
25 | git diff HEAD
26 | if [[ -z $msg ]]; then
27 | read -p 'Message:' msg
28 | if [[ -z $msg ]]; then msg='update'; fi
29 | fi
30 | git commit -m "$msg"
31 | git push
32 | done
33 |
--------------------------------------------------------------------------------
/charles/bin/copy-path:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env fish
2 | echo -n $PWD/$argv[1] | pbcopy
3 |
--------------------------------------------------------------------------------
/charles/bin/ef:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # edit fifo
3 | $EDITOR ~/.local/share/CharlesScripts/charles/bin/fifo
4 |
--------------------------------------------------------------------------------
/charles/bin/fifo:
--------------------------------------------------------------------------------
1 | ../../../../../.config/CharlesBackup/fifo
--------------------------------------------------------------------------------
/charles/bin/follow:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import os
3 | import re
4 | import sys
5 | import warnings
6 | from itertools import zip_longest
7 | from math import inf
8 |
9 | command = 'mpv --msg-level=sub=error --fs "{}"'
10 | subtitle_arg = '--sub-file="{}"'
11 |
12 | video_formats = {'mp4', 'mkv', 'rmvb', 'flv', 'rm', 'avi', 'mov', 'wmv', 'm2ts'}
13 | srt_formats = {'srt', 'ass'}
14 |
15 | software = command.split()[0]
16 | sys.argv.append('.')
17 | path = sys.argv[1]
18 | schedule_path = os.path.join(path, 'progress')
19 |
20 |
21 | def help_msg():
22 | # help message
23 | print('Watch video series and record the watching progress.\nResume at the progress recorded\n')
24 | print('Usage:')
25 | print('Before startup, you should keep command `{}` in $PATH'.format(software))
26 | print('\tStart series:', 'follow', '[ []]')
27 | print('\tInterrupt series: press Ctrl+C in terminal or just close terminal')
28 | print('\tNext episode: close {} window'.format(software))
29 |
30 |
31 | if path.startswith('-') or path == 'help':
32 | help_msg()
33 | exit()
34 |
35 |
36 | class Subtitle_Matcher(object):
37 | def __init__(self, series, subtitles):
38 | self.pattern = r'\[.*?\]|(?<=[\.\s]).*?(?=[\.\s])|\d+'
39 | self.series = series
40 | self.subtitles = subtitles
41 | self.series_feature = None
42 | self.subtitles_feature = None
43 | self.feature_selection()
44 | self.ready = len(self.subtitles) > 0
45 |
46 | @staticmethod
47 | def feature_score(list_of_features):
48 | if len(list_of_features) - len(set(list_of_features)) > (len(list_of_features) / 2):
49 | return -inf
50 | score = 0
51 | for i in zip_longest(*list_of_features):
52 | score -= len(set(i)) / len(list_of_features)
53 | return score
54 |
55 | @staticmethod
56 | def edit_distance(src, target):
57 | dp = [[0 for i in range(len(target) + 1)] for j in range(len(src) + 1)]
58 | for i in range(1, len(src) + 1):
59 | dp[i][0] = i
60 | for j in range(1, len(target) + 1):
61 | dp[0][j] = j
62 | for i in range(1, len(src) + 1):
63 | for j in range(1, len(target) + 1):
64 | dp[i][j] = min(1 + dp[i - 1][j], 1 + dp[i][j - 1], dp[i - 1][j - 1] + (0 if src[i - 1] == target[j - 1] else 1))
65 | return dp[-1][-1]
66 |
67 | @staticmethod
68 | def num_distance(src, target):
69 | numss = re.findall(r'\d+', src)
70 | numst = re.findall(r'\d+', target)
71 | score = 0
72 | for a, b in zip(numss, numst):
73 | score += abs(int(a) - int(b))
74 | return score
75 |
76 | def extract_feature(self, filename, n):
77 | return re.findall(self.pattern, filename)[n]
78 |
79 | def extract_series_feature(self, filename):
80 | if self.series_feature:
81 | return self.extract_feature(filename, self.series_feature[0])
82 | else:
83 | return filename
84 |
85 | def extract_subtitles_feature(self, filename):
86 | if self.subtitles_feature:
87 | return self.extract_feature(filename, self.subtitles_feature[0])
88 | else:
89 | return filename
90 |
91 | def feature_selection(self):
92 | series_features = list(zip_longest(*[re.findall(self.pattern, i) for i in self.series]))
93 | subtitles_features = list(zip_longest(*[re.findall(self.pattern, i) for i in self.subtitles]))
94 | if len(series_features) > 0 and len(subtitles_features) > 0:
95 | self.series_feature = max(zip(range(len(series_features)), series_features), key=lambda x: self.feature_score(x[1]))
96 | self.subtitles_feature = max(zip(range(len(subtitles_features)), subtitles_features), key=lambda x: self.feature_score(x[1]))
97 |
98 | def match_subtitle(self, episode):
99 | name = episode.rsplit('.', 1)[0]
100 | for subtitle in self.subtitles:
101 | if name == subtitle.rsplit('.', 1)[0]:
102 | return subtitle
103 | if self.subtitles_feature and self.series_feature:
104 | feature_episode = self.extract_series_feature(episode)
105 | self.subtitles.sort(key=lambda x: self.edit_distance(feature_episode, self.extract_subtitles_feature(x)))
106 | self.subtitles.sort(key=lambda x: self.num_distance(feature_episode, self.extract_subtitles_feature(x)))
107 | return self.subtitles[0]
108 |
109 | def __call__(self, *args, **kwargs):
110 | return self.match_subtitle(*args, **kwargs)
111 |
112 |
113 | def main():
114 | # list videos
115 | series = sorted(
116 | [i for i in os.listdir(path) if i.split('.')[-1].lower() in video_formats],
117 | key=lambda x: [int(i) for i in re.findall(r'\d+', x)]
118 | )
119 | subtitles = [i for i in os.listdir(path) if i.split('.')[-1].lower() in srt_formats]
120 | if len(series) == 0:
121 | print('No video found in `{}`'.format(path))
122 | exit(0)
123 |
124 | sub_matcher = Subtitle_Matcher(series, subtitles)
125 |
126 | # decide series index
127 | if len(sys.argv) == 4:
128 | index = int(sys.argv[2]) - 1
129 | else:
130 | if not os.path.exists(schedule_path):
131 | index = 0
132 | else:
133 | current = open(schedule_path, 'r').readline().strip()
134 | index = series.index(current) + 1
135 | print('Started at index:', index + 1)
136 |
137 | # play loop
138 | for video in series[index:]:
139 | video_path = os.path.join(path, video)
140 | try:
141 | cmd = [command.format(video_path)]
142 | if sub_matcher.ready:
143 | sub_path = sub_matcher(video)
144 | if sub_path:
145 | cmd.append(subtitle_arg.format(os.path.join(path, sub_path)))
146 | print(cmd)
147 | status = os.system(' '.join(cmd))
148 | if status != 0:
149 | break
150 | open(schedule_path, 'w').write(video)
151 | except (KeyboardInterrupt, EOFError):
152 | break
153 | except PermissionError:
154 | warnings.warn('this place is not writeable')
155 |
156 |
157 | if __name__ == "__main__":
158 | main()
159 |
--------------------------------------------------------------------------------
/charles/bin/get-path:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env fish
2 | echo -n $PWD/$argv[1]
3 |
--------------------------------------------------------------------------------
/charles/bin/gh-md-toc:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #
4 | # Steps:
5 | #
6 | # 1. Download corresponding html file for some README.md:
7 | # curl -s $1
8 | #
9 | # 2. Discard rows where no substring 'user-content-' (github's markup):
10 | # awk '/user-content-/ { ...
11 | #
12 | # 3.1 Get last number in each row like ' ... sitemap.js.*<\/h/)+2, RLENGTH-5)
21 | #
22 | # 5. Find anchor and insert it inside "(...)":
23 | # substr($0, match($0, "href=\"[^\"]+?\" ")+6, RLENGTH-8)
24 | #
25 |
26 | gh_toc_version="0.4.9"
27 |
28 | gh_user_agent="gh-md-toc v$gh_toc_version"
29 |
30 | #
31 | # Download rendered into html README.md by its url.
32 | #
33 | #
34 | gh_toc_load() {
35 | local gh_url=$1
36 |
37 | if type curl &>/dev/null; then
38 | curl --user-agent "$gh_user_agent" -s "$gh_url"
39 | elif type wget &>/dev/null; then
40 | wget --user-agent="$gh_user_agent" -qO- "$gh_url"
41 | else
42 | echo "Please, install 'curl' or 'wget' and try again."
43 | exit 1
44 | fi
45 | }
46 |
47 | #
48 | # Converts local md file into html by GitHub
49 | #
50 | # ➥ curl -X POST --data '{"text": "Hello world github/linguist#1 **cool**, and #1!"}' https://api.github.com/markdown
51 | # Hello world github/linguist#1 cool , and #1!
'"
52 | gh_toc_md2html() {
53 | local gh_file_md=$1
54 | URL=https://api.github.com/markdown/raw
55 | TOKEN="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/token.txt"
56 | if [ -f "$TOKEN" ]; then
57 | URL="$URL?access_token=$(cat $TOKEN)"
58 | fi
59 | curl -s --user-agent "$gh_user_agent" \
60 | --data-binary @"$gh_file_md" -H "Content-Type:text/plain" \
61 | $URL
62 | }
63 |
64 | #
65 | # Is passed string url
66 | #
67 | gh_is_url() {
68 | case $1 in
69 | https* | http*)
70 | echo "yes";;
71 | *)
72 | echo "no";;
73 | esac
74 | }
75 |
76 | #
77 | # TOC generator
78 | #
79 | gh_toc(){
80 | local gh_src=$1
81 | local gh_src_copy=$1
82 | local gh_ttl_docs=$2
83 |
84 | if [ "$gh_src" = "" ]; then
85 | echo "Please, enter URL or local path for a README.md"
86 | exit 1
87 | fi
88 |
89 |
90 | # Show "TOC" string only if working with one document
91 | if [ "$gh_ttl_docs" = "1" ]; then
92 |
93 | echo "Table of Contents"
94 | echo "================="
95 | echo ""
96 | gh_src_copy=""
97 |
98 | fi
99 |
100 | if [ "$(gh_is_url "$gh_src")" == "yes" ]; then
101 | gh_toc_load "$gh_src" | gh_toc_grab "$gh_src_copy"
102 | else
103 | gh_toc_md2html "$gh_src" | gh_toc_grab "$gh_src_copy"
104 | fi
105 | }
106 |
107 | #
108 | # Grabber of the TOC from rendered html
109 | #
110 | # $1 — a source url of document.
111 | # It's need if TOC is generated for multiple documents.
112 | #
113 | gh_toc_grab() {
114 | # if closed is on the new line, then move it on the prev line
115 | # for example:
116 | # was: The command foo1
117 | #
118 | # became: The command foo1
119 | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n<\/h/<\/h/g' |
120 | # find strings that corresponds to template
121 | grep -E -o '//' | sed 's/<\/code>//' |
124 | # now all rows are like:
125 | # ... .*<\/h/)+2, RLENGTH-5)"](" gh_url substr($0, match($0, "href=\"[^\"]+?\" ")+6, RLENGTH-8) ")"}' | sed 'y/+/ /; s/%/\\x/g')"
130 | }
131 |
132 | #
133 | # Returns filename only from full path or url
134 | #
135 | gh_toc_get_filename() {
136 | echo "${1##*/}"
137 | }
138 |
139 | #
140 | # Options hendlers
141 | #
142 | gh_toc_app() {
143 | local app_name="gh-md-toc"
144 |
145 | if [ "$1" = '--help' ] || [ $# -eq 0 ] ; then
146 | echo "GitHub TOC generator ($app_name): $gh_toc_version"
147 | echo ""
148 | echo "Usage:"
149 | echo " $app_name src [src] Create TOC for a README file (url or local path)"
150 | echo " $app_name - Create TOC for markdown from STDIN"
151 | echo " $app_name --help Show help"
152 | echo " $app_name --version Show version"
153 | return
154 | fi
155 |
156 | if [ "$1" = '--version' ]; then
157 | echo "$gh_toc_version"
158 | return
159 | fi
160 |
161 | if [ "$1" = "-" ]; then
162 | if [ -z "$TMPDIR" ]; then
163 | TMPDIR="/tmp"
164 | elif [ -n "$TMPDIR" -a ! -d "$TMPDIR" ]; then
165 | mkdir -p "$TMPDIR"
166 | fi
167 | local gh_tmp_md
168 | gh_tmp_md=$(mktemp $TMPDIR/tmp.XXXXXX)
169 | while read input; do
170 | echo "$input" >> "$gh_tmp_md"
171 | done
172 | gh_toc_md2html "$gh_tmp_md" | gh_toc_grab ""
173 | return
174 | fi
175 |
176 | for md in "$@"
177 | do
178 | echo ""
179 | gh_toc "$md" "$#"
180 | done
181 |
182 | echo ""
183 | echo "Created by [gh-md-toc](https://github.com/ekalinin/github-markdown-toc)"
184 | }
185 |
186 | #
187 | # Entry point
188 | #
189 | gh_toc_app "$@"
190 |
--------------------------------------------------------------------------------
/charles/bin/gnome-shell-extensions-backup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/fish
2 | cd $HOME/.local/share/gnome-shell/
3 | zip -r /tmp/gnome-shell-extensions.zip extensions/
4 | mv /tmp/gnome-shell-extensions.zip ~/.config/CharlesBackup
5 |
--------------------------------------------------------------------------------
/charles/bin/gnome-shell-extensions-restore:
--------------------------------------------------------------------------------
1 | #!/usr/bin/fish
2 | cd ~/.config/CharlesBackup
3 | cp gnome-shell-extensions.zip $HOME/.local/share/gnome-shell/
4 | cd $HOME/.local/share/gnome-shell/
5 | unzip gnome-shell-extensions.zip
6 | rm gnome-shell-extensions.zip
7 |
8 | echo 'You should restart the gnome-shell(alt+f2 -> r -> enter), and enable extension in gnome-tweak-tool'
9 |
--------------------------------------------------------------------------------
/charles/bin/gojuon:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import random
3 | import sys
4 | import time
5 |
6 | help_messages = '''gajuon learning helper
7 | Usage:
8 | gajuon test katakana/hepburn do a test
9 | gajuon search search for given character
10 | gajuon table show gajuon table
11 | gajuon help show this helping message
12 | '''
13 | a = {'a': ['あ', 'ア'], 'i': ['い', 'イ'], 'u': ['う', 'ウ'], 'e': ['え', 'エ'], 'o': ['お', 'オ']}
14 | k = {'ka': ['か', 'カ'], 'ki': ['き', 'キ'], 'ku': ['く', 'ク'], 'ke': ['け', 'ケ'], 'ko': ['こ', 'コ']}
15 | s = {'sa': ['さ', 'サ'], 'shi': ['し', 'シ'], 'su': ['す', 'ス'], 'se': ['せ', 'セ'], 'so': ['そ', 'ソ']}
16 | t = {'ta': ['た', 'タ'], 'chi': ['ち', 'チ'], 'tsu': ['つ', 'ツ'], 'te': ['て', 'テ'], 'to': ['と', 'ト']}
17 | n = {'na': ['な', 'ナ'], 'ni': ['に', 'ニ'], 'nu': ['ぬ', 'ヌ'], 'ne': ['ね', 'ネ'], 'no': ['の', 'ノ']}
18 | h = {'ha': ['は', 'ハ'], 'hi': ['ひ', 'ヒ'], 'fu': ['ふ', 'フ'], 'he': ['へ', 'ヘ'], 'ho': ['ほ', 'ホ']}
19 | m = {'ma': ['ま', 'マ'], 'mi': ['み', 'ミ'], 'mu': ['む', 'ム'], 'me': ['め', 'メ'], 'mo': ['も', 'モ']}
20 | y = {'ya': ['や', 'ヤ'], 'yu': ['ゆ', 'ユ'], 'yo': ['よ', 'ヨ']}
21 | r = {'ra': ['ら', 'ラ'], 'ri': ['り', 'リ'], 'ru': ['る', 'ル'], 're': ['れ', 'レ'], 'ro': ['ろ', 'ロ']}
22 | w = {'wa': ['わ', 'ワ'], ' n': ['ん', 'ン'], 'wo': ['を', 'ヲ']}
23 |
24 | g = {'ga': ['が', 'ガ'], 'gi': ['ぎ', 'ギ'], 'gu': ['ぐ', 'グ'], 'ge': ['げ', 'ゲ'], 'go': ['ご', 'ゴ']}
25 | z = {'za': ['ざ', 'ザ'], 'ji': ['じ', 'ジ'], 'zu': ['ず', 'ズ'], 'ze': ['ぜ', 'ゼ'], 'zo': ['ぞ', 'ゾ']}
26 | d = {'da': ['だ', 'ダ'], 'ji': ['ぢ', 'ヂ'], 'zu': ['づ', 'ヅ'], 'de': ['で', 'デ'], 'do': ['ど', 'ド']}
27 | b = {'ba': ['ば', 'バ'], 'bi': ['び', 'ビ'], 'bu': ['ぶ', 'ブ'], 'be': ['べ', 'ベ'], 'bo': ['ぼ', 'ボ']}
28 | p = {'pa': ['ぱ', 'パ'], 'pi': ['ぴ', 'ピ'], 'pu': ['ぷ', 'プ'], 'pe': ['ぺ', 'ペ'], 'po': ['ぽ', 'ポ']}
29 |
30 |
31 | data = [
32 | a,
33 | k,
34 | s,
35 | t,
36 | n,
37 | h,
38 | m,
39 | y,
40 | r,
41 | w,
42 |
43 | g,
44 | z,
45 | d,
46 | b,
47 | p,
48 | ]
49 |
50 |
51 | characters: list = sum([list(i.items()) for i in data], list())
52 |
53 |
54 | def test():
55 | if len(sys.argv) < 3:
56 | index = [0, 1]
57 | elif sys.argv[2][0].lower() == 'h':
58 | index = [0]
59 | elif sys.argv[2][0].lower() == 'k':
60 | index = [1]
61 | else:
62 | index = [0, 1]
63 | if sys.argv[-1].isdigit():
64 | test_chars = max(1, int(sys.argv[-1]))
65 | else:
66 | test_chars = 1
67 | wrong = list()
68 | quiz = 0
69 | correct = 0
70 | while(True):
71 | random.shuffle(characters)
72 | start = time.time()
73 | indexes = random.sample(index * len(characters), len(characters))
74 | if len(index) == 2:
75 | indexes += [1 - i for i in indexes]
76 | try:
77 | quiz_list = list()
78 | for character, idx in zip(characters * len(index), indexes):
79 | quiz_list.append((character, idx))
80 | if len(quiz_list) < test_chars:
81 | continue
82 | result = input('{}:{}'.format(' '.join([quiz_char[1][quiz_idx] for quiz_char, quiz_idx in quiz_list]), ' ' if test_chars == 1 else '\n')).strip().split()
83 | for rst, (quiz_char, idx) in zip(result, quiz_list):
84 | if not (rst == quiz_char[0].strip() or rst in quiz_char[1]):
85 | print('{}: {}, {}'.format(quiz_char[0], quiz_char[1][0], quiz_char[1][1]))
86 | wrong.append((rst, quiz_char))
87 | else:
88 | correct += 1
89 | quiz += 1
90 | quiz_list = list()
91 | finally:
92 | if quiz:
93 | end = time.time()
94 | print('\nACCURACY: {}/{}={:0.2f}%'.format(correct, quiz, 100 * (correct / quiz)))
95 | print('AVERAGE {:0.2f}s/char'.format((end - start) / quiz))
96 | print('WRONG ANSWERS:')
97 | for result, character in wrong:
98 | print('{}: {}, {}\t\\ {}'.format(character[0], character[1][0], character[1][1], result))
99 |
100 |
101 | def search():
102 | while True:
103 | found = list()
104 | char = input('Searching for:')
105 | for line in data:
106 | if char in line:
107 | key = char
108 | found.append((key, line[key]))
109 | else:
110 | for key in line:
111 | if char in line[key]:
112 | found.append((key, line[key]))
113 | for key, line in found:
114 | print('{}: {}, {}'.format(key, line[0], line[1]))
115 |
116 |
117 | def table():
118 | sort_dict = {'a': 1, 'i': 2, 'u': 3, 'e': 4, 'o': 5, 'n': 3}
119 | for i in data:
120 | tmp = sorted(i.keys(), key=lambda x: sort_dict[x[-1]])
121 | chars = list()
122 | japan = list()
123 | for char in tmp:
124 | while len(chars) < sort_dict[char[-1]] - 1:
125 | chars.append(' ')
126 | japan.append(' ' * 8)
127 | chars.append(char)
128 | japan.append(', '.join(i[char]))
129 | print(('{:^6}' * 5).format(*japan))
130 | print(('{:^8}' * 5).format(*chars))
131 | print()
132 |
133 |
134 | def main():
135 | if len(sys.argv) >= 2:
136 | mode = sys.argv[1]
137 | else:
138 | mode = 'help'
139 |
140 | funs = {
141 | 'test': test,
142 | 'search': search,
143 | 'table': table,
144 | }
145 |
146 | if mode in funs:
147 | try:
148 | funs[mode]()
149 | except (EOFError, KeyboardInterrupt):
150 | exit()
151 | else:
152 | print(help_messages)
153 |
154 |
155 | if __name__ == '__main__':
156 | main()
157 |
--------------------------------------------------------------------------------
/charles/bin/inst:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # this script automatically install an app using APT and backup the software list to ~/.backup/
3 | if [[ -f /etc/issue ]]; then
4 | OS=$(cat /etc/issue | cut -f 1 -d ' ')
5 | fi
6 | if [[ $(uname) == 'Darwin' ]]; then
7 | OS='Darwin'
8 | fi
9 | APPS_BACKUP_PATH=~/.config/CharlesBackup/Packages/$OS.list
10 | mkdir -p ~/.config/CharlesBackup
11 |
12 | if [ $# = 0 ]; then cat $APPS_BACKUP_PATH; fi
13 |
14 | case $OS in
15 | 'Arch') INSTALL() { sudo pacman -S --noconfirm --needed $@; } ;;
16 | 'Ubuntu') INSTALL() {
17 | if [[ ${app%-} == $app ]]; then
18 | dpkg -s $@ >/dev/null 2>&1
19 | else
20 | false
21 | fi
22 | if [[ $? == 0 ]]; then
23 | echo $@ already installed
24 | else
25 | echo -e '\nInstalling' $@
26 | sudo apt install $@ -y --allow-unauthenticated
27 | fi
28 | } ;;
29 | 'Darwin') INSTALL() { brew install $@; } ;;
30 | *) echo 'Your distribution has not implementd yet, please modify this command' ;;
31 | esac
32 |
33 | for app in $@; do
34 | if [ -n "$app" ]; then
35 | false
36 | while [ $? -ne 0 -a $? -ne 100 -a $? -ne 130 ]; do
37 | if [ $? -ne 0 ]; then
38 | echo $? $app $(date) >>~/.cache/inst.err.log
39 | sleep 3
40 | fi
41 | INSTALL $app
42 | done
43 | if [ $? = 0 ]; then
44 | echo $app >>$APPS_BACKUP_PATH
45 | fi
46 | fi
47 | done
48 |
49 | sort -su $APPS_BACKUP_PATH -o $APPS_BACKUP_PATH >~/.cache/backuplist4apps
50 | rm ~/.cache/backuplist4apps
51 |
--------------------------------------------------------------------------------
/charles/bin/itunes2rhythmbox:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import heapq
3 | import multiprocessing
4 | import os
5 | import re
6 | import sys
7 | from itertools import zip_longest
8 | from xml.etree import ElementTree
9 |
10 | help_message = '''Usage: Close Rhythmbox, then type: itunes2rhythmbox
11 |
12 | If you are to move or sync your whole iTunes library to Rhythmbox, This script
13 | will help you to convert iTunes playlist to Rhythmbox style playlist, and
14 | import the playlist to Rhythmbox directly.
15 |
16 | Before using this script, you should have:
17 | - an iTunes folder copied directly from your Windows/Mac computer(with the
18 | iTunes files already consolidated: in iTunes, click File -> Library ->
19 | Organize Library -> Consolidate files -> OK), or just the `iTunes Media`
20 | Folder located at `iTunes/`
21 | - a copy of `iTunes Music Library.xml`, which usually located at `iTunes/`
22 |
23 | You should modify this script configurations at start of the script, and the
24 | meaning of entries will be described as follows:
25 |
26 | - library_location: The `iTunes Media` folder path
27 | - rhythmbox_playlist: The rhythmbox playlist xml path
28 | - iTunes_db: `iTunes Music Library.xml` path
29 | - skip_list: playlists which you do not want to convert to your Rhythmbox
30 | - source_itunes_music_folder: do not modify it
31 | '''
32 | # Configurations
33 | library_location = '~/Music/Music/Media'
34 |
35 | rhythmbox_playlist = '~/.local/share/rhythmbox/playlists.xml'
36 |
37 | itunes_db = '~/Music/Music/Library.xml'
38 |
39 | skip_list = [
40 | '资料库',
41 | '音乐',
42 | '已下载',
43 | '播客',
44 | 'Library',
45 | 'Downloaded',
46 | 'Favorites',
47 | 'Music',
48 | 'Movies',
49 | 'TV Shows',
50 | 'Podcasts',
51 | 'Audiobooks',
52 | 'Languages',
53 | 'Special',
54 | # 'Dislike',
55 | # 'Not Classified',
56 | # 'Not Favorate',
57 | # 'Not Rated',
58 | 'Pomodoro',
59 | 'Voice Memos',
60 | ]
61 |
62 | MATCH_JUDGEMENT_THRESHOLD = 6
63 | MATCH_SELECTIONS = 10
64 | quote_safe_char = "!$'()*+,-/=@_~"
65 |
66 | source_itunes_music_folder = None
67 | # End of configuration
68 |
69 | __author__ = "Charles Xu"
70 | __github__ = "https://github.com/the0demiurge"
71 | __girlfriend__ = "pang"
72 | try:
73 | from urllib import quote, unquote
74 | except ImportError:
75 | from urllib.parse import quote, unquote
76 |
77 |
78 | def itunes_quote(string):
79 | string = quote(string, safe=quote_safe_char)
80 | string = string.replace('%26', '&')
81 | return string
82 |
83 |
84 | library_location_orig = library_location
85 | if not (library_location.startswith('http://') or library_location.startswith('file://') or library_location.startswith('https://')):
86 | library_location = 'file://' + \
87 | itunes_quote(os.path.abspath(os.path.expanduser(library_location)))
88 | if not library_location.endswith('/'):
89 | library_location += '/'
90 | rhythmbox_playlist, itunes_db = os.path.abspath(os.path.expanduser(rhythmbox_playlist)), os.path.abspath(os.path.expanduser(itunes_db))
91 |
92 |
93 | def xml2dict(xml_path):
94 | xml_obj = ElementTree.parse(xml_path)
95 | root = xml_obj.getroot()
96 |
97 | def traverse(root):
98 | children = list(root)
99 | return {root.tag: {'children': [traverse(child) for child in children], 'attrib': root.attrib, 'text': root.text}}
100 |
101 | return traverse(root)
102 |
103 |
104 | def parse_itunesdb(xml_path):
105 | xml_obj = ElementTree.parse(xml_path)
106 | root = list(xml_obj.getroot())[0]
107 |
108 | def traverse(root):
109 | children = list(root)
110 |
111 | handlers = {
112 | 'dict': lambda root, children: {traverse(key): traverse(value) for key, value in zip(children[::2], children[1::2])} if len(children) % 2 == 0 else ValueError('dict must be paired'),
113 | 'key': lambda root, children: root.text,
114 | 'string': lambda root, children: root.text,
115 | 'date': lambda root, children: root.text,
116 | 'data': lambda root, children: root.text,
117 | 'integer': lambda root, children: root.text,
118 | 'true': lambda root, children: True,
119 | 'false': lambda root, children: False,
120 | 'array': lambda root, children: [traverse(child) for child in children],
121 | }
122 |
123 | if root.tag in handlers:
124 | return handlers[root.tag](root, children)
125 | else:
126 | raise KeyError(root.tag)
127 |
128 | return traverse(root)
129 |
130 |
131 | def playlist2rbxml(playlists, destination):
132 | '''
133 | Arguments:
134 | playlists [{'name': str, 'item': [str]}]
135 | '''
136 | head = '\n\n'
137 | playlist_head = '\n'
138 | song = '{} \n'
139 | playlist_tail = ' \n'
140 | tail = ' \n \n'
141 | with open(destination, 'w') as f:
142 | f.write(head)
143 | for playlist in playlists:
144 | f.write(playlist_head.format(playlist['name']))
145 | for track in playlist['item']:
146 | f.write(song.format(track))
147 | f.write(playlist_tail)
148 | f.write(tail)
149 |
150 |
151 | def get_all_files_path(path):
152 | result = list()
153 | path = os.path.abspath(os.path.expanduser(path))
154 | for agent in os.walk(path):
155 | for file_name in agent[2]:
156 | if not file_name.startswith('.'):
157 | result.append(os.path.join(agent[0], file_name))
158 | return result
159 |
160 |
161 | def edit_distance(src, target):
162 | dp = [[0 for i in range(len(target) + 1)] for j in range(len(src) + 1)]
163 | for i in range(1, len(src) + 1):
164 | dp[i][0] = i
165 | for j in range(1, len(target) + 1):
166 | dp[0][j] = j
167 | for i in range(1, len(src) + 1):
168 | for j in range(1, len(target) + 1):
169 | dp[i][j] = min(1 + dp[i - 1][j], 1 + dp[i][j - 1], dp[i - 1][j - 1] + (0 if src[i - 1] == target[j - 1] else 1))
170 | return dp[-1][-1]
171 |
172 |
173 | def edit_distance_wrapper(data):
174 | distance = 0
175 | for src, target in zip_longest(data[0].split('/'), data[1].split('/')):
176 | if src == target:
177 | continue
178 | elif None in (src, target):
179 | if src is not None:
180 | distance += len(src)
181 | elif target is not None:
182 | distance += len(target)
183 | else:
184 | distance += edit_distance(src, target)
185 | return distance
186 |
187 |
188 | pool = multiprocessing.Pool()
189 | music_match_buffer = dict()
190 |
191 |
192 | def music_match(path, music_match_library):
193 | if path in music_match_buffer:
194 | return music_match_buffer[path]
195 | distances = pool.map(edit_distance_wrapper, zip((path,) * len(music_match_library), music_match_library))
196 | zipper = tuple(zip(distances, music_match_library))
197 | distance, matched = min(zipper, key=lambda x: x[0])
198 | if distance >= MATCH_JUDGEMENT_THRESHOLD:
199 | feature = r'\d*-*[a-zA-Z]*/*\.*'
200 | candidates = heapq.nsmallest(MATCH_SELECTIONS, zipper, key=lambda x: x[0])
201 | filtered = [i for i in candidates if ''.join(re.findall(feature, path)) == ''.join(re.findall(feature, i[1]))]
202 | if len(filtered) == 1:
203 | distance, matched = filtered[0]
204 | else:
205 | distance, matched = min(candidates, key=lambda x: edit_distance(re.findall(feature, path), re.findall(feature, x[1])))
206 |
207 | print('Dist:', distance, 'Matched: "{}" -- "{}"'.format(path.split('/')[-1], matched.split('/')[-1]))
208 | music_match_buffer[path] = matched
209 | return matched
210 |
211 |
212 | def convert_music_path(music_location, source_itunes_music_folder, library_location, music_match_library):
213 | data = music_location.replace(source_itunes_music_folder, library_location, 1).split('://', 1)
214 | if len(data) == 1:
215 | music_file_path = unquote(data[0])
216 | head = ''
217 | else:
218 | music_file_path = unquote(data[1])
219 | head = data[0] + '://'
220 | if not os.path.exists(music_file_path):
221 | matched_music_file_path = music_match(music_file_path, music_match_library)
222 | else:
223 | matched_music_file_path = music_file_path
224 | if music_file_path in music_match_library:
225 | music_match_library.remove(music_file_path)
226 | return head + itunes_quote(matched_music_file_path)
227 |
228 |
229 | def get_playlist(itunes_dict, skip_list=skip_list, convert_function=convert_music_path, **convert_args):
230 | tracks, playlists = itunes_dict['Tracks'], itunes_dict['Playlists']
231 | return [{'name': playlist['Name'], 'item': [convert_function(tracks[track['Track ID']]['Location'], **convert_args) for track in playlist['Playlist Items']]} for playlist in playlists if playlist['Name'] not in skip_list and 'Playlist Items' in playlist]
232 |
233 |
234 | def main():
235 | music_match_library = get_all_files_path(library_location_orig)
236 | rhythmbox_pid = list(map(eval, os.popen("ps -A|grep rhythmbox|awk '{print $1}'").readlines()))
237 | if rhythmbox_pid:
238 | if '-f' in sys.argv or '--force' in sys.argv:
239 | prompt = 'y'
240 | else:
241 | prompt = input('rhyhtmbox process found: {}, kill it?[Y/n]:'.format(rhythmbox_pid)).lower()
242 | if prompt == 'n':
243 | exit()
244 | elif prompt == 'y' or prompt == '':
245 | for pid in rhythmbox_pid:
246 | os.kill(pid, 2)
247 | print('rhythmbox quitted')
248 | else:
249 | print('You should input "y" or "n"')
250 | exit(1)
251 |
252 | itunes_dict = parse_itunesdb(itunes_db)
253 | global source_itunes_music_folder
254 | if not source_itunes_music_folder:
255 | source_itunes_music_folder = itunes_dict['Music Folder']
256 | playlists = get_playlist(
257 | itunes_dict,
258 | skip_list=skip_list,
259 | convert_function=convert_music_path,
260 | source_itunes_music_folder=source_itunes_music_folder,
261 | library_location=library_location,
262 | music_match_library=music_match_library
263 | )
264 | for playlist in playlists:
265 | print(len(playlist['item']), playlist['name'], sep='\t')
266 | playlist2rbxml(playlists, rhythmbox_playlist)
267 | print(len(playlists), 'playlists imported')
268 |
269 |
270 | if __name__ == '__main__':
271 | if 'help' in sys.argv or '-h' in sys.argv or '--help' in sys.argv or not os.path.isfile(itunes_db):
272 | print(help_message)
273 | else:
274 | main()
275 |
--------------------------------------------------------------------------------
/charles/bin/mac-addr-flush:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | import os
3 | import random
4 |
5 |
6 | def main():
7 | def random_mac():
8 | new_mac = []
9 | for i in range(6):
10 | x = "".join(random.sample('0123456789abcdef', 2))
11 | new_mac.append(x)
12 | new_mac = ":".join(new_mac)
13 | return new_mac
14 |
15 | mac = random_mac()
16 | input('Change your Mac addr temporarily to {}, press Enter to continue:\n'.format(mac))
17 | os.system('sudo ifconfig eth0 down')
18 | os.system('sudo ifconfig eth0 hw ether {}'.format(mac))
19 | os.system('sudo ifconfig eth0 up')
20 |
21 |
22 | if __name__ == '__main__':
23 | try:
24 | main()
25 | except:
26 | print('Mac address has not changed')
27 |
--------------------------------------------------------------------------------
/charles/bin/omf-backup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env fish
2 | omf list -a | sed 's/\s/\n/g' | sort -biu | tail -n +2 >$CHARLES_BACKUP/Packages/omf.list
3 | cat $CHARLES_BACKUP/Packages/omf.list
4 |
--------------------------------------------------------------------------------
/charles/bin/omf-restore:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env fish
2 | omf install (cat $CHARLES_BACKUP/Packages/omf.list)
3 | omf theme bobthefish
4 |
--------------------------------------------------------------------------------
/charles/bin/pacman-disowned:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$
4 | db=$tmp/db
5 | fs=$tmp/fs
6 |
7 | mkdir "$tmp"
8 | trap 'rm -rf "$tmp"' EXIT
9 |
10 | pacman -Qlq | sort -u >"$db"
11 |
12 | find /bin /etc /lib /sbin /usr \
13 | ! -name lost+found \
14 | \( -type d -printf '%p/\n' -o -print \) | sort >"$fs"
15 |
16 | comm -23 "$fs" "$db"
17 |
--------------------------------------------------------------------------------
/charles/bin/prj-sync:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | cd $HOME
3 |
4 | # init check
5 | for cmd in jq rsync; do
6 | type $cmd >/dev/null 2>&1 || {
7 | echo >&2 "$cmd is required but it's not installed. Aborting."
8 | exit 1
9 | }
10 | done
11 |
12 | CONFIG_PATH="$HOME/.config/prj-sync.json"
13 | EXCLUDE_PATH="$HOME/.config/prj-sync-exclude.list"
14 |
15 | if [ ! -e $CONFIG_PATH ]; then
16 | echo '{
17 | //"source":"your/project/path,"
18 | //"target": ["username1@server-ip1:remote/path1", "username2@server-ip2:remote/path2"],
19 | }' >$CONFIG_PATH
20 | fi
21 |
22 | if [ ! -e $EXCLUDE_PATH ]; then
23 | echo -e '.git\n.svn\n.hg' >$EXCLUDE_PATH
24 | fi
25 |
26 | # defining functions
27 | help() {
28 | echo -e "prj-sync:\nSync your project repository to multiple remote servers using rsync and ssh"
29 | echo
30 | echo "Usage:"
31 | echo " prj-sync push to server"
32 | echo " prj-sync config edit the config file, you need to set \$EDITOR first"
33 | echo " prj-sync test print debug info without push"
34 | echo " prj-sync dry-run dry-run rsync to print debug message"
35 | echo " prj-sync -h, --help help show this help message"
36 | echo
37 | echo "configuration file: $CONFIG_PATH"
38 | echo "exclude pattern list: $EXCLUDE_PATH"
39 | echo "EDITOR: $EDITOR"
40 | }
41 |
42 | input() {
43 | # processing input
44 | src=$(jq -r .source $CONFIG_PATH)
45 | if [ $? -ne 0 ]; then
46 | echo -e "\nError orrured in configuration:\n$CONFIG_PATH\nedit it again" 2>&1
47 | exit 3
48 | fi
49 |
50 | tgt=$(jq -r .target[] $CONFIG_PATH)
51 |
52 | if [ src = null -o tgt = null ]; then
53 | echo >&2 "target or source in configuration file $CONFIG_PATH not found, edit it"
54 | exit 2
55 | fi
56 | }
57 |
58 | push() {
59 | input
60 | for path in $tgt; do
61 | if [ $1 = dry ]; then dry_run="--dry-run"; fi
62 | cmd="rsync -e ssh -ChKlmrtz --inplace --partial --append $dry_run --delete-before --info=progress2 --progress --exclude-from=$EXCLUDE_PATH $src $path"
63 | echo $cmd
64 | if [ $1 != test ]; then $cmd; fi
65 | done
66 | }
67 |
68 | config() {
69 | $EDITOR $CONFIG_PATH
70 | $EDITOR $EXCLUDE_PATH
71 | }
72 |
73 | # running
74 | case $1 in
75 | -h) help ;;
76 | --help) help ;;
77 | help) help ;;
78 | config) config ;;
79 | test) push test ;;
80 | dry-run) push dry ;;
81 | *) push push ;;
82 | esac
83 |
--------------------------------------------------------------------------------
/charles/bin/ssr:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # 作者:老徐
3 | # SSR免费分享网站(所有帐号均来源于网上别人的分享):http://ss.pythonic.life
4 | # 源代码主页:https://github.com/the0demiurge
5 | # 访问https://github.com/the0demiurge/CharlesScripts/blob/master/charles/bin/ssr获取本脚本的最新版
6 | # 使用方法:把该脚本放到$PATH里面并加入可执行权限就行(比如说放到/usr/local/bin)
7 | # 首次使用输入ssr install后安装时会自动安装到 $HOME/.local/share/shadowsocksr
8 | # 输入ssr config进行配置,输入JSON格式的配置文件
9 | # 输入ssr uninstall卸载
10 | # 输入ssr help 展示帮助信息
11 |
12 | set -e
13 | if [ -z "$EDITOR" ]; then
14 | EDITOR=vi
15 | fi
16 |
17 | WEBSITE=http://ss.pythonic.life
18 | BRANCH=manyuser
19 | GIT_REPO=https://github.com/shadowsocksrr/shadowsocksr.git
20 | INSTALL_PATH=$HOME/.local/share/shadowsocksr
21 |
22 | ssr_help() {
23 | echo ShadowSocksR python client tool
24 | echo -e if you have not installed ssr, run \`ssr install\` first
25 | echo Usage:
26 | echo -e "\t" "ssr help"
27 | echo -e "\n" "Install/Uninstall"
28 | echo -e "\t" "ssr install install shadowsocksr client"
29 | echo -e "\t" "ssr uninstall uninstall shadowsocksr client"
30 | echo -e "\n" "Config and Subscribe"
31 | echo -e "\t" "ssr update update subscription from $WEBSITE"
32 | echo -e "\t" "ssr config edit config.json"
33 | echo -e "\t" "ssr xclip paste configs from clipboard to config.json"
34 | echo -e "\n" "Start/Stop/Restart"
35 | echo -e "\t" "ssr start start the shadowsocks service"
36 | echo -e "\t" "ssr stop stop the shadowsocks service"
37 | echo -e "\t" "ssr restart restart the shadowsocks service"
38 | echo -e "\n" "Testing and Maintenance"
39 | echo -e "\t" "ssr test get ip from cip.cc using socks5 proxy"
40 | echo -e "\t" "ssr log cat the log of shadowsocks"
41 | echo -e "\t" "ssr shell cd into ssr installation dir"
42 | echo -e "\t" "ssr clean clean ssr configuration backups"
43 | }
44 |
45 | ssr_install() {
46 | git clone -b $BRANCH $GIT_REPO $INSTALL_PATH
47 | echo -e "Install finished!\nYou can visit my website $WEBSITE to acquire free ssr configs"
48 | }
49 |
50 | ssr_uninstall() {
51 | echo "Danger! are you to remove $INSTALL_PATH forever?(y/N)"
52 | read doit
53 | if [ $doit == 'y' ]; then rm -rvf $INSTALL_PATH; fi
54 | }
55 |
56 | ssr_test() {
57 | echo Testing Connection...
58 | if [[ ! -z $(which jq 2>/dev/null) ]]; then
59 | echo 'jq in use'
60 | PORT=$(jq .local_port $INSTALL_PATH/config.json)
61 | else
62 | PORT=$(sed -r 's/\/\/.*$|\s+//g' $INSTALL_PATH/config.json | grep -oP '(?/dev/null) ]]; then
73 | echo "You may install proxychains4 and configure it properly to test net delay"
74 | else
75 | echo -e '\nChecking delay...'
76 | proxychains4 ping -c 5 cip.cc
77 | fi
78 | fi
79 | }
80 |
81 | ssr_start() {
82 | cd $INSTALL_PATH/shadowsocks/
83 | python local.py -d start --pid-file=$INSTALL_PATH/ssr.pid --log-file=$INSTALL_PATH/ssr.log
84 | sleep 1
85 | ssr_test
86 | }
87 |
88 | ssr_stop() {
89 | cd $INSTALL_PATH/shadowsocks/
90 | python local.py -d stop --pid-file=$INSTALL_PATH/ssr.pid --log-file=$INSTALL_PATH/ssr.log
91 | }
92 |
93 | ssr_restart() {
94 | ssr_stop
95 | ssr_start
96 | }
97 |
98 | ssr_config() {
99 | $EDITOR $INSTALL_PATH/config.json
100 | ssr_restart
101 | }
102 |
103 | BLOCKED='
104 |
105 | Update failed! For more information, see
106 |
107 | https://github.com/the0demiurge/ShadowSocksShare-OpenShift/issues/17
108 |
109 | And edit `$WEBSITE` in this script.'
110 |
111 | ISSUE='
112 |
113 | The response was empty, try it 10 mins later or report it on
114 |
115 | https://github.com/the0demiurge/CharlesScripts/issues'
116 |
117 | ssr_update() {
118 | JSON=$(curl -L $WEBSITE/json)
119 | # If failed
120 | case $? in
121 | 0) ;;
122 | *)
123 | echo -e $BLOCKED
124 | exit $?
125 | ;;
126 | esac
127 |
128 | # If json is empty
129 | case $JSON in
130 | 'Not Found')
131 | echo -e $BLOCKED
132 | exit $?
133 | ;;
134 | '' | '{}')
135 | echo $ISSUE
136 | exit 2
137 | ;;
138 | esac
139 |
140 | mv $INSTALL_PATH/config.json $INSTALL_PATH/config.json.bak.$(date +%y-%m-%d-%T)
141 | echo -e "$JSON" | tee $INSTALL_PATH/config.json
142 | ssr_restart
143 | echo -e "Updated from $WEBSITE"
144 | }
145 |
146 | ssr_xclip() {
147 | xclip -o | tee $INSTALL_PATH/config.json
148 | ssr_restart
149 | }
150 |
151 | ssr_log() {
152 | tail -f $INSTALL_PATH/ssr.log
153 | }
154 |
155 | ssr_shell() {
156 | cd $INSTALL_PATH
157 | $SHELL
158 | }
159 |
160 | ssr_clean() {
161 | rm -ri $INSTALL_PATH/config.json.bak.*
162 | }
163 |
164 | ssr_main() {
165 | case $1 in
166 | help) ssr_help ;;
167 | install) ssr_install ;;
168 | uninstall) ssr_uninstall ;;
169 | update) ssr_update ;;
170 | config) ssr_config ;;
171 | xclip) ssr_xclip ;;
172 | start) ssr_start ;;
173 | stop) ssr_stop ;;
174 | restart) ssr_restart ;;
175 | test) ssr_test ;;
176 | log) ssr_log ;;
177 | shell) ssr_shell ;;
178 | clean) ssr_clean ;;
179 | *) ssr_help ;;
180 | esac
181 | }
182 |
183 | ssr_main $1
184 |
--------------------------------------------------------------------------------
/charles/bin/thunderdecode:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | help="Decodes thunder, flashget, qqdl links to original link.\nUsage: thunderdecode ' '"
3 |
4 | if [ -z $1 ]; then
5 | echo -e $help
6 | exit
7 | fi
8 |
9 | format=$(echo $1 | cut -d ':' -f 1)
10 |
11 | case $format in
12 | 'thunder')
13 | link=$(echo ${1#thunder://} | base64 -d)
14 | link=${link#AA}
15 | link=${link%ZZ}
16 | ;;
17 | 'qqdl')
18 | link=$(echo ${1#qqdl://} | base64 -d)
19 | ;;
20 | 'flashget')
21 | link=${1#flashget://}
22 | link=${link%'&forece'}
23 | link=$(echo $link | base64 -d)
24 | link=${link#'[FLASHGET]'}
25 | link=${link%'[FLASHGET]'}
26 | ;;
27 | esac
28 |
29 | echo $link
30 |
--------------------------------------------------------------------------------
/charles/bin/tomato:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # set an reminder and it'll remind you of doing something.
3 | # note time something
4 | # i.e.: type "note 4m 'go to see a movie with my gf'", and it'll notify you to "go to see a movie with my gf" after 4 minuts.
5 |
6 | while [ true ]; do
7 | echo -e "\rWorking\t\r"
8 | notify-send --urgency=critical 'Go To Work'
9 | fifo
10 | sleep 25m
11 | for i in $(seq 10); do
12 | echo -ne '\a\r\t\r'
13 | sleep .1s
14 | done
15 |
16 | echo -e "\rResting\t\r"
17 | notify-send --urgency=critical 'Rest'
18 | sleep 5m
19 | for i in $(seq 10); do
20 | echo -ne '\a\r\t\r'
21 | sleep .1s
22 | done
23 | done
24 |
--------------------------------------------------------------------------------
/charles/bin/wallpaper-earthview:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Wallpaper Downloading Directory
4 | PaperFolder=~/.cache/wallpaper
5 | if [ ! -d $PaperFolder ]; then mkdir -p $PaperFolder; fi
6 |
7 | # Paper Downloading Path
8 | PaperPathTmp=$PaperFolder/background-image-temp.jpg
9 | PaperPath=$PaperFolder/background-image.jpg
10 | if [ -e $PaperPathTmp ]; then rm $PaperPathTmp; fi
11 |
12 | # Paper downloading range
13 | START=1000
14 | END=7024
15 |
16 | # Download wallpaper till successful
17 | TIMES=0
18 | false
19 | while [ $? != 0 ]; do
20 | TIMES=$((TIMES + 1))
21 | if [ $TIMES -gt 50 ]; then exit 1; fi
22 | false
23 | RANDOM_NUMBER=$(date +%s%N)
24 | PaperIndex=$((RANDOM_NUMBER % ($START - $END + 1) + $START))
25 | PaperUrl=https://www.gstatic.com/prettyearth/assets/full/$((PaperIndex)).jpg
26 |
27 | # curl is more stable in bad network connection
28 | echo GET $PaperUrl
29 | if [[ ! $(curl -sw "%{content_type}" $PaperUrl -o $PaperPathTmp) =~ "image" ]]; then
30 | false
31 | fi
32 | # curl done
33 | done
34 | mv $PaperPathTmp $PaperPath
35 |
--------------------------------------------------------------------------------
/charles/bin/wallpaper-random:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Wallpaper Downloading Directory
4 | PaperFolder=~/.cache/wallpaper
5 | if [ ! -d $PaperFolder ]; then mkdir -p $PaperFolder; fi
6 |
7 | # Paper Downloading Path
8 | PaperPathTmp=$PaperFolder/dialog-image-temp.jpg
9 | PaperPath=$PaperFolder/dialog-image.jpg
10 | if [ -e $PaperPathTmp ]; then rm $PaperPathTmp; fi
11 |
12 | # unsplish.com
13 | image_api=https://source.unsplash.com/random/1920x1200
14 |
15 | # download
16 | curl -L $image_api -o $PaperPathTmp && mv $PaperPathTmp $PaperPath
17 |
--------------------------------------------------------------------------------
/charles/bin/yao:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # this script automatically install an app using APT and backup the software list to ~/.backup/
3 | APPS_BACKUP_PATH=~/.config/CharlesBackup/Packages/aur.list
4 | mkdir -p ~/.config/CharlesBackup
5 |
6 | if [ $# = 0 ]; then cat $APPS_BACKUP_PATH; fi
7 |
8 | INSTALL() { yay -S $@ --needed --noconfirm; }
9 |
10 | for app in $@; do
11 | if [ -n "$app" ]; then
12 | INSTALL $app
13 | if [ $? = 0 ]; then
14 | echo $app >>$APPS_BACKUP_PATH
15 | fi
16 | fi
17 | done
18 |
19 | sort -su $APPS_BACKUP_PATH -o $APPS_BACKUP_PATH >~/.cache/backuplist4apps
20 | rm ~/.cache/backuplist4apps
21 |
--------------------------------------------------------------------------------
/charles/installation.d/conf.d/.config-powerline-tmux:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | POWERLINE_ROOT_PATH=$(sudo pip show powerline-status | grep Location | sed 's/Location: //')
3 |
4 | if [ ! -z "$POWERLINE_ROOT_PATH" ]; then
5 | echo 'run-shell "powerline-daemon -q"' >>~/.tmux.conf
6 | echo "source $POWERLINE_ROOT_PATH/powerline/bindings/tmux/powerline.conf" >>~/.tmux.conf
7 | else
8 | echo 'There is no powerline installation found!'
9 | echo 'You should manually add powerline installation path to the ~/.tmux.conf file. i. e.:'
10 | echo 'run-shell "powerline-daemon -q"'
11 | echo "source \$POWERLINE_ROOT_PATH/powerline/bindings/tmux/powerline.conf"
12 | read -p 'press Enter to continue:'
13 | exit 1
14 | fi
15 |
--------------------------------------------------------------------------------
/charles/installation.d/conf.d/config-aria2:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | echo "enable-rpc=true
3 | rpc-secret=
4 | max-concurrent-downloads=15
5 | continue=true
6 | load-cookies=true
7 | max-connection-per-server=16
8 | min-split-size=10M
9 | split=100
10 | max-overall-download-limit=0
11 | max-download-limit=0
12 | max-overall-upload-limit=0
13 | max-upload-limit=0
14 | dir=$HOME/Downloads
15 | file-allocation=none
16 | input-file=$HOME/.cache/aria2.session
17 | save-session=$HOME/.cache/aria2.session
18 | save-session-interval=60
19 | force-save=true" | tee $HOME/.config/aria2c.conf
20 | $EDITOR $HOME/.config/aria2c.conf
21 |
--------------------------------------------------------------------------------
/charles/installation.d/conf.d/config-bash:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | echo "export CHARLES_HOME=$HOME/.local/share/CharlesScripts/charles" | tee -a ~/.bashrc
3 | echo 'export CHARLES_BACKUP=~/.config/CharlesBackup' >>~/.bashrc
4 | echo 'source $CHARLES_HOME/shell.rc.d/init.shell' >>~/.bashrc
5 |
--------------------------------------------------------------------------------
/charles/installation.d/conf.d/config-conda:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env fish
2 | #conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
3 | #conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
4 | #conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
5 | #conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
6 | #conda config --set show_channel_urls yes
7 |
8 | conda install matplotlib scikit-learn numpy sympy pandas seaborn pillow pandoc ipython==8.4.0 jupyter requests beautifulsoup4 selenium --yes
9 | #conda install pytorch-cpu torchvision-cpu --yes #-c pytorch
10 | conda install xeus-cling --yes -c conda-forge
11 |
--------------------------------------------------------------------------------
/charles/installation.d/conf.d/config-cron:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | echo "SHELL=/bin/bash
3 | PATH=/usr/bin:/usr/local/bin:/bin:/home/$USER/.local/share/CharlesScripts/charles/bin
4 |
5 |
6 | 0 * * * * wallpaper-earthview
7 | 0 * * * * wallpaper-random
8 | " | sudo tee -a /var/spool/cron/$USER
9 |
--------------------------------------------------------------------------------
/charles/installation.d/conf.d/config-fcitx-on-wayland:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | echo 'export XMODIFIERS=@im=fcitx
3 | export QT4_IM_MODULE=fcitx
4 | export QT_IM_MODULE=fcitx
5 | export GTK_IM_MODULE=fcitx
6 | ' | sudo tee -a /etc/environment
7 |
--------------------------------------------------------------------------------
/charles/installation.d/conf.d/config-fish:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | export CHARLES_HOME=$HOME/.local/share/CharlesScripts/charles
3 | export CHARLES_BACKUP=$HOME/.config/CharlesBackup
4 |
5 | if [[ $(uname) == 'Darwin' ]]; then
6 | OS='Darwin'
7 | else
8 | OS=$(cat /etc/issue | cut -f 1 -d ' ')
9 | fi
10 | case $OS in
11 | 'Arch') INSTALL() { sudo pacman -S $@; } ;;
12 | 'Ubuntu') INSTALL() { sudo apt install $@ -y --allow-unauthenticated; } ;;
13 | 'Darwin') INSTALL() { brew install $@; } ;;
14 | *) echo 'Your distribution has not implementd yet, please modify this command' ;;
15 | esac
16 | CONF_DIR=$HOME/.config/fish/conf.d
17 | if [[ ! -d $CONF_DIR ]]; then
18 | mkdir -p $CONF_DIR
19 | fi
20 | mkdir -p ~/.cabal/bin
21 |
22 | if [ $(which autojump | wc -l) == 0 ]; then INSTALL autojump; fi
23 | if [ -f /usr/share/autojump/autojump.fish ];then ln -sf /usr/share/autojump/autojump.fish $CONF_DIR/autojump.fish;fi
24 | if [ -f /usr/local/share/autojump/autojump.fish ];then ln -sf /usr/local/share/autojump/autojump.fish $CONF_DIR/autojump.fish;fi
25 |
26 | ln -sf $CHARLES_HOME/shell.rc.d/init.fish $CONF_DIR/charles.fish
27 |
28 |
29 |
30 | #ABBRS
31 | fish -c "abbr -a -- axel 'axel -acn50'"
32 | fish -c "abbr -a -- ccat 'ccat --bg=dark'"
33 | fish -c "abbr -a -- c 'clear; cd'"
34 | fish -c "abbr -a -- ... 'cd ../..'"
35 | fish -c "abbr -a -- cl 'cd ..;ls'"
36 | fish -c "abbr -a -- cling 'cling --std=c++17'"
37 | fish -c "abbr -a -- dd 'dd status=progress'"
38 | fish -c "abbr -a -- du. 'du . --max-depth 1 -h'"
39 | fish -c "abbr -a -- eg 'grep -E'"
40 | fish -c "abbr -a -- emacsc 'emacs --no-window-system'"
41 | fish -c "abbr -a -- fd 'fd -IL'"
42 | fish -c "abbr -a -- fpv fzf\ --preview\ \'ccat\ --color=always\ \{\}\'"
43 | fish -c "abbr -a -- ftps 'python3 -m http.server 8080'"
44 | fish -c "abbr -a -- gaa 'git add -A'"
45 | fish -c "abbr -a -- gb 'git branch'"
46 | fish -c "abbr -a -- gck 'git checkout'"
47 | fish -c "abbr -a -- gcm 'git commit -m'"
48 | fish -c "abbr -a -- gitup 'for i in (ls);cd $i;git checkout .;git pull&;cd ..;end'"
49 | fish -c "abbr -a -- gl 'git l'"
50 | fish -c "abbr -a -- gm 'git merge --no-ff'"
51 | fish -c "abbr -a -- gp 'git push'"
52 | fish -c "abbr -a -- gpl 'git pull'"
53 | fish -c "abbr -a -- gst 'git status'"
54 | fish -c "abbr -a -- histg 'history | grep'"
55 | fish -c "abbr -a -- i ipython"
56 | fish -c "abbr -a -- lal 'ls -lahF'"
57 | fish -c "abbr -a -- la 'ls -a'"
58 | fish -c "abbr -a -- le 'ls|egrep'"
59 | fish -c "abbr -a -- lf 'ls -lah --full-time'"
60 | fish -c "abbr -a -- lg 'ls -a|grep -i'"
61 | fish -c "abbr -a -- ll 'ls -lhF'"
62 | fish -c "abbr -a -- l ls"
63 | fish -c "abbr -a -- mag2torrent 'aria2c --bt-metadata-only=true --bt-save-metadata=true'"
64 | fish -c "abbr -a -- n 'open .'"
65 | fish -c "abbr -a -- o open"
66 | fish -c "abbr -a -- pdb 'python -mpowerline.bindings.pdb'"
67 | fish -c "abbr -a -- pp pypy3"
68 | fish -c "abbr -a -- p python"
69 | fish -c "abbr -a -- r ranger"
70 | fish -c "abbr -a -- socksp 'export ALL_PROXY=socks5://127.0.0.1:1080'"
71 | fish -c "abbr -a -- sshp ssh\ -o\ ProxyCommand=\'nc\ -x\ 127.0.0.1:1080\ \%h\ \%p\'"
72 | fish -c "abbr -a -- su 'sudo su'"
73 | fish -c "abbr -a -- wget 'wget -c -nc -t0'"
74 |
75 | case $OS in
76 | 'Ubuntu') fish -c "abbr u 'apt-upgrade'" ;;
77 | 'Arch') fish -c "abbr u 'pacman -Syu;pacman -Rs (pacman -Qtdq)'" ;;
78 | esac
79 |
--------------------------------------------------------------------------------
/charles/installation.d/conf.d/config-git:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # kitty
3 | git config --global alias.d difftool
4 |
5 | git config --global core.editor "nvim"
6 | git config --global color.ui true
7 | git config --global core.ignorecase false
8 | git config --global core.quotepath false
9 | git config --global color.status auto
10 | git config --global color.diff auto
11 | git config --global color.branch auto
12 | git config --global color.interactive auto
13 | git config --global alias.l "log --graph --pretty=format:'%Cred%h%Creset %Cgreen(%ad) -%C(yellow)%D%Creset %s %C(bold blue)<%an>%Creset' --date=format-local:'%Y-%m-%d %a %H:%M:%S'"
14 |
15 | git config --global merge.tool meld
16 | git config --global mergetool.prompt false
17 |
18 | # diff-so-fancy
19 | git config --global core.pager "diff-so-fancy | less --tabs=4 -RFX"
20 | git config --global color.ui true
21 | git config --global color.diff-highlight.oldNormal "red bold"
22 | git config --global color.diff-highlight.oldHighlight "red bold 52"
23 | git config --global color.diff-highlight.newNormal "green bold"
24 | git config --global color.diff-highlight.newHighlight "green bold 22"
25 | git config --global color.diff.meta "yellow"
26 | git config --global color.diff.frag "magenta bold"
27 | git config --global color.diff.commit "yellow bold"
28 | git config --global color.diff.old "red bold"
29 | git config --global color.diff.new "green bold"
30 | git config --global color.diff.whitespace "red reverse"
31 |
--------------------------------------------------------------------------------
/charles/installation.d/conf.d/config-gnome:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | gsettings set org.gnome.nautilus.preferences click-policy 'single'
3 | gsettings set org.gtk.Settings.FileChooser sort-directories-first true
4 | gsettings set org.gtk.Settings.FileChooser show-hidden false
5 | gsettings set org.gtk.Settings.FileChooser clock-format '12h'
6 | gsettings set org.gnome.desktop.interface clock-format '12h'
7 | gsettings set org.gnome.desktop.interface clock-show-date true
8 |
9 | PaperFolder=~/.cache/wallpaper
10 | gsettings set org.gnome.desktop.background picture-uri "file://$PaperPath"
11 | gsettings set org.gnome.desktop.screensaver picture-uri "file://$PaperPath"
12 | #gsettings set org.gnome.settings-daemon.plugins.background active true
13 |
14 | # Setting Theme to Arc Flatabulous Dark
15 | gsettings set org.gnome.desktop.interface gtk-theme Arc-Flatabulous-Dark
16 |
17 | # Setting for lunar calendar plugin for english users
18 | sudo cp /usr/share/locale/zh_CN/LC_MESSAGES/lunar-date.mo /usr/share/locale/en/LC_MESSAGES/
19 |
20 | # Fixing bug for Nautilus in xdg-open
21 | xdg-mime default org.gnome.Nautilus.desktop inode/directory
22 |
23 | echo "export XMODIFIERS=@im=fcitx" | tee ~/.xprofile
24 | echo "export QT4_IM_MODULE=fcitx" | tee -a ~/.xprofile
25 | echo "export QT_IM_MODULE=fcitx" | tee -a ~/.xprofile
26 | echo "export GTK_IM_MODULE=fcitx" | tee -a ~/.xprofile
27 |
--------------------------------------------------------------------------------
/charles/installation.d/conf.d/config-homebrew:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | echo 'set -x HOMEBREW_NO_AUTO_UPDATE true' | tee ~/.config/fish/conf.d/homebrew.fish
3 | echo 'set -x MANPATH "/Library/Apple/usr/share/man" $MANPATH' | tee -a ~/.config/fish/conf.d/homebrew.fish
4 | echo 'set -x MANPATH "/Library/Developer/CommandLineTools/usr/share/man" $MANPATH' | tee -a ~/.config/fish/conf.d/homebrew.fish
5 | echo 'set -x MANPATH "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/share/man" $MANPATH' | tee -a ~/.config/fish/conf.d/homebrew.fish
6 | echo 'set -x MANPATH "/usr/share/man" $MANPATH' | tee -a ~/.config/fish/conf.d/homebrew.fish
7 | echo 'set -g fish_user_paths "/usr/local/bin" $fish_user_paths' | tee -a ~/.config/fish/conf.d/homebrew.fish
8 | echo 'set -g fish_user_paths "/usr/local/sbin" $fish_user_paths' | tee -a ~/.config/fish/conf.d/homebrew.fish
9 | echo 'set -x MANPATH "/usr/local/share/man" $MANPATH' | tee -a ~/.config/fish/conf.d/homebrew.fish
10 | echo 'set -g fish_user_paths "/usr/local/opt/coreutils/libexec/gnubin" $fish_user_paths' | tee -a ~/.config/fish/conf.d/homebrew.fish
11 | echo 'set -x MANPATH "/usr/local/opt/coreutils/libexec/gnuman" $MANPATH' | tee -a ~/.config/fish/conf.d/homebrew.fish
12 | echo 'set -g fish_user_paths "/usr/local/opt/findutils/libexec/gnubin" $fish_user_paths' | tee -a ~/.config/fish/conf.d/homebrew.fish
13 | echo 'set -x MANPATH "/usr/local/opt/findutils/libexec/gnuman" $MANPATH' | tee -a ~/.config/fish/conf.d/homebrew.fish
14 | echo 'set -g fish_user_paths "/usr/local/opt/gnu-tar/libexec/gnubin" $fish_user_paths' | tee -a ~/.config/fish/conf.d/homebrew.fish
15 | echo 'set -x MANPATH "/usr/local/opt/gnu-tar/libexec/gnuman" $MANPATH' | tee -a ~/.config/fish/conf.d/homebrew.fish
16 | echo 'set -g fish_user_paths "/usr/local/opt/gnu-sed/libexec/gnubin" $fish_user_paths' | tee -a ~/.config/fish/conf.d/homebrew.fish
17 | echo 'set -x MANPATH "/usr/local/opt/gnu-sed/libexec/gnuman" $MANPATH' | tee -a ~/.config/fish/conf.d/homebrew.fish
18 | echo 'set -g fish_user_paths "/usr/local/opt/grep/libexec/gnubin" $fish_user_paths' | tee -a ~/.config/fish/conf.d/homebrew.fish
19 | echo 'set -x MANPATH "/usr/local/opt/grep/libexec/gnuman" $MANPATH' | tee -a ~/.config/fish/conf.d/homebrew.fish
20 | echo 'set -g fish_user_paths "/usr/local/opt/gawk/libexec/gnubin" $fish_user_paths' | tee -a ~/.config/fish/conf.d/homebrew.fish
21 | echo 'set -x MANPATH "/usr/local/opt/gawk/libexec/gnuman" $MANPATH' | tee -a ~/.config/fish/conf.d/homebrew.fish
22 | echo 'set -g fish_user_paths "/usr/local/opt/curl/bin" $fish_user_paths' | tee -a ~/.config/fish/conf.d/homebrew.fish
23 | echo 'set -x MANPATH "/usr/local/opt/curl/share/man" $MANPATH' | tee -a ~/.config/fish/conf.d/homebrew.fish
24 |
25 |
26 | brew tap homebrew/bundle
27 | brew tap homebrew/cask
28 | brew tap homebrew/cask-drivers
29 | brew tap homebrew/cask-fonts
30 | brew tap homebrew/command-not-found
31 | brew tap homebrew/core
32 |
33 | brew update
34 |
--------------------------------------------------------------------------------
/charles/installation.d/conf.d/config-kitty:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | echo 'kitty + complete setup fish | source
3 | function icat
4 | kitty +kitten icat $argv
5 | end
6 | '|tee $HOME/.config/fish/conf.d/kitten.fish
7 |
--------------------------------------------------------------------------------
/charles/installation.d/conf.d/config-pip:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | pip install pip -U
3 | pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
4 |
--------------------------------------------------------------------------------
/charles/installation.d/conf.d/config-powerline-bash:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | POWERLINE_ROOT_PATH=$(sudo pip3 show powerline-status | grep Location | sed 's/Location: //')
3 |
4 | if [ ! -z "$POWERLINE_ROOT_PATH" ]; then
5 | echo ". $POWERLINE_ROOT_PATH/powerline/bindings/bash/powerline.sh" >>~/.bashrc
6 | else
7 | echo 'There is no powerline installation found!'
8 | echo 'You should manually add powerline installation path to the ~/.bashrc file. i. e.:'
9 | echo ". \$POWERLINE_ROOT_PATH/powerline/bindings/bash/powerline.sh"
10 | read -p 'press Enter to continue:'
11 | exit 1
12 | fi
13 |
--------------------------------------------------------------------------------
/charles/installation.d/conf.d/config-powerline-ipython:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | IPY_CONFIG_PATH=~/.ipython/profile_default/ipython_config.py
3 | # pip install -U powerline-status || true
4 | pip install git+https://github.com/powerline/powerline.git@develop -U || true
5 | if [ ! -e "~/.ipython/profile_default/" ]; then mkdir -p ~/.ipython/profile_default/; fi
6 | echo "import os" >$IPY_CONFIG_PATH
7 |
8 | echo "from powerline.bindings.ipython.since_7 import PowerlinePrompts" >>$IPY_CONFIG_PATH
9 | echo "c = get_config()" >>$IPY_CONFIG_PATH
10 | echo "c.TerminalInteractiveShell.simple_prompt = False" >>$IPY_CONFIG_PATH
11 | echo "c.TerminalInteractiveShell.prompts_class = PowerlinePrompts" >>$IPY_CONFIG_PATH
12 | echo "c.InteractiveShellApp.extensions = ['autoreload']" >>$IPY_CONFIG_PATH
13 | echo "c.InteractiveShellApp.exec_lines = ['%autoreload 3']" >>$IPY_CONFIG_PATH
14 |
--------------------------------------------------------------------------------
/charles/installation.d/conf.d/config-tlp:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # To complete the installation you must enable TLP's services (refer to the TLP FAQ):
4 | sudo systemctl enable tlp.service
5 | sudo systemctl enable tlp-sleep.service
6 |
7 | # Using the Radio Device Wizard (tlp-rdw) requires an additional service:
8 | sudo systemctl enable NetworkManager-dispatcher.service
9 |
10 | # You should also mask the following services to avoid conflicts and assure proper operation of TLP's radio device switching options:
11 | sudo systemctl mask systemd-rfkill.service
12 | sudo systemctl mask systemd-rfkill.socket
13 |
14 | echo To handle problems on TLP, you must read the article below and configure correctly.
15 | echo 'https://wiki.archlinux.org/index.php/TLP#Btrfs'
16 |
--------------------------------------------------------------------------------
/charles/installation.d/conf.d/config-tmux:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # oh my tmux
3 |
4 | cd
5 | git clone https://github.com/gpakosz/.tmux.git
6 | ln -s -f .tmux/.tmux.conf
7 | cp .tmux/.tmux.conf.local .
8 |
9 | echo "tmux_conf_theme_left_separator_main=''" >>~/.tmux.conf.local
10 | echo "tmux_conf_theme_left_separator_sub=''" >>~/.tmux.conf.local
11 | echo "tmux_conf_theme_right_separator_main=''" >>~/.tmux.conf.local
12 | echo "tmux_conf_theme_right_separator_sub=''" >>~/.tmux.conf.local
13 |
--------------------------------------------------------------------------------
/charles/installation.d/get.d/get-albert:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | wget -nv -O Release.key \
3 | https://build.opensuse.org/projects/home:manuelschneid3r/public_key
4 | sudo apt-key add - /etc/apt/sources.list.d/home:manuelschneid3r.list"
7 |
--------------------------------------------------------------------------------
/charles/installation.d/get.d/get-aur:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo '[archlinuxcn]
4 | #The Chinese Arch Linux communities packages.
5 | SigLevel = Optional TrustAll
6 | Server = https://mirrors.ustc.edu.cn/archlinuxcn/$arch' | sudo tee -a /etc/pacman.conf
7 |
8 | sudo pacman -Syu yay
9 |
--------------------------------------------------------------------------------
/charles/installation.d/get.d/get-calibre:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | case $(cat /etc/issue | cut -f 1 -d ' ') in
3 | 'Arch') INSTALL() { sudo pacman -S $@; } ;;
4 | 'Ubuntu') INSTALL() { sudo apt install $@ -y --allow-unauthenticated; } ;;
5 | *) echo 'Your distribution has not implementd yet, please modify this command' ;;
6 | esac
7 | if [ $(which wget | wc -l) == 0 ]; then INSTALL wget; fi
8 | if [ $(which python | wc -l) == 0 ]; then INSTALL python; fi
9 |
10 | sudo -v && wget -nv -O- https://download.calibre-ebook.com/linux-installer.py | sudo python -c "import sys; main=lambda:sys.stderr.write('Download failed\n'); exec(sys.stdin.read()); main()"
11 |
--------------------------------------------------------------------------------
/charles/installation.d/get.d/get-docker:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | case $(cat /etc/issue | cut -f 1 -d ' ') in
3 | 'Arch') INSTALL() { sudo pacman -S $@; } ;;
4 | 'Ubuntu') INSTALL() { sudo apt install $@ -y --allow-unauthenticated; } ;;
5 | *) echo 'Your distribution has not implementd yet, please modify this command' ;;
6 | esac
7 | if [ $(which curl | wc -l) == 0 ]; then INSTALL curl; fi
8 | curl -sSL https://get.docker.com/ | sh
9 |
--------------------------------------------------------------------------------
/charles/installation.d/get.d/get-duck-cowsay:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | echo '$the_cow = <<"EOC";
3 | $thoughts
4 | $thoughts
5 | $thoughts >()_
6 | (__)__ _
7 | EOC' | sudo tee /usr/share/cows/duck.cow
8 |
--------------------------------------------------------------------------------
/charles/installation.d/get.d/get-fasd:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | if [[ $(cat /etc/issue | cut -f 1 -d ' ') == 'Ubuntu' ]]; then
3 | sudo add-apt-repository ppa:aacebedo/fasd -y
4 | sudo apt-get update
5 | sudo apt-get install fasd
6 | fi
7 |
--------------------------------------------------------------------------------
/charles/installation.d/get.d/get-homebrew-command-not-found:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -x
3 | brew tap homebrew/command-not-found
4 | mkdir -p ~/.config/fish/conf.d
5 | echo 'brew command command-not-found-init > /dev/null 2>&1; and . (brew command-not-found-init)' | tee ~/.config/fish/conf.d/homebrew-command-not-found.fish
6 |
--------------------------------------------------------------------------------
/charles/installation.d/get.d/get-oh-my-fish:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | case $(cat /etc/issue | cut -f 1 -d ' ') in
3 | 'Arch') INSTALL() { sudo pacman -S $@; } ;;
4 | 'Ubuntu') INSTALL() { sudo apt install $@ -y --allow-unauthenticated; } ;;
5 | *) echo 'Your distribution has not implementd yet, please modify this command' ;;
6 | esac
7 | if [ $(which fish | wc -l) == 0 ]; then INSTALL fish; fi
8 | if [ $(which curl | wc -l) == 0 ]; then INSTALL curl; fi
9 |
10 | curl -L https://get.oh-my.fish | fish
11 |
--------------------------------------------------------------------------------
/charles/installation.d/get.d/get-playdeb:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | echo 'deb http://archive.getdeb.net/ubuntu zesty-getdeb games' | sudo tee /etc/apt/sources.list.d/playdeb2.list
3 | wget -q -O- http://archive.getdeb.net/getdeb-archive.key | sudo apt-key add -
4 |
--------------------------------------------------------------------------------
/charles/installation.d/get.d/get-powerline:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | case $(cat /etc/issue | cut -f 1 -d ' ') in
3 | 'Arch') INSTALL() { sudo pacman -S $@; } ;;
4 | 'Ubuntu') INSTALL() { sudo apt install $@ -y --allow-unauthenticated; } ;;
5 | *) echo 'Your distribution has not implementd yet, please modify this command' ;;
6 | esac
7 | if [ $(sudo whereis pip3 | grep /usr | wc -l) == 0 ]; then INSTALL python3-pip; fi
8 | sudo pip3 install --user powerline-status
9 |
--------------------------------------------------------------------------------
/charles/installation.d/get.d/get-spacemacs:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | case $(cat /etc/issue | cut -f 1 -d ' ') in
3 | 'Arch') INSTALL() { sudo pacman -S $@; } ;;
4 | 'Ubuntu') INSTALL() { sudo apt install $@ -y --allow-unauthenticated; } ;;
5 | *) echo 'Your distribution has not implementd yet, please modify this command' ;;
6 | esac
7 | if [ $(which git | wc -l) == 0 ]; then INSTALL git; fi
8 | git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d
9 |
--------------------------------------------------------------------------------
/charles/installation.d/get.d/get-spacevim:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | case $(cat /etc/issue | cut -f 1 -d ' ') in
3 | 'Arch') INSTALL() { sudo pacman -S $@; } ;;
4 | 'Ubuntu') INSTALL() { sudo apt install $@ -y --allow-unauthenticated; } ;;
5 | *) echo 'Your distribution has not implementd yet, please modify this command' ;;
6 | esac
7 | if [ $(which curl | wc -l) == 0 ]; then INSTALL curl; fi
8 | curl -sLf https://spacevim.org/install.sh | bash
9 |
--------------------------------------------------------------------------------
/charles/installation.d/get.d/get-sublime-text-3:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | if [[ $(cat /etc/issue | cut -f 1 -d ' ') == 'Ubuntu' ]]; then
3 | if [ $(which wget | wc -l) == 0 ]; then sudo apt install wget; fi
4 | wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
5 | echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
6 | sudo apt update
7 | sudo apt install sublime-text
8 | else
9 | echo 'This script is for Ubuntu only!'
10 | fi
11 |
--------------------------------------------------------------------------------
/charles/installation.d/get.d/get-thefuck:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | case $(cat /etc/issue | cut -f 1 -d ' ') in
3 | 'Arch') INSTALL() { sudo pacman -S $@; } ;;
4 | 'Ubuntu') INSTALL() { sudo apt install $@ -y --allow-unauthenticated; } ;;
5 | *) echo 'Your distribution has not implementd yet, please modify this command' ;;
6 | esac
7 | if [ $(which thefuck | wc -l) == 0 ]; then INSTALL thefuck; fi
8 |
9 | mkdir -p ~/.config/fish/conf.d
10 | echo 'function fuck -d "Correct your previous console command"' | tee ~/.config/fish/conf.d/thefuck.fish
11 | echo ' set -l exit_code $status' | tee -a ~/.config/fish/conf.d/thefuck.fish
12 | echo ' set -x TF_ALIAS fuck' | tee -a ~/.config/fish/conf.d/thefuck.fish
13 | echo ' set -l fucked_up_command $history[1]' | tee -a ~/.config/fish/conf.d/thefuck.fish
14 | echo ' thefuck $fucked_up_command | read -l unfucked_command' | tee -a ~/.config/fish/conf.d/thefuck.fish
15 | echo ' if [ "$unfucked_command" != "" ]' | tee -a ~/.config/fish/conf.d/thefuck.fish
16 | echo ' eval $unfucked_command' | tee -a ~/.config/fish/conf.d/thefuck.fish
17 | echo ' if test $exit_code -ne 0' | tee -a ~/.config/fish/conf.d/thefuck.fish
18 | echo ' history --delete $fucked_up_command' | tee -a ~/.config/fish/conf.d/thefuck.fish
19 | echo ' history --merge ^ /dev/null' | tee -a ~/.config/fish/conf.d/thefuck.fish
20 | echo ' return 0' | tee -a ~/.config/fish/conf.d/thefuck.fish
21 | echo ' end' | tee -a ~/.config/fish/conf.d/thefuck.fish
22 | echo ' end' | tee -a ~/.config/fish/conf.d/thefuck.fish
23 | echo 'end' | tee -a ~/.config/fish/conf.d/thefuck.fish
24 |
--------------------------------------------------------------------------------
/charles/installation.d/get.d/get-tldr-cheat:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | case $(cat /etc/issue | cut -f 1 -d ' ') in
3 | 'Arch') INSTALL() { sudo pacman -S $@; } ;;
4 | 'Ubuntu') INSTALL() { sudo apt install $@ -y --allow-unauthenticated; } ;;
5 | *) echo 'Your distribution has not implementd yet, please modify this command' ;;
6 | esac
7 | if [ $(which pip | wc -l) == 0 ]; then INSTALL python-pip; fi
8 | sudo pip install -U cheat tldr
9 |
--------------------------------------------------------------------------------
/charles/installation.d/get.d/get-typora:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # optional, but recommended
3 |
4 | sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BA300B7755AFCFAE
5 |
6 | # add Typora's repository
7 |
8 | sudo add-apt-repository 'deb https://typora.io linux/'
9 |
10 | sudo apt-get update
11 |
12 | # install typora
13 |
14 | sudo apt-get install typora
15 |
--------------------------------------------------------------------------------
/charles/installation.d/get.d/get-up:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | if [ $(which curl | wc -l) == 0 ]; then INSTALL curl; fi
3 | curl --create-dirs -o ~/.config/fish/conf.d/up.fish https://raw.githubusercontent.com/shannonmoeller/up/master/up.fish
4 |
--------------------------------------------------------------------------------
/charles/installation.d/get.d/get-xsh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | case $(cat /etc/issue | cut -f 1 -d ' ') in
3 | 'Arch') INSTALL() { sudo pacman -S $@; } ;;
4 | 'Ubuntu') INSTALL() { sudo apt install $@ -y --allow-unauthenticated; } ;;
5 | *) echo 'Your distribution has not implementd yet, please modify this command' ;;
6 | esac
7 | if [ $(which curl | wc -l) == 0 ]; then INSTALL curl -y; fi
8 | curl -L https://xiki.com/install_xsh -o ~/install_xsh
9 | bash ~/install_xsh
10 | rm ~/install_xsh
11 | echo "set -x fish_user_paths ~/xiki-project/bin/ \$fish_user_paths" >~/.config/fish/conf.d/xsh.fish
12 |
--------------------------------------------------------------------------------
/charles/shell.rc.d/init.fish:
--------------------------------------------------------------------------------
1 | set -x CHARLES_HOME $HOME/.local/share/CharlesScripts/charles
2 | set -x CHARLES_BACKUP $HOME/.config/CharlesBackup
3 |
4 | #LANG
5 | set -x LANG UTF-8
6 | set -x LC_ALL en_US.UTF-8
7 | set -x LC_CTYPE en_US.UTF-8
8 |
9 | #PATHS
10 | set -x fish_user_paths $CHARLES_HOME/bin $fish_user_paths
11 | set -x fish_user_paths $HOME/.local/bin $fish_user_paths
12 |
13 | #VARIABLES
14 | set -x TF_CPP_MIN_LOG_LEVEL 2
15 | set -x EDITOR nvim
16 | set -x FZF_DEFAULT_OPTS "--bind='ctrl-o:execute(subl {})+abort'"
17 | set -x SDCV_PAGER less
18 |
19 | #COLOR_LESS
20 | set -x PAGER less
21 | set -x LESS "-R -i -g -c -W"
22 | set -x LESSOPEN '|/usr/bin/env lesspipe %s'
23 | set -x LESSCLOSE '/usr/bin/env lesspipe %s %s'
24 | #COLOR MAN
25 | set -x LESS_TERMCAP_mb (printf "\033[01;31m")
26 | set -x LESS_TERMCAP_md (printf "\033[01;31m")
27 | set -x LESS_TERMCAP_me (printf "\033[0m")
28 | set -x LESS_TERMCAP_se (printf "\033[0m")
29 | set -x LESS_TERMCAP_so (printf "\033[01;44;33m")
30 | set -x LESS_TERMCAP_ue (printf "\033[0m")
31 | set -x LESS_TERMCAP_us (printf "\033[01;32m")
32 |
33 | #BOBTHEFISH
34 | set -x theme_date_format "+%A, %B %d, %l:%M%P"
35 | set -x theme_nerd_fonts yes
36 | set -x theme_title_display_process yes
37 | set -x theme_title_display_path yes
38 | set -x theme_title_display_user yes
39 | set -x theme_title_use_abbreviated_path yes
40 | set -x theme_color_scheme zenburn # dark, light, solarized, solarized-dark, solarized-light, base16, zenburn, gruvbox
41 |
42 |
43 | #FUNCTIONS
44 |
45 | function backup
46 | for i in "$argv"
47 | cp -r "$i" "$i.bak"
48 | end
49 | end
50 |
51 | function check-ports
52 | for port in (netstat -na|grep LISTEN|awk '{print $4}'|grep -Po '\d+$'|sort -nu)
53 | echo $port
54 | set cmd_info (sudo lsof -i :$port|grep LISTEN|tail -1)
55 | sudo lsof -i :$port
56 | ps u -p (echo $cmd_info|awk '{print $2}') | tail -1 | awk '{print $11}'
57 | echo
58 | end
59 | end
60 |
61 | function cls
62 | cd "$argv"
63 | ls
64 | end
65 |
66 | function g
67 | git pull
68 | git add -A
69 | git diff --cached
70 | echo "type the commits or cancel with Ctrl+C"
71 | git status
72 | read COMMIT
73 | git commit -m "$argv $COMMIT"
74 | git log -1 HEAD
75 | if git push
76 | echo push succeeded
77 | for i in (seq 25)
78 | echo
79 | end
80 | fortune | cowsay -f bunny -n
81 | else
82 | for i in (seq 3)
83 | echo push failed
84 | end
85 | echo push failed $PWD
86 | for i in (seq 25)
87 | echo
88 | end
89 | cowsay -f bong -n "push failed!!! push again!!!"
90 | end
91 | end
92 |
93 | function mcd
94 | mkdir -p "$argv"
95 | cd "$argv"
96 | end
97 |
98 | function md5move
99 | for i in (ls $argv[1])
100 | set md5 (md5sum $i|string split ' ')[1]
101 | set tail (string split -m1 -r '.' $i)[2]
102 | mv $i $md5.$tail
103 | end
104 | end
105 |
106 | function viz
107 | switch $argv[2]
108 | case eps
109 | dot -T $argv[2] -o /tmp/(string trim -r -c dot $argv[1])png $argv[1]
110 | convert /tmp/(string trim -r -c dot $argv[1])png (string trim -r -c dot $argv[1])eps
111 | rm /tmp/(string trim -r -c dot $argv[1])png
112 | case "*"
113 | dot -T $argv[2] -o (string trim -r -c dot $argv[1])$argv[2] $argv[1]
114 | end
115 | end
116 |
--------------------------------------------------------------------------------
/charles/shell.rc.d/init.shell:
--------------------------------------------------------------------------------
1 | #INIT
2 | for filename in ${SOURCES_LIST[@]}; do
3 | if [ -f $filename ]; then source $filename; fi
4 | done
5 |
6 | #PATHS
7 | export CHARLES_HOME=$HOME/.local/share/CharlesScripts/charles
8 | export PATH=$CHARLES_HOME/bin:$PATH
9 |
10 | #VARIABLES
11 | export TF_CPP_MIN_LOG_LEVEL=2
12 |
13 | #COLOR_LESS
14 | export PAGER="less"
15 | export LESS="-C -M -I -j 10 -# 4 -R -i -g -c -W"
16 | export LESSOPEN='|/usr/bin/env lesspipe.sh %s'
17 | export LESSCLOSE='/usr/bin/env lesspipe.sh %s %s'
18 | #COLOR MAN
19 | export LESS_TERMCAP_mb=$'\E[01;31m'
20 | export LESS_TERMCAP_md=$'\E[01;31m'
21 | export LESS_TERMCAP_me=$'\E[0m'
22 | export LESS_TERMCAP_se=$'\E[0m'
23 | export LESS_TERMCAP_so=$'\E[01;44;33m'
24 | export LESS_TERMCAP_ue=$'\E[0m'
25 | export LESS_TERMCAP_us=$'\E[01;32m'
26 |
27 | #ALIASES
28 | alias ..='cd ..'
29 | alias ...='cd ../..'
30 | alias c='clear; cd'
31 | alias cl='cd ..;ls'
32 | alias eg='grep -E'
33 | alias emacsc='emacs --no-window-system'
34 | alias histg='history | grep'
35 | alias i='ipython --no-confirm-exit --no-banner --pprint -i --pylab=auto'
36 | alias l='ls --color=auto'
37 | alias la='ls -a'
38 | alias le='ls -a|egrep'
39 | alias lf='ls -lah --full-time'
40 | alias lg='ls -a|grep'
41 | alias ll='ls -lah'
42 | alias n='nautilus .&'
43 | alias o='xdg-open'
44 | alias p='python'
45 | alias pdb='python -mpowerline.bindings.pdb'
46 | alias su='sudo su'
47 | alias sd='sudo shutdown -h 0'
48 | alias u='update'
49 | alias t='tensorboard --logdir="."'
50 |
51 | #FUNCTIONS
52 |
53 | backup() { cp "$1"{,.bak}; }
54 |
55 | cls() {
56 | cd "$1"
57 | ls
58 | }
59 |
60 | mcd() {
61 | mkdir -p "$1"
62 | cd "$1"
63 | }
64 |
65 | md5check() { md5sum "$1" | grep "$2"; }
66 |
67 | extract() {
68 | if [ -f $1 ]; then
69 | case $1 in
70 | *.tar.bz2) tar xjf $1 ;;
71 | *.tar.gz) tar xzf $1 ;;
72 | *.bz2) bunzip2 $1 ;;
73 | *.rar) unrar e $1 ;;
74 | *.gz) gunzip $1 ;;
75 | *.tar) tar xf $1 ;;
76 | *.tbz2) tar xjf $1 ;;
77 | *.tgz) tar xzf $1 ;;
78 | *.zip) unzip $1 ;;
79 | *.Z) uncompress $1 ;;
80 | *.7z) 7z x $1 ;;
81 | *) echo "'$1' cannot be extracted via extract()" ;;
82 | esac
83 | else
84 | echo "'$1' is not a valid file"
85 | fi
86 | }
87 |
--------------------------------------------------------------------------------
/figs/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/the0demiurge/CharlesScripts/c567d210b482383a638717906cdd5be24a451e77/figs/1.png
--------------------------------------------------------------------------------
/figs/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/the0demiurge/CharlesScripts/c567d210b482383a638717906cdd5be24a451e77/figs/2.png
--------------------------------------------------------------------------------
/figs/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/the0demiurge/CharlesScripts/c567d210b482383a638717906cdd5be24a451e77/figs/3.png
--------------------------------------------------------------------------------
/install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | OS=$(cat /etc/issue | cut -f 1 -d ' ')
3 | CHARLES_BACKUP=~/.config/CharlesBackup
4 | case $OS in
5 | 'Arch')
6 | INSTALL() { sudo pacman -S --needed $@; }
7 | UPDATE() { sudo pacman -Sy; }
8 | ;;
9 | 'Ubuntu')
10 | INSTALL() { sudo apt install $@ -y --allow-unauthenticated; }
11 | UPDATE() { sudo apt update; }
12 | ;;
13 | *) echo 'Your distribution has not implementd yet, please modify this command' ;;
14 | esac
15 |
16 | if [[ $0 != 'debug' ]]; then
17 | set -e
18 | fi
19 |
20 | promptn() {
21 | read -p 'Will you run '$1'?[y/N]' PMT
22 | if [[ $PMT == 'y' || $PMT == 'Y' ]]; then
23 | . ./$1
24 | fi
25 | }
26 |
27 | prompty() {
28 | read -p 'Will you run '$1'?[Y/n]' PMT
29 | if [[ $PMT != 'n' && $PMT != 'N' ]]; then
30 | . ./$1
31 | fi
32 | }
33 |
34 | dependency() {
35 | echo 'Installing part of the dependencies...'
36 | UPDATE
37 | case $OS in
38 | 'Arch') INSTALL git cowsay sl fish mlocate fortune-mod ;;
39 | 'Ubuntu') INSTALL git cowsay oneko sl fortune fish mlocate ;;
40 | *) echo 'Your distribution has not implementd yet, please modify this command' ;;
41 | esac
42 | sudo updatedb
43 | }
44 |
45 | gitclone() {
46 | if [ ! -d ~/.local/share ]; then mkdir -p ~/.local/share; fi
47 | if [[ -x ~/.local/share/CharlesScripts ]]; then rm -rf ~/.local/share/CharlesScripts; fi
48 | git clone https://github.com/the0demiurge/CharlesScripts.git ~/.local/share/CharlesScripts
49 | if [[ ! -x $CHARLES_BACKUP ]]; then
50 | echo 'Please type your backup git repo address. If you do not have one, you may create it on GitHub.com.'
51 | read -p 'Press Enter to skip' REPO
52 | git clone $REPO $CHARLES_BACKUP || true
53 | fi
54 | if [[ ! -x $CHARLES_BACKUP ]]; then
55 | echo 'Clone failed! Default CharlesBackup will be cloned!'
56 | git clone https://github.com/the0demiurge/CharlesBackup.git $CHARLES_BACKUP
57 | echo 'You may modify $CHARLES_BACKUP, and type:'
58 | echo 'cd $CHARLES_BACKUP'
59 | echo 'git remote set-url origin '
60 | echo 'git add -A; git commit -m "init commit";git push -u origin master'
61 | fi
62 | }
63 |
64 | get() {
65 | Y_LIST=(get-fasd
66 | get-powerline
67 | get-thefuck
68 | get-oh-my-fishi
69 | get-albert
70 | get-playdeb
71 | get-typora)
72 |
73 | N_LIST=(get-calibre
74 | get-docker
75 | get-spacemacs
76 | get-spacevim
77 | get-sublime-text-3
78 | get-xsh)
79 |
80 | for Y in ${Y_LIST[@]}; do
81 | cd ~/.local/share/CharlesScripts/charles/installation.d/get.d/
82 | prompty $Y
83 | done
84 |
85 | for N in ${N_LIST[@]}; do
86 | cd ~/.local/share/CharlesScripts/charles/installation.d/get.d/
87 | promptn $N
88 | done
89 | }
90 |
91 | conf() {
92 | Y_LIST=(config-bash
93 | config-fish
94 | config-git
95 | config-gnome
96 | config-powerline-bash
97 | config-tmux)
98 |
99 | N_LIST=(config-powerline-ipython
100 | config-wine32)
101 |
102 | for Y in ${Y_LIST[@]}; do
103 | cd ~/.local/share/CharlesScripts/charles/installation.d/conf.d/
104 | prompty $Y
105 | done
106 |
107 | for N in ${N_LIST[@]}; do
108 | cd ~/.local/share/CharlesScripts/charles/installation.d/conf.d/
109 | promptn $N
110 | done
111 | }
112 |
113 | restore() {
114 | read -p 'DANGER! Restore dotfiles from ~/.local/share/CharlesScripts/data/home/.* ?[y/N]' PMT
115 | if [[ $PMT == 'y' || $PMT == 'Y' ]]; then
116 | cp -rv ~/.local/share/CharlesScripts/data/home/.* ~/
117 | fi
118 |
119 | Y_LIST=(gnome-shell-extensions-restore
120 | )
121 |
122 | for Y in ${Y_LIST[@]}; do
123 | cd ~/.local/share/CharlesScripts/charles/bin
124 | prompty $Y
125 | done
126 | }
127 | dependency
128 | gitclone
129 | get
130 | conf
131 | restore
132 |
133 | cd ~/.local/share/CharlesScripts/charles/installation.d/get.d/
134 | prompty get-oh-my-fish
135 |
136 | cd ~/.local/share/CharlesScripts/charles/bin
137 | prompty omf-restore
138 | echo 'Finished!'
139 |
--------------------------------------------------------------------------------
/test/install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | if [[ $0 != 'debug' ]]; then
3 | set -e
4 | fi
5 |
6 | promptn() {
7 | read -p 'Will you run '$1'?[y/N]' PMT
8 | if [[ $PMT == 'y' || $PMT == 'Y' ]]; then
9 | . ./$1
10 | fi
11 | }
12 |
13 | prompty() {
14 | read -p 'Will you run '$1'?[Y/n]' PMT
15 | if [[ $PMT != 'n' || $PMT != 'N' ]]; then
16 | . ./$1
17 | fi
18 | }
19 |
20 | dependency() {
21 | echo 'Installing part of the dependencies...'
22 | sudo apt update
23 | sudo apt install git cowsay oneko sl fortune fish mlocate
24 | sudo updatedb
25 | }
26 |
27 | gitclone() {
28 | if [ ! -d ~/.local/share ]; then mkdir -p ~/.local/share; fi
29 | git clone https://github.com/the0demiurge/CharlesScripts.git ~/.local/share/CharlesScripts
30 | read -p 'Please type your backup git repo address. If you do not have one, you may create it on GitHub.com.\nPress Enter to skip\n' REPO
31 | git clone $REPO $CHARLES_BACKUP || true
32 | if [[ ! -x $CHARLES_BACKUP ]]; then
33 | echo 'Clone failed! Default CharlesBackup will be cloned!'
34 | git clone https://github.com/the0demiurge/CharlesScripts.git $CHARLES_BACKUP
35 | echo 'You may modify $CHARLES_BACKUP, and type:'
36 | echo 'cd $CHARLES_BACKUP'
37 | echo 'git remote set-url origin '
38 | echo 'git add -A; git commit -m "init commit";git push -u origin master'
39 | fi
40 | }
41 |
42 | get() {
43 | Y_LIST=(get-fasd
44 | # get-powerline)
45 | #get-oh-my-fish
46 | # get-thefuck)
47 | )
48 |
49 | # N_LIST=(get-calibre
50 | # get-docker
51 | # get-spacemacs
52 | # get-spacevim
53 | # get-sublime-text-3
54 | # get-xsh)
55 |
56 | for Y in ${Y_LIST[@]}; do
57 | cd ~/.local/share/CharlesScripts/charles/installation.d/get.d/
58 | prompty $Y
59 | done
60 |
61 | for N in ${N_LIST[@]}; do
62 | cd ~/.local/share/CharlesScripts/charles/installation.d/get.d/
63 | prompty $N
64 | done
65 | }
66 |
67 | conf() {
68 | Y_LIST=(config-bash
69 | # config-fish
70 | config-git
71 | config-powerline-bash
72 | config-tmux)
73 |
74 | N_LIST=(config-powerline-ipython)
75 |
76 | for Y in ${Y_LIST[@]}; do
77 | cd ~/.local/share/CharlesScripts/charles/installation.d/conf.d/
78 | echo $Y
79 | prompty $Y
80 | done
81 |
82 | for N in ${N_LIST[@]}; do
83 | cd ~/.local/share/CharlesScripts/charles/installation.d/conf.d/
84 | echo $N
85 | prompty $N
86 | done
87 | }
88 |
89 | restore() {
90 | read -p 'DANGER! Restore dotfiles from ~/.local/share/CharlesScripts/data/home/.* ?[y/N]' PMT
91 | if [[ $PMT == 'y' || $PMT == 'Y' ]]; then
92 | cp -rvi ~/.local/share/CharlesScripts/data/home/.* ~/ || true
93 | fi
94 |
95 | cd ~/.local/share/CharlesScripts/charles/bin
96 |
97 | # Y_LIST=(
98 | # omf-restore)
99 |
100 | for Y in ${Y_LIST[@]}; do
101 | echo $Y
102 | prompty $Y
103 | done
104 | }
105 | dependency
106 | gitclone
107 | get
108 | conf
109 | restore
110 |
111 | cd ~/.local/share/CharlesScripts/charles/installation.d/get.d/
112 | prompty get-oh-my-fish
113 |
--------------------------------------------------------------------------------
/tools/README.md:
--------------------------------------------------------------------------------
1 | # tools
2 | 自己写的一些小工具
3 | ## auto_hosts_updater
4 | 自动更新hosts的小工具,可以翻墙+去广告。
5 |
6 | 包含:
7 |
8 | * linux版
9 | * windows版
10 | ## codecombine
11 | 把代码整合到一个文件里,然后给出字数统计
12 |
13 | 用法:*./codecombine from_path "regular expression pattern" save_path*
14 |
--------------------------------------------------------------------------------
/tools/auto_hosts_updater/README.md:
--------------------------------------------------------------------------------
1 | # 自动更新Hosts脚本
2 | 里面有两个源,一个翻墙一个去广告,大家可以放心使用,用管理员权限运行脚本即可。
3 | 要是不想使用,运行相应的卸载脚本即可。
4 | 要是你想增加/删除/修改/查看里面的源,源码很简单,稍微看一下就知道怎么做了。
5 |
--------------------------------------------------------------------------------
/tools/auto_hosts_updater/linux/install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | echo '#!/bin/bash' | sudo tee /etc/cron.daily/update-hosts
4 | echo 'Automatic Hosts Updater' | sudo tee -a /etc/cron.daily/update-hosts
5 | echo '' | sudo tee -a /etc/cron.daily/update-hosts
6 | echo 'HOSTS_LIST=(' | sudo tee -a /etc/cron.daily/update-hosts
7 | echo '"https://github.com/googlehosts/hosts/raw/master/hosts-files/hosts"' | sudo tee -a /etc/cron.daily/update-hosts
8 | echo '"https://github.com/vokins/yhosts/raw/master/hosts"' | sudo tee -a /etc/cron.daily/update-hosts
9 | # echo '"https://raw.githubusercontent.com/Lerist/Go-Hosts/master/hosts"'|sudo tee -a /etc/cron.daily/update-hosts
10 | # echo '"https://raw.githubusercontent.com/Lerist/Go-Hosts/master/hosts-ad"'|sudo tee -a /etc/cron.daily/update-hosts
11 | echo ')' | sudo tee -a /etc/cron.daily/update-hosts
12 | echo '' | sudo tee -a /etc/cron.daily/update-hosts
13 | echo 'for item in ${HOSTS_LIST[@]};do' | sudo tee -a /etc/cron.daily/update-hosts
14 | echo ' false' | sudo tee -a /etc/cron.daily/update-hosts
15 | echo ' while [ $? != 0 ]; do' | sudo tee -a /etc/cron.daily/update-hosts
16 | echo ' curl -L $item|tee -a /tmp/hosts' | sudo tee -a /etc/cron.daily/update-hosts
17 | echo ' done' | sudo tee -a /etc/cron.daily/update-hosts
18 | echo 'done' | sudo tee -a /etc/cron.daily/update-hosts
19 | echo '' | sudo tee -a /etc/cron.daily/update-hosts
20 | echo 'if [ -e /tmp/hosts ]; then' | sudo tee -a /etc/cron.daily/update-hosts
21 | echo ' echo "127.0.0.1 " `cat /etc/hostname`|tee /etc/hosts' | sudo tee -a /etc/cron.daily/update-hosts
22 | echo ' cat /tmp/hosts|tee -a /etc/hosts' | sudo tee -a /etc/cron.daily/update-hosts
23 | echo ' rm /tmp/hosts' | sudo tee -a /etc/cron.daily/update-hosts
24 | echo ' echo ""' | sudo tee -a /etc/cron.daily/update-hosts
25 | echo ' echo ""' | sudo tee -a /etc/cron.daily/update-hosts
26 | echo ' echo "hosts updat succeeded!"' | sudo tee -a /etc/cron.daily/update-hosts
27 | echo ' exit 0' | sudo tee -a /etc/cron.daily/update-hosts
28 | echo 'else' | sudo tee -a /etc/cron.daily/update-hosts
29 | echo ' echo "failed!"' | sudo tee -a /etc/cron.daily/update-hosts
30 | echo ' exit 1' | sudo tee -a /etc/cron.daily/update-hosts
31 | echo 'fi' | sudo tee -a /etc/cron.daily/update-hosts
32 |
33 | sudo bash /etc/cron.daily/update-hosts
34 |
--------------------------------------------------------------------------------
/tools/auto_hosts_updater/linux/uninst.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | echo "127.0.0.1 " $(cat /etc/hostname) | sudo tee /etc/hosts
3 | sudo rm /etc/hosts
4 |
--------------------------------------------------------------------------------
/tools/auto_hosts_updater/windows/README.md:
--------------------------------------------------------------------------------
1 | **该方法不适用于win7,win7及以下请使用[laoD介绍的软件](https://github.com/racaljk/hosts/tree/master/tools)**:[Windows版链接](https://github.com/HostsTools/Windows),以及[下载链接](https://git.io/vX1Pz)
2 | #自动更新hosts脚本#
3 | 自动翻墙,也可以通过修改install.bat里面网址来修改hosts源,使其增加广告屏蔽功能
4 | ##使用方法##
5 | 右键-使用管理员权限运行,即可安装该服务
6 |
--------------------------------------------------------------------------------
/tools/auto_hosts_updater/windows/install.bat:
--------------------------------------------------------------------------------
1 | @powershell set-executionpolicy unrestricted
2 | schtasks /create /tn update-hosts /sc daily /ru "NT Authority\System" /tr %SystemRoot%\System32\drivers\etc\update-hosts.ps1
3 |
4 | #update-hosts.ps1
5 | echo mkdir %TEMP%\hosts > %SystemRoot%\System32\drivers\etc\update-hosts.ps1
6 | echo $client = new-object System.Net.WebClient >> %SystemRoot%\System32\drivers\etc\update-hosts.ps1
7 | echo $client.DownloadFile('https://github.com/googlehosts/hosts/raw/master/hosts-files/hosts') >> %SystemRoot%\System32\drivers\etc\update-hosts.ps1
8 | echo $client.DownloadFile('https://github.com/vokins/yhosts/raw/master/hosts') >> %SystemRoot%\System32\drivers\etc\update-hosts.ps1
9 | rem echo $client.DownloadFile('https://raw.githubusercontent.com/Lerist/Go-Hosts/master/hosts') >> %SystemRoot%\System32\drivers\etc\update-hosts.ps1
10 | rem echo $client.DownloadFile('https://raw.githubusercontent.com/Lerist/Go-Hosts/master/hosts-ad') >> %SystemRoot%\System32\drivers\etc\update-hosts.ps1
11 | echo cat %TEMP%\hosts\* ^> %SystemRoot%\System32\drivers\etc\hosts >> %SystemRoot%\System32\drivers\etc\update-hosts.ps1
12 | echo rm -recurse %TEMP%\hosts >> %SystemRoot%\System32\drivers\etc\update-hosts.ps1
13 |
14 | echo updating hosts
15 | powershell %SystemRoot%\System32\drivers\etc\update-hosts.ps1
16 | ipconfig /flushdns
17 | echo 'done'
18 |
--------------------------------------------------------------------------------
/tools/auto_hosts_updater/windows/uninst.bat:
--------------------------------------------------------------------------------
1 | @powershell set-executionpolicy default
2 | schtasks /delete /tn Update-Hosts
3 | del %SystemRoot%\System32\drivers\etc\update-hosts.ps1
4 | del %SystemRoot%\System32\drivers\etc\hosts
5 | ipconfig /flushdns
6 |
--------------------------------------------------------------------------------
/tools/codecombine:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | if [ $# -ne 3 ]; then
3 | echo 'USAGE: ./codecombine from_path "pattern" save_path'
4 | else
5 | from_path=$1
6 | pattern=$2
7 | save_path=$3
8 |
9 | if [ -f $save_path ]; then
10 | rm -i $save_path
11 | fi
12 | find $from_path -name $pattern \
13 | -exec echo "File: {}" \; \
14 | -exec cat "{}" \; \
15 | -exec echo "" \; \
16 | -exec echo "" \; \
17 | -exec echo "" \; \
18 | -exec echo "" \; >>$save_path >>$save_path >>$save_path >>$save_path >>$save_path >>$save_path
19 | wc $save_path
20 | fi
21 |
--------------------------------------------------------------------------------