{"id":14065927,"url":"https://github.com/Spec04/obs_alias_generator","last_synced_at":"2025-07-29T21:34:13.775Z","repository":{"id":223332780,"uuid":"288958140","full_name":"Spec04/obs_alias_generator","owner":"Spec04","description":"Generate Alias file for Obsidian vault","archived":false,"fork":false,"pushed_at":"2020-08-20T12:38:44.000Z","size":20,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-13T07:10:00.940Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Spec04.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-20T09:06:15.000Z","updated_at":"2024-08-13T07:10:03.814Z","dependencies_parsed_at":null,"dependency_job_id":"b3fa2e4e-8caa-4291-966a-de3033c0a00d","html_url":"https://github.com/Spec04/obs_alias_generator","commit_stats":null,"previous_names":["spec04/obs_alias_generator"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Spec04%2Fobs_alias_generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Spec04%2Fobs_alias_generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Spec04%2Fobs_alias_generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Spec04%2Fobs_alias_generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Spec04","download_url":"https://codeload.github.com/Spec04/obs_alias_generator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228052635,"owners_count":17862105,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-13T07:04:50.735Z","updated_at":"2024-12-04T05:31:08.955Z","avatar_url":"https://github.com/Spec04.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Obsidian Alias File Generator\n\nA python script that compiles a yaml file of noted aliases for all notes within an obsidian vault. Makes easier forward linking possible.\n\nUseful in creating shorthand names for notes due to acronym usage or to link in intext citations.\n\n### Function\nThis script performs the following function:\n- Searches an obsidian vault for all markdown files \n- Inspects each file for an alias keyword tag\n- If tag found, extracts the subsequent alias names for that file\n- Compiles all filenames and related tags into a YAML file\n\n### NOTE\nThis script is designed to do some of the heavy lifting of creating a YAML file to feed into [**Ben Perkins'** great work to create forward links in obsidian notes](https://github.com/perkinsben/obs_tools/tree/master/forward_linker)\n\nThe intent of this script/method is to manage the alias names directly within obsidian notes, rather than in a secondary document (the .yaml file) which is a degree of separation away from the note in question.\n\n------\n## Requirements\n\n### Python \n* Python 3 + pip\n* [PyYAML](https://pypi.org/project/PyYAML/)\n\n```\npip install pyyaml\n```\n\n### Obsidian\nWithin your markdown note file(s) an alias 'tag' must be added in the text to identify that the line contains aliases for the filename. This tag can be any unique string, but should be placed at the beginning of the line. \n\nAlias tags can be any combination of characters (string), if you plan on using the tag later in the document and dont want it flagged, set the ```line_limit``` value to a small enough number before you intend to use the tag (i.e. top 10 lines). Best to avoid this and only use a unique tag.\n\nI tend to use ```::::``` as it is subtle and unobtrusive and place my aliases directly under the note title. But just as easily could be ```See Also:``` or ```=)``` you are only limited by your imagination\n\n------\n\n## Running the code\n\n### Inputs\nThe code requires the following inputs:\n* Input 0: Path to the python script\n* Input 1: Path to vault\n* Input 2: Alias search key as a string\n* Input 3: Filename for the saved YAML file\n    * Just the filename (string) without an extension\n    * e.g. ```aliases``` will create ```aliases.yml```\n* Input 4: Number of lines to limit search from top\n    * For searching the entire file input ```0``` or ```\"\"``` \n    * e.g. ```10``` will search only the first ```10 lines```\n    * Line limit is used to avoid searching through large notes when you know the alias tag is only always in the first few lines of the file. \n\n### Command line\n#### If using the guided CLI prompts:\nRun the following command in a terminal window. Python will prompt for additional inputs\n```\npython alias_creator.py\n```\n\n### If using CLI directly:\nAlternatively you can enter the inputs directly as arguments to speed up the process\n```\npython alias_creator.py {obsidian vault root} {alias key} {yaml filename} {line limit}\n```\nThe following would create an ```aliases.yml``` file for my ```Example_Vault``` by searching the first ```10``` lines of all files for the ```::::``` alias tag.\n```\npython alias_creator.py \"C:/Obsidian/Example_Vault\" \"::::\" \"aliases\" \"10\"\n```\n\n\n### For Windows users:\nFor making it even easier you can create a .BAT file (.txt file with extension change to .bat) and add the direct CLI commands from above. This makes it easier to run as a shortcut, and keep the inputs on hand if you regularly update your alias file.\n\n```cmd\n@echo off\npython alias_creator.py {obsidian vault root} {alias key} {yaml filename} {line limit}\npause\n```\nThe following would create an ```aliases.yml``` file for my ```Example_Vault``` by searching the first ```10``` lines of all files for the ```::::``` alias tag.\n``` cmd\n@echo off\npython ^\n    alias_creator.py ^\n    \"C:/Obsidian/Example_Vault\" ^\n    \"::::\" ^\n    \"aliases\" ^\n    \"10\"\npause\n```\n-------\n## Example usage\n\nWhile working on your note called ```Working from home.md``` you would add the alias tag ```::::``` which identifies alternative aliases for the file, and add additional aliases you wish to link this note to.\n```md\n# Working from home\n:::: Remote working, Remote worker, WFH\n\nA side effect of the pandemic is that ...\n```\nExecuting the script will generate the following entry into your yml alias file:\n\n```yaml\nWorking from home:\n- Remote working\n- Remote worker\n- WFH\n```\n\nThe script will also include some additional header information within your alias file for tracking when it was last run and under what inputs. This additional header does not negatively impact forward linking code.\n\nAn example of the full output would be:\n\n```yaml\n# ------------------------------\n# ALIAS FILE FOR OBSIDIAN VAULT\n# Vault: Example_Vault\n# Created: 19-08-2020, 22:32:05\n# ------------------------------\n# Alias Key: '::::'\n# Line Limit: 10 lines\n# ------------------------------\n\nWorking from home:\n- Remote working\n- Remote worker\n- WFH\n```\n\n---------\n\n\n## Acknowledgments\n* Shoutout to [Ben Perkins](https://github.com/perkinsben/obs_tools/tree/master/forward_linker) for his useful script that inspired this one.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSpec04%2Fobs_alias_generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSpec04%2Fobs_alias_generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSpec04%2Fobs_alias_generator/lists"}