diff --git a/dtags/chars.py b/dtags/chars.py index effecaf..85054b0 100644 --- a/dtags/chars.py +++ b/dtags/chars.py @@ -6,7 +6,7 @@ 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', '_', '-' + '8', '9', '_', '-', '#' } # Allowed characters in directory paths PATH_CHARS = { @@ -14,7 +14,7 @@ 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', '-', '_', '.', '/', '~', ' ' + '8', '9', '-', '_', '.', '/', '~', ' ', '#' } diff --git a/dtags/commands/__init__.py b/dtags/commands/__init__.py index 2b0d037..40e211e 100644 --- a/dtags/commands/__init__.py +++ b/dtags/commands/__init__.py @@ -265,16 +265,16 @@ def refresh(): if config is None: abort('dtags: unsupported shell: ' + style.bad(shell_path)) - assign_string = 'set -g {} "{}"' if shell_name == 'fish' else '{}="{}"' + declare_str = 'set -g {} "{}"' if shell_name == 'fish' else '{}="{}"' mapping, _ = load_mapping() - print('\n'.join( - assign_string.format(tag.replace('-', '_'), paths.pop()) - for tag, paths in mapping.items() - if len(paths) == 1 and - tag.replace('-', '_') not in os.environ and - not get_invalid_tag_chars(tag) - )) - - - + declarations = [] + for tag, paths in mapping.items(): + cleaned_tag = tag.replace('-', '_').replace('#', '_') + if ( + cleaned_tag not in os.environ and + not get_invalid_tag_chars(tag) and + len(paths) == 1 + ): + declarations.append(declare_str.format(cleaned_tag, paths.pop())) + print('\n'.join(declarations)) diff --git a/dtags/version.py b/dtags/version.py index 26f5151..11ad25d 100644 --- a/dtags/version.py +++ b/dtags/version.py @@ -1 +1 @@ -VERSION = '3.1.2' +VERSION = '3.2.0'