Skip to content

Commit

Permalink
Set COLUMNS and LINES in container shell (#804)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfay committed May 1, 2018
1 parent 996b8c4 commit 5b52556
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/ddevapp/ddevapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ddevapp

import (
"fmt"
"golang.org/x/crypto/ssh/terminal"
"net/url"
"os"
"path/filepath"
Expand All @@ -23,7 +24,7 @@ import (
"github.com/drud/ddev/pkg/util"
"github.com/fsouza/go-dockerclient"
"github.com/lextoumbourou/goodhosts"
shellwords "github.com/mattn/go-shellwords"
"github.com/mattn/go-shellwords"
)

const containerWaitTimeout = 61
Expand Down Expand Up @@ -737,6 +738,15 @@ func (app *DdevApp) DockerEnv() {
"DDEV_ROUTER_HTTPS_PORT": app.RouterHTTPSPort,
}

// Find out terminal dimensions
columns, lines, err := terminal.GetSize(0)
if err != nil {
columns = 80
lines = 24
}
envVars["COLUMNS"] = strconv.Itoa(columns)
envVars["LINES"] = strconv.Itoa(lines)

if len(app.AdditionalHostnames) > 0 {
// TODO: Warn people about additional names in use.
envVars["DDEV_HOSTNAME"] = strings.Join(app.GetHostnames(), ",")
Expand Down
6 changes: 6 additions & 0 deletions pkg/ddevapp/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ services:
com.ddev.app-type: {{ .appType }}
com.ddev.approot: $DDEV_APPROOT
com.ddev.app-url: $DDEV_URL
environment:
- COLUMNS=$COLUMNS
- LINES=$LINES
web:
container_name: {{ .plugin }}-${DDEV_SITENAME}-web
image: $DDEV_WEBIMAGE
Expand All @@ -49,6 +53,8 @@ services:
- DDEV_ROUTER_HTTPS_PORT=$DDEV_ROUTER_HTTPS_PORT
- DEPLOY_NAME=local
- VIRTUAL_HOST=$DDEV_HOSTNAME
- COLUMNS=$COLUMNS
- LINES=$LINES
# HTTP_EXPOSE allows for ports accepting HTTP traffic to be accessible from <site>.ddev.local:<port>
# To expose a container port to a different host port, define the port as hostPort:containerPort
- HTTP_EXPOSE=${DDEV_ROUTER_HTTP_PORT}:80,{{ .mailhogport }}
Expand Down
2 changes: 2 additions & 0 deletions pkg/testcommon/testcommon.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ func ClearDockerEnv() {
"DDEV_PROJECT_TYPE",
"DDEV_ROUTER_HTTP_PORT",
"DDEV_ROUTER_HTTPS_PORT",
"COLUMNS",
"LINES",
}
for _, env := range envVars {
err := os.Unsetenv(env)
Expand Down

0 comments on commit 5b52556

Please sign in to comment.