[misc] refactory stage 1

This commit is contained in:
Klesh Wong 2020-09-17 10:24:35 +00:00
parent a470e9812b
commit ca52056e5b
33 changed files with 301 additions and 212 deletions

24
.gitignore vendored
View File

@ -1,13 +1,13 @@
config/mpv/watch_later/
config/fish/fishd.*
config/fish/conf.d/
config/fish/fish_variables
config/fish/conf.d/virtualfish-loader.fish
config/ranger/bookmarks
config/ranger/history
config/ranger/tagged
config/ranger/plugins
config/Thunar/accels.scm
config/nvim/autoload
config/nvim/plugged
config/nvim/.*
fish/config/fishd.*
fish/config/conf.d/
fish/config/fish_variables
fish/config/conf.d/virtualfish-loader.fish
ranger/config/bookmarks
ranger/config/history
ranger/config/tagged
ranger/config/plugins
Thunar/config/accels.scm
nvim/config/autoload
nvim/config/plugged
nvim/config/.*

View File

@ -1,105 +0,0 @@
! interface
URxvt.scrollBar: false
URxvt*scrollTtyOutput: false
URxvt*scrollTtyKeypress: true
URxvt*scrollWithBuffer: true
! fonts
URxvt.font: \
xft:Source Code Pro:size=12, \
xft:Symbols Nerd Font:style=Light:pixelsize=12:antialias=true:hinting=true, \
xft:WenQuanYi Micro Hei Mono Light:size=12:antialias=true,hinting=1
!xft:Symbola:size=12:antialias=true:hinting=light, \
!xft:Noto Color Emoji:size=12:antialias=true:hinting=light, \
!xft:Hermit:size=12:antialias=true:hinting=light, \
!xft:WenQuanYi Micro Hei Mono Light:size=12:antialias=true, \
!xft:FuraCode Nerd Font Mono:pixelsize=12, \
!xft:Wuncon Siji:pixelsize=12
!URxvt.letterSpace: 1
URxvt.internalBorder: 10
! plugins
URxvt.perl-ext-common: default,matcher,resize-font
! middle click to open url
URxvt.url-launcher: /usr/bin/xdg-open
URxvt.matcher.button: 2
! C-S-c/C-S-v for copy/paste
URxvt.keysym.Shift-Control-V: eval:paste_clipboard
URxvt.keysym.Shift-Control-C: eval:selection_to_clipboard
! avoid Ctrl+Shift to activate ISO 14755 mode
URxvt.iso14755: false
URxvt.iso14755_52: false
!
! color theme
!
#define S_base03 #002b36
#define S_base02 #073642
#define S_base01 #586e75
#define S_base00 #657b83
#define S_base0 #839496
#define S_base1 #93a1a1
#define S_base2 #eee8d5
#define S_base3 #fdf6e3
*background: S_base03
*foreground: S_base0
*fadeColor: S_base03
*cursorColor: S_base1
*pointerColorBackground:S_base01
*pointerColorForeground:S_base1
#define S_yellow #b58900
#define S_orange #cb4b16
#define S_red #dc322f
#define S_magenta #d33682
#define S_violet #6c71c4
#define S_blue #268bd2
#define S_cyan #2aa198
#define S_green #859900
!! background transparency
!URxvt.background: [70]#000000
!URxvt.depth: 32
URxvt*inheritPixmap: true
URxvt*transparent: true
URxvt.shading: 20
!URxvt*blurRadius: 16x16
!! black dark/light
*color0: S_base02
*color8: S_base03
!! red dark/light
*color1: S_red
*color9: S_orange
!! green dark/light
*color2: S_green
*color10: S_base01
!! yellow dark/light
*color3: S_yellow
*color11: S_base00
!! blue dark/light
*color4: S_blue
*color12: S_base0
!! magenta dark/light
*color5: S_magenta
*color13: S_violet
!! cyan dark/light
*color6: S_cyan
*color14: S_base1
!! white dark/light
*color7: S_base2
*color15: S_base3

View File

