Browse Source

Organize scripts

fix_ci
Ein Verne 3 years ago
parent
commit
92793486c5
  1. 8
      config/bootstrap.conf.yml
  2. 0
      python_scripts/clone-all-gitlab.py
  3. 0
      script/byzanz-record-gui.sh
  4. 0
      script/byzanz-record-region.sh
  5. 0
      script/byzanz-record-window.sh
  6. 2
      script/install.sh
  7. 0
      script/install_android_decompiler.sh
  8. 0
      script/install_byzanz_record.sh
  9. 0
      script/install_conky.sh
  10. 102
      script/qiniu-autosync.sh
  11. 64
      script/tmux_local_install.sh
  12. 0
      script/ubuntu_init.sh
  13. 110
      tmux/.tmux.conf
  14. 2
      tmux/scripts/uptime.sh

8
config/bootstrap.conf.yml

@ -10,6 +10,14 @@
then git pull; then git pull;
else git clone https://github.com/zdharma-continuum/zinit.git ~/.zinit/bin; fi else git clone https://github.com/zdharma-continuum/zinit.git ~/.zinit/bin; fi
- shell:
- description: Clone TPM
quiet: true
command: |
if cd ~/.tmux/plugins/tpm;
then git pull;
else git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
# Change default shell to zsh # Change default shell to zsh
- shell: - shell:
- description: Change default shell to zsh - description: Change default shell to zsh

0
clone-all-gitlab.py → python_scripts/clone-all-gitlab.py

0
byzanz-record-gui.sh → script/byzanz-record-gui.sh

0
byzanz-record-region.sh → script/byzanz-record-region.sh

0
byzanz-record-window.sh → script/byzanz-record-window.sh

2
install.sh → script/install.sh

@ -2,7 +2,7 @@
VIMDIR=${1:-$HOME} VIMDIR=${1:-$HOME}
# install ctags to solve "Exuberant ctags not found in PATH" error # install ctags to solve "Exuberant ctags not found in PATH" error
sudo apt-get install -y git zsh zsh-antigen vim vim-gtk tmux sudo apt-get install -y git zsh vim tmux
sudo apt-get install -y exuberant-ctags sudo apt-get install -y exuberant-ctags
sudo apt-get install -y htop tree zip unzip wget nethogs sudo apt-get install -y htop tree zip unzip wget nethogs

0
install_android_decompiler.sh → script/install_android_decompiler.sh

0
install_byzanz_record.sh → script/install_byzanz_record.sh

0
install_conky.sh → script/install_conky.sh

102
script/qiniu-autosync.sh

