Apply line-buffering method with print()
This commit is contained in:
parent
c272ee03b9
commit
5fe0a4b5fd
2 changed files with 9 additions and 3 deletions
|
@ -138,7 +138,12 @@ function notegrep() {
|
|||
;;
|
||||
-m | --multiple )
|
||||
cd ~
|
||||
if [ "$(python3 ~/.shellnotes/util/notegrep/m.py $regex $notename | wc -l)" -ge 20 ]; then
|
||||
python3 ~/.shellnotes/util/notegrep/m.py $regex $notename | less -R
|
||||
else
|
||||
python3 ~/.shellnotes/util/notegrep/m.py $regex $notename
|
||||
fi
|
||||
|
||||
cd $DIR
|
||||
;;
|
||||
*)
|
||||
|
|
|
@ -29,8 +29,8 @@ class Multi():
|
|||
for file in self.files:
|
||||
try:
|
||||
if file == "": return 0
|
||||
print("\n"+file if path.exists('Notes/'+file) else f"\n{file} (not found):\n-")
|
||||
print("=" * len(file) if path.exists('Notes/'+file) else "")
|
||||
print("\n"+file if path.exists('Notes/'+file) else f"\n{file} (not found):\n-", flush=True)
|
||||
print("=" * len(file) if path.exists('Notes/'+file) else "", flush=True)
|
||||
|
||||
for pattern in self.patterns:
|
||||
if pattern == "": return 0
|
||||
|
@ -39,6 +39,7 @@ class Multi():
|
|||
if re.search(pattern, line):
|
||||
out = os.system(f"""echo -n "'{pattern}'": && grep -n --color=always {pattern} Notes/{file}""")
|
||||
#bug: pattern is generated multiple times
|
||||
|
||||
except FileNotFoundError: pass
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue