Skip to content

Commit fd7c42f

Browse files
committed
Packaging
1 parent e5681a7 commit fd7c42f

File tree

8 files changed

+191
-84
lines changed

8 files changed

+191
-84
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.coverage*
2+
.mypy_cache/
3+
.nox/
4+
.tox/
5+
__pycache__/
6+
dist/
7+
docs/_build/

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2017-2018, 2020-2022 John Thorvald Wodder II
3+
Copyright (c) 2017-2018, 2020-2024 John Thorvald Wodder II
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

pyproject.toml

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "jwodder-ps1"
7+
dynamic = ["version"]
8+
description = "Yet another bash/zsh custom prompt script"
9+
readme = "README.rst"
10+
requires-python = ">=3.8"
11+
license = "MIT"
12+
license-files = { paths = ["LICENSE"] }
13+
authors = [
14+
{ name = "John Thorvald Wodder II", email = "[email protected]" }
15+
]
16+
17+
keywords = [
18+
###
19+
]
20+
21+
classifiers = [
22+
"Programming Language :: Python :: 3 :: Only",
23+
"Programming Language :: Python :: 3",
24+
"Programming Language :: Python :: 3.8",
25+
"Programming Language :: Python :: 3.9",
26+
"Programming Language :: Python :: 3.10",
27+
"Programming Language :: Python :: 3.11",
28+
"Programming Language :: Python :: 3.12",
29+
"Programming Language :: Python :: Implementation :: CPython",
30+
"Programming Language :: Python :: Implementation :: PyPy",
31+
"License :: OSI Approved :: MIT License",
32+
###
33+
"Typing :: Typed",
34+
]
35+
36+
dependencies = []
37+
38+
[project.scripts]
39+
jwodder-ps1 = "jwodder_ps1.__main__:main"
40+
41+
[project.urls]
42+
"Source Code" = "https://github.com/jwodder/ps1.py"
43+
"Bug Tracker" = "https://github.com/jwodder/ps1.py/issues"
44+
45+
[tool.hatch.version]
46+
path = "src/jwodder_ps1/__init__.py"
47+
48+
[tool.hatch.build.targets.sdist]
49+
include = [
50+
"/docs",
51+
"/src",
52+
"/test",
53+
"CHANGELOG.*",
54+
"CONTRIBUTORS.*",
55+
"tox.ini",
56+
]
57+
58+
[tool.hatch.envs.default]
59+
python = "3"
60+
61+
[tool.mypy]
62+
allow_incomplete_defs = false
63+
allow_untyped_defs = false
64+
ignore_missing_imports = false
65+
# <https://github.com/python/mypy/issues/7773>:
66+
no_implicit_optional = true
67+
implicit_reexport = false
68+
local_partial_types = true
69+
pretty = true
70+
show_error_codes = true
71+
show_traceback = true
72+
strict_equality = true
73+
warn_redundant_casts = true
74+
warn_return_any = true
75+
warn_unreachable = true

setup.cfg

-17
This file was deleted.

src/jwodder_ps1/__init__.py

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
"""
2+
Yet another bash/zsh prompt script
3+
4+
Here we have yet another script for Git-aware customization of the command
5+
prompt in Bash and zsh. Unlike all the other scripts, I wrote this one, so
6+
it's better.
7+
8+
Features:
9+
10+
- lets you know if you have mail in ``$MAIL``
11+
- shows chroot, `virtualenv <https://virtualenv.pypa.io>`_, and `Conda
12+
<https://conda.io>`_ environment prompt prefixes
13+
- automatically truncates the current directory path if it gets too long
14+
- shows the status of the current Git repository
15+
- thoroughly documented and easily customizable
16+
- supports both Bash and zsh
17+
- can optionally output just the Git status, in case you want to combine it
18+
with your own prompt string
19+
20+
Visit <https://github.com/jwodder/ps1.py> for more information.
21+
22+
23+
Installation & Setup
24+
====================
25+
26+
1. Save this script to your computer somewhere (I put my copy at
27+
``~/share/ps1.py``)
28+
29+
2. If using Bash, add the following line to the end of your ``~/.bashrc``:
30+
31+
.. code:: shell
32+
33+
PROMPT_COMMAND="$PROMPT_COMMAND"'; PS1="$(/usr/bin/python3 ~/share/ps1.py "${PS1_GIT:-}")"'
34+
35+
If using zsh, add the following to the end of your ``~/.zshrc``:
36+
37+
.. code:: shell
38+
39+
precmd_ps1_py() { PS1="$(/usr/bin/python3 ~/share/ps1.py --zsh "${PS1_GIT:-}")" }
40+
precmd_functions+=( precmd_ps1_py )
41+
42+
If you want to use just the Git status portion of the script's output and
43+
combine it with your own prompt string, replace the ``PS1`` assignment with
44+
your desired prompt, with ``$(/usr/bin/python3 ~/share/ps1.py --git-only
45+
"${PS1_GIT:-}")`` inserted where you want the Git status string.
46+
47+
Replace ``/usr/bin/python3`` with the path to your Python 3 interpreter, and
48+
replace ``~/share/ps1.py`` with the location you saved ``ps1.py`` at as
49+
appropriate.
50+
51+
3. Open a new shell
52+
53+
4. Enjoy!
54+
55+
5. If the Git integration causes you trouble (either because something breaks
56+
or just because it's taking too long to run), it can be temporarily disabled
57+
by running ``PS1_GIT=off`` on the command line.
58+
"""
59+
60+
__version__ = "0.6.0.dev1"
61+
__author__ = "John Thorvald Wodder II"
62+
__author_email__ = "[email protected]"
63+
__license__ = "MIT"
64+
__url__ = "https://github.com/jwodder/ps1.py"

