linux shell git+golang的几个简洁函数备忘一下

function gm() 
{
  git status | grep -w "modified:" | awk '{print $3}' | while read line;do git add $line;done
}
export -f gm
function findg()
{
  if [ $# -ne 1 -a $# -ne 2 ];then
    echo "findg only accept 1 or 2 param" && return 1
  fi
  local pos=.
  local name=$1
  if [ $# -eq 2 ];then
    pos=$1
    name=$2
  fi
  find $pos -name "*.go" -type f | xargs grep -i -n "$name"
}
export -f findg
function vimg()
{
  local line
  f=`echo "$1" | cut -d ':' -f 1`
  line=`echo "$1" | cut -d ':' -f 2`
  if [ "$line" = "" ];then
    line=1
  fi
  vim $f +$line
}
export -f vimg

猜你喜欢

转载自blog.csdn.net/wangxugangzy05/article/details/82663685