twd-m4sc0 1.5.1__py3-none-any.whl → 1.5.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/logger.py ADDED
@@ -0,0 +1,47 @@
1
+ import os
2
+ import time
3
+
4
+
5
+ def format_message(message, config):
6
+ """Format the log message according to the provided config."""
7
+ result = config.get("log_format", "[$T]: $M")
8
+ result = result.replace("$T", time.strftime("%Y-%m-%d %H:%M:%S"))
9
+ result = result.replace("$M", message)
10
+ return result
11
+
12
+
13
+ def ensure_directory_exists(file_path):
14
+ """Ensure the directory for the given file path exists."""
15
+ directory = os.path.dirname(file_path)
16
+ if not os.path.exists(directory):
17
+ os.makedirs(directory, exist_ok=True)
18
+
19
+
20
+ def write_log(message, config):
21
+ """Write log message to the log file specified in the config."""
22
+ log_file = os.path.expanduser(config.get("log_file"))
23
+ log_file = os.path.abspath(log_file)
24
+ ensure_directory_exists(log_file) # Ensure the directory exists
25
+ with open(log_file, "a+") as f:
26
+ f.write(message + "\n")
27
+
28
+
29
+ def write_error(message, config):
30
+ """Write error message to the error file specified in the config."""
31
+ error_file = os.path.expanduser(config.get("error_file"))
32
+ error_file = os.path.abspath(error_file)
33
+ ensure_directory_exists(error_file) # Ensure the directory exists
34
+ with open(error_file, "a+") as f:
35
+ f.write(message + "\n")
36
+
37
+
38
+ def log(message, config):
39
+ """Log the message using the provided config."""
40
+ formatted_message = format_message(message, config)
41
+ write_log(formatted_message, config)
42
+
43
+
44
+ def error(message, config):
45
+ """Log the error using the provided config."""
46
+ formatted_message = format_message(message, config)
47
+ write_error(formatted_message, config)
twd/twd.py CHANGED
@@ -1,60 +1,102 @@
1
1
  import os
2
2
  import argparse
3
- import sys
4
3
  import json
5
4
  import hashlib
6
5
  import time
7
6
  import re
8
7
  from importlib.metadata import version, PackageNotFoundError
8
+ from .logger import log, error
9
9
 
10
10
  TWD_DIR = os.path.join(os.path.expanduser("~"), ".twd")
11
- CONFIG_FILE = os.path.join(TWD_DIR, 'config')
11
+ CONFIG_FILE = os.path.join(TWD_DIR, "config")
12
12
 
13
13
  DEFAULT_CONFIG = {
14
- "data_file": "~/.twd/data",
15
- "output_behaviour": 2
14
+ "data_file": os.path.expanduser("~/.twd/data"),
15
+ "output_behaviour": 2,
16
+ "log_file": os.path.expanduser("~/.twd/log"),
17
+ "error_file": os.path.expanduser("~/.twd/error"),
18
+ "log_format": "[$T]: $M",
16
19
  }
17
20
 
18
- os.makedirs(TWD_DIR, exist_ok=True)
21
+ # os.makedirs(TWD_DIR, exist_ok=True)
22
+
19
23
 
20
24
  def create_alias_id():
21
25
  data = str(time.time()) + str(os.urandom(16))
22
26
  return hashlib.sha256(data.encode()).hexdigest()[:12]
23
27
 
28
+
24
29
  def load_config():
25
30
  if not os.path.exists(CONFIG_FILE):
26
- with open(CONFIG_FILE, 'w') as file:
31
+ with open(CONFIG_FILE, "w") as file:
27
32
  json.dump(DEFAULT_CONFIG, file, indent=4)
28
33
  return DEFAULT_CONFIG
29
34
  else:
30
- with open(CONFIG_FILE, 'r') as file:
35
+ with open(CONFIG_FILE, "r") as file:
31
36
  try:
32
37
  return json.load(file)
33
38
  except json.JSONDecodeError as e:
34
- print(f"Error loading config: {e}")
39
+ error(f"Error loading config: {e}", DEFAULT_CONFIG)
35
40
  return DEFAULT_CONFIG
36
41
 
42
+
37
43
  CONFIG = load_config()
