Organize files

This commit is contained in:
dmarakom6 2021-07-05 11:50:01 +03:00
parent 2970369d42
commit c9827f2dcd
38 changed files with 532 additions and 345 deletions

View file

@ -5,7 +5,7 @@ Released under the "All rights reserved" category. See the RIGHTS.txt file
in /docs/github/ for its full text.
info
NOTES_EDITOR="$(eval cat ~/.shellnotes/util/sd/sd-input1.txt)"
QUICK_NOTES_EDITOR="$(eval cat ~/.shellnotes/util/sd/sd-input2.txt)"
DEFAULT_PATH="$(eval echo $(cat ~/.shellnotes/util/sd/sd-input3.txt))"
NOTES_EDITOR="$(eval cat ~/.shellnotes/util/shellnotes/sd/sd-input1.txt)"
QUICK_NOTES_EDITOR="$(eval cat ~/.shellnotes/util/shellnotes/sd/sd-input2.txt)"
DEFAULT_PATH="$(eval echo $(cat ~/.shellnotes/util/shellnotes/sd/sd-input3.txt))"

View file

@ -1,36 +1,19 @@
.\" Manpage for shellnotes-delnote.
.\" Manpage for delnote
.\" Contact dmarakom@gmail.com to correct errors or typos.
.TH delnote 1
.TH man 8 "30/12/2020" "" "delnote man page"
.SH NAME
shellnotes-delnote \- Delete a note in your notes folder.
.SH SYNOPSIS
.PP
.B delnote
.IR [FILE...]
.PP
.B delnote
.IR [FILE...]
[\fIOPTION\fR]
.PP
.B delnote
[\fIOPTION\fR]
delnote [FILENAME] [OPTION]
.SH DESCRIPTION
.B delnote
finds and removes the desired note (or all the notes) from your notes folder.
delnote() finds and removes the desired note or all the notes from your notes folder.
.SH OPTIONS
.TP
.BR \-all
Delete all notes.
.\".SH BUGS
[FILENAME] \- The name of the note to delete.
\fR \or\fR
[-all] \- Delete all notes.
\fR \or\fR
leave a blank parameter ("delnote") and shellnotes will ask you for the filename with an input.
.SH BUGS
If the default path for delnote() is not valid, the program is likely to return an error.
.SH AUTHOR
Dimitris Marakomihelakis (dmarakom@gmail.com)
Dimitris Marakomihelakis (dmarakom@gmail.com)

View file

@ -1,30 +1,16 @@
.\" Manpage for shellnotes-findmisplacednote.
.\" Manpage for findmisplacednote
.\" Contact dmarakom@gmail.com to correct errors or typos.
.TH findmisplacednote 1
.TH man 8 "30/12/2020" "" "findmisplacednote man page"
.SH NAME
shellnotes-findmisplacednote \- Find a note missing from your notes folder.
.SH SYNOPSIS
.PP
.B findmisplacednote
.IR [FILE...]
findmisplacednote [FILENAME]
.SH DESCRIPTION
.B findmisplacednote
uses find (do "man find") to check if a note exists in the user's system.
This command must be run only when findnote (do "man findnote") doesn't result in an existing note.
.\".SH OPTIONS
.\".SH BUGS
.\".TP
.\".BR \Withoutstringbug ", " \-wsBug ", " \72
.\"If there are no matches in the input, "notegrep -ws" will display the file as is.
findmisplacednote() uses find (do "man find") to check if a note exists in the user's system. This command must be run only when findnote (do "man findnote") doesn't result in an existing note.
.SH OPTIONS
[FILENAME] \- The name of the note.
leave a blank parameter ("findmisplacednote") and shellnotes will ask you for the filename with an input.
.SH BUGS
No known bugs.
.SH AUTHOR
Dimitris Marakomihelakis (dmarakom@gmail.com)
Dimitris Marakomihelakis (dmarakom@gmail.com)

View file

@ -1,30 +1,16 @@
.\" Manpage for shellnotes-findnote.
.\" Manpage for findnote
.\" Contact dmarakom@gmail.com to correct errors or typos.
.TH findnote 1
.TH man 8 "30/12/2020" "" "findnote man page"
.SH NAME
shellnotes-findnote \- Find a note in your notes folder.
.SH SYNOPSIS
.PP
.B findnote
.IR [FILE...]
findnote [FILENAME]
.SH DESCRIPTION
.B findnote
checks if a note exists in your notes folder using the "find" command. This is a handy command for users with numerous notes who would just like to know whether a note actually exists in their notes folder.
.\".SH OPTIONS
.\".SH BUGS
.\".TP
.\".BR \Withoutstringbug ", " \-wsBug ", " \72
.\"If there are no matches in the input, "notegrep -ws" will display the file as is.
findnote() checks if a note exists in your notes folder.
.SH OPTIONS
[FILENAME] \- The name of the note.
leave a blank parameter ("findnote") and shellnotes will ask you for the filename with an input.
.SH BUGS
No known bugs.
.SH AUTHOR
Dimitris Marakomihelakis (dmarakom@gmail.com)
Dimitris Marakomihelakis (dmarakom@gmail.com)

