twd-m4sc0 1.1.0__tar.gz → 1.2.1__tar.gz
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_m4sc0-1.2.1/PKG-INFO +122 -0
- twd_m4sc0-1.2.1/README.md +109 -0
- {twd_m4sc0-1.1.0 → twd_m4sc0-1.2.1}/setup.py +1 -1
- {twd_m4sc0-1.1.0 → twd_m4sc0-1.2.1}/twd/twd.py +39 -18
- twd_m4sc0-1.2.1/twd_m4sc0.egg-info/PKG-INFO +122 -0
- twd_m4sc0-1.1.0/PKG-INFO +0 -12
- twd_m4sc0-1.1.0/README.md +0 -0
- twd_m4sc0-1.1.0/twd_m4sc0.egg-info/PKG-INFO +0 -12
- {twd_m4sc0-1.1.0 → twd_m4sc0-1.2.1}/LICENSE +0 -0
- {twd_m4sc0-1.1.0 → twd_m4sc0-1.2.1}/setup.cfg +0 -0
- {twd_m4sc0-1.1.0 → twd_m4sc0-1.2.1}/tests/__init__.py +0 -0
- {twd_m4sc0-1.1.0 → twd_m4sc0-1.2.1}/tests/test_twd.py +0 -0
- {twd_m4sc0-1.1.0 → twd_m4sc0-1.2.1}/twd/__init__.py +0 -0
- {twd_m4sc0-1.1.0 → twd_m4sc0-1.2.1}/twd/__main__.py +0 -0
- {twd_m4sc0-1.1.0 → twd_m4sc0-1.2.1}/twd_m4sc0.egg-info/SOURCES.txt +0 -0
- {twd_m4sc0-1.1.0 → twd_m4sc0-1.2.1}/twd_m4sc0.egg-info/dependency_links.txt +0 -0
- {twd_m4sc0-1.1.0 → twd_m4sc0-1.2.1}/twd_m4sc0.egg-info/entry_points.txt +0 -0
- {twd_m4sc0-1.1.0 → twd_m4sc0-1.2.1}/twd_m4sc0.egg-info/top_level.txt +0 -0
twd_m4sc0-1.2.1/PKG-INFO
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: twd_m4sc0
|
|
3
|
+
Version: 1.2.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 $(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
|
+
### Optional Parameters
|
|
70
|
+
|
|
71
|
+
#### Simple Output
|
|
72
|
+
|
|
73
|
+
Simpler output is meant to be for script or grep usage
|
|
74
|
+
|
|
75
|
+
- Example with simple-output
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
user:~/.config $ twd -s --simple-output
|
|
79
|
+
/home/user/.config
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
- Example without simple-output
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
user:~/.config $ twd -s
|
|
86
|
+
Saved TWD to /home/user/.config
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
#### No Output
|
|
90
|
+
|
|
91
|
+
No output is meant for just no output (impressive ik)
|
|
92
|
+
|
|
93
|
+
- Example with no-output
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
user:~/.config $ twd -s --no-output
|
|
97
|
+
# no output
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
- Example without no-output
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
user:~/.config $ twd -s
|
|
104
|
+
Saved TWD to /home/user/.config
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
# Contribution
|
|
108
|
+
|
|
109
|
+
To set up a dev environment:
|
|
110
|
+
|
|
111
|
+
1. Clone the repo:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
git clone https://github.com/m4sc0/twd
|
|
115
|
+
cd twd
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
2. Install the package in editable mode using `pip`:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
pip install -e .
|
|
122
|
+
```
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# twd-m4sc0
|
|
2
|
+
|
|
3
|
+
`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.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Save the current working directory.
|
|
8
|
+
- Go back to the saved directory.
|
|
9
|
+
- List the saved directory.
|
|
10
|
+
- Integrates with your shell for seamless directory management.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
### Installation using `pip`:
|
|
15
|
+
|
|
16
|
+
1. Install the package from the `pypi` repository:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install twd-m4sc0
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
2. Add the following line to your `.bashrc` or `.zshrc` to set up the shell function:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
eval $(twd --shell)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
3. Exit and reopen the terminal or reload using:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
source ~/.bashrc
|
|
32
|
+
# or
|
|
33
|
+
source ~/.zshrc
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
- Save a directory
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
twd -s [path]
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
- Go to the saved directory
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
twd -g
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
- List the saved directory
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
twd -l
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Optional Parameters
|
|
57
|
+
|
|
58
|
+
#### Simple Output
|
|
59
|
+
|
|
60
|
+
Simpler output is meant to be for script or grep usage
|
|
61
|
+
|
|
62
|
+
- Example with simple-output
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
user:~/.config $ twd -s --simple-output
|
|
66
|
+
/home/user/.config
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
- Example without simple-output
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
user:~/.config $ twd -s
|
|
73
|
+
Saved TWD to /home/user/.config
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
#### No Output
|
|
77
|
+
|
|
78
|
+
No output is meant for just no output (impressive ik)
|
|
79
|
+
|
|
80
|
+
- Example with no-output
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
user:~/.config $ twd -s --no-output
|
|
84
|
+
# no output
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
- Example without no-output
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
user:~/.config $ twd -s
|
|
91
|
+
Saved TWD to /home/user/.config
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
# Contribution
|
|
95
|
+
|
|
96
|
+
To set up a dev environment:
|
|
97
|
+
|
|
98
|
+
1. Clone the repo:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
git clone https://github.com/m4sc0/twd
|
|
102
|
+
cd twd
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
2. Install the package in editable mode using `pip`:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
pip install -e .
|
|
109
|
+
```
|
|
@@ -8,7 +8,23 @@ TWD_FILE = os.path.join(os.path.expanduser("~"), ".twd")
|
|
|
8
8
|
def get_absolute_path(path):
|
|
9
9
|
return os.path.abspath(path)
|
|
10
10
|
|
|
11
|
-
def
|
|
11
|
+
def output_handler(message=None, path=None, output=True, simple_output=False):
|
|
12
|
+
"""
|
|
13
|
+
Handles all output based on the flags --no-output and --simple-output.
|
|
14
|
+
- message: Regular output string
|
|
15
|
+
- path: Path to be printed (in simple output mode)
|
|
16
|
+
- output: Whether output is enabled
|
|
17
|
+
- simple_output: Whether only essential output should be shown
|
|
18
|
+
"""
|
|
19
|
+
if not output:
|
|
20
|
+
return
|
|
21
|
+
|
|
22
|
+
if simple_output and path:
|
|
23
|
+
print(path)
|
|
24
|
+
elif not simple_output and message:
|
|
25
|
+
print(message)
|
|
26
|
+
|
|
27
|
+
def save_directory(path=None, output=True, simple_output=False):
|
|
12
28
|
if path is None:
|
|
13
29
|
path = os.getcwd()
|
|
14
30
|
else:
|
|
@@ -17,36 +33,36 @@ def save_directory(path=None):
|
|
|
17
33
|
with open(TWD_FILE, "w") as f:
|
|
18
34
|
f.write(path)
|
|
19
35
|
|
|
20
|
-
|
|
36
|
+
output_handler(f"Saved TWD to {path}", path, output, simple_output)
|
|
21
37
|
|
|
22
38
|
def load_directory():
|
|
23
39
|
if not os.path.exists(TWD_FILE):
|
|
24
40
|
return None
|
|
25
|
-
|
|
41
|
+
|
|
26
42
|
with open(TWD_FILE, "r") as f:
|
|
27
43
|
return f.read().strip()
|
|
28
44
|
|
|
29
|
-
def go_to_directory():
|
|
45
|
+
def go_to_directory(output=True, simple_output=False):
|
|
30
46
|
TWD = load_directory()
|
|
31
|
-
|
|
47
|
+
|
|
32
48
|
if TWD is None:
|
|
33
|
-
|
|
49
|
+
output_handler("No TWD found", None, output, simple_output)
|
|
34
50
|
return 1
|
|
35
51
|
else:
|
|
36
52
|
if os.path.exists(TWD):
|
|
37
|
-
|
|
53
|
+
output_handler(f"cd {TWD}", TWD, output, simple_output)
|
|
38
54
|
return 0
|
|
39
55
|
else:
|
|
40
|
-
|
|
56
|
+
output_handler(f"Directory does not exist: {TWD}", None, output, simple_output)
|
|
41
57
|
return 1
|
|
42
58
|
|
|
43
|
-
def show_directory():
|
|
59
|
+
def show_directory(output=True, simple_output=False):
|
|
44
60
|
TWD = load_directory()
|
|
45
|
-
|
|
61
|
+
|
|
46
62
|
if TWD is None:
|
|
47
|
-
|
|
63
|
+
output_handler("No TWD set", None, output, simple_output)
|
|
48
64
|
else:
|
|
49
|
-
|
|
65
|
+
output_handler(f"Current TWD: {TWD}", TWD, output, simple_output)
|
|
50
66
|
|
|
51
67
|
def get_package_version():
|
|
52
68
|
try:
|
|
@@ -56,22 +72,27 @@ def get_package_version():
|
|
|
56
72
|
|
|
57
73
|
def main():
|
|
58
74
|
parser = argparse.ArgumentParser(description="Temporarily save and navigate to working directories.")
|
|
59
|
-
|
|
75
|
+
|
|
60
76
|
parser.add_argument('-s', '--save', nargs='?', const='', help="Save the current or specified directory")
|
|
61
77
|
parser.add_argument('-g', '--go', action='store_true', help="Go to the saved directory")
|
|
62
78
|
parser.add_argument('-l', '--list', action='store_true', help="Show saved TWD")
|
|
63
|
-
parser.add_argument('--shell', action='store_true', help="Output shell function for integration")
|
|
64
79
|
parser.add_argument('-v', '--version', action='version', version=f'TWD Version: {get_package_version()}', help='Show the current version of TWD installed')
|
|
80
|
+
parser.add_argument('--shell', action='store_true', help="Output shell function for integration")
|
|
81
|
+
parser.add_argument('--simple-output', action='store_true', help="Only print essential output (new directory, absolute path, etc.)")
|
|
82
|
+
parser.add_argument('--no-output', action='store_true', help="Prevents the console from sending output")
|
|
65
83
|
|
|
66
84
|
args = parser.parse_args()
|
|
67
85
|
|
|
86
|
+
output = not args.no_output
|
|
87
|
+
simple_output = args.simple_output
|
|
88
|
+
|
|
68
89
|
if args.shell:
|
|
69
90
|
print('''
|
|
70
91
|
function twd() {
|
|
71
92
|
output=$(python3 -m twd "$@")
|
|
72
93
|
if [[ "$1" == "-g" ]]; then
|
|
73
94
|
eval "$output"
|
|
74
|
-
else
|
|
95
|
+
else
|
|
75
96
|
echo "$output"
|
|
76
97
|
fi
|
|
77
98
|
}
|
|
@@ -79,11 +100,11 @@ def main():
|
|
|
79
100
|
return 0
|
|
80
101
|
|
|
81
102
|
if args.save is not None:
|
|
82
|
-
save_directory(args.save if args.save else None)
|
|
103
|
+
save_directory(args.save if args.save else None, output, simple_output)
|
|
83
104
|
elif args.go:
|
|
84
|
-
return go_to_directory()
|
|
105
|
+
return go_to_directory(output, simple_output)
|
|
85
106
|
elif args.list:
|
|
86
|
-
show_directory()
|
|
107
|
+
show_directory(output, simple_output)
|
|
87
108
|
else:
|
|
88
109
|
parser.print_help()
|
|
89
110
|
return 1
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: twd_m4sc0
|
|
3
|
+
Version: 1.2.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 $(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
|
+
### Optional Parameters
|
|
70
|
+
|
|
71
|
+
#### Simple Output
|
|
72
|
+
|
|
73
|
+
Simpler output is meant to be for script or grep usage
|
|
74
|
+
|
|
75
|
+
- Example with simple-output
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
user:~/.config $ twd -s --simple-output
|
|
79
|
+
/home/user/.config
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
- Example without simple-output
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
user:~/.config $ twd -s
|
|
86
|
+
Saved TWD to /home/user/.config
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
#### No Output
|
|
90
|
+
|
|
91
|
+
No output is meant for just no output (impressive ik)
|
|
92
|
+
|
|
93
|
+
- Example with no-output
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
user:~/.config $ twd -s --no-output
|
|
97
|
+
# no output
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
- Example without no-output
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
user:~/.config $ twd -s
|
|
104
|
+
Saved TWD to /home/user/.config
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
# Contribution
|
|
108
|
+
|
|
109
|
+
To set up a dev environment:
|
|
110
|
+
|
|
111
|
+
1. Clone the repo:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
git clone https://github.com/m4sc0/twd
|
|
115
|
+
cd twd
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
2. Install the package in editable mode using `pip`:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
pip install -e .
|
|
122
|
+
```
|
twd_m4sc0-1.1.0/PKG-INFO
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: twd_m4sc0
|
|
3
|
-
Version: 1.1.0
|
|
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
|
twd_m4sc0-1.1.0/README.md
DELETED
|
File without changes
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: twd_m4sc0
|
|
3
|
-
Version: 1.1.0
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|