Compare commits

..

No commits in common. "d49ba30b3510908dc8c997f3860fa74d32a0e925" and "842daf7924fae4a139b621e459c30cb9af5e2947" have entirely different histories.

2 changed files with 4 additions and 12 deletions

View file

@ -15,8 +15,7 @@ set an env variable for $EDITOR and/or $VISUAL in .bashrc
export EDITOR=vi
export VISUAL=geany
## Usage:
## Usage
`skratch` creates a random file in .skratch and opens it in the EDITOR
`<filename>` opens or creates a file with a specific name in ~/.skratch
@ -25,6 +24,4 @@ set an env variable for $EDITOR and/or $VISUAL in .bashrc
`-l` lists files in ~/.skratch
`-s` adds a suffix to the file
`-v` uses the VISUAL editor

View file

@ -39,11 +39,11 @@ def get_editor(use_v):
return v
return e
def run(editor, sk_path, filename=None, f_suffix=""):
def run(editor, sk_path, filename=None):
if not filename:
t = time.localtime()
filename = f"skratch-{t.tm_year}-{t.tm_mon}-{t.tm_mday}-"
fd, fp = tempfile.mkstemp(prefix=filename, dir=sk_path, suffix=f_suffix)
fd, fp = tempfile.mkstemp(prefix=filename, dir=sk_path)
os.close(fd)
else:
fp = os.path.join(sk_path, filename)
@ -77,11 +77,6 @@ def main():
help="list files",
action="store_true")
group.add_argument(
"-s",
help="add suffix",
action="store")
parser.add_argument(
"-v",
help="visual editor",
@ -92,6 +87,6 @@ def main():
editor = get_editor(args.v)
if args.c: delete_all(sk_path)
elif args.l: list_all(sk_path)
else: run(editor,sk_path, args.filename, args.s)
else: run(editor,sk_path, args.filename)
main()