Hey folks! I'm looking for a way to set up an alias or function that allows me to edit a command and then execute it with a simple key press. I want to modify the command flag to change the date according to how many days ago I want to reference. The specific command I'm working with is: `alias dd="touch ./markdown_$(date --date='-1 day' +%a_%-d).md"`. Any help would be greatly appreciated! Thanks in advance!
1 Answer
It sounds like you might be better off creating a function instead of just an alias since aliases can be pretty limited. Check this out:
```bash
ddd() {
day=${*:--1 day}
touch ./markdown_$(date --date="$day" +%a_%-d).md
}
```
With this, you can just type `ddd` for yesterday or `ddd -4 days` for four days ago, and so on. Just a heads-up, I changed `dd` to `ddd` because the original `dd` command is super important in UNIX, and I wouldn't want to overwrite that!
Thanks a lot for the help! Where exactly do I need to place this function? The CLI can be a bit overwhelming for me.