Code Monkey home page Code Monkey logo

hyperlink's Introduction

hyperlink

hyperlink (OSC8) utility script with tmux support.

Usage

$ hyperlink <link> [<text>]

$ hyperlink http://example.com "This is a link"

# If you omit <text>, <link> is also used as <text>.
$ hyperlink http://example.com

Go

Library

GoDoc

import "github.com/haya14busa/hyperlink"

Install

go get -u github.com/haya14busa/hyperlink/cmd/hyperlink

hyperlink's People

Contributors

haya14busa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

hyperlink's Issues

Implemented as a one-liner POSIX-shell

Here:

hyperlink

#!/usr/bin/env sh
printf "\e]8;;%s\e\\\\%s\e]8;;\e\\\\" "$1" "${2:-$1}"

Make it executable:

chmod +x hyperlink

Or as a function with a demo:

#!/usr/bin/env sh

# Prints a terminal-clickable hyperlink
# Implements: OSC 8 <URL> ST <Link-text> OSC 8 ST
# See: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
#
# @Params
# $1: The hyperlink URL
# $2: The optional hyperlink text (defaults to URL)
#
# @Outputs
# The terminal-clickable hyperlink
hyperlink(){ printf "\e]8;;%s\e\\\\%s\e]8;;\e\\\\" "$1" "${2:-$1}";}


hl=$(
  hyperlink \
    "https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda" \
    "OSC 8 <URL> ST <Link-text> OSC 8 ST"
)

printf 'Demo of the %s sequence to make hyperlinks clickable in terminal:\n\n' \
  "$hl"

hyperlink https://www.example.com/ "Example link"
printf \\n
hyperlink https://www.example.com/
printf \\n

tmux 2.9a not hyperlinking text

Thanks for the tool / Go code. However it doesn't seem to be working in tmux 2.9a (I haven't tried other version combinations).

I've read some of the background re. tmux not fully supporting hyperlinks, so I figure this is probably more of a tmux problem than a haya14busa/hyperlink problem, but I figured I'd post this issue as FYI.

Plain gnome-terminal links correctly:
image

tmux 2.9a within gnome-terminal does not link the text:
image

I can verify the extra tmux escape sequences are present:

pda@pda220 ~ ❯ hyperlink http://example.org/ Example | hd 
00000000  1b 50 74 6d 75 78 3b 1b  1b 5d 38 3b 3b 68 74 74  |.Ptmux;..]8;;htt|
00000010  70 3a 2f 2f 65 78 61 6d  70 6c 65 2e 6f 72 67 2f  |p://example.org/|
00000020  07 1b 5c 45 78 61 6d 70  6c 65 1b 50 74 6d 75 78  |..\Example.Ptmux|
00000030  3b 1b 1b 5d 38 3b 3b 07  1b 5c                    |;..]8;;..\|

So they're either not quite right, or tmux is disregarding them for some reason. Either way, tmux seems to be stripping the hyperlink sequence before sending it to gnome-terminal.

I'm on latest 94acdd4. My TERM is xterm-256color outside tmux and tmux-256color inside tmux.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.