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
|
- Installation & Generalization
|
||||||
- Command Memory/Env Support
|
- Command Memory/Env Support
|
||||||
- Double wh does an la, not ls
|
- Double wh does an la, not ls
|
||||||
- Git Repo detection for ls
|
|
||||||
- Clipboard functionality
|
- Clipboard functionality
|
||||||
- Binary File MIME Types
|
- Binary File MIME Types
|
||||||
|
16
do_what.py
16
do_what.py
@ -11,6 +11,7 @@ print_file="cat"
|
|||||||
pretty_print_file="less -R"
|
pretty_print_file="less -R"
|
||||||
edit_file="vim"
|
edit_file="vim"
|
||||||
list_directory="ls --color=auto"
|
list_directory="ls --color=auto"
|
||||||
|
list_git_directory="ls --color=auto"
|
||||||
change_dir="cd"
|
change_dir="cd"
|
||||||
print_dir="pwd"
|
print_dir="pwd"
|
||||||
help_command="man"
|
help_command="man"
|
||||||
@ -77,6 +78,8 @@ if ( os.path.isfile(ENV_HOME+'/.config/do_what/what.config') ):
|
|||||||
help_command = config['DEFAULT']['help_command']
|
help_command = config['DEFAULT']['help_command']
|
||||||
if ( 'path_locator' in config['DEFAULT'] ):
|
if ( 'path_locator' in config['DEFAULT'] ):
|
||||||
path_locator = config['DEFAULT']['path_locator']
|
path_locator = config['DEFAULT']['path_locator']
|
||||||
|
if ( 'list_git_directory' in config['DEFAULT'] ):
|
||||||
|
list_git_directory = config['DEFAULT']['list_git_directory']
|
||||||
else:
|
else:
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config['DEFAULT'] = {
|
config['DEFAULT'] = {
|
||||||
@ -86,6 +89,7 @@ else:
|
|||||||
'print_file': print_file,
|
'print_file': print_file,
|
||||||
'help_command': help_command,
|
'help_command': help_command,
|
||||||
'path_locator': path_locator,
|
'path_locator': path_locator,
|
||||||
|
'list_git_directory': list_git_directory,
|
||||||
}
|
}
|
||||||
print("echo Default config loaded.")
|
print("echo Default config loaded.")
|
||||||
with open(ENV_HOME+'/.config/do_what/what.config', 'w') as configfile:
|
with open(ENV_HOME+'/.config/do_what/what.config', 'w') as configfile:
|
||||||
@ -103,8 +107,11 @@ for arg in sys.argv:
|
|||||||
|
|
||||||
if ( (not active and len(sys.argv) == 1) or (active and len(sys.argv) == 2) ):
|
if ( (not active and len(sys.argv) == 1) or (active and len(sys.argv) == 2) ):
|
||||||
# list the contents of the current directory
|
# list the contents of the current directory
|
||||||
if ( not active ):
|
if ( not active ):
|
||||||
print(list_directory)
|
if ( os.path.isdir('.git') ):
|
||||||
|
print(list_git_directory)
|
||||||
|
else:
|
||||||
|
print(list_directory)
|
||||||
# print the working directory (active)
|
# print the working directory (active)
|
||||||
elif ( active ):
|
elif ( active ):
|
||||||
print(print_dir)
|
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 directory, list its contents
|
||||||
if ( os.path.isdir(path) and not active ):
|
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)
|
# if directory, change into it (active)
|
||||||
elif ( os.path.isdir(path) and active ):
|
elif ( os.path.isdir(path) and active ):
|
||||||
print(change_dir+" "+path)
|
print(change_dir+" "+path)
|
||||||
|
Loading…
Reference in New Issue
Block a user