@ -0,0 +1,102 @@
#!/bin/sh
# Writen by 404 - <https://github.com/why404>
# 此脚本可监控 Linux/Unix 上指定的文件夹,并将此文件夹内的新增或改动文件自动同步到七牛云存储,可设定同步删除。
# 1. 需先安装 inotify-tools - <https://github.com/rvoicilas/inotify-tools/wiki>
# 2. 然后下载 qboxrsctl - <http://docs.qiniutek.com/v3/tools/qboxrsctl/>
# 获取七牛云存储 ACCESS_KEY 和 SECRET_KEY 以及 BUCKET_NAME (空间名称) 请登录:<https://dev.qiniutek.com>
# 用法(反斜杠用于排版换行需要,实际情况下可忽略):
#
# ./qiniu-autosync.sh -a /PATH/TO/appkey.json \ # appkey.json 写明 {"access_key":"YOUR_ACCESS_KEY", "secret_key": "YOUR_SECRET_KEY"}
# -b BUCKET_NAME \ # 用于存储文件的七牛空间名称
# -c /PATH/TO/qboxrsctl \ # qboxrsctl 可执行命令所在路径
# -d /PATH/TO/WATCH_DIR \ # 要监控的目录,绝对路径
# -e ALLOW_DELETE_TrueOrFalse \ # 是否允许自动删除,缺省为 false
# -f FILE_BLOCK_SIZE \ # 文件切片分块大小,超过这个大小启用并行断点续上传,缺省为 4194304 (4MB)
# -g INOTIFY_IGNORE_PATTERN # 忽略列表(正则),缺省为 "^(.+(\~|\.sw.?)|4913)$" (即 vim 临时文件)
#
# 超过这个大小启用并行断点续上传,缺省 4 MB
QINIU_BLOCK_SIZE=4194304
# 是否允许自动删除,缺省不允许
ALLOW_DELETE=false
# 忽略 vim 创建的临时文件,这里可以自定义忽略正则
INOTIFY_IGNORE_PATTERN="^(.+(\~|\.sw.?)|4913)$"
# inotifywait 可执行命令所在路径
INOTIFY_BIN=/usr/bin/inotifywait
INOTIFY_EVENTS="moved_to,create,delete,close_write,close"
INOTIFY_TIME_FMT="%d/%m/%y %H:%M"
INOTIFY_FORMAT="%T %e %w%f"
while getopts a:b:c:d:e:f:g: option
do
case "${option}"
in
a) QINIU_APPKEY_FILE=${OPTARG};;
b) QINIU_BUCKET=${OPTARG};;
c) QINIU_CMD=${OPTARG};;
d) WATCH_DIR=${OPTARG};;
e) ALLOW_DELETE=${OPTARG};;
f) QINIU_BLOCK_SIZE=${OPTARG};;
g) INOTIFY_IGNORE_PATTERN=${OPTARG};;
esac
done
getFileKey() {
dir=$1
file=$2
key=${file##*$dir}
if [ `echo $key | cut -c1-1` = "/" ]; then
key=`echo $key | cut -c2-${#key}`
fi
echo $key
}
$INOTIFY_BIN --exclude "$INOTIFY_IGNORE_PATTERN" -mre "$INOTIFY_EVENTS" --timefmt "$INOTIFY_TIME_FMT" --format "$INOTIFY_FORMAT" $WATCH_DIR | while read date time event file
do
case "$event" in
CLOSE_WRITE,CLOSE | MOVED_TO)
key=`getFileKey $WATCH_DIR "$file"`
echo "start uploading ${file}"
if [ `stat -c %s "$file"` -gt $QINIU_BLOCK_SIZE ]; then
$QINIU_CMD -a $QINIU_APPKEY_FILE put -c $QINIU_BUCKET "$key" "$file"
else
$QINIU_CMD -a $QINIU_APPKEY_FILE put $QINIU_BUCKET "$key" "$file"
fi
echo "successfully uploaded $QINIU_BUCKET:$key"
;;
DELETE)
echo "deleting file: ${file}"
if $ALLOW_DELETE; then
key=`getFileKey $WATCH_DIR "$file"`
echo "deleting key: ${key}"
$QINIU_CMD -a $QINIU_APPKEY_FILE del $QINIU_BUCKET "$key"
echo "successfully deleted $QINIU_BUCKET:$key"
else
echo "${date} ${time} ${file} ${event}"
echo "\"$QINIU_BUCKET:$key\" will not be deleted."
fi
;;
*)
echo "${date} ${time} ${file} ${event}"
;;
esac
done

64
script/tmux_local_install.sh