View file

@ -1,42 +1,18 @@
.\" Manpage for shellnotes-listnotes.
.\" Manpage for listnotes.
.\" Contact dmarakom@gmail.com to correct errors or typos.
.TH listnotes 1
.TH man 8 "30/12/2020" "" "listnotes man page"
.SH NAME
shellnotes-listnotes \- list your notes from wherever you are.
shellnotes-listnotes \- List your notes in your note folder from wherever you are.
.SH SYNOPSIS
.PP
.B listnotes
[\fIOPTION\fR]
listnotes
.SH DESCRIPTION
.B listnotes
uses ls (do "man ls") to list all your notes in different ways.
listnotes() uses ls (do "man ls") to list all your notes.
.SH OPTIONS
.TP
.BR \-d ", " \--dynamic
Dynamic view of all your notes and their content.
.TP
.BR \-n ", " \--number
Count the number of notes in your notes folder.
.TP
.BR \-f ", " \--folder
Show the current default notes folder.
-d or --dynamic \- Dynamic view of all your notes and their content.
-n or --number \- Number of notes in your notes folder.
-f or --folder \- The current Notes folder.
leave a blank parameter ("listnotes") and shellnotes will show a regular list of your notes.
.SH BUGS
.\".TP
.\".BR \-
.\".PP
If the default path for listnotes() is not valid, the program is likely to crash.
.SH AUTHOR
Dimitris Marakomihelakis (dmarakom@gmail.com)
Dimitris Marakomihelakis (dmarakom@gmail.com)

View file

@ -1,29 +1,16 @@
.\" Manpage for shellnotes-newnote.
.\" Manpage for newnote
.\" Contact dmarakom@gmail.com to correct errors or typos.
.TH newnote 1
.TH man 8 "30/12/2020" "" "newnote man page"
.SH NAME
shellnotes-newnote \- write a new note using your text editor.
shellnotes-newnote \- Write a new note using your text editor.
.SH SYNOPSIS
.PP
.B newnote
.IR [FILE...]
newnote [FILENAME]
.SH DESCRIPTION
.B newnote
uses your default text-editor to write a new note and saves it into your notes folder when finished.
.\" .SH OPTIONS
newnote() uses your default text-editor to write a new note and saves it into your notes folder when finished.
.SH OPTIONS
[FILENAME] \- The name of the new note.
leave a blank parameter ("newnote") and shellnotes will ask you for the filename with an input.
.SH BUGS
.TP
.BR \-noSaveBug ", " \-nsBug ", " \110
If the text editor is closed without saving the new file, newnote diplays "Note saved...", but the file is not really saved.
If the default editor for newnote() is not valid, the program is likely to crash.
.SH AUTHOR
Dimitris Marakomihelakis (dmarakom@gmail.com)
Dimitris Marakomihelakis (dmarakom@gmail.com)

View file

@ -1,27 +1,16 @@
.\" Manpage for shellnotes-notewc.
.\" Manpage for notewc
.\" Contact dmarakom@gmail.com to correct errors or typos.
.TH notewc 1
.TH man 8 "30/12/2020" "" "notewc man page"
.SH NAME
shellnotes-notewc \- get info about a note.
shellnotes-notewc \- Get info about a note in your notes folder.
.SH SYNOPSIS
.PP
.B notewc
.IR [FILE...]
notewc [FILENAME]
.SH DESCRIPTION
.B notewc
uses wc (do "man wc") to show lines, words, chars and name of a note.
.\".SH OPTIONS
.\".SH BUGS
notewc() uses wc (do "man wc") to show (lines/words/chars/name) of a note.
.SH OPTIONS
[FILENAME] \- The name of the note.
leave a blank parameter ("notewc") and shellnotes will ask you for the filename with an input.
.SH BUGS
If wc is not pre-installed the command won't work.
.SH AUTHOR
Dimitris Marakomihelakis (dmarakom@gmail.com)

View file