38
44
 
39
45
  TWD_FILE = os.path.expanduser(CONFIG.get("data_file", "~/.twd/data"))
40
46
 
47
+
41
48
  def ensure_data_file_exists():
42
49
  if not os.path.exists(TWD_FILE):
43
- with open(TWD_FILE, 'w') as f:
44
- json.dump({}, f)
50
+ try:
51
+ with open(TWD_FILE, "w") as f:
52
+ json.dump({}, f)
53
+ except OSError as e:
54
+ error(f"Error creating data file: {e}", CONFIG)
55
+
56
+ log_file = os.path.expanduser(CONFIG.get("log_file"))
57
+ error_file = os.path.expanduser(CONFIG.get("error_file"))
58
+
59
+ if not os.path.exists(log_file):
60
+ try:
61
+ with open(log_file, "w+") as f:
62
+ f.write("")
63
+ except OSError as e:
64
+ error(f"Error creating log file: {e}", CONFIG)
65
+
66
+ if not os.path.exists(error_file):
67
+ try:
68
+ with open(error_file, "w+") as f:
69
+ f.write("")
70
+ except OSError as e:
71
+ error(f"Error creating error file: {e}", CONFIG)
72
+
45
73
 
46
74
  ensure_data_file_exists()
47
75
 
76
+
48
77
  def get_absolute_path(path):
49
- return os.path.abspath(path)
78
+ try:
79
+ return os.path.abspath(path)
80
+ except Exception as e:
81
+ error(f"Error getting absolute path for {path}: {e}", CONFIG)
82
+ raise
83
+
50
84
 
51
85
  def validate_alias(alias):
52
86
  """Ensure the alias contains only valid characters."""
53
- if not re.match(r'^[\w-]+$', alias):
54
- raise ValueError(f"Invalid alias: '{alias}'. Aliases can only contain alphanumeric characters, dashes, and underscores.")
87
+ if not re.match(r"^[\w-]+$", alias):
88
+ error(f"Invalid alias provided: {alias}", CONFIG)
89
+ raise ValueError(
90
+ f"Invalid alias: '{alias}'. Aliases can only contain alphanumeric characters, dashes, and underscores."
91
+ )
55
92
  return alias
56
93
 
57
- def output_handler(message=None, path=None, output=True, simple_output=False, message_type=0):
94
+
95
+ def output_handler(
96
+ message=None, path=None, output=True, simple_output=False, message_type=0
97
+ ):
98
+ log(f"Type: {message_type}, Msg: {message or path}", CONFIG)
99
+
58
100
  if not output or CONFIG["output_behaviour"] == 0:
59
101
  return
60
102
 