@ -1,15 +0,0 @@
function _nvm_uninstall -e nvm_uninstall
if test -s "$nvm_config/version"
read -l ver <$nvm_config/version
if set -l i (contains -i -- "$nvm_config/$ver/bin" $fish_user_paths)
set -e fish_user_paths[$i]
end
command rm -f $nvm_config/version
end
for name in (set -n | command awk '/^nvm_/')
set -e "$name"
end
functions -e (functions -a | command awk '/^_nvm_/')
end

35
env.sh Executable file
View File

@ -0,0 +1,35 @@
#!/bin/bash
set -e
ROOT=$(readlink -f $(dirname "${BASH_SOURCE[0]}"))
PM=n/a
if which pacman > /dev/null; then
PM=pacman
elif which apt > /dev/null; then
PM=apt
fi
if [ "$PM" = "n/a" ]; then
echo "Unsupported Package Manager"
exit -1
fi
in-china () {
if [ -z "$IS_CHINA" ]; then
IS_CHINA=no
if curl -q myip.ipip.net | grep '中国' > /dev/null; then
IS_CHINA=yes
fi
fi
[ "$IS_CHINA" = "no" ] && return -1
return 0
}
ln-dir () {
[ "$#" -ne 2 ] && echo "ln-dir <dir> <symlink>"
[ ! -L "$2" ] && rm -rf $2
SYM_DIR=$(dirname $2)
[ -n "$SYM_DIR" ] && mkdir -p $SYM_DIR
ln -sf $1 $2
}

1
fish/config/config Symbolic link
View File

@ -0,0 +1 @@
/home/klesh/dotfiles/fish/config

26
fish/install.sh Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash
DIR=$(readlink -f $(dirname $0))
. $DIR/../env.sh
# install fish shell
case "$PM" in
apt)
sudo add-apt-repository ppa:fish-shell/release-3 -y
sudo apt update
sudo apt install fish libnotify-bin xdotool -y
;;
pacman)
sudo pacman -S fish xdotool
;;
esac
# set fish as default shell
DEFAULT_SHELL=$(getent passwd $USER | cut -d: -f7)
FISH_SHELL=$(which fish)
if [ "$DEFAULT_SHELL" != "$FISH_SHELL" ]; then
chsh -s $FISH_SHELL
fi
# symlink config
ln-dir $DIR/config ~/.config/fish

55
fonts/install.sh Executable file
View File

@ -0,0 +1,55 @@
#!/bin/bash
DIR=$(readlink -f $(dirname $0))
. $DIR/../env.sh
echo Installing fonts
# install fonts
case "$PM" in
apt)
sudo apt install \
fonts-wqy-microhei \
fonts-droid-fallback \
fonts-cascadia-code \
ttf-dejavu \
gucharmap
;;
pacman)
sudo pacman -S \
terminus-font \
ttf-droid \
freetype2 \
ttf-cascadia-code \
ttf-dejavu \
wqy-microhei-lite \
gucharmap
echo TO DO
exit -1
;;
esac
# install hermit nerd font
if ! ls /usr/share/fonts | grep -i hurmit > /dev/null; then
if [ ! -f /tmp/hermit.zip ]; then
if in-china; then
git clone https://gitee.com/klesh/nerd-fonts.git /tmp/nerd-fonts
mv /tmp/nerd-fonts/Hermit-v2.1.0.zip /tmp/hermit.zip
rm -rf /tmp/nerd-fonts
else
echo 'for rest of the world'
HNF_PATH=$(curl -L https://github.com/ryanoasis/nerd-fonts/releases/latest | grep -i hermit | sed -n 's/.*href="\([^"]*\).*/\1/p')
HNF_URL="https://github.com$HNF_PATH"
curl -L $HNF_URL --output /tmp/hermit.zip || rm -rf /tmp/hermit.zip && false
fi
fi
unzip /tmp/hermit.zip -d /tmp/hermit
rm /tmp/hermit/*Windows*
sudo cp /tmp/hermit/* /usr/share/fonts
fi
# configuration
sudo ln -sf /etc/fonts/conf.avail/70-no-bitmaps.conf /etc/fonts/conf.d
sudo ln -sf /etc/fonts/conf.avail/10-sub-pixel-rgb.conf /etc/fonts/conf.d
sudo ln -sf /etc/fonts/conf.avail/11-lcdfilter-default.conf /etc/fonts/conf.d
sudo cp $DIR/freetype2.sh /etc/profile.d/freetype2.sh
sudo cp $DIR/local.conf /etc/fonts/local.conf

12
gui-apps/install.sh Normal file
View File

@ -0,0 +1,12 @@
#!/bin/bash
DIR=$(readlink -f $(dirname $0))
. $DIR/../env.sh
# install gui apps like chromium, vscode, etc...
if [ "$PM" = "pacman" ]; then
echo TODO
exit -1
elif [ "$PM" = "apt" ]; then
sudo apt install chromium-browser
fi

34
nodejs/install.sh Executable file
View File

@ -0,0 +1,34 @@
#!/bin/bash
DIR=$(readlink -f $(dirname $0))
. $DIR/../env.sh
# install nodejs and yarn
case "$PM" in
apt)
sudo apt install nodejs yarnpkg
;;
pacman)
sudo pacman -S nodejs yarn
;;
esac
# config mirrors for CHINA
if in-china; then
yarnpkg config set registry https://registry.npm.taobao.org --global && \
yarnpkg config set disturl https://npm.taobao.org/dist --global && \
yarnpkg config set sass_binary_site https://npm.taobao.org/mirrors/node-sass --global && \
yarnpkg config set electron_mirror https://npm.taobao.org/mirrors/electron/ --global && \
yarnpkg config set puppeteer_download_host https://npm.taobao.org/mirrors --global && \
yarnpkg config set chromedriver_cdnurl https://npm.taobao.org/mirrors/chromedriver --global && \
yarnpkg config set operadriver_cdnurl https://npm.taobao.org/mirrors/operadriver --global && \
yarnpkg config set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs --global && \
yarnpkg config set selenium_cdnurl https://npm.taobao.org/mirrors/selenium --global && \
yarnpkg config set sqlite3_binary_host_mirror "https://foxgis.oss-cn-shanghai.aliyuncs.com/" --global && \
yarnpkg config set profiler_binary_host_mirror "https://npm.taobao.org/mirrors/node-inspector/" --global && \
yarnpkg config set chromedriver_cdnurl "https://cdn.npm.taobao.org/dist/chromedriver" --global && \
yarnpkg config set node_inspector_cdnurl https://npm.taobao.org/mirrors/node-inspector --global && \
yarnpkg config set sentrycli_cdnurl 'https://npm.taobao.org/mirrors/sentry-cli'
fi

View File

@ -89,11 +89,12 @@ call plug#begin()
Plug 'editorconfig/editorconfig-vim'
Plug 'tpope/vim-surround'
Plug 'jiangmiao/auto-pairs'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'neoclide/coc-json', {'do': 'yarnpkg install --frozen-lockfile'}
Plug 'iamcco/coc-vimlsp', {'do': 'yarnpkg install --frozen-lockfile'}
Plug 'neoclide/coc-python', {'do': 'yarnpkg install --frozen-lockfile'}
Plug 'weirongxu/coc-explorer', {'do': 'yarnpkg install --frozen-lockfile'}
Plug 'preservim/nerdtree'
"Plug 'neoclide/coc.nvim', {'branch': 'release'}
"Plug 'neoclide/coc-json', {'do': 'yarnpkg install --frozen-lockfile'}
"Plug 'iamcco/coc-vimlsp', {'do': 'yarnpkg install --frozen-lockfile'}
"Plug 'neoclide/coc-python', {'do': 'yarnpkg install --frozen-lockfile'}
"Plug 'weirongxu/coc-explorer', {'do': 'yarnpkg install --frozen-lockfile'}
Plug 'liuchengxu/eleline.vim'
Plug 'tpope/vim-fugitive' " git 功能
Plug 'scrooloose/nerdcommenter'
@ -105,29 +106,36 @@ call plug#end()
" ==== coc configuration ====
let g:coc_disable_startup_warning = 1
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
"let g:coc_disable_startup_warning = 1
"nmap <silent> gd <Plug>(coc-definition)
"nmap <silent> gy <Plug>(coc-type-definition)
"nmap <silent> gi <Plug>(coc-implementation)
"nmap <silent> gr <Plug>(coc-references)
xmap <silent> <leader>fs <Plug>(coc-format-selected)
nmap <silent> <leader>fs <Plug>(coc-format-selected)
nmap <silent> <leader>fb <Plug>(coc-format)
nmap <silent> <leader>rn <Plug>(coc-rename)
nmap <silent> <leader>ne <Plug>(coc-diagnostic-next-error)
nmap <silent> <leader>pe <Plug>(coc-diagnostic-prev-error)
nmap <silent> <leader>fe :CocCommand explorer --toggle<CR>
nmap <silent> <leader>if :CocInfo<CR>
nmap <silent> <leader>cl :CocList<CR>
nmap <silent> <leader>sd :call CocAction('doHover')<CR>
nmap <silent> <leader>ss :syntax sync fromstart<CR>
nmap <silent> <leader>ol <Plug>(coc-openlink)
"xmap <silent> <leader>fs <Plug>(coc-format-selected)
"nmap <silent> <leader>fs <Plug>(coc-format-selected)
"nmap <silent> <leader>fb <Plug>(coc-format)
"nmap <silent> <leader>rn <Plug>(coc-rename)
"nmap <silent> <leader>ne <Plug>(coc-diagnostic-next-error)
"nmap <silent> <leader>pe <Plug>(coc-diagnostic-prev-error)
"nmap <silent> <leader>fe :CocCommand explorer --toggle<CR>
"nmap <silent> <leader>if :CocInfo<CR>
"nmap <silent> <leader>cl :CocList<CR>
"nmap <silent> <leader>sd :call CocAction('doHover')<CR>
"nmap <silent> <leader>ss :syntax sync fromstart<CR>
"nmap <silent> <leader>ol <Plug>(coc-openlink)
" ==== grepper configuration ====
nmap <silent> <leader>ap :call AutoPairsToggle()<CR>
nnoremap <leader>sg :Grepper -tool git<CR>
nnoremap <leader>sc :Grepper -tool grep<CR>
" ==== NERDTree configuration ====
nnoremap <leader>fe :NERDTreeToggle<CR>
" ==== fugitive configuration ====
nnoremap <leader>gs :Gstatus<CR>
nnoremap <leader>gc :Gcommit<CR>

22
nvim/install.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
DIR=$(readlink -f $(dirname $0))
. $DIR/../env.sh
# check dependencies
! which yarnpkg && $ROOT/nodejs/install.sh
# install nvim
case "$PM" in
apt)
sudo add-apt-repository ppa:neovim-ppa/stable -y
sudo apt update
sudo apt install -y neovim
;;
pacman)
sudo pacman -S neovim
;;
esac
# symlink configuration
ln-dir $DIR/config ~/.config/nvim

View File

@ -1,5 +0,0 @@
[global]
#trusted-host = mirrors.aliyun.com
#index-url = https://mirrors.aliyun.com/pypi/simple
index-url = https://pypi.doubanio.com/simple
trusted-host = pypi.doubanio.com

20
python/install.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
DIR=$(readlink -f $(dirname $0))
. $DIR/../env.sh
# install python3
case "$PM" in
apt)
sudo apt install python3 python3-pip
;;
pacman)
sudo pacman -S python
;;
esac
# config pip mirror for CHINA
if in-china; then
mkdir -p ~/.pip
ln -sf $DIR/pip.conf ~/.pip/pip.conf
fi

5
python/pip.conf Normal file
View File

@ -0,0 +1,5 @@
[global]
trusted-host = mirrors.aliyun.com
index-url = https://mirrors.aliyun.com/pypi/simple
#index-url = https://pypi.doubanio.com/simple
#trusted-host = pypi.doubanio.com

15
ranger/install.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
DIR=$(readlink -f $(dirname $0))
. $DIR/../env.sh
# install ranger
case "$PM" in
apt)
! which pip3 && $ROOT/python/install.sh
sudo pip3 install ranger-fm
;;
pacman)
sudo pacman -S ranger
;;
esac

25
ubuntu/install-dwm.sh → suckless/install.sh Normal file → Executable file
View File

@ -1,10 +1,16 @@
#!/bin/bash
set -e
DIR=$(readlink -f $(dirname $0))
. $DIR/../env.sh
$ROOT/fonts/install.sh
# install dependencies
case "$PM" in
apt)
sudo apt install \
build-essential \
unzip \
xorg \
libx11-dev \
libxft-dev \
@ -16,22 +22,31 @@ sudo apt install \
ibus ibus-table ibus-table-wubi \
gnome-keyring \
trayer
sudo apt remove gdm3
;;
pacman)
echo TO DO
exit -1
;;
esac
# clone / compile utilities and dwm itself
mkdir -p ~/Projects/suckless
git clone https://gitee.com/klesh/st.git ~/Projects/suckless/st
[! -d ~/Projects/suckless/st] && git clone https://gitee.com/klesh/st.git ~/Projects/suckless/st
cd ~/Projects/suckless/st && sudo rm -f config.h && sudo make clean install
git clone https://gitee.com/klesh/dmenu.git ~/Projects/suckless/dmenu
[! -d ~/Projects/suckless/dmenu] &&git clone https://gitee.com/klesh/dmenu.git ~/Projects/suckless/dmenu
cd ~/Projects/suckless/dmenu && sudo rm -f config.h && sudo make clean install
git clone https://gitee.com/klesh/slock.git ~/Projects/suckless/slock
[! -d ~/Projects/suckless/slock] &&git clone https://gitee.com/klesh/slock.git ~/Projects/suckless/slock
cd ~/Projects/suckless/slock && sudo rm -f config.h && sudo make clean install
git clone https://gitee.com/klesh/dwm.git ~/Projects/suckless/dwm
[! -d ~/Projects/suckless/dwm] &&git clone https://gitee.com/klesh/dwm.git ~/Projects/suckless/dwm
cd ~/Projects/suckless/dwm && sudo rm -f config.h && sudo make clean install
# config xinit to start for dwm

1
tmux/install.sh Normal file
View File

@ -0,0 +1 @@
#!/bin/bash

View File

@ -1,26 +0,0 @@
#!/bin/bash
set -e
[ ! -f /tmp/node.tar.xz ] && curl -L https://nodejs.org/dist/v12.18.2/node-v12.18.2-linux-x64.tar.xz -o /tmp/node.tar.xz
rm -rf /tmp/node
mkdir -p /tmp/node
tar xf /tmp/node.tar.xz --strip 1 -C /tmp/node
pushd /tmp/node
sudo cp -r bin include lib share /usr/local
popd
rm -rf /tmp/node*
sudo apt install yarnpkg
yarnpkg config set registry https://registry.npm.taobao.org --global && \
yarnpkg config set disturl https://npm.taobao.org/dist --global && \
yarnpkg config set sass_binary_site https://npm.taobao.org/mirrors/node-sass --global && \
yarnpkg config set electron_mirror https://npm.taobao.org/mirrors/electron/ --global && \
yarnpkg config set puppeteer_download_host https://npm.taobao.org/mirrors --global && \
yarnpkg config set chromedriver_cdnurl https://npm.taobao.org/mirrors/chromedriver --global && \
yarnpkg config set operadriver_cdnurl https://npm.taobao.org/mirrors/operadriver --global && \
yarnpkg config set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs --global && \
yarnpkg config set selenium_cdnurl https://npm.taobao.org/mirrors/selenium --global && \
yarnpkg config set sqlite3_binary_host_mirror "https://foxgis.oss-cn-shanghai.aliyuncs.com/" --global && \
yarnpkg config set profiler_binary_host_mirror "https://npm.taobao.org/mirrors/node-inspector/" --global && \
yarnpkg config set chromedriver_cdnurl "https://cdn.npm.taobao.org/dist/chromedriver" --global && \
yarnpkg config set node_inspector_cdnurl https://npm.taobao.org/mirrors/node-inspector --global

0
ubuntu/install-py3.sh Normal file → Executable file
View File

View File

@ -1,9 +0,0 @@
#!/bin/bash
set -e
sudo add-apt-repository ppa:jonathonf/vim -y
sudo add-apt-repository ppa:neovim-ppa/stable -y
sudo apt update
sudo apt install -y vim
sudo apt install -y neovim