@ -1,27 +1,16 @@
.\" Manpage for shellnotes-quicknote.
.\" Manpage for quicknote.
.\" Contact dmarakom@gmail.com to correct errors or typos.
.TH quicknote 1
.TH man 8 "30/12/2020" "" "quicknote man page"
.SH NAME
shellnotes-quicknote \- write a new note directly via terminal.
shellnotes-quicknote \- Write a new note directly via terminal.
.SH SYNOPSIS
.PP
.B quicknote
.IR [FILE...]
quicknote [FILENAME]
.SH DESCRIPTION
.B quicknote
uses your in-terminal text-editor to write a new note and saves it into your notes folder when finished.
It works well with the nano editor.
.\".SH OPTIONS
.\".SH BUGS
quicknote() uses your in-terminal text-editor to write a new note and saves it into your notes folder when finished.
.SH OPTIONS
[FILENAME] \- The name of the new note.
leave a blank parameter ("quicknote") and shellnotes will ask you for the filename with an input.
.SH BUGS
If the default editor for quicknote() is not valid, the program is likely to crash.
.SH AUTHOR
Dimitris Marakomihelakis (dmarakom@gmail.com)
Dimitris Marakomihelakis (dmarakom@gmail.com)

View file

@ -1,34 +1,16 @@
.\" Manpage for quickread.
.\" Contact dmarakom@gmail.com to correct errors or typos.
.TH quickread 1
.TH man 8 "30/12/2020" "" "quickread man page"
.SH NAME
shellnotes-quickread \- Read new note directly in your terminal.
.SH SYNOPSIS
.PP
.B notegrep
[\fIOPTION\fR]
.IR [FILE...]
quickread [FILENAME]
.SH DESCRIPTION
.B quickread
uses cat (do "man cat") to view a note. It only runs inside your notes folder.
.\".SH OPTIONS
.TP
.BR \-sc ", " \--split-char =\fISTRING\fR
Split the note on a string or character and then display it.
.\".SH BUGS
.\".TP
.\".BR \Withoutstringbug ", " \-wsBug ", " \72
.\"If there are no matches in the input, "notegrep -ws" will display the file as is.
quickread() uses cat (do "man cat") to view a note.
.SH OPTIONS
[FILENAME] \- The name of the note.
leave a blank parameter ("quickread") and shellnotes will ask you for the filename with an input.
.SH BUGS
No known bugs.
.SH AUTHOR
Dimitris Marakomihelakis (dmarakom@gmail.com)
Dimitris Marakomihelakis (dmarakom@gmail.com)

View file

@ -1,31 +1,16 @@
.\" Manpage for shellnotes-readnote.
.\" Manpage for readnote.
.\" Contact dmarakom@gmail.com to correct errors or typos.
.TH readnote 1
.TH man 8 "30/12/2020" "" "readnote man page"
.SH NAME
shellnotes-readnote \- read a note using your favourite text editor.
shellnotes-readnote \- Read a note using your text editor.
.SH SYNOPSIS
.PP
.B readnote
.IR [FILE...]
readnote [FILENAME]
.SH DESCRIPTION
.B readnote
uses your default text-editor to read a note.
.\".SH OPTIONS
readnote() uses your default text-editor to read a note.
.SH OPTIONS
[FILENAME] \- The name of the note.
leave a blank parameter ("readnote") and shellnotes will ask you for the filename with an input.
.SH BUGS
.TP
.BR \-nonReadOnlyMode", " \-nrmBug ", " \114
.PP
readnote does not launch the text editor in read-only mode, giving the user permission to make changes.
If the default editor for readnote() is not valid, the program is likely to crash.
.SH AUTHOR
Dimitris Marakomihelakis (dmarakom@gmail.com)
Dimitris Marakomihelakis (dmarakom@gmail.com)

View file

@ -1,27 +1,17 @@
.\" Manpage for shellnotes-renamenote.
.\" Manpage for renamenote
.\" Contact dmarakom@gmail.com to correct errors or typos.
.TH renamenote 1
.TH man 8 "30/12/2020" "" "renamenote man page"
.SH NAME
shellnotes-renamenote \- rename a note in your notes folder.
shellnotes-renamenote \- Rename a note in your notes folder.
.SH SYNOPSIS
.PP
.B renamenote
.IR [FILE...]
.IR new_[FILE...]
renamenote [FILENAME] [NEW_FILENAME]
.SH DESCRIPTION
.B renamenote
uses mv (do "man mv") to rename a note in your default notes folder.
.\".SH OPTIONS
.\".SH BUGS
renamenote() uses mv (do "man mv") to rename a note in your default notes folder
.SH OPTIONS
[FILENAME] \- The name of the note.
[NEW_FILENAME] \- The new name of the note
leave a blank parameter ("renamenote") and shellnotes will ask you for the filename and the new filename with an input.
.SH BUGS
No known bugs.
.SH AUTHOR
Dimitris Marakomihelakis (dmarakom@gmail.com)
Dimitris Marakomihelakis (dmarakom@gmail.com)

View file

