1
0
mirror of https://github.com/wting/autojump synced 2024-10-27 20:34:07 +00:00

add increase directory weight

This commit is contained in:
William Ting 2013-12-16 16:26:41 -06:00
parent 694d150882
commit 35a0991385
2 changed files with 11 additions and 11 deletions

View File

@ -85,10 +85,10 @@ def parse_args(config):
parser.add_argument( parser.add_argument(
'-a', '--add', metavar='DIRECTORY', '-a', '--add', metavar='DIRECTORY',
help='add path') help='add path')
# parser.add_argument( parser.add_argument(
# '-i', '--increase', metavar='WEIGHT', nargs='?', type=int, '-i', '--increase', metavar='WEIGHT', nargs='?', type=int,
# const=20, default=False, const=20, default=False,
# help='manually increase path weight in database') help='increase current directory weight')
# parser.add_argument( # parser.add_argument(
# '-d', '--decrease', metavar='WEIGHT', nargs='?', type=int, # '-d', '--decrease', metavar='WEIGHT', nargs='?', type=int,
# const=15, default=False, # const=15, default=False,
@ -115,11 +115,10 @@ def parse_args(config):
add_path(config, args.add) add_path(config, args.add)
sys.exit(0) sys.exit(0)
# if args.increase: if args.increase:
# print("%.2f:\t old directory weight" % db.get_weight(os.getcwd())) path, weight = add_path(config, os.getcwd(), args.increase)
# db.add(os.getcwd(), args.increase) print(encode_local("%.1f:\t%s" % (weight, path)))
# print("%.2f:\t new directory weight" % db.get_weight(os.getcwd())) sys.exit(0)
# sys.exit(0)
# if args.decrease: # if args.decrease:
# print("%.2f:\t old directory weight" % db.get_weight(os.getcwd())) # print("%.2f:\t old directory weight" % db.get_weight(os.getcwd()))
@ -154,7 +153,7 @@ def add_path(config, path, increment=10):
"""Add a new path or increment an existing one.""" """Add a new path or increment an existing one."""
path = decode(path).rstrip(os.sep) path = decode(path).rstrip(os.sep)
if path == os.path.expanduser('~'): if path == os.path.expanduser('~'):
return return path, 0
data = load(config) data = load(config)
@ -164,6 +163,7 @@ def add_path(config, path, increment=10):
data[path] = increment data[path] = increment
save(config, data) save(config, data)
return path, data[path]
def print_stats(config): def print_stats(config):

View File

@ -58,7 +58,7 @@ def migrate_osx_xdg_data(config):
Older versions incorrectly used Linux XDG_DATA_HOME paths on OS X. This Older versions incorrectly used Linux XDG_DATA_HOME paths on OS X. This
migrates autojump files from ~/.local/share/autojump to ~/Library/autojump migrates autojump files from ~/.local/share/autojump to ~/Library/autojump
""" """
assert is_osx(), "Expecting OSX." assert is_osx(), "This function should only be run on OS X."
xdg_data_home = os.path.join(os.path.expanduser('~'), '.local', 'share') xdg_data_home = os.path.join(os.path.expanduser('~'), '.local', 'share')
xdg_aj_home = os.path.join(xdg_data_home, 'autojump') xdg_aj_home = os.path.join(xdg_data_home, 'autojump')