-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add new command to copy tab as link - Initial commit
- Loading branch information
1 parent
c6275ce
commit ad15ed4
Showing
5 changed files
with
56 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Clipboard, closeMainWindow, showToast, Toast } from "@raycast/api"; | ||
import { getCurrentTabName, getCurrentTabURL } from "./utils"; | ||
|
||
export default async function Command() { | ||
try { | ||
await closeMainWindow(); | ||
|
||
const [title, url] = await Promise.all([getCurrentTabName(), getCurrentTabURL()]); | ||
await Clipboard.copy({ text: `[${title}](${url})`, html: `<a href="${url}">${title}</a>` }); | ||
|
||
await showToast({ | ||
style: Toast.Style.Success, | ||
title: "Copied title as link to clipboard", | ||
}); | ||
} catch (error) { | ||
console.error(error); | ||
|
||
await showToast({ | ||
style: Toast.Style.Failure, | ||
title: "Failed copying title as link to clipboard", | ||
message: error instanceof Error ? error.message : undefined, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters