mark-stash 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mark_cli/__init__.py +8 -0
- mark_cli/__main__.py +8 -0
- mark_cli/cli.py +401 -0
- mark_stash-0.1.0.dist-info/METADATA +192 -0
- mark_stash-0.1.0.dist-info/RECORD +9 -0
- mark_stash-0.1.0.dist-info/WHEEL +5 -0
- mark_stash-0.1.0.dist-info/entry_points.txt +2 -0
- mark_stash-0.1.0.dist-info/licenses/LICENSE +21 -0
- mark_stash-0.1.0.dist-info/top_level.txt +1 -0
mark_cli/__init__.py
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"""mark - a tiny one-line note list with an fzf picker and clipboard copy."""
|
|
2
|
+
|
|
3
|
+
from importlib.metadata import PackageNotFoundError, version as _dist_version
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
__version__ = _dist_version("mark-stash")
|
|
7
|
+
except PackageNotFoundError: # source checkout without an installation
|
|
8
|
+
__version__ = "0.1.0"
|
mark_cli/__main__.py
ADDED
mark_cli/cli.py
ADDED
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
"""mark - a tiny one-line note list with an fzf picker and clipboard copy.
|
|
2
|
+
|
|
3
|
+
Usage:
|
|
4
|
+
mark <text> record <text> (joins the arguments with spaces)
|
|
5
|
+
mark fuzzy-pick a mark with fzf and copy it to the clipboard
|
|
6
|
+
mark -l list marks, newest first
|
|
7
|
+
mark -d fuzzy-pick a mark and delete it
|
|
8
|
+
mark -m fuzzy-pick a mark and edit its text
|
|
9
|
+
mark --path print the mark file path
|
|
10
|
+
|
|
11
|
+
Storage is a plain UTF-8 text file outside the repository, one mark per line
|
|
12
|
+
(newest last). Set MARK_FILE to keep the list somewhere else.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import argparse
|
|
18
|
+
import os
|
|
19
|
+
import shutil
|
|
20
|
+
import subprocess
|
|
21
|
+
import sys
|
|
22
|
+
from pathlib import Path
|
|
23
|
+
from typing import List, Optional, Tuple
|
|
24
|
+
|
|
25
|
+
from . import __version__
|
|
26
|
+
|
|
27
|
+
APP_NAME = "mark"
|
|
28
|
+
DEFAULT_PROMPT = "mark> "
|
|
29
|
+
EDIT_PROMPT = "edit> "
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# --------------------------------------------------------------------- storage
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def data_path() -> Path:
|
|
36
|
+
"""Path of the mark file (override with ``MARK_FILE``)."""
|
|
37
|
+
env = os.environ.get("MARK_FILE")
|
|
38
|
+
if env:
|
|
39
|
+
return Path(env).expanduser()
|
|
40
|
+
if sys.platform == "darwin":
|
|
41
|
+
base = Path.home() / "Library" / "Application Support"
|
|
42
|
+
else:
|
|
43
|
+
base = Path(os.environ.get("XDG_DATA_HOME", Path.home() / ".local" / "share"))
|
|
44
|
+
return base / APP_NAME / "marks.txt"
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def read_marks(path: Path) -> List[str]:
|
|
48
|
+
"""Read the mark file, dropping blank lines and trailing whitespace."""
|
|
49
|
+
try:
|
|
50
|
+
raw = path.read_text(encoding="utf-8")
|
|
51
|
+
except FileNotFoundError:
|
|
52
|
+
return []
|
|
53
|
+
marks = []
|
|
54
|
+
for line in raw.splitlines():
|
|
55
|
+
line = line.strip()
|
|
56
|
+
if line:
|
|
57
|
+
marks.append(line)
|
|
58
|
+
return marks
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def write_marks(path: Path, marks: List[str]) -> None:
|
|
62
|
+
"""Atomically replace the mark file, one mark per line, mode 0600."""
|
|
63
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
64
|
+
tmp = path.with_name(path.name + ".tmp")
|
|
65
|
+
fd = os.open(str(tmp), os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600)
|
|
66
|
+
with os.fdopen(fd, "w", encoding="utf-8", newline="\n") as handle:
|
|
67
|
+
for mark in marks:
|
|
68
|
+
handle.write(mark + "\n")
|
|
69
|
+
os.replace(str(tmp), str(path))
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def add_marks(path: Path, texts: List[str]) -> List[str]:
|
|
73
|
+
"""Add marks, moving duplicates to the end (newest) and dropping blanks."""
|
|
74
|
+
marks = read_marks(path)
|
|
75
|
+
added = 0
|
|
76
|
+
for text in texts:
|
|
77
|
+
line = text.strip()
|
|
78
|
+
if not line:
|
|
79
|
+
continue
|
|
80
|
+
marks = [old for old in marks if old != line]
|
|
81
|
+
marks.append(line)
|
|
82
|
+
added += 1
|
|
83
|
+
if added:
|
|
84
|
+
write_marks(path, marks)
|
|
85
|
+
return marks
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def split_text(args: List[str]) -> List[str]:
|
|
89
|
+
"""Turn the command line into one mark per non-empty line."""
|
|
90
|
+
text = " ".join(args)
|
|
91
|
+
return [line.strip() for line in text.splitlines() if line.strip()]
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
# ---------------------------------------------------------------------- picker
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def select(items: List[str], query: str = "") -> Tuple[Optional[str], str]:
|
|
98
|
+
"""Pick one item.
|
|
99
|
+
|
|
100
|
+
Returns ``(choice, query)``; ``choice`` is ``None`` when the picker was
|
|
101
|
+
cancelled. ``query`` is the text left in the fzf prompt, so callers that
|
|
102
|
+
re-open the picker (``mark -d``) can keep the current filter.
|
|
103
|
+
"""
|
|
104
|
+
if shutil.which(_fzf_exe()):
|
|
105
|
+
return fzf_select(items, query)
|
|
106
|
+
return numbered_select(items), ""
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def _fzf_exe() -> str:
|
|
110
|
+
return os.environ.get("MARK_FZF") or "fzf"
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def fzf_select(items: List[str], query: str = "") -> Tuple[Optional[str], str]:
|
|
114
|
+
prompt = os.environ.get("MARK_PROMPT", DEFAULT_PROMPT)
|
|
115
|
+
cmd = [
|
|
116
|
+
_fzf_exe(),
|
|
117
|
+
"--height=40%",
|
|
118
|
+
"--reverse",
|
|
119
|
+
"--no-multi",
|
|
120
|
+
"--print-query",
|
|
121
|
+
"--prompt=" + prompt,
|
|
122
|
+
"--query=" + query,
|
|
123
|
+
]
|
|
124
|
+
try:
|
|
125
|
+
proc = subprocess.run(
|
|
126
|
+
cmd,
|
|
127
|
+
input="\n".join(items) + "\n",
|
|
128
|
+
text=True,
|
|
129
|
+
stdout=subprocess.PIPE,
|
|
130
|
+
)
|
|
131
|
+
except OSError:
|
|
132
|
+
return numbered_select(items), ""
|
|
133
|
+
if proc.returncode != 0:
|
|
134
|
+
return None, query
|
|
135
|
+
# --print-query makes fzf emit the query first, then the selected line.
|
|
136
|
+
lines = proc.stdout.splitlines()
|
|
137
|
+
new_query = lines[0] if lines else query
|
|
138
|
+
choice = lines[1] if len(lines) > 1 else None
|
|
139
|
+
return choice, new_query
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def numbered_select(items: List[str]) -> Optional[str]:
|
|
143
|
+
"""Minimal picker for machines without fzf."""
|
|
144
|
+
for index, item in enumerate(items, 1):
|
|
145
|
+
print(f"{index:3} {item}")
|
|
146
|
+
try:
|
|
147
|
+
answer = input("select> ").strip()
|
|
148
|
+
except (EOFError, KeyboardInterrupt):
|
|
149
|
+
return None
|
|
150
|
+
if not answer or answer.lower() in ("q", "quit"):
|
|
151
|
+
return None
|
|
152
|
+
if answer.isdigit() and 1 <= int(answer) <= len(items):
|
|
153
|
+
return items[int(answer) - 1]
|
|
154
|
+
print("mark: invalid selection", file=sys.stderr)
|
|
155
|
+
return None
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def edit_text(text: str) -> Optional[str]:
|
|
159
|
+
"""Let the user rewrite one mark; ``None`` when the edit was cancelled."""
|
|
160
|
+
if shutil.which(_fzf_exe()):
|
|
161
|
+
try:
|
|
162
|
+
return fzf_edit(text)
|
|
163
|
+
except OSError:
|
|
164
|
+
pass
|
|
165
|
+
return prompt_edit(text)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def fzf_edit(text: str) -> Optional[str]:
|
|
169
|
+
"""Edit ``text`` inside fzf, prefilled in its prompt.
|
|
170
|
+
|
|
171
|
+
``--phony`` shows the dummy input line instead of filtering it, so Enter
|
|
172
|
+
always accepts whatever was typed into the prompt.
|
|
173
|
+
"""
|
|
174
|
+
cmd = [
|
|
175
|
+
_fzf_exe(),
|
|
176
|
+
"--height=20%",
|
|
177
|
+
"--reverse",
|
|
178
|
+
"--no-multi",
|
|
179
|
+
"--phony",
|
|
180
|
+
"--print-query",
|
|
181
|
+
"--prompt=" + EDIT_PROMPT,
|
|
182
|
+
"--query=" + text,
|
|
183
|
+
]
|
|
184
|
+
proc = subprocess.run(
|
|
185
|
+
cmd,
|
|
186
|
+
input=" \n",
|
|
187
|
+
text=True,
|
|
188
|
+
stdout=subprocess.PIPE,
|
|
189
|
+
)
|
|
190
|
+
if proc.returncode != 0:
|
|
191
|
+
return None
|
|
192
|
+
lines = proc.stdout.splitlines()
|
|
193
|
+
return lines[0] if lines else text
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def prompt_edit(text: str) -> Optional[str]:
|
|
197
|
+
"""Edit fallback: a plain prompt pre-filled with the current text."""
|
|
198
|
+
try:
|
|
199
|
+
import readline
|
|
200
|
+
except ImportError:
|
|
201
|
+
readline = None
|
|
202
|
+
if readline is None:
|
|
203
|
+
print(text)
|
|
204
|
+
else:
|
|
205
|
+
readline.set_startup_hook(lambda: readline.insert_text(text))
|
|
206
|
+
try:
|
|
207
|
+
return input(EDIT_PROMPT)
|
|
208
|
+
except (EOFError, KeyboardInterrupt):
|
|
209
|
+
return None
|
|
210
|
+
finally:
|
|
211
|
+
if readline is not None:
|
|
212
|
+
readline.set_startup_hook()
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
# ------------------------------------------------------------------- clipboard
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def clipboard_candidates() -> List[List[str]]:
|
|
219
|
+
if sys.platform == "darwin":
|
|
220
|
+
return [["pbcopy"]]
|
|
221
|
+
if os.name == "nt":
|
|
222
|
+
return [["clip"]]
|
|
223
|
+
candidates = []
|
|
224
|
+
if os.environ.get("WAYLAND_DISPLAY"):
|
|
225
|
+
candidates.append(["wl-copy"])
|
|
226
|
+
candidates += [
|
|
227
|
+
["xclip", "-selection", "clipboard"],
|
|
228
|
+
["xsel", "--clipboard", "--input"],
|
|
229
|
+
["wl-copy"],
|
|
230
|
+
]
|
|
231
|
+
return candidates
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
def copy_to_clipboard(text: str) -> bool:
|
|
235
|
+
for cmd in clipboard_candidates():
|
|
236
|
+
if not shutil.which(cmd[0]):
|
|
237
|
+
continue
|
|
238
|
+
try:
|
|
239
|
+
subprocess.run(
|
|
240
|
+
cmd,
|
|
241
|
+
input=text,
|
|
242
|
+
text=True,
|
|
243
|
+
check=True,
|
|
244
|
+
stdout=subprocess.DEVNULL,
|
|
245
|
+
stderr=subprocess.DEVNULL,
|
|
246
|
+
)
|
|
247
|
+
return True
|
|
248
|
+
except (OSError, subprocess.CalledProcessError):
|
|
249
|
+
continue
|
|
250
|
+
return False
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
# ------------------------------------------------------------------------ cli
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
257
|
+
parser = argparse.ArgumentParser(
|
|
258
|
+
prog="mark",
|
|
259
|
+
description="Record one-line notes, then fuzzy-pick one to copy.",
|
|
260
|
+
)
|
|
261
|
+
parser.add_argument(
|
|
262
|
+
"text",
|
|
263
|
+
nargs="*",
|
|
264
|
+
help="text to record; omit it to pick a mark and copy it",
|
|
265
|
+
)
|
|
266
|
+
parser.add_argument(
|
|
267
|
+
"-l", "--list", action="store_true", help="list marks, newest first"
|
|
268
|
+
)
|
|
269
|
+
parser.add_argument(
|
|
270
|
+
"-d", "--delete", action="store_true", help="pick a mark and delete it"
|
|
271
|
+
)
|
|
272
|
+
parser.add_argument(
|
|
273
|
+
"-m", "--modify", action="store_true", help="pick a mark and edit its text"
|
|
274
|
+
)
|
|
275
|
+
parser.add_argument(
|
|
276
|
+
"--path", action="store_true", help="print the mark file path"
|
|
277
|
+
)
|
|
278
|
+
parser.add_argument(
|
|
279
|
+
"-V", "--version", action="version", version="mark " + __version__
|
|
280
|
+
)
|
|
281
|
+
return parser
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
def main(argv: Optional[List[str]] = None) -> int:
|
|
285
|
+
parser = build_parser()
|
|
286
|
+
args = parser.parse_args(argv)
|
|
287
|
+
|
|
288
|
+
if sum([bool(args.text), args.list, args.delete, args.modify, args.path]) > 1:
|
|
289
|
+
parser.error("use only one of: text, --list, --delete, --modify, --path")
|
|
290
|
+
|
|
291
|
+
path = data_path()
|
|
292
|
+
try:
|
|
293
|
+
return run(args, path)
|
|
294
|
+
except BrokenPipeError:
|
|
295
|
+
devnull = os.open(os.devnull, os.O_WRONLY)
|
|
296
|
+
os.dup2(devnull, sys.stdout.fileno())
|
|
297
|
+
return 0
|
|
298
|
+
except OSError as exc:
|
|
299
|
+
print(f"mark: {exc}", file=sys.stderr)
|
|
300
|
+
return 1
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
def run(args: argparse.Namespace, path: Path) -> int:
|
|
304
|
+
if args.path:
|
|
305
|
+
print(path)
|
|
306
|
+
return 0
|
|
307
|
+
|
|
308
|
+
if args.list:
|
|
309
|
+
marks = read_marks(path)
|
|
310
|
+
if not marks:
|
|
311
|
+
return _no_marks()
|
|
312
|
+
for mark in reversed(marks):
|
|
313
|
+
print(mark)
|
|
314
|
+
return 0
|
|
315
|
+
|
|
316
|
+
if args.delete:
|
|
317
|
+
return delete_marks(path)
|
|
318
|
+
|
|
319
|
+
if args.modify:
|
|
320
|
+
return modify_marks(path)
|
|
321
|
+
|
|
322
|
+
if args.text:
|
|
323
|
+
texts = split_text(args.text)
|
|
324
|
+
if not texts:
|
|
325
|
+
print("mark: empty mark", file=sys.stderr)
|
|
326
|
+
return 2
|
|
327
|
+
marks = add_marks(path, texts)
|
|
328
|
+
if sys.stderr.isatty():
|
|
329
|
+
if len(texts) == 1:
|
|
330
|
+
print(f"\u2713 marked {texts[0]}", file=sys.stderr)
|
|
331
|
+
else:
|
|
332
|
+
print(f"\u2713 marked {len(texts)} lines", file=sys.stderr)
|
|
333
|
+
return 0
|
|
334
|
+
|
|
335
|
+
marks = read_marks(path)
|
|
336
|
+
if not marks:
|
|
337
|
+
return _no_marks()
|
|
338
|
+
choice, _ = select(list(reversed(marks)))
|
|
339
|
+
if choice is None:
|
|
340
|
+
return 130
|
|
341
|
+
print(choice)
|
|
342
|
+
if not copy_to_clipboard(choice):
|
|
343
|
+
print("mark: no clipboard tool found; printed instead", file=sys.stderr)
|
|
344
|
+
return 0
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
def delete_marks(path: Path) -> int:
|
|
348
|
+
"""Keep the picker open after each deletion; Esc (or an empty list) ends it."""
|
|
349
|
+
query = ""
|
|
350
|
+
deleted = 0
|
|
351
|
+
while True:
|
|
352
|
+
marks = read_marks(path)
|
|
353
|
+
if not marks:
|
|
354
|
+
if deleted:
|
|
355
|
+
print(
|
|
356
|
+
f"mark: deleted {deleted} mark(s); the list is now empty",
|
|
357
|
+
file=sys.stderr,
|
|
358
|
+
)
|
|
359
|
+
return 0
|
|
360
|
+
return _no_marks()
|
|
361
|
+
choice, query = select(list(reversed(marks)), query)
|
|
362
|
+
if choice is None:
|
|
363
|
+
return 130
|
|
364
|
+
marks.remove(choice)
|
|
365
|
+
write_marks(path, marks)
|
|
366
|
+
deleted += 1
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
def modify_marks(path: Path) -> int:
|
|
370
|
+
"""Pick a mark, edit its text and save it in place."""
|
|
371
|
+
marks = read_marks(path)
|
|
372
|
+
if not marks:
|
|
373
|
+
return _no_marks()
|
|
374
|
+
choice, _ = select(list(reversed(marks)))
|
|
375
|
+
if choice is None:
|
|
376
|
+
return 130
|
|
377
|
+
text = edit_text(choice)
|
|
378
|
+
if text is None:
|
|
379
|
+
return 130
|
|
380
|
+
text = text.strip()
|
|
381
|
+
if not text:
|
|
382
|
+
print("mark: empty mark", file=sys.stderr)
|
|
383
|
+
return 2
|
|
384
|
+
index = marks.index(choice)
|
|
385
|
+
# Keep the edited mark where it was; drop an older copy of the new text.
|
|
386
|
+
updated = [
|
|
387
|
+
text if i == index else mark
|
|
388
|
+
for i, mark in enumerate(marks)
|
|
389
|
+
if i == index or mark != text
|
|
390
|
+
]
|
|
391
|
+
if updated == marks:
|
|
392
|
+
return 0
|
|
393
|
+
write_marks(path, updated)
|
|
394
|
+
if sys.stderr.isatty():
|
|
395
|
+
print(f"\u2713 updated {text}", file=sys.stderr)
|
|
396
|
+
return 0
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
def _no_marks() -> int:
|
|
400
|
+
print("mark: no marks yet - add one with: mark <text>", file=sys.stderr)
|
|
401
|
+
return 1
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mark-stash
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A tiny one-line note list with an fzf picker and clipboard copy
|
|
5
|
+
Author-email: neo <qqiwei@users.noreply.github.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/qqiwei/mark
|
|
8
|
+
Project-URL: Repository, https://github.com/qqiwei/mark
|
|
9
|
+
Project-URL: Issues, https://github.com/qqiwei/mark/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/qqiwei/mark/commits/main
|
|
11
|
+
Keywords: notes,clipboard,fzf,cli,productivity
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
14
|
+
Classifier: Operating System :: MacOS
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Topic :: Utilities
|
|
23
|
+
Requires-Python: >=3.11
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: build>=1.0; extra == "dev"
|
|
28
|
+
Requires-Dist: twine>=5.0; extra == "dev"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# mark
|
|
32
|
+
|
|
33
|
+
**English** | [简体中文](README.zh-CN.md)
|
|
34
|
+
|
|
35
|
+
A tiny command-line "note here" list: record one-line snippets with
|
|
36
|
+
`mark <text>`, then run `mark` with no arguments to fuzzy-pick one and copy it
|
|
37
|
+
to the clipboard. No database, no dependencies — just a plain text file and
|
|
38
|
+
[`fzf`](https://github.com/junegunn/fzf).
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
$ mark https://example.com/read-later
|
|
42
|
+
$ mark ask Alice about the invoice
|
|
43
|
+
$ mark
|
|
44
|
+
> ask Alice about the invoice # fzf opens, type a few letters
|
|
45
|
+
ask Alice about the invoice # Enter: copied to the clipboard
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Why
|
|
49
|
+
|
|
50
|
+
Sometimes you just need to park a URL, an address, an ID or a sentence for a
|
|
51
|
+
minute. `mark` keeps that list one keystroke away and copies the chosen line,
|
|
52
|
+
so it can be pasted anywhere.
|
|
53
|
+
|
|
54
|
+
## Requirements
|
|
55
|
+
|
|
56
|
+
- Python 3.11+
|
|
57
|
+
- `fzf` for the fuzzy picker (optional — without it you get a numbered list)
|
|
58
|
+
- a clipboard tool: `pbcopy` on macOS, `wl-copy` / `xclip` / `xsel` on Linux,
|
|
59
|
+
`clip` on Windows. If none is found the chosen mark is simply printed.
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
The PyPI distribution is `mark-stash`; the command is still `mark`:
|
|
64
|
+
|
|
65
|
+
```sh
|
|
66
|
+
pipx install mark-stash # recommended: isolated environment
|
|
67
|
+
uv tool install mark-stash
|
|
68
|
+
pip install --user mark-stash
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Upgrade / uninstall (your list is kept):
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
pipx upgrade mark-stash
|
|
75
|
+
pipx uninstall mark-stash
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
From a source checkout:
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
git clone git@github.com:qqiwei/mark.git
|
|
82
|
+
cd mark
|
|
83
|
+
pipx install --editable . # live edits, command available as `mark`
|
|
84
|
+
# or run it without installing:
|
|
85
|
+
./mark --version
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Usage
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
mark buy milk, eggs # record a line
|
|
92
|
+
mark "https://example.com" # quote spaces and shell characters
|
|
93
|
+
mark # fuzzy-pick and copy (Enter), cancel with Esc
|
|
94
|
+
mark -l # list marks, newest first
|
|
95
|
+
mark -d # delete repeatedly; Esc quits
|
|
96
|
+
mark -m # pick a mark and edit it; Enter saves, Esc cancels
|
|
97
|
+
mark --path # print where the mark file lives
|
|
98
|
+
mark -- -l # record a line that starts with a dash
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Notes:
|
|
102
|
+
|
|
103
|
+
- Arguments are joined with single spaces: `mark buy milk` records `buy milk`.
|
|
104
|
+
- A newline inside one argument becomes several marks:
|
|
105
|
+
`mark "$(pbpaste)"` records each pasted line separately.
|
|
106
|
+
- Recording an existing line moves it to the newest position instead of
|
|
107
|
+
creating a duplicate.
|
|
108
|
+
- `mark -d` stays open after each deletion (and keeps the current fzf query),
|
|
109
|
+
so several marks can be removed in a row; press Esc to stop. If the list
|
|
110
|
+
becomes empty it exits by itself.
|
|
111
|
+
- `mark -m` picks a line the same way, then re-opens fzf with that text
|
|
112
|
+
pre-filled in the prompt: edit it in place, press Enter to save, or Esc to
|
|
113
|
+
cancel. Editing a line into text that already exists drops the older
|
|
114
|
+
duplicate; an empty line is rejected and nothing changes.
|
|
115
|
+
- When `mark` is cancelled (Esc / Ctrl-C) it exits with status 130.
|
|
116
|
+
- Running `mark` with no arguments and an empty list prints a hint and exits 1.
|
|
117
|
+
|
|
118
|
+
## Storage
|
|
119
|
+
|
|
120
|
+
One mark per line, UTF-8, newest last. The file is created with mode `0600`
|
|
121
|
+
and lives outside the repository:
|
|
122
|
+
|
|
123
|
+
| Platform | Default path |
|
|
124
|
+
| --- | --- |
|
|
125
|
+
| macOS | `~/Library/Application Support/mark/marks.txt` |
|
|
126
|
+
| Linux / others | `$XDG_DATA_HOME/mark/marks.txt` (usually `~/.local/share/mark/marks.txt`) |
|
|
127
|
+
|
|
128
|
+
Because it is a plain text file you can edit it by hand, `grep` it, or sync it
|
|
129
|
+
with your notes. The repository ignores `*.txt`, so it can never be committed
|
|
130
|
+
by accident.
|
|
131
|
+
|
|
132
|
+
### Environment variables
|
|
133
|
+
|
|
134
|
+
| Variable | Meaning |
|
|
135
|
+
| --- | --- |
|
|
136
|
+
| `MARK_FILE` | Use another mark file (`~` is expanded) |
|
|
137
|
+
| `MARK_FZF` | Path or name of the picker to run instead of `fzf` |
|
|
138
|
+
| `MARK_PROMPT` | Picker prompt (default `mark> `) |
|
|
139
|
+
|
|
140
|
+
## Development
|
|
141
|
+
|
|
142
|
+
```sh
|
|
143
|
+
git clone git@github.com:qqiwei/mark.git
|
|
144
|
+
cd mark
|
|
145
|
+
pipx install --editable .
|
|
146
|
+
python3 -m unittest discover -s tests -v
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Layout:
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
mark_cli/
|
|
153
|
+
__init__.py version lookup
|
|
154
|
+
__main__.py python -m mark_cli
|
|
155
|
+
cli.py storage, picker, clipboard and the argparse entry point
|
|
156
|
+
mark source launcher (adds the repo root to sys.path)
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
The tests set `MARK_FILE` to a temporary file, so they never touch your list.
|
|
160
|
+
|
|
161
|
+
## Uninstall
|
|
162
|
+
|
|
163
|
+
```sh
|
|
164
|
+
pipx uninstall mark-stash
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Optionally delete the list too:
|
|
168
|
+
|
|
169
|
+
```sh
|
|
170
|
+
rm -r ~/Library/Application\ Support/mark # macOS
|
|
171
|
+
rm -r ~/.local/share/mark # Linux
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Releasing
|
|
175
|
+
|
|
176
|
+
The version lives in `pyproject.toml` (with a fallback in
|
|
177
|
+
`mark_cli/__init__.py`). Push a `v*` tag and the workflow runs the tests,
|
|
178
|
+
builds the sdist/wheel, checks the metadata and publishes with PyPI trusted
|
|
179
|
+
publishing (no API token needed):
|
|
180
|
+
|
|
181
|
+
```sh
|
|
182
|
+
git tag v0.1.0
|
|
183
|
+
git push origin main --tags
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Before the first release, add a pending publisher on PyPI: project
|
|
187
|
+
`mark-stash`, owner `qqiwei`, repository `mark`, workflow `publish.yml`,
|
|
188
|
+
environment `pypi`.
|
|
189
|
+
|
|
190
|
+
## License
|
|
191
|
+
|
|
192
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
mark_cli/__init__.py,sha256=TDYitTxV2h7mopB80p0cuAp2gCcfpSWm622CBel8KhE,307
|
|
2
|
+
mark_cli/__main__.py,sha256=5REv_NrZj_xNCj1tHs1OPd0kL9qP2Zhn656fg4oe4do,120
|
|
3
|
+
mark_cli/cli.py,sha256=vzLMlK69ZTIAPdIz08b6doqRnVB_PEyYBRk9B5abuE8,11633
|
|
4
|
+
mark_stash-0.1.0.dist-info/licenses/LICENSE,sha256=m00jXjsRiZddy_Hjyg4HtCFcPOMgxcNkE_aMUKnrZcc,1060
|
|
5
|
+
mark_stash-0.1.0.dist-info/METADATA,sha256=x9sZkBwmqC9VZAA-wlLgF3ZvL02Drg733tHgu301Qp0,6131
|
|
6
|
+
mark_stash-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
7
|
+
mark_stash-0.1.0.dist-info/entry_points.txt,sha256=thp_0jA2edBUJFFRGx984i1sbE4Mc_CIZ5pQNrxViiA,43
|
|
8
|
+
mark_stash-0.1.0.dist-info/top_level.txt,sha256=iD42mVCmopFw3YB2eZOb-W5vFLIwyBsBe4tMdYQoxEY,9
|
|
9
|
+
mark_stash-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 neo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mark_cli
|