-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwd.py
More file actions
executable file
·37 lines (30 loc) · 744 Bytes
/
wd.py
File metadata and controls
executable file
·37 lines (30 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python3
import os
import sys
# warp directory run commands
wd = os.path.expanduser("~/.wdrc")
def usage():
print("wd - warp directory")
print("usage: ")
print("\twd [alias] ; warp to alias")
def load():
with open(wd) as fp:
ln = fp.read().split()
for l in ln:
l = l.split("=")
if sys.argv[1] == l[0]:
if os.path.isdir(l[1]):
print(l[1])
else:
sys.exit(2)
def main():
# just check the count
if len(sys.argv) != 2:
usage()
sys.exit(1)
alias = sys.argv[1]
if alias == "":
return os.path.expanduser("~")
load()
if __name__ == '__main__':
main()