Skip to content

Instantly share code, notes, and snippets.

@rbarzic
Created June 5, 2025 07:16
Show Gist options
  • Select an option

  • Save rbarzic/2f36ca8e604c52ef224bfd7a456f688a to your computer and use it in GitHub Desktop.

Select an option

Save rbarzic/2f36ca8e604c52ef224bfd7a456f688a to your computer and use it in GitHub Desktop.
Managing cdargs files both at $HOME and in a specific directory
TOP:=$(shell pwd)
# cdargs management
# keys starting with '-' are expected to come from a global
# (under $HOME) .cdargs file
cdargs_update:
cat .cdargs | grep -v '^-' | sed "s|$(TOP)|\$$(TOP)|g" | sed "s|$$HOME|\$$(HOME)|g" > .cdargs_for_everyboby
# Create a local .cdargs file by merging a global one (under $HOME) and .cdargs_for_everyboby
cdargs_create:
cat .cdargs_for_everyboby | sed "s|\$$(TOP)|$(TOP)|g" | sed "s|\$$(HOME)|$$HOME|g" > .cdargs
[ -f ~/.cdargs ] && cat ~/.cdargs | sed 's/^/-/' >> .cdargs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment