DEV Community

Cover image for Translate with alias
JoseXS
JoseXS

Posted on

 

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!

Oldest comments (0)