@ -0,0 +1,64 @@
#!/bin/bash -
# https://gist.github.com/ryin/3106801
# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# exit on error
set -e
TMUX_VERSION=2.9a
LIBEVENT_VERSION=2.1.8-stable
NCURSES_VERSION=6.1
# create our directories
mkdir -p $HOME/local $HOME/tmux_tmp
cd $HOME/tmux_tmp
# download source files for tmux, libevent, and ncurses
wget https://github.com/tmux/tmux/releases/download/${TMUX_VERSION}/tmux-${TMUX_VERSION}.tar.gz
wget https://github.com/libevent/libevent/releases/download/release-${LIBEVENT_VERSION}/libevent-${LIBEVENT_VERSION}.tar.gz
wget https://ftp.gnu.org/pub/gnu/ncurses/ncurses-${NCURSES_VERSION}.tar.gz
# extract files, configure, and compile
############
# libevent #
############
#tar xvzf libevent-${LIBEVENT_VERSION}.tar.gz
#cd libevent-${LIBEVENT_VERSION}
#./configure --prefix=$HOME/local --disable-shared
#make
#make install
#cd ..
#
#############
## ncurses #
#############
#tar xvzf ncurses-${NCURSES_VERSION}.tar.gz
#cd ncurses-${NCURSES_VERSION}
#./configure --prefix=$HOME/local
#make
#make install
#cd ..
#
#############
## tmux #
#############
#tar xvzf tmux-${TMUX_VERSION}.tar.gz
#cd tmux-${TMUX_VERSION}
#./configure CFLAGS="-I$HOME/local/include -I$HOME/local/include/ncurses" LDFLAGS="-L$HOME/local/lib -L$HOME/local/include/ncurses -L$HOME/local/include"
#CPPFLAGS="-I$HOME/local/include -I$HOME/local/include/ncurses" LDFLAGS="-static -L$HOME/local/include -L$HOME/local/include/ncurses -L$HOME/local/lib" make
#cp tmux $HOME/local/bin
#
#cd $HOME
#
## cleanup
#rm -rf $HOME/tmux_tmp
#
#echo "$HOME/local/bin/tmux is now available. You can optionally add $HOME/local/bin to your PATH."
#
## for the in order to add to the .bashrc (for /sh/bash) comment-in below line
#echo 'export PATH="$HOME/local/bin:$PATH"' >> $HOME/.bashrc

0
ubuntu_init.sh → script/ubuntu_init.sh

110
tmux/.tmux.conf

