• java
  • go
  • 数据库
  • linux
  • 中间件
  • 书
  • 源码
  • 夕拾

  • java
  • go
  • 数据库
  • linux
  • 中间件
  • 书
  • 源码
  • 夕拾

shell 工具

shell 脚本工具

  • shell 脚本工具
    • 打开资源管理器(expwd)
      • windows(gitbash)
    • 截屏
    • git-hook(post-update)

打开资源管理器(expwd)

windows(gitbash)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/bash
string=`pwd`
array=(${string//\// })
result=''
for var in ${array[@]}
do
if [ $var == ${array[0]} ]; then
result=$var':\';
else
result=$result$var'\'
fi

done
echo explorer "$result"
explorer "$result"

截屏

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#/bin/bash
# win10抓取锁屏的工具,目录改成自己的
dir=/c/Users/{user}/AppData/Local/Packages/Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy/LocalState/Assets
tmpImg=/d/tmp/img
rm -rf $tmpImg
mkdir -p $tmpImg
for file in `ls $dir`
do

if [ `ls -l $dir/$file | awk '{print $5}'` -gt 10000 ]; then
echo `ls -l $dir/$file | awk '{print $5}'`
cp $dir/$file $tmpImg/$file.png
fi
done

git-hook(post-update)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
echo $ref
if
[[ $ref =~ .*/master$ ]]
pro_name=novel-page
projectdir=/var/www/html
gitdir=/home/git
# bookdir=/var/www/html/$pro_name
then
echo "Master ref received. Deploying master branch to production..."
# git --work-tree=$bookdir/$pro --git-dir=/home/git/book/readme checkout -f
SOURCE="$2"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
echo "DIR:"${DIR}
BASE_DIR="$(dirname "$DIR")"
echo "BASE_DIR:${BASE_DIR}"
echo "pwd:`pwd`"
PWD=`pwd`
PRO_NAME=${PWD##*/}
echo "PRO_NAME:"${PRO_NAME}
HTML_DIR="/var/www/html"
cd ${HTML_DIR}
rm -rf novel
echo `git clone "${BASE_DIR}/${PRO_NAME}"`
cd ${PRO_NAME}
# ----------------------start
npm install
npm run build
mv dist/ ../novel
rm -rf '/var/www/html/'+${PRO_NAME}
#-----------------------end
#mv -r dist/* $projectdir/novel
#rsync -a _book/* ./
else
echo "Ref $ref successfully received."
fi
linux top 命令
Mysql 索引
  1. 1. shell 脚本工具
    1. 1.1. 打开资源管理器(expwd)
      1. 1.1.1. windows(gitbash)
    2. 1.2. 截屏
    3. 1.3. git-hook(post-update)
© 2023 haoxp
Hexo theme