added the -n line number option to less/more
This commit is contained in:
@@ -378,7 +378,7 @@ freq [160 | 80] # get/set the ESP8266 frequency
|
|||||||
exec <python-filename> # execute a small python file
|
exec <python-filename> # execute a small python file
|
||||||
free # display the heap size: used + free
|
free # display the heap size: used + free
|
||||||
wc <filename> # display the line count, word count and bytes
|
wc <filename> # display the line count, word count and bytes
|
||||||
less <filename> # similar to cat, but displays 30 lines at a time
|
less/more [-n] <filename> # similar to cat, but displays 30 lines at a time
|
||||||
```
|
```
|
||||||
Synonyms: `ip = ifconfig`, `more = less`, `dig = nslookup = host`
|
Synonyms: `ip = ifconfig`, `more = less`, `dig = nslookup = host`
|
||||||
|
|
||||||
|
|||||||
12
tf_extend.py
12
tf_extend.py
@@ -11,11 +11,13 @@ class wc():
|
|||||||
self.words += len(text.split())
|
self.words += len(text.split())
|
||||||
|
|
||||||
class lessor():
|
class lessor():
|
||||||
def __init__(self):
|
def __init__(self,nums=False):
|
||||||
self.i=0
|
self.i=0
|
||||||
|
self.nums=nums
|
||||||
def write(self,text):
|
def write(self,text):
|
||||||
if self.i==-1: return
|
if self.i==-1: return
|
||||||
self.i += 1
|
self.i += 1
|
||||||
|
if self.nums: sys.stdout.write(str(self.i)+' ')
|
||||||
sys.stdout.write(text)
|
sys.stdout.write(text)
|
||||||
if self.i%30==0:
|
if self.i%30==0:
|
||||||
sys.stdout.write("====> press <enter> to see more, N or Q to quit <====\n")
|
sys.stdout.write("====> press <enter> to see more, N or Q to quit <====\n")
|
||||||
@@ -33,10 +35,14 @@ def cmd(args):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
if cmd in ('wc','more','less'):
|
if cmd in ('wc','more','less'):
|
||||||
|
nums=False
|
||||||
if cmd=='wc':
|
if cmd=='wc':
|
||||||
w = wc()
|
w = wc()
|
||||||
else:
|
else:
|
||||||
w = lessor()
|
if args[1]=='-n':
|
||||||
|
nums=True
|
||||||
|
del(args[1])
|
||||||
|
w = lessor(nums)
|
||||||
try:
|
try:
|
||||||
tf.transfer(args[1],w)
|
tf.transfer(args[1],w)
|
||||||
if cmd=='wc':
|
if cmd=='wc':
|
||||||
@@ -95,7 +101,7 @@ def cmd(args):
|
|||||||
print(" ifconfig/ip \t\thost/dig/nslookup <domain.name>")
|
print(" ifconfig/ip \t\thost/dig/nslookup <domain.name>")
|
||||||
print(" freq [ 160 | 80 ] \t\texec <python-filename>")
|
print(" freq [ 160 | 80 ] \t\texec <python-filename>")
|
||||||
print(" free \t\t\twc <filename>")
|
print(" free \t\t\twc <filename>")
|
||||||
print(" less/more <filename>")
|
print(" less/more [-n] <filename>")
|
||||||
else: # command not found
|
else: # command not found
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user