From 3846e51f53b03f84b23ba2f186bfe542eac57e57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=9F=E9=85=8C=20=E9=B5=AC=E5=85=84?= Date: Fri, 14 Dec 2018 05:52:33 +0800 Subject: [PATCH] Added pv support for mysqls --- bash/bashrc/sources/30_mysql | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/bash/bashrc/sources/30_mysql b/bash/bashrc/sources/30_mysql index cd29eef..01d4682 100755 --- a/bash/bashrc/sources/30_mysql +++ b/bash/bashrc/sources/30_mysql @@ -30,10 +30,19 @@ function mysqls () { echo else GZIP=false - if [ "$1" == "z" ]; then + PV=false + _ANY=false + if [[ "$1" == *z* ]]; then GZIP=true - shift - fi + _ANY=true + fi + if [[ "$1" == *p* ]]; then + PV=true + _ANY=true + fi + if $_ANY; then + shift + fi USER=$(grep -i $1 ~/.mysql_pass | awk 'BEGIN{FS=":"}{ print $5 }') PASS=$(grepmysql $1 true) @@ -44,10 +53,17 @@ function mysqls () { fi if $GZIP; then - gunzip -c $3 | mysql -u $USER --password=$PASS -D $2 + if $PV; then + pv $3 | gunzip | mysql -u $USER --password=$PASS -D $2 + else + gunzip -c $3 | mysql -u $USER --password=$PASS -D $2 + fi else - mysql -u $USER --password=$PASS -D $2 < $3 + if $PV; then + pv $3 | mysql -u $USER --password=$PASS -D $2 + else + mysql -u $USER --password=$PASS -D $2 < $3 + fi fi - fi }