twd-m4sc0 2.0.1__py3-none-any.whl → 2.0.3__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.
twd/twd.py CHANGED
@@ -18,6 +18,7 @@ CONFIG_FILE = os.path.join(TWD_DIR, "config")
18
18
  DEFAULT_CONFIG = {
19
19
  "data_file": os.path.expanduser("~/.twd/data"),
20
20
  "output_behaviour": 2,
21
+ "clear_after_screen": False,
21
22
  "log_file": os.path.expanduser("~/.twd/log"),
22
23
  "error_file": os.path.expanduser("~/.twd/error"),
23
24
  "log_format": "%(asctime)s - %(levelname)s - %(message)s",
@@ -92,18 +93,24 @@ def validate_alias(alias):
92
93
  def output_handler(
93
94
  message=None, path=None, output=True, simple_output=False, message_type=0
94
95
  ):
95
- log.info(f"Type: {message_type}, Msg: {message or path}")
96
+ log.info(message or path)
96
97
 
97
98
  if CONFIG["output_behaviour"] == 1 or simple_output:
98
99
  if path:
99
100
  with open("/tmp/twd_path", "w") as f:
100
101
  f.write(path)
102
+ if CONFIG["clear_after_screen"]:
103
+ with open("/tmp/twd_clear", "w") as f:
104
+ f.write(path)
101
105
  if output:
102
106
  print(path)
103
107
  elif CONFIG["output_behaviour"] == 2:
104
108
  if path:
105
109
  with open("/tmp/twd_path", "w") as f:
106
110
  f.write(path)
111
+ if CONFIG["clear_after_screen"]:
112
+ with open("/tmp/twd_clear", "w") as f:
113
+ f.write(path)
107
114
  if output:
108
115
  print(message)
109
116
 
@@ -248,6 +255,16 @@ This feature is to prevent accidental execution.""",
248
255
  output_handler("TWD File deleted and TWD unset", None, output, simple_output)
249
256
 
250
257
 
258
+ def setup(alias):
259
+ bashrc_path = os.path.expanduser("~/.bashrc")
260
+ alias = "twd" if not alias else alias
261
+ with open(bashrc_path, "a") as file:
262
+ file.write(f"\neval $(python3 -m twd --shell {alias})\n")
263
+ print("Please execute the following command to activate TWD:")
264
+ print("")
265
+ print(f"source {bashrc_path}")
266
+
267
+
251
268
  def get_package_version():
252
269
  try:
253
270
  return version("twd_m4sc0")
@@ -261,6 +278,10 @@ def main():
261
278
  description="Temporarily save and navigate to working directories."
262
279
  )
263
280
 
281
+ parser.add_argument(
282
+ "--setup", nargs="?", const="twd", help="Automatic setup in the .bashrc file"
283
+ )
284
+
264
285
  parser.add_argument("directory", nargs="?", help="Directory to save")
265
286
  parser.add_argument(
266
287
  "alias", nargs="?", help="Alias for the saved directory (optional)"
@@ -310,9 +331,17 @@ def main():
310
331
  cd "$(cat /tmp/twd_path)";
311
332
  /bin/rm -f /tmp/twd_path;
312
333
  fi;
334
+ if [ -f /tmp/twd_clear ]; then
335
+ clear;
336
+ /bin/rm -f /tmp/twd_clear;
337
+ fi;
313
338
  }}""")
314
339
  return 0
315
340
 
341
+ if args.setup:
342
+ setup(args.setup)
343
+ return 0
344
+
316
345
  directory = args.directory or args.dir
317
346
  alias = args.alias or args.ali
318
347
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: twd_m4sc0
3
- Version: 2.0.1
3
+ Version: 2.0.3
4
4
  Summary: A tool to temporarily save and go to a working directory
5
5
  Home-page: https://github.com/m4sc0/twd
6
6
  Author: m4sc0
@@ -11,12 +11,11 @@ Requires-Python: >=3.6
11
11
  Description-Content-Type: text/markdown
12
12
  License-File: LICENSE
13
13
 
14
-
15
14
  # twd-m4sc0
16
15
 
17
16
  `twd-m4sc0` is a command-line tool that allows you to temporarily save a working directory and easily navigate back to it. It's designed for developers and users who frequently need to switch between directories in the terminal.
18
17
 
19
- > All Versions `< v1.5` are considered deprecated and should not be used anymore because of the `config` file that was introduced in that version. This file is incompatible with newer versions and might cause issues or break the program.
18
+ > All Versions `< v1.5` are considered deprecated and should not be used anymore because of the `config` file that was introduced in that version. This file is incompatible with newer versions and might cause issues or break the program.
20
19
 
21
20
  ## Features
22
21
 
