Skip to content
JP Bruins Slot edited this page Mar 14, 2020 · 24 revisions

Configuration

version
v0.4.1

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 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

  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, this redirect will fail, which is expected.

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

  5. 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]"
  1. From the response, copy the access_token and place it in your .slack-term

Alternatively you can do the following (source: @terabyte):

$ sudo apt-get install gdb
<...>
$ for i in $(ps auxwwwfg | grep firefox | grep -v grep | cut -c9-15); do gcore -o $i.core $i; done
$ cat *.core |  grep -ao 'xoxs-[-0-9a-f]*' | sort | uniq -c | sort
<output...>
$ rm *.core

.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",
            "<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",
            "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:.

Clone this wiki locally