DEV Community

Cover image for Translate with alias
JoseXS
JoseXS

Posted on

2 1

Translate with alias

Hello!

For those of us who do not know English and throw a lot of Google Translate...

  • Install translate-shell

brew install translate-shell

  • Add alias in .bash_profile or .zshrc

Note: The parameter: is the language, try to put different and obtain more results (example :en)

alias trad="trans :es "$(pbpaste)" -b | pbcopy"

Now when we want to translate what we have on the clipboard, we simply put trad in the terminal and we will have it copied

Update: I leave the file for Raycast, in case you want to use it with a combination of keys. I have based on this script (link)


#!/bin/bash

# Dependency: requires translate-shell
# Install with Homebrew: `brew install translate-shell`

# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Traducir
# @raycast.mode silent
# @raycast.packageName Translate clipboard

# Documentation:
# @raycast.author josexs
# @raycast.authorURL https://github.com/josexs
# @raycast.description Translate to ES and copy text of clipboard.

if ! command -v trans &> /dev/null; then
    echo "trans command is required (https://github.com/soimort/translate-shell).";
    exit 1;
fi

trans :es "$(pbpaste)" -b | pbcopy

Enter fullscreen mode Exit fullscreen mode

See you with more tips!

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay