Relnoted history builtin

Tweaked validation regex to use extended regexs
This commit is contained in:
ridiculousfish 2012-06-04 23:54:43 -07:00
parent 85cbb943b5
commit be1d216b34
2 changed files with 15 additions and 3 deletions

View file

@ -22,6 +22,18 @@ li {
<li>A SIGTERM now ends the whole execution stack again (<a href="https://github.com/ridiculousfish/fishfish/issues/13">from this issue</a>).
</ul>
<h3>New Features</h3>
<ul>
<li>A <b>history builtin</b>, and associated interactive function that enables deleting history items. Example usage:
<ul>
<li>Print all history items beginning with echo: <span class="mono">history --search --prefix echo</span></li>
<li>Print all history items containing foo: <span class="mono">history --search --contains foo</span></li>
<li>Interactively delete some items containing foo: <span class="mono">history --delete --contains foo</span></li>
</ul><br>
Credit to Siteshwar for implementation. Thanks Siteshwar!
</li>
<hr>

View file

@ -53,8 +53,8 @@ function history --description "Deletes an item from history"
end
read --local --prompt "echo 'Delete which entries? > '" choice
set choice (echo $choice | tr " " "\n")
set choice (echo $choice | tr " " "\n")
for i in $choice
# Skip empty input; for example, if the user just hits return
@ -63,7 +63,7 @@ function history --description "Deletes an item from history"
end
#Following two validations could be embedded with "and" but I find the syntax kind of weird.
if not echo $i | grep -q "^[0-9]+\$"
if not echo $i | grep -E -q "^[0-9]+\$"
printf "Invalid input: %s\n" $i
continue
end