Skip to content

Commit 812edb1

Browse files
committed
fixed spaces in file names by replacing with _ EXCEPT IMPORT
1 parent 9ce97de commit 812edb1

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

notes

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
# VARIABLES
1010
VERSION=1.0
1111
#NOTES_UMASK='077'
12-
NOTESDIR="${NOTESDIR:-${HOME}/.notes}"
12+
# Handle $XDG_DATA_DIR -or- NOTESDIR being set in environment
13+
if [ -z "$XDG_DATA_DIR" ] ; then
14+
NOTESDIR="${NOTESDIR:-${HOME}/.notes}"
15+
else
16+
NOTESDIR="${XDG_DATA_DIR}/.notes"
17+
fi
1318
CONFIGFILE="${NOTESDIR}/config"
1419
INITIAL_NOTEBOOK="${NOTESDIR}/notes"
1520
DEFAULT_POINTER="${NOTESDIR}/DEFAULT"
@@ -32,7 +37,7 @@ cmd_init (){ # setup directories and GPG key to be used
3237

3338
if [ ! -d "$NOTESDIR" ]; then
3439
echo Creating notes directory: $NOTESDIR
35-
mkdir $NOTESDIR
40+
mkdir -p $NOTESDIR
3641
fi
3742

3843
create_config
@@ -72,12 +77,14 @@ create_config () {
7277
KEY="`gpg -K --with-colons | grep fpr | head -1 | tr -d 'fpr:::::::::' `"
7378
echo "KEY $KEY" > $CONFIGFILE
7479

80+
echo "NOTESDIR $NOTESDIR" >> $CONFIGFILE
81+
7582
echo Default config written:
7683
cat $CONFIGFILE
7784
}
7885

7986
get_recipient () {
80-
KEY=`grep KEY $CONFIGFILE| sed s/^KEY// | tr -d [:blank:]`
87+
KEY=`grep KEY ${CONFIGFILE}| sed s/^KEY// | tr -d [:blank:]`
8188
}
8289

8390
get_gpg_keyid () {
@@ -155,23 +162,20 @@ note_add () {
155162

156163
note_import () {
157164
toimport="$@"
158-
pathname="`dirname ${toimport}`"
165+
pathname="`dirname ${toimport}`"
159166
notefile="`basename ${toimport}`"
160-
notefile="`echo ${notefile} | tr ' ' '_'`"
161-
162-
echo $toimport
163-
echo $pathname
164-
echo $notefile
167+
target="`echo ${notefile} | tr ' ' '_'`"
165168

166169
get_recipient
167-
170+
168171
if [ -f "${toimport}" ] ; then
169-
$GPG -e -r $KEY $GPG_OPTS -o "${USE_POINTER}/${notefile}.gpg" "${pathname}/${notefile}"
172+
$GPG -e -r $KEY $GPG_OPTS -o "${USE_POINTER}/${target}.gpg" "${toimport}"
170173
fi
171174
}
172175

173176
note_view () {
174-
notefile="$USE_POINTER/$@"
177+
notefile="`echo $@ | tr ' ' '_'`"
178+
notefile="${USE_POINTER}/${notefile}"
175179

176180
get_recipient
177181

@@ -185,8 +189,8 @@ note_view () {
185189
}
186190

187191
note_edit () {
188-
myoptions="`echo ${theoptions} | tr ' ' '_'`"
189-
notefile="$USE_POINTER/$@"
192+
notefile="`echo $@ | tr ' ' '_'`"
193+
notefile="${USE_POINTER}/${notefile}"
190194
decrypted="`echo ${notefile} | sed s/.gpg//`"
191195

192196
get_recipient
@@ -214,7 +218,8 @@ note_list () {
214218
}
215219

216220
note_delete () {
217-
notefile="$USE_POINTER/$@"
221+
notefile="`echo $@ | tr ' ' '_'`"
222+
notefile="${USE_POINTER}/${notefile}"
218223

219224
if [ -f "$notefile" ]; then
220225
rm -i "$notefile"
@@ -228,9 +233,11 @@ note_delete () {
228233
note_rename () {
229234
MVCP="$1"
230235
shift
231-
notefile="$USE_POINTER/$@"
236+
237+
notefile="`echo $@ | tr ' ' '_'`"
238+
notefile="${USE_POINTER}/${notefile}"
232239
read -p "Please enter new name for note: " newname
233-
newname="`echo ${newname} | tr ' ' '_'`"
240+
newname="`echo ${newname} | tr ' ' '_'`"
234241

235242
case $notefile in
236243
*gpg) skip;;

0 commit comments

Comments
 (0)