ps1.py renamed to src/jwodder_ps1/__main__.py

+1-66
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,3 @@
1-
#!/usr/bin/python3
2-
"""
3-
Yet another bash/zsh prompt script
4-
5-
Here we have yet another script for Git-aware customization of the command
6-
prompt in Bash and zsh. Unlike all the other scripts, I wrote this one, so
7-
it's better.
8-
9-
Features:
10-
11-
- lets you know if you have mail in ``$MAIL``
12-
- shows chroot, `virtualenv <https://virtualenv.pypa.io>`_, and `Conda
13-
<https://conda.io>`_ environment prompt prefixes
14-
- automatically truncates the current directory path if it gets too long
15-
- shows the status of the current Git repository
16-
- thoroughly documented and easily customizable
17-
- supports both Bash and zsh
18-
- can optionally output just the Git status, in case you want to combine it
19-
with your own prompt string
20-
21-
Visit <https://github.com/jwodder/ps1.py> for more information.
22-
23-
24-
Installation & Setup
25-
====================
26-
27-
1. Save this script to your computer somewhere (I put my copy at
28-
``~/share/ps1.py``)
29-
30-
2. If using Bash, add the following line to the end of your ``~/.bashrc``:
31-
32-
.. code:: shell
33-
34-
PROMPT_COMMAND="$PROMPT_COMMAND"'; PS1="$(/usr/bin/python3 ~/share/ps1.py "${PS1_GIT:-}")"'
35-
36-
If using zsh, add the following to the end of your ``~/.zshrc``:
37-
38-
.. code:: shell
39-
40-
precmd_ps1_py() { PS1="$(/usr/bin/python3 ~/share/ps1.py --zsh "${PS1_GIT:-}")" }
41-
precmd_functions+=( precmd_ps1_py )
42-
43-
If you want to use just the Git status portion of the script's output and
44-
combine it with your own prompt string, replace the ``PS1`` assignment with
45-
your desired prompt, with ``$(/usr/bin/python3 ~/share/ps1.py --git-only
46-
"${PS1_GIT:-}")`` inserted where you want the Git status string.
47-
48-
Replace ``/usr/bin/python3`` with the path to your Python 3 interpreter, and
49-
replace ``~/share/ps1.py`` with the location you saved ``ps1.py`` at as
50-
appropriate.
51-
52-
3. Open a new shell
53-
54-
4. Enjoy!
55-
56-
5. If the Git integration causes you trouble (either because something breaks
57-
or just because it's taking too long to run), it can be temporarily disabled
58-
by running ``PS1_GIT=off`` on the command line.
59-
"""
60-
61-
__version__ = "0.5.0"
62-
__author__ = "John T. Wodder II"
63-
__author_email__ = "[email protected]"
64-
__license__ = "MIT"
65-
__url__ = "https://github.com/jwodder/ps1.py"
66-
671
import argparse
682
from ast import literal_eval
693
from enum import Enum
@@ -80,6 +14,7 @@
8014
run,
8115
)
8216
from types import SimpleNamespace
17+
from . import __url__, __version__
8318

8419
#: Default maximum display length of the path to the current working directory
8520
MAX_CWD_LEN = 30

src/jwodder_ps1/py.typed

Whitespace-only changes.

tox.ini

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[tox]
2+
envlist = lint,typing
3+
skip_missing_interpreters = True
4+
isolated_build = True
5+
minversion = 3.3.0
6+
7+
[testenv:lint]
8+
skip_install = True
9+
deps =
10+
flake8
11+
flake8-bugbear
12+
flake8-builtins
13+
flake8-unused-arguments
14+
commands =
15+
flake8 src
16+
17+
[testenv:typing]
18+
deps =
19+
mypy
20+
commands =
21+
mypy src
22+
23+
[flake8]
24+
doctests = True
25+
extend-exclude = build/,dist/,test/data,venv/
26+
max-doc-length = 100
27+
max-line-length = 80
28+
unused-arguments-ignore-stub-functions = True
29+
extend-select = B901,B902,B950
30+
ignore = A003,A005,B005,E203,E262,E266,E501,E704,U101,W503
31+
32+
per-file-ignores =
33+
src/jwodder_ps1/__init__.py:B950
34+
35+
[isort]
36+
atomic = True
37+
force_sort_within_sections = True
38+
honor_noqa = True
39+
lines_between_sections = 0
40+
profile = black
41+
reverse_relative = True
42+
sort_relative_in_force_sorted_sections = True
43+
src_paths = src

0 commit comments

Comments
 (0)