shithub: bin.rc

Download patch

ref: 81ad767e7c490eed99c6c5424c2cbf23f1d0a047
parent: c57c8ab75d68d973e7b032792c6b729efcc13a93
author: kvik <kvik@a-b.xyz>
date: Sat Feb 22 09:08:14 EST 2020

Add -p option for printing a mark; rearrange some code

--- a/bin/k
+++ b/bin/k
@@ -1,27 +1,35 @@
 #!/bin/rc
 # k - mark position (from sam)
 
-marks=$ws/marks
-if(~ $#marks 0)
+marks = $ws/marks
+if(! test -f $marks)
 	marks=/tmp/marks.default
 
+cmd = (mark)
 while(~ $1 -* && ! ~ $1 --){
-	switch($1){
-	case -c
-		>$marks; exit
-	case -p
-		plumb -d edit $marks
-	case -v
-		test -f $marks && window 'label marks; tail -f '$marks
-		exit
-	case *;
-		exit usage
+	 switch($1){
+	 case -c ; cmd = clear
+	 case -m ; cmd = mark
+	 case -p ; cmd = print
+	 case -w ; cmd = window
+	 case * ; exit usage
 	}
 	shift
 }
-if(~ $1 --)
-	shift
-	
+if(~ $1 --) shift
+
 if(~ $#% 0)
-	exit notsam
-echo $%:$'%l' $* >>$marks
+	exit 'not in sam'
+
+switch($cmd){
+case mark
+	echo $%:$%dot(1) $* >>$marks
+case print
+	echo $%:$%dot(1)
+case clear
+	>$marks
+case window
+	test -f $marks && window 'label marks; tail -f '$marks
+case *
+	exit usage
+}