@ -1,61 +1,22 @@
.\" Manpage for shellnotes.
.\" Contact dmarakom@gmail.com to correct errors or typos.
.TH shellnotes 1
.TH man 8 "30/12/2020" "" "shellnotes man page"
.SH NAME
shellnotes \- an easy, simple and fast way to keep notes directly via terminal.
shellnotes \- An easy, simple and fast way to keep notes directly via terminal.
.SH SYNOPSIS
.PP
.B shellnotes
[\fROPTION\fR]
shellnotes [OPTION]
.SH DESCRIPTION
.B shellnotes
is a note system for advanced linux and terminal users. With this tool, you can wither write, read, rename or delete your notes safely and rapidly.
Shellnotes also has numerous other features and subtools, that can help every user on a daily basis.
Shellnotes is a note system for advanced linux and terminal users. It is made out of a lot of other commands and scripts, so if you want to get information and help for every single one of them, you should visit the Help Page (~/.shellnotes/docs/help manually, or type shellnotes --help in the terminal).
.SH OPTIONS
.TP
.BR \-i ", " \--info
Get info about shellnotes, as well as a copyright notice.
.TP
.BR \-v ", " \--version
Displays your current version of shellnotes.
.TP
.BR \-r ", " \--repository
Get info about the project's github repository.
.TP
.BR \-h ", " \--help
Enter the Shellnotes Help Page (SHP).
.TP
.BR \-u ", " \--update
Searches for an update and applies it on shellnotes if necessary.
.TP
.BR \-au ", " \--auto-update
Toggle the auto-update feature.
Shellnotes auto-update searches for a new a new update in the project's github repository every time you open your terminal and asks you whether to apply it or not.
.TP
.BR \-sd ", " \--set-defaults
Redirects the user to the shellnotes configuration tool (set_defaults.sh)
.TP
.BR \-l ", " \--logs
View a logfile.
.\".SH BUGS
-u or --update \- Update shellnotes.
-v or --version \- Display the current version.
-h or --help \- Display help from the Help Page.
-r \- View the github repository of the program.
-sd or --set-defaults \- Set default editors and folder for writing and storing your notes.
-au or --auto-update \- Toggle the auto-update feature.
-l or --logs \- Open a logfile.
leave a blank parameter ("shellnotes") for checking if shellnotes is installed correctly.
.SH BUGS
No known bugs.
.SH AUTHOR
Dimitris Marakomihelakis (dmarakom@gmail.com)
Dimitris Marakomihelakis (dmarakom@gmail.com)

View file

@ -17,9 +17,9 @@ echo "3. Select default path for saving your notes (Notes folder)"
echo "4. View defaults (editors, folder, source)"
echo
echo -n "[1,2,3,4]: " && read input
input1="$(cat ~/.shellnotes/util/sd/sd-input1.txt)"
input2="$(cat ~/.shellnotes/util/sd/sd-input2.txt)"
input3="$(cat ~/.shellnotes/util/sd/sd-input3.txt)"
input1="$(cat ~/.shellnotes/util/shellnotes/sd/sd-input1.txt)"
input2="$(cat ~/.shellnotes/util/shellnotes/sd/sd-input2.txt)"
input3="$(cat ~/.shellnotes/util/shellnotes/sd/sd-input3.txt)"
@ -29,7 +29,7 @@ if [[ "$input" == "1" ]]; then
if [[ "$(which $name)" == "$input1" ]]; then
echo "This is already the default notes editor."
else
echo "$(which $name)" > ~/.shellnotes/util/sd/sd-input1.txt
echo "$(which $name)" > ~/.shellnotes/util/shellnotes/shellnotes/sd/sd-input1.txt
echo "Default notes editor updated."
echo "Please restart your terminal."
fi
@ -48,7 +48,7 @@ elif [[ "$input" == "2" ]]; then
if [[ "$(which $name)" == "$input2" ]]; then
echo "This is already the default quick notes editor."
else
echo "$(which $name)" > ~/.shellnotes/util/sd/sd-input2.txt
echo "$(which $name)" > ~/.shellnotes/util/shellnotes/sd/sd-input2.txt
echo "Default quick notes editor updated."
echo "Please restart your terminal."
fi
@ -70,7 +70,7 @@ elif [[ "$input" == "3" ]]; then
./sdfailed
else
mv $DEFAULT_PATH/* $name
echo "$name" > ~/.shellnotes/util/sd/sd-input3.txt
echo "$name" > ~/.shellnotes/util/shellnotes/sd/sd-input3.txt
echo "Default notes folder updated."
echo "Please restart your terminal."
fi

View file

@ -1,9 +1,3 @@
#The first line is the user's default shell found during installation process.
#Warning! If you don't have gedit(text editor) or nano installed, you may have to change the default text editor.
#The lines below must NOT be changed.
DIR="$(pwd)"
. ~/.shellnotes/util/getv.sh
. ~/.shellnotes/def/defaults.sh
@ -25,3 +19,4 @@ DIR="$(pwd)"
. ~/.shellnotes/util/shellnotes.sh
. ~/.shellnotes/util/.hidden/.clearlogs.sh
. ~/.shellnotes/util/.hidden/.resetshellnotes.sh

View file

@ -10,9 +10,9 @@ function resetshellnotes() {
proceed() {
echo "y\n" | clearlogs >/dev/null
echo "" > ~/.shellnotes/util/listnotes/output/*
echo "/usr/bin/gedit" > ~/.shellnotes/util/sd/sd-input1.txt
echo "/bin/nano"> ~/.shellnotes/util/sd/sd-input2.txt
echo "~/Notes" > ~/.shellnotes/util/sd/sd-input3.txt
echo "/usr/bin/gedit" > ~/.shellnotes/util/shellnotes/sd/sd-input1.txt
echo "/bin/nano"> ~/.shellnotes/util/shellnotes/sd/sd-input2.txt
echo "~/Notes" > ~/.shellnotes/util/shellnotes/sd/sd-input3.txt
sed -i '1d' ~/.shellnotes/.shellnotes.sh
}

View file

@ -29,8 +29,8 @@ class cd:
os.chdir(self.savedPath)
folder = "cat ~/.shellnotes/util/sd/sd-input3.txt"
files = "eval echo $(cat ~/.shellnotes/util/sd/sd-input3.txt) | xargs ls | wc -l"
folder = "cat ~/.shellnotes/util/shellnotes/sd/sd-input3.txt"
files = "eval echo $(cat ~/.shellnotes/util/shellnotes/sd/sd-input3.txt) | xargs ls | wc -l"
os.system(folder + "> ~/.shellnotes/util/listnotes/output/dir.txt 2> ~/.shellnotes/util/listnotes/output/direrr.txt")

View file

@ -5,7 +5,7 @@ Released under the "All rights reserved" category. See the RIGHTS.txt file
in /docs/github/ for its full text.
info
folder="$(cat ~/.shellnotes/util/sd/sd-input3.txt)"
files="$(eval echo $(cat ~/.shellnotes/util/sd/sd-input3.txt) | xargs ls | wc -l)"
folder="$(cat ~/.shellnotes/util/shellnotes/sd/sd-input3.txt)"
files="$(eval echo $(cat ~/.shellnotes/util/shellnotes/sd/sd-input3.txt) | xargs ls | wc -l)"
echo "Found $files files in $folder."

View file

@ -125,23 +125,23 @@ function notegrep() {
case $option in
-sc | --split-char)
. ~/.shellnotes/util/notegrep/sc.sh
. ~/.shellnotes/util/notegrep/sc/sc.sh
;;
-cl | --count-lines )
. ~/.shellnotes/util/notegrep/cl.sh
. ~/.shellnotes/util/notegrep/cl/cl.sh
;;
-sl | --show-lines )
. ~/.shellnotes/util/notegrep/sl.sh
. ~/.shellnotes/util/notegrep/sl/sl.sh
;;
-ws | --without-string )
. ~/.shellnotes/util/notegrep/ws.sh
. ~/.shellnotes/util/notegrep/ws/ws.sh
;;
-m | --multiple )
cd ~
if [ "$(python3 ~/.shellnotes/util/notegrep/m.py $regex $notename | wc -l)" -ge 25 ]; then
python3 ~/.shellnotes/util/notegrep/m.py $regex $notename | less -R
if [ "$(python3 ~/.shellnotes/util/notegrep/m/m.py $regex $notename | wc -l)" -ge 25 ]; then
python3 ~/.shellnotes/util/notegrep/m/m.py $regex $notename | less -R
else
python3 ~/.shellnotes/util/notegrep/m.py $regex $notename
python3 ~/.shellnotes/util/notegrep/m/m.py $regex $notename
fi
cd $DIR
;;
@ -176,12 +176,12 @@ function notegrep() {
-cf | --count-files )
export regex=$2
export option=$1
. ~/.shellnotes/util/notegrep/cf.sh
. ~/.shellnotes/util/notegrep/cf/cf.sh
;;
-sf | --show-files )
export regex=$2
export option=$1
. ~/.shellnotes/util/notegrep/sf.sh
. ~/.shellnotes/util/notegrep/sf/sf.sh
;;
-sc | --split-char | -cl | --count-lines | -sf | --show-lines | -ws | --without-string | -m | --multiple)
echo "Invalid use of parameter '$regex'.\nUsage:\nnotegrep [PATTERN] file...\nnotegrep [OPTION] [PATTERN] file...\nnotegrep [OPTION] file...\nnotegrep [OPTION] [PATTERN]"

23
util/notegrep/cf/cf.sh Normal file
View file

@ -0,0 +1,23 @@
:<<'info'
shellnotes - cf.sh
(C) Dimitris Marakomihelakis
Released under the "All rights reserved" category. See the RIGHTS.txt file
in /docs/github/ for its full text.
info
files="$(grep -rwl $regex $DEFAULT_PATH/* | wc -l)"
if [ $files -eq 1 ]; then
echo "Found $files matching file in $DEFAULT_PATH."
elif [ $files -gt 1 ]; then
echo "Found $files matching files in $DEFAULT_PATH."
echo -n "Show files?(Y/N): " && read show
case $show in
yes | y | Y | YES | Yes )
grep -rwl $regex $DEFAULT_PATH/*
;;
esac
else
echo "No matching files found."
fi

30
util/notegrep/cl/cl.sh Normal file
View file

@ -0,0 +1,30 @@
:<<'info'
shellnotes - cl.sh
(C) Dimitris Marakomihelakis
Released under the "All rights reserved" category. See the RIGHTS.txt file
in /docs/github/ for its full text.
info
if [ -f $DEFAULT_PATH/$notename ]; then
out="$(grep -c $regex $DEFAULT_PATH/$notename)"
if [ $out -eq 1 ]; then
echo "Compressed $out line of grep output."
elif [ $out -gt 1 ]; then
echo "Compressed $out lines of grep output."
echo -n "Show lines?(Y/N): " && read show
case $show in
yes | y | Y | YES | Yes )
grep -n $regex $DEFAULT_PATH/$notename
;;
esac
else
echo "No matching lines found."
fi
else
echo "No such file."
return 0
fi

69
util/notegrep/m/m.py Normal file
View file

@ -0,0 +1,69 @@
#!/usr/bin/env python3
#shellnotes - m.py
#(C) Dimitris Marakomihelakis
#Released under the "All rights reserved" category. See the RIGHTS.txt file
#in /docs/github/ for its full text.
import sys
import os.path
from os import path
import subprocess
from subprocess import check_output
import re
class Multi():
def __init__(self, patterns, files):
self.patterns = patterns
self.files = files
def check_empty(self):
if "" in self.patterns: raise IndexError #asks for direct input
def remove_duplicates(self):
self.patterns, self.files = list(dict.fromkeys(self.patterns)), list(dict.fromkeys(self.files))
def remove_spaces(self):
self.patterns, self.files = [elem.strip(' ') for elem in self.patterns], [elem.strip(' ') for elem in self.files]
def split_extras(self): #not using this for now
if len(sys.argv) == 4:
if "-i" in sys.argv[-1] or "--ignore" in sys.argv[-1]:
re.sub(r'\s(--\ignore+|-\i)', '', sys.sys.argv[-1]) #remove everything from sys.argv[-1], except "-i" or "--ignore", if it exists.
def print_matches(self):
for file in self.files:
try:
if file == "": return 0
print("\n"+file if path.exists('Notes/'+file) else f"\n{file} (not found):", flush=True)
print("=" * len(file) if path.exists('Notes/'+file) else "-", flush=True)
with open('Notes/'+file, 'r') as f:
text = f.read()
for pattern in self.patterns:
if re.search(pattern, text):
out = os.system(f"""echo -n "'\033[1;35;40m{pattern}\033[0;37;0m'": && grep -n --color=always {pattern} Notes/{file}""")
except FileNotFoundError: pass
def main():
try:
newMulti = Multi(sys.argv[1].split(','), sys.argv[2].split(','))
newMulti.check_empty()
newMulti.remove_spaces()
newMulti.remove_duplicates()
newMulti.print_matches()
except IndexError:
patterns = input("Enter patterns, separated by a comma: ")
files = input("Enter files, separated by a comma: ")
newMulti = Multi(patterns.split(','), files.split(','))
newMulti.remove_spaces()
newMulti.remove_duplicates()
newMulti.print_matches()
if __name__ == "__main__":
main()

30
util/notegrep/sc/sc.sh Normal file
View file

@ -0,0 +1,30 @@
:<<'info'
shellnotes - sc.sh
(C) Dimitris Marakomihelakis
Released under the "All rights reserved" category. See the RIGHTS.txt file
in /docs/github/ for its full text.
info
if [ -f $DEFAULT_PATH/$notename ]; then
if grep -q $regex $DEFAULT_PATH/$notename; then
out="$(cat $DEFAULT_PATH/$notename | sed s/$regex/\\n/g | wc -l)"
if [ $out -gt 20 ]; then
cat $DEFAULT_PATH/$notename | sed s/$regex/\\n/g | less
elif [ $out -le 20 ]; then
cat $DEFAULT_PATH/$notename | sed s/$regex/\\n/g
fi
else
echo "No matches found."
return 0
fi
else
echo "This note doesn't exist."
return 0
fi

14
util/notegrep/sf/sf.sh Normal file
View file

@ -0,0 +1,14 @@
:<<'info'
shellnotes - sf.sh
(C) Dimitris Marakomihelakis
Released under the "All rights reserved" category. See the RIGHTS.txt file
in /docs/github/ for its full text.
info
files="$(grep -rwl $regex $DEFAULT_PATH/* | wc -l)"
if [ $files -ge 1 ]; then
grep -rwl $regex $DEFAULT_PATH/*
else
echo "No matching files found."
fi

19
util/notegrep/sl/sl.sh Normal file
View file

@ -0,0 +1,19 @@
:<<'info'
shellnotes - sl.sh
(C) Dimitris Marakomihelakis
Released under the "All rights reserved" category. See the RIGHTS.txt file
in /docs/github/ for its full text.
info
if [ -f $DEFAULT_PATH/$notename ]; then
out="$(grep -n $regex $DEFAULT_PATH/$notename | wc -l)"
if [ $out -eq 0 ]; then
echo "No matching lines found."
else
grep -n $regex $DEFAULT_PATH/$notename
fi
else
echo "No such file."
fi

50
util/notegrep/ws/ws.sh Normal file
View file

@ -0,0 +1,50 @@
:<<'info'
shellnotes - ws.sh
(C) Dimitris Marakomihelakis
Released under the "All rights reserved" category. See the RIGHTS.txt file
in /docs/github/ for its full text.
info
grepv() { #the command run when input is valid
if [ $(grep -v $regex $DEFAULT_PATH/$notename | wc -l) -ge 20 ]; then
grep -v $regex $DEFAULT_PATH/$notename | less
else
grep -v $regex $DEFAULT_PATH/$notename
fi
}
nomatch() {
echo -n "There are no matches.\nView note anyway?(Y/N): " && read view
case $view in
y | Y | yes | YES | Yes )
if [ $(cat $DEFAULT_PATH/$notename | wc -l) -ge 20 ]; then
less $DEFAULT_PATH/$notename
else
cat $DEFAULT_PATH/$notename
fi
return 0
;;
*)
echo "Cancelled."
return 0
;;
esac
}
if [ -f $DEFAULT_PATH/$notename ]; then
if grep -vq $regex $DEFAULT_PATH/$notename ; then
test "$(cat $DEFAULT_PATH/$notename)" = "$(grep -v $regex $DEFAULT_PATH/$notename)" && nomatch || grepv && return 0
else
echo "Pattern matches the whole file."
return 0
fi
else
echo "This note doesn't exist."
return 0
fi

View file

@ -6,14 +6,14 @@ in /docs/github/ for its full text.
info
function shellnotes() {
. ~/.shellnotes/util/h/h.sh
. ~/.shellnotes/util/v/v.sh
. ~/.shellnotes/util/r/r.sh
. ~/.shellnotes/util/u/u.sh
. ~/.shellnotes/util/l/l.sh
. ~/.shellnotes/util/au/au.sh
. ~/.shellnotes/util/sd/sd.sh
. ~/.shellnotes/util/i/i.sh
. ~/.shellnotes/util/shellnotes/h/h.sh
. ~/.shellnotes/util/shellnotes/v/v.sh
. ~/.shellnotes/util/shellnotes/r/r.sh
. ~/.shellnotes/util/shellnotes/u/u.sh
. ~/.shellnotes/util/shellnotes/l/l.sh
. ~/.shellnotes/util/shellnotes/au/au.sh
. ~/.shellnotes/util/shellnotes/sd/sd.sh
. ~/.shellnotes/util/shellnotes/i/i.sh
if [[ $# > 1 ]]; then
echo "Too many arguments."
elif [[ $# = 0 ]];then

30
util/shellnotes/au/au.sh Normal file
View file

@ -0,0 +1,30 @@
:<<'info'
shellnotes - au.sh
(C) Dimitris Marakomihelakis
Released under the "All rights reserved" category. See the RIGHTS.txt file
in /docs/github/ for its full text.
info
case $1 in -au|--auto-update )
if grep -q 'ChUpd.sh' ~/.shellnotes/.shellnotes.sh; then
echo "auto-update feature is enabled."
echo -n "Disable it? [Y/N]: " && read input
case $input in Yes|y|Y|yes|YES )
sed -i '/ChUpd.sh/d' ~/.shellnotes/.shellnotes.sh
echo "auto-update is now disabled."
echo "To enable, run 'shellnotes -au' again."
esac
else
echo "auto-update feature is disabled."
echo -n "Enable it? [Y/N]: " && read input
case $input in Yes|y|Y|yes|YES )
long=$(grep -n "#The lines below must NOT be changed." ~/.shellnotes/.shellnotes.sh)
short=$(echo "${long}" | head -c1)
short=$`$short+1` 2>/dev/null
file=$(eval echo "~/.shellnotes/util/ChUpd.sh")
sed -i "$short i\. $file" ~/.shellnotes/.shellnotes.sh
echo "auto-update is now enabled."
echo "To disable, run 'shellnotes -au' again."
esac
fi
esac

11
util/shellnotes/h/h.sh Normal file
View file

@ -0,0 +1,11 @@
:<<'info'
shellnotes - h.sh
(C) Dimitris Marakomihelakis
Released under the "All rights reserved" category. See the RIGHTS.txt file
in /docs/github/ for its full text.
info
case $1 in -h|--help )
less ~/.shellnotes/docs/help
cd $DIR
esac

11
util/shellnotes/i/i.sh Normal file
View file

@ -0,0 +1,11 @@
:<<'info'
shellnotes - i.sh
(C) Dimitris Marakomihelakis
Released under the "All rights reserved" category. See the RIGHTS.txt file
in /docs/github/ for its full text.
info
case $1 in -i|--i )
echo "This is an original copy of the shellnotes project from the github repository."
echo "Copyright © Dimitris Marakomihelakis. All rights reserved."
esac

44
util/shellnotes/l/l.sh Normal file
View file

@ -0,0 +1,44 @@
:<<'info'
shellnotes - l.sh
(C) Dimitris Marakomihelakis
Released under the "All rights reserved" category. See the RIGHTS.txt file
in /docs/github/ for its full text.
info
case $1 in -l|--logs )
clear
echo "Please select a logfile to open"
echo "-------------------------------"
echo
echo "1. disablement errors"
echo "2. enablement errors"
echo "3. installation errors"
echo "4. update errors"
echo "5. uninstallation errors"
echo "6. set-defaults errors"
echo
echo "For more info about which one to choose, read /docs/system/loggingsystem.txt"
echo
echo -n "[1,2,3,4,5]: " && read input
if [ -z $input ]; then
echo "Invalid input."
return 0
else
if [ $input = 1 ]; then
less ~/.shellnotes/logs/disfailed.txt
elif [ $input = 2 ]; then
less ~/.shellnotes/logs/enfailed.txt
elif [ $input = 3 ]; then
less ~/.shellnotes/logs/ifailed.txt
elif [ $input = 4 ]; then
less ~/.shellnotes/logs/ufailed.txt
elif [ $input = 5 ]; then
less ~/.shellnotes/logs/uninfailed.txt
elif [ $input = 6 ]; then
less ~/.shellnotes/logs/sdfailed.txt
else
echo "Invalid input."
fi
fi
esac

10
util/shellnotes/r/r.sh Normal file
View file

@ -0,0 +1,10 @@
:<<'info'
shellnotes - r.sh
(C) Dimitris Marakomihelakis
Released under the "All rights reserved" category. See the RIGHTS.txt file
in /docs/github/ for its full text.
info
case $1 in -r|--repository )
echo "Github repository: https://github.com/dmarakom6/shellnotes/blob/master/"
esac

View file

@ -0,0 +1 @@
/usr/bin/gedit

View file

@ -0,0 +1 @@
/bin/nano

View file

@ -0,0 +1 @@
~/Notes

10
util/shellnotes/sd/sd.sh Normal file
View file

@ -0,0 +1,10 @@
:<<'info'
shellnotes - sd.sh
(C) Dimitris Marakomihelakis
Released under the "All rights reserved" category. See the RIGHTS.txt file
in /docs/github/ for its full text.
info
case $1 in -sd|--set-defaults )
. ~/.shellnotes/set_defaults.sh
esac

14
util/shellnotes/u/u.sh Normal file
View file

@ -0,0 +1,14 @@
:<<'info'
shellnotes - u.sh
(C) Dimitris Marakomihelakis
Released under the "All rights reserved" category. See the RIGHTS.txt file
in /docs/github/ for its full text.
info
case $1 in -u|--update )
if [ -n "`$SHELL -c 'echo $BASH_VERSION'`" ]; then
. ~/.shellnotes/bash_update.sh
else
. ~/.shellnotes/update.sh
fi
esac

10
util/shellnotes/v/v.sh Normal file
View file

@ -0,0 +1,10 @@
:<<'info'
shellnotes - v.sh
(C) Dimitris Marakomihelakis
Released under the "All rights reserved" category. See the RIGHTS.txt file
in /docs/github/ for its full text.
info
case $1 in -v|--version )
echo "Shellnotes version: $VER"
esac