@@ -29,7 +28,7 @@ License-File: LICENSE
29
28
 
30
29
  ## Installation
31
30
 
32
- ### Installation using `pip`:
31
+ ### Installation using `pip`
33
32
 
34
33
  1. Install the package from the `pypi` repository:
35
34
 
@@ -37,19 +36,41 @@ License-File: LICENSE
37
36
  pip install twd-m4sc0
38
37
  ```
39
38
 
40
- 2. Add the following line to your `.bashrc` or `.zshrc` to set up the shell function:
39
+ 2. Ensure proper installation by checking the version
40
+
41
+ ```bash
42
+ python3 -m twd -v
43
+ ```
44
+
45
+ ### Setup using in-built commands
46
+
47
+ > This setup information is only recommend if you're system is using the `.bashrc` file provided by debian based systems and it's located at `~/.bashrc`. If you're unsure what you're shell configuration file is called or where it's located please refer to your official OS documentation to ensure proper functionality.
48
+
49
+ 1. Run the following command to activate the `twd` shell function
50
+
51
+ > Replace `[alias]` with an alias of your choice to customize the way you're calling the script and follow the given instructions
52
+
53
+ ```bash
54
+ python3 -m twd --setup [alias]
55
+ ```
56
+
57
+ ### Manual setup
41
58
 
42
- > Since 1.5.4 you can also set a different command for the `twd` program by replacing `[alias]` in the following code by your custom alias
59
+ 1. Add the following line to your shell configuration file:
43
60
 
44
61
  ```bash
45
62
  eval $(python3 -m twd --shell [alias])
46
63
  ```
47
64
 
48
- 3. Exit and reopen the terminal or reload using:
65
+ 2. Run the following command to apply the new configuration:
49
66
 
50
67
  ```bash
51
68
  source ~/.bashrc
52
- # or
69
+ ```
70
+
71
+ or
72
+
73
+ ```bash
53
74
  source ~/.zshrc
54
75
  ```
55
76
 
@@ -5,10 +5,10 @@ twd/__main__.py,sha256=gM_Py51pQFH3CXdDIuPzBW6eNlFH1UHeRAmgAPWQyik,61
5
5
  twd/crud.py,sha256=QTruLgK9aBorJ1VKpeBS-joeD1DZbK2JfQm9tl3v5Bc,3057
6
6
  twd/logger.py,sha256=WG-JBbkdizR2KMODGcxREj1N--CgY-PdIC_agyZ5PHU,1590
7
7
  twd/screen.py,sha256=vQFNtast5-P_XrdvbY7XyIx2MGoNR7TUoVHHkXUTbvc,7066
8
- twd/twd.py,sha256=m-wad_GY6plzaatBKatkd5vp4UTV_fjXdHJauzInPYQ,10488
9
- twd_m4sc0-2.0.1.dist-info/LICENSE,sha256=eQSDjcD_fvOwfjmrzxKJhtZsSI39seMawuvsgeD_dfw,1062
10
- twd_m4sc0-2.0.1.dist-info/METADATA,sha256=BhP5_39Pb76v64cvxgDrsbauBCB4MYO5tfQdigh5LJg,3528
11
- twd_m4sc0-2.0.1.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
12
- twd_m4sc0-2.0.1.dist-info/entry_points.txt,sha256=QfYDHHjipkVN4oalpACFmIeYHb7GQCJY4SC12bTsiQQ,37
13
- twd_m4sc0-2.0.1.dist-info/top_level.txt,sha256=PXToru2Yr2Xh3F_F-pHXtuOQVp5x7KKCPFf94P_VI5U,10
14
- twd_m4sc0-2.0.1.dist-info/RECORD,,
8
+ twd/twd.py,sha256=-YEu8JizOccuu3OeZzKecaRRelqzw-f92knG9shTJNM,11398
9
+ twd_m4sc0-2.0.3.dist-info/LICENSE,sha256=eQSDjcD_fvOwfjmrzxKJhtZsSI39seMawuvsgeD_dfw,1062
10
+ twd_m4sc0-2.0.3.dist-info/METADATA,sha256=FGQSzmNf6LcLOflPD7z6suetLy6-TOiw0YWy5lJryKs,4084
11
+ twd_m4sc0-2.0.3.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
12
+ twd_m4sc0-2.0.3.dist-info/entry_points.txt,sha256=QfYDHHjipkVN4oalpACFmIeYHb7GQCJY4SC12bTsiQQ,37
13
+ twd_m4sc0-2.0.3.dist-info/top_level.txt,sha256=PXToru2Yr2Xh3F_F-pHXtuOQVp5x7KKCPFf94P_VI5U,10
14
+ twd_m4sc0-2.0.3.dist-info/RECORD,,