Skip to content

Commit

Permalink
Sync
Browse files Browse the repository at this point in the history
  • Loading branch information
mskelton committed Mar 23, 2024
1 parent 035fe46 commit 4722286
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 29 deletions.
26 changes: 12 additions & 14 deletions e2e/bytes/20230903044640.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ tags: [cli]
---

I recently came across a [Raycast](https://www.raycast.com) extension that
allows you to play/pause music from YouTube music while it's running in
your browser. After exploring how it worked internally given I was a bit
astonished it is even possible, I found that it's all just using
AppleScript.
allows you to play/pause music from YouTube music while it's running in your
browser. After exploring how it worked internally given I was a bit astonished
it is even possible, I found that it's all just using AppleScript.

So, a bit of bash code later and I had a working implementation of a new
`js` command to allow running JavaScript either the active browser tab or
in all windows with a given URL.
So, a bit of bash code later and I had a working implementation of a new `js`
command to allow running JavaScript either the active browser tab or in all
windows with a given URL.

```bash showLineNumbers js
#!/usr/bin/env bash
Expand Down Expand Up @@ -68,22 +67,21 @@ osascript -e "
" >/dev/null
```

Here's the command that will play music from YouTube music like what the
Raycast extension was doing. But this now can be a terminal command!
Here's the command that will play music from YouTube music like what the Raycast
extension was doing. But this now can be a terminal command!

```bash play
js --url music.youtube.com "document.querySelector('#play-pause-button[aria-label=Play]').click()"
```

Definitely planning on using this more for other areas where I have simple
JavaScript I want to execute, such as clicking something after a hot
reload, etc.
JavaScript I want to execute, such as clicking something after a hot reload,
etc.

## Chromium security

In Chromium based browsers (e.g. Chrome, Arc), you need to enable a
developer flag in order for this to work properly. You can find it in the
menu:
In Chromium based browsers (e.g. Chrome, Arc), you need to enable a developer
flag in order for this to work properly. You can find it in the menu:

```
View -> Developer -> Allow JavaScript from Apple Events
Expand Down
18 changes: 9 additions & 9 deletions e2e/bytes/20230904035410.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ title: Better Shell Aliases
tags: [fish, cli]
---

I use shell aliases quite heavily to simplify common CLI commands. However,
one of my biggest pain points when using them is they didn't work as well
in certain complex commands.
I use shell aliases quite heavily to simplify common CLI commands. However, one
of my biggest pain points when using them is they didn't work as well in certain
complex commands.

For example, suppose I have the following alias in my Fish config that
assigns the `task` command to an alias `t`:
For example, suppose I have the following alias in my Fish config that assigns
the `task` command to an alias `t`:

```bash
alias t="task"
Expand All @@ -26,8 +26,8 @@ But with a complex command like this, it doesn't work:
seq 10 | xargs -I {} t add Testing {}
```

I found that a simple solution was to simple create a binary in addition to
the alias. For the `t` alias, this would look like this:
I found that a simple solution was to simple create a binary in addition to the
alias. For the `t` alias, this would look like this:

```bash
#!/usr/bin/env bash
Expand All @@ -36,5 +36,5 @@ task "$@"
```

Now, you could just create the binary and remove the alias, but the alias
ensures fish can provide autocompletion properly, so I find that the
combination of both gives the best of both worlds.
ensures fish can provide autocompletion properly, so I find that the combination
of both gives the best of both worlds.
12 changes: 6 additions & 6 deletions e2e/bytes/20230906143340.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ title: Using Git Hooks When Creating Worktrees
tags: [git]
---

I've started to use `git worktree`s more lately but one of the pain points
I had was that they don't copied ignored files such as `.env` files. I
found I was able to improve this workflow by adding a `post-checkout` hook.
I've started to use `git worktree`s more lately but one of the pain points I had
was that they don't copied ignored files such as `.env` files. I found I was
able to improve this workflow by adding a `post-checkout` hook.

In a nutshell, the hook will check if we are checking out a new worktree
(that's what the `"$1" == "0000..."` is all about). If we are, then we can
run some code to copy over whatever files we need to.
In a nutshell, the hook will check if we are checking out a new worktree (that's
what the `"$1" == "0000..."` is all about). If we are, then we can run some code
to copy over whatever files we need to.

```bash showLineNumbers .git/hooks/post-checkout
#!/bin/bash
Expand Down

0 comments on commit 4722286

Please sign in to comment.