-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhide.bash
More file actions
executable file
·42 lines (32 loc) · 871 Bytes
/
Copy pathhide.bash
File metadata and controls
executable file
·42 lines (32 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env bash
# Move note from tag directory
# to hidden directory with saved
# origine position for restore
# Arguments:
# $1 - absolute path to note
# or restore flag(--restore | -r)
projectdir=$(dirname $0)
hidden_directory="$projectdir/hidden"
function restore {
echo "Write tag and note name(file name)"
read tag_name note_name
local file="$hidden_directory/$tag_name/$note_name"
if [[ ! -f $file ]]; then
echo "This note not exist or not hidden"
exit
fi
mv -i $file "$projectdir/content/$tag_name/$note_name"
exit
}
if [[ $1 = '-r' || $1 = '--restore' ]]; then
restore
fi
if [[ ! -f $1 ]]; then
echo "This note is not exist, check the path to file"
exit
fi
tag=$(basename $(dirname $1))
note=$(basename $1)
mkdir -p $hidden_directory/$tag
cat $1 >$hidden_directory/$tag/$note
rm $1