@ -17,6 +17,7 @@ setw -q -g utf8 on
# edit configuration # edit configuration
bind e new-window -n '~/.tmux.conf.local' "sh -c '\${EDITOR:-vim} ~/.tmux.conf.local && tmux source ~/.tmux.conf && tmux display \"~/.tmux.conf sourced\"'" bind e new-window -n '~/.tmux.conf.local' "sh -c '\${EDITOR:-vim} ~/.tmux.conf.local && tmux source ~/.tmux.conf && tmux display \"~/.tmux.conf sourced\"'"
bind C-x setw synchronize-panes
bind r source-file ~/.tmux.conf \; display-message "tmux config reloaded" # create new short cut to reload tmux.conf bind r source-file ~/.tmux.conf \; display-message "tmux config reloaded" # create new short cut to reload tmux.conf
@ -124,7 +125,7 @@ set-option -g status-justify centre
# show session, windows, pane in left status bar # show session, windows, pane in left status bar
set -g status-left-length 40 set -g status-left-length 40
set -g status-left-style bg=colour233,fg=colour243 # set -g status-left-style bg=colour233,fg=colour243
set -g status-left '#[fg=colour233,bg=colour241,bold] #[fg=colour233,bg=colour245,bold]#S #I/#[fg=colour233,bg=colour245,bold]#P ' set -g status-left '#[fg=colour233,bg=colour241,bold] #[fg=colour233,bg=colour245,bold]#S #I/#[fg=colour233,bg=colour245,bold]#P '
# fiddle with colors of inactive windows # fiddle with colors of inactive windows
@ -156,6 +157,68 @@ setw -g window-status-current-format "#[bg=brightmagenta]#[fg=colour8] #I #[fg=c
#setw -g window-status-bg colour234 #setw -g window-status-bg colour234
#setw -g window-status-attr dim #setw -g window-status-attr dim
# Length of tmux status line
set -g status-left-length 30
set -g status-right-length 150
set-option -g status "on"
# Default statusbar color
set-option -g status-style bg=colour237,fg=colour223 # bg=bg1, fg=fg1
# Default window title colors
set-window-option -g window-status-style bg=colour214,fg=colour237 # bg=yellow, fg=bg1
# Default window with an activity alert
set-window-option -g window-status-activity-style bg=colour237,fg=colour248 # bg=bg1, fg=fg3
# Active window title colors
set-window-option -g window-status-current-style bg=red,fg=colour237 # fg=bg1
# Set active pane border color
set-option -g pane-active-border-style fg=colour214
# Set inactive pane border color
set-option -g pane-border-style fg=colour239
# Message info
set-option -g message-style bg=colour239,fg=colour223 # bg=bg2, fg=fg1
# Writing commands inactive
set-option -g message-command-style bg=colour239,fg=colour223 # bg=fg3, fg=bg1
# Pane number display
set-option -g display-panes-active-colour colour1 #fg2
set-option -g display-panes-colour colour237 #bg1
# Clock
set-window-option -g clock-mode-colour colour109 #blue
# Bell
set-window-option -g window-status-bell-style bg=colour167,fg=colour235 # bg=red, fg=bg
set-option -g status-left "\
#[fg=colour7, bg=colour241]#{?client_prefix,#[bg=colour167],} ❐ #S \
#[fg=colour241, bg=colour237]#{?client_prefix,#[fg=colour167],}#{?window_zoomed_flag, 🔍,}"
set-option -g status-right "\
#[fg=colour214, bg=colour237] \
#[fg=colour223, bg=colour237] #(~/dotfiles/tmux/scripts/uptime.sh) \
#[fg=colour246, bg=colour237] %m/%d\
#[fg=colour109] %H:%M \
#[fg=colour248, bg=colour239]"
set-window-option -g window-status-current-format "\
#[fg=colour237, bg=colour214]\
#[fg=colour239, bg=colour214] #I* \
#[fg=colour239, bg=colour214, bold] #W \
#[fg=colour214, bg=colour237]"
set-window-option -g window-status-format "\
#[fg=colour237,bg=colour239,noitalics]\
#[fg=colour223,bg=colour239] #I \
#[fg=colour223, bg=colour239] #W \
#[fg=colour239, bg=colour237]"
# user defined # user defined
if '[ -f ~/.tmux.conf.local ]' 'source ~/.tmux.conf.local' if '[ -f ~/.tmux.conf.local ]' 'source ~/.tmux.conf.local'
@ -193,3 +256,48 @@ set -g @resurrect-capture-pane-contents 'on'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm' run '~/.tmux/plugins/tpm/tpm'
#############################
############# Tmux Vars
#############################
# $(echo $USER) - shows the current username
# %a --> Day of week (Mon)
# %A --> Day of week Expanded (Monday)
# %b --> Month (Jan)
# %d --> Day (31)
# %Y --> Year (2017)
# %D --> Month/Day/Year (12/31/2017)
# %v --> Day-Month-Year (31-Dec-2017)
# %r --> Hour:Min:Sec AM/PM (12:30:27 PM)
# %T --> 24 Hour:Min:Sec (16:30:27)
# %X --> Hour:Min:Sec (12:30:27)
# %R --> 24 Hour:Min (16:30)
# %H --> 24 Hour (16)
# %l --> Hour (12)
# %M --> Mins (30)
# %S --> Seconds (09)
# %p --> AM/PM (AM)
# For a more complete list view: https://linux.die.net/man/3/strftime
#colour0 (black)
#colour1 (red)
#colour2 (green)
#colour3 (yellow)
#colour4 (blue)
#colour7 (white)
#colour5 colour6 colour7 colour8 colour9 colour10 colour11 colour12 colour13 colour14 colour15 colour16 colour17
#D ()
#F ()
#H (hostname)
#I (window index)
#P ()
#S (session index)
#T (pane title)
#W (currnet task like vim if editing a file in vim or zsh if running zsh)

2
tmux/scripts/uptime.sh

@ -0,0 +1,2 @@
#!/bin/bash
uptime | rev | cut -d":" -f1 | rev | sed s/,//g
Loading…
Cancel
Save