@@ -69,6 +111,7 @@ def output_handler(message=None, path=None, output=True, simple_output=False, me
69
111
  elif not simple_output and message:
70
112
  print(f"0;{message}")
71
113
 
114
+
72
115
  def save_directory(path=None, alias=None, output=True, simple_output=False):
73
116
  if path is None:
74
117
  path = os.getcwd()
@@ -79,49 +122,72 @@ def save_directory(path=None, alias=None, output=True, simple_output=False):
79
122
  alias = validate_alias(alias)
80
123
 
81
124
  try:
82
- with open(TWD_FILE, 'r') as f:
125
+ with open(TWD_FILE, "r") as f:
83
126
  data = json.load(f)
84
- except json.JSONDecodeError:
127
+ except json.JSONDecodeError as e:
128
+ error(f"Error reading TWD file: {e}", CONFIG)
85
129
  data = {}
86
130
 
87
131
  alias_id = create_alias_id()
88
132
  data[alias_id] = {
89
133
  "path": path,
90
134
  "alias": alias if alias else alias_id,
91
- "created_at": time.time()
135
+ "created_at": time.time(),
92
136
  }
93
137
 
94
- with open(TWD_FILE, 'w') as f:
95
- json.dump(data, f, indent=4)
138
+ try:
139
+ with open(TWD_FILE, "w") as f:
140
+ json.dump(data, f, indent=4)
141
+ except OSError as e:
142
+ error(f"Error writing to TWD file: {e}", CONFIG)
143
+ raise
144
+
145
+ output_handler(
146
+ f"Saved TWD to {path} with alias '{alias or alias_id}'",
147
+ path,
148
+ output,
149
+ simple_output,
150
+ )
96
151
 
97
- output_handler(f"Saved TWD to {path} with alias '{alias or alias_id}'", path, output, simple_output)
98
152
 
99
153
  def load_directory():
100
154
  if not os.path.exists(TWD_FILE):
101
155
  return None
102
-
103
- with open(TWD_FILE, "r") as f:
104
- try:
156
+
157
+ try:
158
+ with open(TWD_FILE, "r") as f:
105
159
  return json.load(f)
106
- except json.JSONDecodeError:
107
- return None
160
+ except json.JSONDecodeError as e:
161
+ error(f"Error loading TWD file: {e}", CONFIG)
162
+ return None
163
+
108
164
 
109
- def go_to_directory(output=True, simple_output=False):
165
+ def go_to_directory(alias=None, output=True, simple_output=False):
110
166
  dirs = load_directory()
111
167
 
112
168
  if not dirs:
113
169
  output_handler("No TWD found", None, output, simple_output)
114
170
  return 1
115
171
  else:
116
- last_alias, last_entry = list(dirs.items())[-1]
117
- TWD = last_entry['path']
172
+ for entry_id, entry in dirs.items():
173
+ if "alias" in entry and entry["alias"] and entry["alias"] == alias:
174
+ TWD = entry["path"]
175
+
176
+ if os.path.exists(TWD):
177
+ output_handler(
178
+ f"cd {TWD}", TWD, output, simple_output, message_type=1
179
+ )
180
+ return 0
181
+ else:
182
+ error(f"Directory does not exist: {TWD}", CONFIG)
183
+ output_handler(
184
+ f"Directory does not exist: {TWD}", None, output, simple_output
185
+ )
186
+ return 1
187
+
188
+ output_handler("No TWD with alias found", None, output, simple_output)
189
+ return 1
118
190
 
119
- if os.path.exists(TWD):
120
- output_handler(f"cd {TWD}", TWD, output, simple_output, message_type=1)
121
- return 0
122
- else:
123
- output_handler(f"Directory does not exist: {TWD}", None, output, simple_output)
124
- return 1
125
191
 
126
192
  def show_directory(output=True, simple_output=False):
127
193
  dirs = load_directory()
@@ -130,20 +196,27 @@ def show_directory(output=True, simple_output=False):
130
196
  output_handler("No TWD set", None, output, simple_output)
131
197
  return
132
198
 
133
- max_alias_len = max(len(entry['alias']) for entry in dirs.values()) if dirs else 0
199
+ max_alias_len = max(len(entry["alias"]) for entry in dirs.values()) if dirs else 0
134
200
  max_id_len = max(len(alias_id) for alias_id in dirs.keys()) if dirs else 0
135
- max_path_len = max(len(entry['path']) for entry in dirs.values()) if dirs else 0
201
+ max_path_len = max(len(entry["path"]) for entry in dirs.values()) if dirs else 0
136
202
 
137
203
  header = f"{'Alias'.ljust(max_alias_len)} {'ID'.ljust(max_id_len)} {'Path'.ljust(max_path_len)} Created At"
138
204
  print(header)
139
205
  print("-" * len(header))
140
206
 
141
207
  for alias_id, entry in dirs.items():
142
- alias = entry['alias'].ljust(max_alias_len)
143
- path = entry['path'].ljust(max_path_len)
144
- created_at = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(entry['created_at']))
208
+ alias = entry["alias"].ljust(max_alias_len)
209
+ path = entry["path"].ljust(max_path_len)
210
+ created_at = time.strftime(
211
+ "%Y-%m-%d %H:%M:%S", time.localtime(entry["created_at"])
212
+ )
145
213
  alias_id_str = alias_id.ljust(max_id_len)
146
- output_handler(f"{alias} {alias_id_str} {path} {created_at}", None, output, simple_output)
214
+ output_handler(
215
+ f"{alias} {alias_id_str} {path} {created_at}",
216
+ None,
217
+ output,
218
+ simple_output,
219
+ )
147
220
 
148
221
 
149
222
  def unset_directory(output=True, simple_output=False, force=False):
@@ -151,48 +224,89 @@ def unset_directory(output=True, simple_output=False, force=False):
151
224
  output_handler(f"No TWD file found", None, output, simple_output)
152
225
  else:
153
226
  if not force:
154
- output_handler(r'''If you want to execute deleting and therefore unsetting all set TWD's, please use "--force" or "-f" and run again.
227
+ output_handler(
228
+ r"""If you want to execute deleting and therefore unsetting all set TWD's, please use "--force" or "-f" and run again.
155
229
 
156
230
 
157
- This feature is to prevent accidental execution.''', None, True, False)
231
+ This feature is to prevent accidental execution.""",
232
+ None,
233
+ True,
234
+ False,
235
+ )
158
236
  return
159
- os.remove(TWD_FILE)
237
+ try:
238
+ os.remove(TWD_FILE)
239
+ except OSError as e:
240
+ error(f"Error deleting TWD file: {e}", CONFIG)
241
+ raise
160
242
  output_handler(f"TWD File deleted and TWD unset", None, output, simple_output)
161
243
 
244
+
162
245
  def get_package_version():
163
246
  try:
164
247
  return version("twd_m4sc0")
165
- except PackageNotFoundError:
248
+ except PackageNotFoundError as e:
249
+ error(f"Package version not found: {e}", CONFIG)
166
250
  return "Unknown version"
167
251
 
252
+
168
253
  def main():
169
254
  global TWD_FILE
170
255
 
171
- parser = argparse.ArgumentParser(description="Temporarily save and navigate to working directories.")
256
+ parser = argparse.ArgumentParser(
257
+ description="Temporarily save and navigate to working directories."
258
+ )
172
259
 
173
260
  # Positional arguments
174
- parser.add_argument('directory', nargs='?', help="Directory to save")
175
- parser.add_argument('alias', nargs='?', help="Alias for the saved directory (optional)")
261
+ parser.add_argument("directory", nargs="?", help="Directory to save")
262
+ parser.add_argument(
263
+ "alias", nargs="?", help="Alias for the saved directory (optional)"
264
+ )
176
265
 
177
266
  # Optional Arguments/Flags
178
- parser.add_argument('-s', '--save', action='store_true', help="Save the current or specified directory")
179
- parser.add_argument('-d', '--directory', help="Directory to save")
180
- parser.add_argument('-a', '--alias', help="Alias for the saved directory")
181
- parser.add_argument('-g', '--go', action='store_true', help="Go to the saved directory")
182
- parser.add_argument('-l', '--list', action='store_true', help="Show saved TWD")
183
- parser.add_argument('-u', '--unset', action='store_true', help="Unset the saved TWD")
184
- parser.add_argument('-v', '--version', action='version', version=f'TWD Version: {get_package_version()}', help='Show the current version of TWD installed')
185
- parser.add_argument('-f', '--force', action='store_true', help="Force an action")
186
- parser.add_argument('--shell', action='store_true', help="Output shell function for integration")
187
- parser.add_argument('--simple-output', action='store_true', help="Only print essential output (new directory, absolute path, etc.)")
188
- parser.add_argument('--no-output', action='store_true', help="Prevents the console from sending output")
267
+ parser.add_argument(
268
+ "-s",
269
+ "--save",
270
+ action="store_true",
271
+ help="Save the current or specified directory",
272
+ )
273
+ parser.add_argument("-d", "--dir", nargs="?", help="Directory to save")
274
+ parser.add_argument("-a", "--ali", nargs="?", help="Alias for the saved directory")
275
+ parser.add_argument(
276
+ "-g", "--go", nargs="?", const=None, help="Go to the saved directory"
277
+ )
278
+ parser.add_argument("-l", "--list", action="store_true", help="Show saved TWD")
279
+ parser.add_argument(
280
+ "-u", "--unset", action="store_true", help="Unset the saved TWD"
281
+ )
282
+ parser.add_argument(
283
+ "-v",
284
+ "--version",
285
+ action="version",
286
+ version=f"TWD Version: {get_package_version()}",
287
+ help="Show the current version of TWD installed",
288
+ )
289
+ parser.add_argument("-f", "--force", action="store_true", help="Force an action")
290
+ parser.add_argument(
291
+ "--shell", action="store_true", help="Output shell function for integration"
292
+ )
293
+ parser.add_argument(
294
+ "--simple-output",
295
+ action="store_true",
296
+ help="Only print essential output (new directory, absolute path, etc.)",
297
+ )
298
+ parser.add_argument(
299
+ "--no-output",
300
+ action="store_true",
301
+ help="Prevents the console from sending output",
302
+ )
189
303
  args = parser.parse_args()
190
304
 
191
305
  output = not args.no_output
192
306
  simple_output = args.simple_output
193
307
 
194
308
  if args.shell:
195
- print(r'''
309
+ print(r"""
196
310
  function twd() {
197
311
  output=$(python3 -m twd "$@");
198
312
  while IFS= read -r line; do
@@ -208,21 +322,22 @@ def main():
208
322
  fi;
209
323
  done <<< "$output";
210
324
  }
211
- ''')
325
+ """)
212
326
  return 0
213
327
 
214
- directory = args.directory or args.directory
215
- alias = args.alias or args.alias
328
+ directory = args.directory or args.dir
329
+ alias = args.alias or args.ali
216
330
 
217
331
  if args.save:
218
332
  if not directory:
219
333
  directory = args.directory or os.getcwd()
220
334
 
221
- alias = args.alias or args.alias
335
+ alias = args.alias or args.ali
222
336
 
223
337
  save_directory(directory, alias, output, simple_output)
224
338
  elif args.go:
225
- return go_to_directory(output, simple_output)
339
+ alias = args.go
340
+ return go_to_directory(alias, output, simple_output)
226
341
  elif args.list:
227
342
  show_directory(output, simple_output)
228
343
  elif args.unset:
@@ -231,6 +346,3 @@ def main():
231
346
  else:
232
347
  parser.print_help()
233
348
  return 1
234
-
235
- if __name__ == "__main__":
236
- sys.exit(main())
@@ -0,0 +1,153 @@
1
+ Metadata-Version: 2.1
2
+ Name: twd_m4sc0
3
+ Version: 1.5.3
4
+ Summary: A tool to temporarily save and go to a working directory
5
+ Home-page: https://github.com/m4sc0/twd
6
+ Author: m4sc0
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.6
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+
14
+
15
+ # twd-m4sc0
16
+
17
+ `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
+
19
+ ## Features
20
+
21
+ - Save the current or specified working directory.
22
+ - Go back to a saved directory using an optional alias.
23
+ - List all saved directories with metadata.
24
+ - Unset and delete saved directories.
25
+ - Integrates with your shell for seamless directory management.
26
+
27
+ ## Installation
28
+
29
+ ### Installation using `pip`:
30
+
31
+ 1. Install the package from the `pypi` repository:
32
+
33
+ ```bash
34
+ pip install twd-m4sc0
35
+ ```
36
+
37
+ 2. Add the following line to your `.bashrc` or `.zshrc` to set up the shell function:
38
+
39
+ ```bash
40
+ eval $(python3 -m twd --shell)
41
+ ```
42
+
43
+ 3. Exit and reopen the terminal or reload using:
44
+
45
+ ```bash
46
+ source ~/.bashrc
47
+ # or
48
+ source ~/.zshrc
49
+ ```
50
+
51
+ ## Usage
52
+
53
+ ### Save a directory
54
+
55
+ - Save the current directory or a specified directory:
56
+
57
+ ```bash
58
+ twd -s [path] [alias]
59
+ ```
60
+
61
+ If no path is specified, the current directory is saved. The alias is optional, and if not provided, an auto-generated ID will be used.
62
+
63
+ ### Go to a saved directory
64
+
65
+ - Navigate to a saved directory using an optional alias:
66
+
67
+ ```bash
68
+ twd -g [alias]
69
+ ```
70
+
71
+ If no alias is provided, the most recently saved directory will be used. If an alias is provided, it will navigate to the directory associated with that alias.
72
+
73
+ ### List saved directories
74
+
75
+ - Display a list of all saved directories:
76
+
77
+ ```bash
78
+ twd -l
79
+ ```
80
+
81
+ ### Unset the TWD and delete the data file
82
+
83
+ - Unset and delete the saved directories:
84
+
85
+ ```bash
86
+ twd -u
87
+ ```
88
+
89
+ You can force this action using the `--force` flag to avoid accidental execution.
90
+
91
+ ```bash
92
+ twd -u --force
93
+ ```
94
+
95
+ ### Optional Parameters
96
+
97
+ #### Simple Output
98
+
99
+ For cleaner, minimal output intended for scripting or piping.
100
+
101
+ - Example with `--simple-output`:
102
+
103
+ ```bash
104
+ twd -s --simple-output
105
+ /home/user/.config
106
+ ```
107
+
108
+ - Example without `--simple-output`:
109
+
110
+ ```bash
111
+ Saved TWD to /home/user/.config
112
+ ```
113
+
114
+ #### No Output
115
+
116
+ Suppresses all output (including confirmation messages).
117
+
118
+ - Example with `--no-output`:
119
+
120
+ ```bash
121
+ twd -s --no-output
122
+ # No output
123
+ ```
124
+
125
+ #### Force
126
+
127
+ Use the `--force` flag to force certain actions, such as when unsetting directories with the `-u` flag.
128
+
129
+ - Example:
130
+
131
+ ```bash
132
+ twd -u --force
133
+ TWD File deleted and TWD unset
134
+ ```
135
+
136
+ ## Contribution
137
+
138
+ To set up a development environment:
139
+
140
+ 1. Clone the repository:
141
+
142
+ ```bash
143
+ git clone https://github.com/m4sc0/twd
144
+ cd twd
145
+ ```
146
+
147
+ 2. Install the package in editable mode using `pip`:
148
+
149
+ ```bash
150
+ pip install -e .
151
+ ```
152
+
153
+ 3. Make your changes, and contribute!
@@ -0,0 +1,12 @@
1
+ tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ tests/test_twd.py,sha256=XrxOo99oqida_7qZ48pA6BCazZekDmG5syw9NvjZWDU,484
3
+ twd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ twd/__main__.py,sha256=gM_Py51pQFH3CXdDIuPzBW6eNlFH1UHeRAmgAPWQyik,61
5
+ twd/logger.py,sha256=Pmhh4sOB-HyJAVBSwiESGRJElJoJ4Anhn-HVF8vxXzY,1595
6
+ twd/twd.py,sha256=rxJfgwCxIe9_FJoIqW6YVxDexJ0cQLZwgpt29yo18Ac,10329
7
+ twd_m4sc0-1.5.3.dist-info/LICENSE,sha256=eQSDjcD_fvOwfjmrzxKJhtZsSI39seMawuvsgeD_dfw,1062
8
+ twd_m4sc0-1.5.3.dist-info/METADATA,sha256=_pAPojkgAayJcfM1_35OtAOJIsZYihiR9anNp5TCecg,3009
9
+ twd_m4sc0-1.5.3.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
10
+ twd_m4sc0-1.5.3.dist-info/entry_points.txt,sha256=QfYDHHjipkVN4oalpACFmIeYHb7GQCJY4SC12bTsiQQ,37
11
+ twd_m4sc0-1.5.3.dist-info/top_level.txt,sha256=PXToru2Yr2Xh3F_F-pHXtuOQVp5x7KKCPFf94P_VI5U,10
12
+ twd_m4sc0-1.5.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.1.0)
2
+ Generator: setuptools (75.2.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,141 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: twd_m4sc0
3
- Version: 1.5.1
4
- Summary: A tool to temporarily save and go to a working directory
5
- Home-page: https://github.com/m4sc0/twd
6
- Author: m4sc0
7
- Classifier: Programming Language :: Python :: 3
8
- Classifier: License :: OSI Approved :: MIT License
9
- Classifier: Operating System :: OS Independent
10
- Requires-Python: >=3.6
11
- Description-Content-Type: text/markdown
12
- License-File: LICENSE
13
-
14
- # twd-m4sc0
15
-
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 all users who frequently need to switch between directories in the terminal.
17
-
18
- ## Features
19
-
20
- - Save the current working directory.
21
- - Go back to the saved directory.
22
- - List the saved directory.
23
- - Integrates with your shell for seamless directory management.
24
-
25
- ## Installation
26
-
27
- ### Installation using `pip`:
28
-
29
- 1. Install the package from the `pypi` repository:
30
-
31
- ```bash
32
- pip install twd-m4sc0
33
- ```
34
-
35
- 2. Add the following line to your `.bashrc` or `.zshrc` to set up the shell function:
36
-
37
- ```bash
38
- eval $(python3 -m twd --shell)
39
- ```
40
-
41
- 3. Exit and reopen the terminal or reload using:
42
-
43
- ```bash
44
- source ~/.bashrc
45
- # or
46
- source ~/.zshrc
47
- ```
48
-
49
- ## Usage
50
-
51
- - Save a directory
52
-
53
- ```bash
54
- twd -s [path]
55
- ```
56
-
57
- - Go to the saved directory
58
-
59
- ```bash
60
- twd -g
61
- ```
62
-
63
- - List the saved directory
64
-
65
- ```bash
66
- twd -l
67
- ```
68
-
69
- - Unset the TWD and delete the file
70
-
71
- ```bash
72
- twd -u
73
- ```
74
-
75
- ### Optional Parameters
76
-
77
- #### Simple Output
78
-
79
- Simpler output is meant to be for script or grep usage
80
-
81
- - Example with simple-output
82
-
83
- ```bash
84
- user:~/.config $ twd -s --simple-output
85
- /home/user/.config
86
- ```
87
-
88
- - Example without simple-output
89
-
90
- ```bash
91
- user:~/.config $ twd -s
92
- Saved TWD to /home/user/.config
93
- ```
94
-
95
- #### No Output
96
-
97
- No output is meant for just no output (impressive ik)
98
-
99
- - Example with no-output
100
-
101
- ```bash
102
- user:~/.config $ twd -s --no-output
103
- # no output
104
- ```
105
-
106
- - Example without no-output
107
-
108
- ```bash
109
- user:~/.config $ twd -s
110
- Saved TWD to /home/user/.config
111
- ```
112
-
113
- #### Force
114
-
115
- Forces an action
116
-
117
- > Currently only implemented on the `-u` flag
118
-
119
- - Example
120
-
121
- ```bash
122
- user:~/.config $ twd -u --force
123
- TWD File deleted and TWD unset
124
- ```
125
-
126
- # Contribution
127
-
128
- To set up a dev environment:
129
-
130
- 1. Clone the repo:
131
-
132
- ```bash
133
- git clone https://github.com/m4sc0/twd
134
- cd twd
135
- ```
136
-
137
- 2. Install the package in editable mode using `pip`:
138
-
139
- ```bash
140
- pip install -e .
141
- ```
@@ -1,11 +0,0 @@
1
- tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- tests/test_twd.py,sha256=XrxOo99oqida_7qZ48pA6BCazZekDmG5syw9NvjZWDU,484
3
- twd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- twd/__main__.py,sha256=gM_Py51pQFH3CXdDIuPzBW6eNlFH1UHeRAmgAPWQyik,61
5
- twd/twd.py,sha256=N-wBGkLgFQ5f5Prml56-MdpBBR9y1OekZZTeZxNz-go,7986
6
- twd_m4sc0-1.5.1.dist-info/LICENSE,sha256=eQSDjcD_fvOwfjmrzxKJhtZsSI39seMawuvsgeD_dfw,1062
7
- twd_m4sc0-1.5.1.dist-info/METADATA,sha256=FJkYLm_PtFlwmqbIo5a2n9LiKnvjN3kAbUNS5nlxX6I,2341
8
- twd_m4sc0-1.5.1.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
9
- twd_m4sc0-1.5.1.dist-info/entry_points.txt,sha256=QfYDHHjipkVN4oalpACFmIeYHb7GQCJY4SC12bTsiQQ,37
10
- twd_m4sc0-1.5.1.dist-info/top_level.txt,sha256=PXToru2Yr2Xh3F_F-pHXtuOQVp5x7KKCPFf94P_VI5U,10
11
- twd_m4sc0-1.5.1.dist-info/RECORD,,