]> git.rmz.io Git - dotfiles.git/blob - bin/vp
lazyvim: port dedup utility
[dotfiles.git] / bin / vp
1 #!/bin/bash
2
3 # Open PKGBUILD if it exists and exit
4 [[ -e PKGBUILD ]] && ${EDITOR:-vim} PKGBUILD && exit
5
6 ################################################################################
7
8 # path to the PKGBUILD.proto
9 PROTO=/usr/share/pacman/PKGBUILD.proto
10 PROTOINST=/usr/share/pacman/proto.install
11 MAINTAINER="Samir Benmendil <samir.benmendil@gmail.com>"
12
13 ################################################################################
14
15 echo "No PKGBUILD was found."
16 while true; do
17 read -p "Do you wish to create one? [Y/n] " yn
18 case $yn in
19 [Yy]* ) break;;
20 '' ) break;;
21 [Nn]* ) exit;;
22 * ) ;;
23 esac
24 done
25 # get the package name
26 # I will consider that the folder you're in is also the pkgname
27 # if its not you can change it later
28 PKGNAME=`basename $(pwd)`
29
30 cp $PROTO PKGBUILD
31 cp $PROTOINST $PKGNAME.install
32
33 sed -i "1,5d" PKGBUILD
34 sed -i "s/# Maintainer: .*/# Maintainer: ${MAINTAINER}\n/" PKGBUILD
35 sed -i "s/pkgname=.*/pkgname=${PKGNAME}/" PKGBUILD
36 $EDITOR PKGBUILD