{"id":13576530,"url":"https://github.com/alecthomas/ondir","last_synced_at":"2025-04-03T02:11:57.100Z","repository":{"id":1081675,"uuid":"927642","full_name":"alecthomas/ondir","owner":"alecthomas","description":"OnDir is a small program to automate tasks specific to certain directories","archived":false,"fork":false,"pushed_at":"2023-12-01T21:53:56.000Z","size":24,"stargazers_count":209,"open_issues_count":1,"forks_count":17,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-24T08:08:23.755Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alecthomas.png","metadata":{"files":{"readme":"README.rst","changelog":"ChangeLog","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null}},"created_at":"2010-09-21T13:05:59.000Z","updated_at":"2024-12-20T05:43:04.000Z","dependencies_parsed_at":"2024-03-17T03:22:08.716Z","dependency_job_id":"65bfc56c-544b-475e-bd48-b984963ac594","html_url":"https://github.com/alecthomas/ondir","commit_stats":{"total_commits":11,"total_committers":4,"mean_commits":2.75,"dds":0.4545454545454546,"last_synced_commit":"55279f0366c32e4295c9f114cbee5ac7776e4d53"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecthomas%2Fondir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecthomas%2Fondir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecthomas%2Fondir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecthomas%2Fondir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alecthomas","download_url":"https://codeload.github.com/alecthomas/ondir/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246922248,"owners_count":20855345,"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-01T15:01:11.120Z","updated_at":"2025-04-03T02:11:57.074Z","avatar_url":"https://github.com/alecthomas.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"OnDir\n=====\n\nIntroduction\n------------\nondir is a small program to automate tasks specific to certain directories. It\nworks by executing scripts in directories when you enter and leave them.\n\nScripts in the doc subdirectory show how to automate this when using either\nBASH or TCSH.\n\nGetting Started\n---------------\n1. Add scripts.sh or scripts.tcsh to your startup scripts for BASH or TCSH,\n   respectively.\n2. Restart your shell.\n3. Add an entry to your ~/.ondirrc such as those described below. \n4. Change into the corresponding path.\n5. Check for success.\n\nDetails\n-------\nAn example of ondirs usefulness is when editing web pages. I have a umask of 077\nby default, but when creating web pages in ~/public_html the web content has\nto be readable by the user the web server runs as. By adding a path section for\nthis directory to my ~/.ondirrc, and corresponding enter and leave sub-sections,\nany scripts in the enter/leave sub-sections are executed when I enter and leave\nthe directory, respectively. Here is how the entry in my ~/.ondirrc would look::\n\n  enter /home/athomas/public_html\n    umask 022\n\n  leave /home/athomas/public_html\n    umask 077\n\nAnd that's all it does. Simple, but effective. \n\nondir takes one parameter, the directory you are leaving.\n\nNote that these scripts will be executed when you pass THROUGH the directory \nas well. Using the preceding example, typing \"cd ~/public_html/mywebpage\" will \nexecute the 'enter' in ~/public_html. The reverse is also true: when leaving \na path, all 'leave' scripts in the intermediate directories are executed.\n\nA more useful example\n---------------------\nOndir is particularly useful with `virtualenv\n\u003chttp://pypi.python.org/pypi/virtualenv\u003e`_. The following config will\nautomatically activate virtualenv's when you change into a directory and\ndeactivate when you move out::\n\n  enter ~/Projects/([^/]+)\n    if [ -r .venv ]; then\n      . ./.venv/bin/activate\n    fi\n\n  leave ~/Projects/([^/]+)\n    deactivate \u003e /dev/null 2\u003e\u00261\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falecthomas%2Fondir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falecthomas%2Fondir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falecthomas%2Fondir/lists"}