qcopy


Logs | Files | LICENSE | GitLab


1
commit 4eb9248427514bd6b780a9d988fbc3e353bff95b
2
Author: Connor Etherington <[email protected]>
3
Date:   Sat May 28 19:50:49 2022 +0200
4
5
    Auto-Commit Update - 20220528
6
---
7
 PKGBUILD      |  4 ++--
8
 usr/bin/qcopy | 38 ++++++++++++++++++++++++++------------
9
 2 files changed, 28 insertions(+), 14 deletions(-)
10
11
diff --git a/PKGBUILD b/PKGBUILD
12
index bff4208..cf39e3f 100644
13
--- a/PKGBUILD
14
+++ b/PKGBUILD
15
@@ -1,13 +1,13 @@
16
 # Maintainer: Connor Etherington <[email protected]>
17
 # ---
18
 pkgname=qcopy
19
-pkgver=1.3
20
+pkgver=1.4
21
 pkgrel=1
22
 pkgdesc="Easily set variables and their respective values for easy access at any point"
23
 arch=(any)
24
 url="https://gitlab.com/a4to/${pkgname}"
25
 license=('MIT')
26
-depends=(fzf dialog xclip bat)
27
+depends=(fzf dialog xsel bat)
28
 install="qcopy.install"
29
 source=(
30
   "https://concise.cc/pkg/${pkgname}-${pkgver}-${pkgrel}-$arch.pkg.tar.zst"
31
diff --git a/usr/bin/qcopy b/usr/bin/qcopy
32
index c658cbe..9f853d6 100755
33
--- a/usr/bin/qcopy
34
+++ b/usr/bin/qcopy
35
@@ -8,12 +8,22 @@
36
 
37
 # Global Variables:
38
 
39
+TMP=`mktemp -qu`
40
+
41
 NEWENTRY="\\n You have not yet set any qcopy variables. Would you like to create one now?\\n "
42
 
43
 ENTRIESFILE="${XDG_DATA_HOME:-$HOME/.local/share}/qcopy/entries"
44
 
45
-TMP=`mktemp -qu`
46
+FZFPREVIEW="cat $ENTRIESFILE|grep {} | grep 'YESPREVIEW' >/dev/null 2>&1 && 
47
+  cat $ENTRIESFILE | grep ^{}= | cut -d\= -f3- | bat --style=numbers,grid --color=always || 
48
+  echo -e '\n\e[1;31m
49
+    ▗▄▄ ▗▄▄ ▗▄▄ ▗  ▖ ▗▖ ▄▄▄▖▗▄▄▖
50
+    ▐ ▝▌▐ ▝▌ ▐  ▝▖▗▘ ▐▌  ▐  ▐
51
+    ▐▄▟▘▐▄▄▘ ▐   ▌▐  ▌▐  ▐  ▐▄▄▖
52
+    ▐   ▐ ▝▖ ▐   ▚▞  ▙▟  ▐  ▐
53
+    ▐   ▐  ▘▗▟▄  ▐▌ ▐  ▌ ▐  ▐▄▄▖
54
 
55
+\e[0m '"
56
 
57
 
58
 # Functions:
59
@@ -24,8 +34,7 @@ FIRSTLOOP(){ [ -f $ENTRIESFILE ] && [ $(cat $ENTRIESFILE | wc -w) -ge 1 ] || FIR
60
 
61
 FIRST(){ dialog --title " ~ First Run ~ " --yesno "$NEWENTRY" 8 82 && NEW && return 0 || clear && exit 1 ; }
62
 
63
-
64
-
65
+  
66
 function NEW {
67
 
68
   ! [ -d  "${XDG_DATA_HOME:-$HOME/.local/share}/qcopy" ] && 
69
@@ -34,15 +43,21 @@ function NEW {
70
   dialog \
71
     --stdout --title " ~ NEW ENTRY ~ " \
72
     --form "\n                  Please fill in the required information :\n " 13 81 3 \
73
-    " Entry Name  :" 1 1 "" 1 16 59 0 \
74
-    " Entry Value :" 2 1 "" 2 16 59 0 >${TMP}
75
+    " Entry Name   :" 1 1 "" 1 16 59 0 \
76
+    " Entry Value  :" 2 1 "" 2 16 59 0  >${TMP}
77
 
78
   ENTRYNAME=$(head -n1 ${TMP} | tail -n1)
79
   ENTRYVALUE=$(head -n2 ${TMP} | tail -n1)
80
+
81
+  dialog \
82
+    --yes-label "Preview" \
83
+    --no-label "No Preview" \
84
+    --title " ~ QCopy ~ " \
85
+    --yesno "\\n         Would you like to preview this entries value upon future selection?\\n " 7 90
86
   
87
-  [[ -n $ENTRYNAME ]] && [[ -n $ENTRYVALUE ]] &&
88
-    echo "${ENTRYNAME}=${ENTRYVALUE}" >> $ENTRIESFILE || 
89
-    MAIN && exit 0
90
+  PREVIEW=${?} && [ ${PREVIEW} -eq "0" ] && PREVIEW="YESPREVIEW" || PREVIEW="NOPREVIEW"
91
+  
92
+  [[ -n $ENTRYNAME ]] && [[ -n $ENTRYVALUE ]] && echo "${ENTRYNAME}=${PREVIEW}=${ENTRYVALUE}" >> $ENTRIESFILE && MAIN && exit 0 || exit 1
93
 
94
 }  
95
 
96
@@ -55,7 +70,7 @@ function DEL {
97
     --prompt="Select for Deletion :" \
98
     --header " " \
99
     --height 99% \
100
-    --preview="cat $ENTRIESFILE|grep {}|cut -d=  -f2-|bat --style=numbers,grid --color=always" \
101
+    --preview "${FZFPREVIEW}" \
102
     --preview-window=70% ) || exit 1
103
 
104
    sed -i "/${VALUE[@]}/d" $ENTRIESFILE
105
@@ -71,10 +86,10 @@ function MAIN {
106
     --prompt="Select for Copying :" \
107
     --header " " \
108
     --height 99% \
109
-    --preview="cat $ENTRIESFILE|grep {}|cut -d=  -f2-|bat --style=numbers,grid --color=always" \
110
+    --preview "${FZFPREVIEW}" \
111
     --preview-window=70% ) || exit 1
112
 
113
-   cat $ENTRIESFILE| grep "${VALUE}"| awk -F= '{print $2}'| sed 's/\s*//g'| xclip -selection clipboard -i
114
+   cat $ENTRIESFILE| grep "${VALUE}"| awk -F\= '{print $3}'| sed 's/\s*//g' | xsel -ib
115
 
116
 }
117
 
118
@@ -91,4 +106,3 @@ FIRSTLOOP && case ${1} in
119
 
120
 esac
121
   
122
-