Skip to content
JP Bruins Slot edited this page May 5, 2020 · 24 revisions

Configuration

version
v0.5.0

Running slack-term

In addition to running slack-term from the command line by using slack-term, you have some additional flags that you can use:

-config [path-to-config-file]

Allows you the specify a different location of the slack term config file. This enables you to run several slack-term instances with different configurations/tokens.

-token [slack-token]

Allows you to specify the slack-token that needs to be used, from the command line. There is also an option to set the slack-token for a single slack-term instance by setting the SLACK_TOKEN environment variable.

Running slack-term without legacy tokens

Also see: https://github.com/erroneousboat/slack-term/issues/136

Method 1

  1. Go to the following page: https://slack.com/oauth/authorize?client_id=91899392594.382712253827&scope=client

  2. Select the workspace to which you want slack-term to provide access to.

  3. Click "Authorize", this will redirect you to a page that contains further instructions.

It is possible that you'll get a message that you're not authorized to install slack-term, there are restrictions on installing apps for a workspace and you need to ask an admin permission for that. You can do that here: https://my.slack.com/apps/AB8LY7FQB-slack-term and click "Request to Install".

Method 2

If you don't want your oauth token be sent to github pages, do the following:

  1. Go to the following page: <https://slack.com/oauth/authorize?client_id=91899392594.382712253827&scope=client&redirect_uri=http%3A%2F%2Fnot.a.host

  2. Click "Authorize", this will redirect you, this redirect will fail, which is expected.

  3. Copy the code portion of the URL. http://not.a.host?code=[code-will-be-here]&state=

  4. In your terminal issue the following command, inserting the code at the right location:

$ curl -s "https://slack.com/api/oauth.access?client_id=91899392594.382712253827&client_secret=c7986be41b6ddb478041d1848dad5f6e&code=[code-goes-here]"

Method 3

source: @terabyte @johnseekins:

# NOTE: needs gdb
$ for i in $(ps auxwwwfg | grep firefox | grep -v grep | awk '{print $2}'); do gcore -o $i.core $i; done
$ grep -ao 'xox.-[-0-9a-f]*' *.core.* | sort | uniq -c | sort

Replace xoxc with xoxs.

Method 4

Source: emacs-slack

  1. Go to slack customization page
  2. Open developer tools
  3. Go to the console and enter: window.prompt("your api token is: ", TS.boot_data.api_token)

Threads

When threads are present in the channel the thread will be shown in the main chat window together with other messages, also the threads will be shown on the right side in a sidebar. When scrolling through the threads in the sidebar it will refresh the main chat window with only the messages in that specific thread. The threads use a hash for their identification, and you'll be able to move through the channels with the thread-up and thread-down key command. This is by default J, K (note shift+j and shift+k). Additionally, you're able to reply to a thread using the hash of the thread and using the following slash command: /reply [hash] hello, world.

slack term config file

Below is an example file, you can leave out the OPTIONAL parts, you are only required to specify a slack_token. Remember that your file should be a valid json file so don't forget to remove the comments.

{
    "slack_token": "yourslacktokenhere",

    // OPTIONAL: set the width of the sidebar (between 1 and 11), default is 1
    "sidebar_width": 1,

    // OPTIONAL: turn on desktop notifications for all incoming messages, set
    // the value as: "all". For only mentions and im messages set the
    // value as: "mention", default is turned off: ""
    "notify": "",

    // OPTIONAL: turn on emoji's, default is false
    "emoji": false,

    // OPTIONAL: define custom key mappings, defaults are:
    "key_map": {
        "command": {
            "i": "mode-insert",
            "/": "mode-search",
            "k": "channel-up",
            "j": "channel-down",
            "g": "channel-top",
            "G": "channel-bottom",
	    "K": "thread-up",
	    "J": "thread-down",
            "<previous>": "chat-up",
            "C-b": "chat-up",
            "C-u": "chat-up",
            "<next>": "chat-down",
            "C-f": "chat-down",
            "C-d": "chat-down",
            "n": "channel-search-next",
            "N": "channel-search-previous",
            "'": "channel-jump",
            "q": "quit",
            "<f1>": "help"
        },
        "insert": {
            "<left>": "cursor-left",
            "<right>": "cursor-right",
            "<enter>": "send",
            "<escape>": "mode-command",
            "<backspace>": "backspace",
            "C-8": "backspace",
            "<delete>": "delete",
            "<space>": "space"
        },
        "search": {
            "<left>": "cursor-left",
            "<right>": "cursor-right",
            "<escape>": "clear-input",
            "<enter>": "clear-input",
            "<backspace>": "backspace",
            "C-8": "backspace",
            "<delete>": "delete",
            "<space>": "space"
        }
    },

    // OPTIONAL: override the default theme, defaults are:
    "theme": {
        "view": {
            "fg": "white",
            "bg": "default",
            "border_fg": "white",
            "border_bg": "",
            "label_fg": "white",
            "label_bg": ""
        },
        "channel": {
            "prefix": "",
            "icon": "",
            "text": ""
        },
        "message": {
            // This uses golang time formatting:
            // - https://yourbasic.org/golang/format-parse-string-time-date-example/
            // - https://golang.org/pkg/time/#Time.Format
            "time_format": "15:04",
            
            // You can use 'colorize' to give every name an individual color
            "name": "",

            "time": "",
            "text": ""
        }
    }
}

Below is a full example of an updated .slack-term file:

{
    "slack_token": "token",
    "notify": "mention",
    "emoji": true,
    "theme": {
        "message": {
            "time_format": "02/01 15:04",
            "time": "fg-green,fg-bold",
            "name": "colorize,fg-bold",
            "text": "fg-blue"
        },
        "channel": {
            "prefix": "fg-red,fg-bold",
            "icon": "fg-green,fg-bold",
            "text": "fg-blue,fg-bold"
        }
    }
}

Theme

Since version 0.3.0 you'll be able to set some colors and the bold attribute in slack-term. To set this you'll need to update your .slack-term file. Below are the default settings which you can override. You can combine colors and attributes by separating them with a , (comma).

{
    "theme": {
        "view": {
            "fg": "white",
            "bg": "default",
            "border_fg": "white",
            "border_bg": "",
            "label_fg": "green,bold"
        },
        "channel": {
            "prefix": "",
            "icon": "",
            "text": ""
        },
        "message": {
            "time": "",
            "name": "",
            "text": ""
        }
    }
}

For the view section you're be able to choose the following colors:

colors
default
black
red
green
yellow
blue
magenta
cyan
white

NOTE: For both the channel and message section you'll be able to set the fore- and background. But this is different from the view section. Prepend the color with either fg- or bg- to get the desired result. E.g. fg-red or fg-magenta,bg-cyan,fg-bold.

Emoji's

You can enable emoji's in the .slack-term file by adding the following key / value:

{
    "emoji": true
}

When supported by your terminal you'll be able to see emoji's. To use emoji's in your messages, use their emoji text value, e.g.: :thumbsup:.