Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jan 17, 2021. It is now read-only.
/sshcodePublic archive

Adding git bash support, closes #94#124

Closed
eargollo wants to merge3 commits intocoder:masterfromeargollo:windows-gitbash
Closed
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions.gitignore
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,3 +2,4 @@ vendor
bin
.vscode
sshcode
sshcode.exe
1 change: 1 addition & 0 deletionsREADME.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,6 +35,7 @@ We currently support:
- Linux
- MacOS
- WSL
- Windows Git Bash (MINGW64) - Requires rsync for Windows. To install rsync download it [here](http://repo.msys2.org/msys/x86_64/rsync-3.1.3-1-x86_64.pkg.tar.xz) and run `tar xvf rsync-3.1.3-1-x86_64.pkg.tar.xz` on Git bash. Don't forget to copy the executable to a folder in the PATH ` cp usr/bin/rsync.exe /mingw64/bin`.

For the remote server, we currently only support Linux `x86_64` (64-bit)
servers with `glibc`. `musl` libc (which is most notably used by Alpine Linux)
Expand Down
29 changes: 29 additions & 0 deletionsmain.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,9 @@ import (
"fmt"
"math/rand"
"os"
"os/user"
"path/filepath"
"runtime"
"strings"
"time"

Expand DownExpand Up@@ -77,6 +80,11 @@ func (c *rootCmd) Run(fl *flag.FlagSet) {
dir = "~"
}

// Get linux relative path if on windows
if runtime.GOOS == "windows" {
dir = relativeWindowsPath(dir)
}

err := sshCode(host, dir, options{
skipSync: c.skipSync,
sshFlags: c.sshFlags,
Expand DownExpand Up@@ -112,3 +120,24 @@ Arguments:
helpTab,
)
}

func relativeWindowsPath(dir string) string {
usr, err := user.Current()
if err != nil {
flog.Error("Could not get user: %v", err)
return dir
}
rel, err := filepath.Rel(usr.HomeDir, dir)
if err != nil {
return dir
}
rel = "~/" + filepath.ToSlash(rel)
return rel
}

// gitbashWindowsDir translates a directory similar to `C:\Users\username\path` to `~/path` for compatibility with Git bash.
func gitbashWindowsDir(dir string) (res string) {
res = filepath.ToSlash(dir)
res = "/" + strings.Replace(res, ":", "", -1)
return res
}
6 changes: 6 additions & 0 deletionssettings.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,6 +24,9 @@ func configDir() (string, error) {
path = os.ExpandEnv("$HOME/.config/Code/User/")
case "darwin":
path = os.ExpandEnv("$HOME/Library/Application Support/Code/User/")
case "windows":
// Can't use the filepath.Clean function to keep Linux format path that works well with gitbash
return gitbashWindowsDir(os.ExpandEnv("$HOME/.config/Code/User")), nil
default:
return "", xerrors.Errorf("unsupported platform: %s", runtime.GOOS)
}
Expand All@@ -39,6 +42,9 @@ func extensionsDir() (string, error) {
switch runtime.GOOS {
case "linux", "darwin":
path = os.ExpandEnv("$HOME/.vscode/extensions/")
case "windows":
// Can't use the filepath.Clean function to keep Linux format path that works well with gitbash
return gitbashWindowsDir(os.ExpandEnv("$HOME/.vscode/extensions")), nil
default:
return "", xerrors.Errorf("unsupported platform: %s", runtime.GOOS)
}
Expand Down
4 changes: 2 additions & 2 deletionssshcode.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -494,8 +494,8 @@ curl $curlflags https://codesrv-ci.cdr.sh/latest-linux
ln latest-linux %v
chmod +x %v`,
codeServerPath,
filepath.Dir(codeServerPath),
filepath.Dir(codeServerPath),
filepath.ToSlash(filepath.Dir(codeServerPath)),
filepath.ToSlash(filepath.Dir(codeServerPath)),
codeServerPath,
codeServerPath,
codeServerPath,
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp