add custom ls option for git repositories
This commit is contained in:
parent
3f9c3b61f2
commit
ba8d4473d0
@ -16,6 +16,5 @@ This project is currently a work-in-progress. Only the fish shell is supported a
|
||||
- Installation & Generalization
|
||||
- Command Memory/Env Support
|
||||
- Double wh does an la, not ls
|
||||
- Git Repo detection for ls
|
||||
- Clipboard functionality
|
||||
- Binary File MIME Types
|
||||
|
14
do_what.py
14
do_what.py
@ -11,6 +11,7 @@ print_file="cat"
|
||||
pretty_print_file="less -R"
|
||||
edit_file="vim"
|
||||
list_directory="ls --color=auto"
|
||||
list_git_directory="ls --color=auto"
|
||||
change_dir="cd"
|
||||
print_dir="pwd"
|
||||
help_command="man"
|
||||
@ -77,6 +78,8 @@ if ( os.path.isfile(ENV_HOME+'/.config/do_what/what.config') ):
|
||||
help_command = config['DEFAULT']['help_command']
|
||||
if ( 'path_locator' in config['DEFAULT'] ):
|
||||
path_locator = config['DEFAULT']['path_locator']
|
||||
if ( 'list_git_directory' in config['DEFAULT'] ):
|
||||
list_git_directory = config['DEFAULT']['list_git_directory']
|
||||
else:
|
||||
config = configparser.ConfigParser()
|
||||
config['DEFAULT'] = {
|
||||
@ -86,6 +89,7 @@ else:
|
||||
'print_file': print_file,
|
||||
'help_command': help_command,
|
||||
'path_locator': path_locator,
|
||||
'list_git_directory': list_git_directory,
|
||||
}
|
||||
print("echo Default config loaded.")
|
||||
with open(ENV_HOME+'/.config/do_what/what.config', 'w') as configfile:
|
||||
@ -104,7 +108,10 @@ for arg in sys.argv:
|
||||
if ( (not active and len(sys.argv) == 1) or (active and len(sys.argv) == 2) ):
|
||||
# list the contents of the current directory
|
||||
if ( not active ):
|
||||
print(list_directory)
|
||||
if ( os.path.isdir('.git') ):
|
||||
print(list_git_directory)
|
||||
else:
|
||||
print(list_directory)
|
||||
# print the working directory (active)
|
||||
elif ( active ):
|
||||
print(print_dir)
|
||||
@ -117,7 +124,10 @@ elif ( (not active and len(sys.argv) == 2) or (active and len(sys.argv) == 3) ):
|
||||
|
||||
# if directory, list its contents
|
||||
if ( os.path.isdir(path) and not active ):
|
||||
print(list_directory+" "+path)
|
||||
if ( os.path.isdir(path+"/.git") ):
|
||||
print(list_git_directory+" "+path)
|
||||
else:
|
||||
print(list_directory+" "+path)
|
||||
# if directory, change into it (active)
|
||||
elif ( os.path.isdir(path) and active ):
|
||||
print(change_dir+" "+path)
|
||||
|
Loading…
Reference in New Issue
Block a user