Skip to content

Commit 46d67af

Browse files
committed
tweaks to handle where a note being renamed/copied doesn't have a .gpg ending
1 parent 36668ce commit 46d67af

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

notes

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,32 @@ note-rename() {
141141
notefile="$USE_POINTER/$@"
142142

143143
read -p "Please enter new name for note: " newname
144+
145+
case $notefile in
146+
*gpg) skip;;
147+
*) notefile="${notefile}.gpg"
148+
esac
149+
144150
newnotefile="${USE_POINTER}/${newname}"
151+
case $newnotefile in
152+
*gpg) skip;;
153+
*) newnotefile="${newnotefile}.gpg"
154+
esac
145155

146156
echo old notefile $notefile
147157
echo new notefile $newnotefile
148158

159+
160+
case $MVCP in
161+
"cp") processing="copying ";;
162+
"mv") processing="moving ";;
163+
esac
164+
149165
if [ -f "$notefile" ] ; then
150-
echo $notefile exists .... renaming
166+
echo $notefile exists .... $processing
151167
$MVCP "$notefile" "$newnotefile"
152168
elif [ -f "${notefile}.gpg" ] ; then
153-
echo $notefile exists .... renaming
169+
echo $notefile exists .... $processing
154170
$MVCP "$notefile" "$newnotefile"
155171
else
156172
echo Note $notefile does not exist, aborting...
@@ -218,8 +234,13 @@ notebook-rename() {
218234
echo old notebook $notebook
219235
echo new notebook $newnotebook
220236

237+
case $MVCP in
238+
"cp") processing="copying ";;
239+
"mv") processing="moving ";;
240+
esac
241+
221242
if [ -d "$notebook" ] ; then
222-
echo $notebook exists .... renaming
243+
echo $notebook exists .... $processing
223244
$MVCP "$notebook" "$newnotebook"
224245
else
225246
echo Note $notebook does not exist, aborting...
@@ -259,6 +280,7 @@ NOTES MANAGEMENT:
259280
notes insert|add add a note
260281
notes import import a text file as a note
261282
notes rename|mv rename a note
283+
notes copy|cp copy a note
262284
notes delete|rm delete a note
263285
notes edit|ed edit a note
264286
@@ -270,6 +292,7 @@ NOTEBOOK MANAGEMENT:
270292
notebook use use a notebook
271293
notebook add|insert add a notebook
272294
notebook rename|mv rename a notebook
295+
notebook copy|cp copy a notebook
273296
notebook delete|rm delete a notebook
274297
275298

0 commit comments

Comments
 (0)