Strange issue with terminal getting messed up: vim/coc-nvim/golang/gopls/zsh/gpg - go

I am having a very annoying issue and I don't know exactly what's the problem. It could have loads of possible causes, so please bear with me trying to fix this.
I use vim to code. I use coc.nvim as plugin for code completion and navigation. Languageserver is set to golang and I use this config:
{
"suggest.noselect": false,
"diagnostic.errorSign": "✘",
"diagnostic.warningSign": "!",
"diagnostic.infoSign": "?",
"diagnostic.checkCurrentLine": true,
"coc.preferences.currentFunctionSymbolAutoUpdate": true,
"coc.preferences.formatOnSaveFiletypes": [
"javascript",
"html",
"json",
"css",
"scss",
"go"
],
"languageserver": {
"golang": {
"command": "gopls",
"rootPatterns": [
"go.work",
"go.mod",
".vim/",
".git/",
".hg/"
],
"trace.server": "verbose",
"filetypes": [
"go"
],
"initializationOptions": {
"usePlaceholders": true
}
},
"golangci-lint-languageserver": {
"command": "golangci-lint-langserver",
"filetypes": [
"go"
],
"initializationOptions": {
"command": [
"golangci-lint",
"run",
"--out-format",
"json"
]
}
}
}
}
What's happening is that apparently randomly, if I open a .go file (it seems to happen mostly with go files which import libraries), my terminal gets irreparably messed up, usually completely messing up my editing session, not knowing if I was able to save or not my current buffer. Have to kill the shell!
Now, this started happening after at work we had been urged to use ssh keys stored on a yubikey. For this to work, we had to reconfigure the gpg-agent.
This is it's config:
enable-ssh-support
ttyname $GPG_TTY
default-cache-ttl 60
max-cache-ttl 60
pinentry-program /usr/bin/pinentry-curses
What I think is happening, is that during my vim editing session some ssh connection is opened (presumably to download github libs?). At the bottom appears something which looks like a prompt to enter the ssh key - but at this point I have lost the control of the terminal. Nothing works.
I think that is pinentry-curses which triggers that. But why is an ssh connection triggered and why does that mess up my terminal?
I run ubuntu 20.04 with i3, zsh with oh-my-zsh and powerlevel10k. I load these plugins for zsh, including the ssh-agent one which I think is needed:
plugins=(git z zsh-autosuggestions vi-mode ssh-agent)
I am really annoyed, any suggestion is highly appreciated!

Related

Show hostname for local host with powerline

I am using powerline with bash, fish, and tmux. The hostname shows up when logging in to remote systems with SSH. But I want to also enable the hostname segment for local users. Here is how it looks on a remote system.
Here is how it looks on as a local user. Note that I have hostname set on the local machine.
The tmux theme works fine.
I have tried editing the default theme by omitting the priority to always show the hostname segment disregarding the display width, and also edited the "only_if_ssh": false argument. How can I enable showing the hostname in the shell prompt as well?
I had to change the following config files to show the hostname for a local system.
Change powerline/config.json to make the key ext:shell:theme point to my custom theme .json file
Customize the theme file to your liking. I have the following in addition to other entries.
{
"segments": {
"left": [
{
"function": "powerline.segments.common.net.hostname",
"priority": 10
}
}
}
Edit __main__.json as follows.
{
"segment_data": {
"hostname": {
"args": {
"only_if_ssh": false
}
}
}
}

How to use a new Windows Terminal app for SSH? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
The Windows Terminal app is advertised as a central hub for all terminal work, so I'm interested in a way to bring my SSH connections into it and replace ancient PuTTY.
You can use a commandline field in your profile configuration to initiate an SSH connection on tab creation.
Step-by-step guide:
Ensure you have an SSH client (try to connect to the server from a Command Prompt tab). #dhgouveia2's post details this step.
Open Settings (Ctrl+,)
Find the "list" array in the "profiles" object
Find a Command Prompt profile ("commandline": "cmd.exe")
Duplicate the profile (copy-paste the whole object, watch for the comma between objects)
Change the "guid" value to a new GUID (for example, from here)
Change the commandline value to "commandline" : "ssh me#my-server -p 22 -i ~/.ssh/id_rsa" (use your own connection command).
Change the profile's "name"
Add an "icon" : "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png" item to use a Tux icon (default icons are here)
You should have something like this:
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"profiles":
{
"list":
[
// ...
{
"guid": "{1d43c510-93e8-4960-a18b-e432641e0930}",
"name": "ssh my-server",
"icon" : "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png",
"commandline": "ssh me#my-server -p 22 -i ~/.ssh/id_rsa"
}
]
}
}
Save the configuration and enjoy the new item in the New Tab drop-down.
You can use native ssh client from Windows 10,
From powershell
Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'
# This should return the following output:
Name : OpenSSH.Client~~~~0.0.1.0
State : NotPresent
Name : OpenSSH.Server~~~~0.0.1.0
State : NotPresent
Install the OpenSSH Client
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
It should return the following output:
Path :
Online : True
RestartNeeded : False
Uninstall the OpenSSH Client
Remove-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
Add the hosts to your ssh config file
From your home folder, go to the .ssh/config file, the folder may not exist if the ssh application has not been used, so it will be necessary to create it on you home folder
C:\Users\%USERPROFILE%\.ssh
#Damo post a very good documentation about the ssh config.
e.g config
Host test
User test
HostName 127.0.0.1
Port 22
IdentityFile ~/.ssh/id_rsa
Windows Terminal
Similar to the #Himura instructions, but instead of using "bash.exe" you will using "ssh.exe".
For connection to the remote host, you can use the hostname from the.ssh/config file e.g ssh.exe test, if you don't want to use a config file, you can use the user#ip ssh.exe test#127.0.0.1 and the password dialog will be promt
Edit your profile.json from the settings on Windows Terminal,
Duplicate a profile
Change the "guid" value to a new GUID
Change the commandline value with ssh.exe, e.g "commandline" : "ssh.exe test"
Change the profile's "name"
e.g
C:\Users\%USERPROFILE%\.ssh\config
Host vagrant
Hostname 127.0.0.1
Port 2222
User vagrant
IdentityFile ~/.ssh/vagrant.key
profile.json
...
{
"acrylicOpacity" : 0.75,
"closeOnExit" : true,
"colorScheme" : "One Half Dark",
"commandline" : "ssh.exe vagrant",
"cursorColor" : "#FFFFFF",
"cursorShape" : "bar",
"fontFace" : "DejaVu Sans Mono for Powerline",
"fontSize" : 10,
"guid" : "{1777cdf0-b2c4-5a63-a204-1111f349ea7c}",
"historySize" : 9001,
"icon" : "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png",
"name" : "Vagrant",
"padding" : "0, 0, 0, 0",
"snapOnInput" : true,
"startingDirectory" : "%USERPROFILE%",
"useAcrylic" : true
}
....
If you want to set the new entry as default, search for the defaultProfile key
....
"globals" :
{
"alwaysShowTabs" : true,
"copyOnSelect" : false,
"defaultProfile" : "{1777cdf0-b2c4-5a63-a204-1111f349ea7c}",
"initialCols" : 120,
"initialRows" : 30,
....
If you want to stay in the terminal and easily manage all your ssh connections inside WSL then i would recommend using the built in ssh config management in the ssh command.
Basically you put all your different ssh configurations in to the file ~/.ssh/config
There is a good post documenting the basic use of this here
Hope this helps.
If you want to connect to a machine on Google Compute Engine using Windows Terminal, you can write a script to replace the default command and use ssh instead of putty.exe. More details here.

How to use ftp.simple in VSCode

I have installed ftp.simple, watched the YouTube video, created a SFTP config for a remote server in the ftp-simple-temp-json, and run the command: Open the file directly from FTP server, among others. Nothing happens -- no messages as sent in the video. Any ideas about what is going wrong? Is there a log file that I can look at? Thanks, Sue.
after installing ftp-simple from extensions
1- check your internet connection.
2- restart VS CODE.
3- cmd + shift + p --> type: ftp-simple:Config --> Enter
4- you can see ftp-simple-temp.json file change it like so
[
{
"name": "Sample-Name",
"host": "Sample-Host",
"port": 21,
"type": "ftp",
"username": "Your FTP USERNAME",
"password": "Your FTP PASSWORD",
"path": "/",
"autosave": true,
"confirm": true
}
]
---> save then hit enter.
5- a little bar at the top of the window shows up with "Sample-Name" given above --> hit enter
6- wait a moment (depending on your internet connection speed)
then another little bar pops up with a directory of your FTP server and just hit enter to see the entire project folder.
you should be fine...
You can check the logs to see if an error occurred.
%appdata%/Code/logs/[Date]/renderer1.log
I found the error I had using this file.
My versions:
VSCode 1.27.2 (64 bits)
ftp-simple 0.6.7
Press F1, in the input type ftp-simple
Click on the ftp-simple:Config then a file will be open
fill the file with true information like below and save it:
{
"name": "any given name",
"host": "given ftp address",
"port": 21,
"type": "ftp",
"username": "given username",
"password": "given password",
"path": "/",
"autosave": true,
"confirm": true
}
Press F1 again and type ftp-simple and click on ftp-simple:Open then your chosen name in a little bar will be show up on top
click on chosen name on the top bar and go to directory you want
if after doing this nothing happened or in the 4th step nothing show up to you then go to log file directory: a address like below
C:\Users\username\AppData\Roaming\Code\logs
and find out what is the problem.

AWS Lambda - Zip Issue- "errorMessage": "Cannot find module './dist/commonjs/index.js'",

One error is:
"errorMessage": "Cannot find module './dist/commonjs/index.js'",
The other error is:
Unable to import module 'index': Error
at Function.Module._resolveFilename (module.js:469:15)
I've seen other posts on the second error, but I've done everything they recommend and still stuck. And they don't mention the /dist/commonjs/index.js issue.
My Lambda Function Handler is set to "index.handler" and my main code is in index.js.
I'm on Windows. My zip file (HebrewVocab.zip) looks like this.
And the node_modules folder seems to be complete and looks like this:
I zipped and uploaded with a PowerShell that I wrote:
Compress-Archive -Path index.js,package.json,node_modules -DestinationPath $ZipFileName
aws lambda update-function-code --function-name HebrewVocab --zip-file
fileb://HebrewVocab.zip
My index.js starts with this code:
exports.handler = function(event, context, callback) {
var alexa = Alexa.handler(event, context, callback);
alexa.registerHandlers(handlers);
alexa.execute();
};
So I seem to meet all the requirements I read on all the other posts of the similar error. I got a HelloWorld project working earlier, but it didn't use the alexa-sdk.
I also did "npm install npm" as one person on Stackoverflow suggested? Is that necessary?
When I "test" in Lamba, as compared to use Alexa voice to test, I see the details:
"errorMessage": "Cannot find module './dist/commonjs/index.js'",
Should ./dist/commonjs be the standard path prefix? I have even exported the "function" to my hard drive (as a .zip), and it's exactly what I uploaded), and there is definitely an index.js there in the root of the .zip file.
As a wild guess, I discovered that commonjs is a package, so I did an "npm install commonjs --save", rezipped, and re-uploaded, but same exact result.
I later found there is a /node_modules/i18next/dist/commonjs with an index.js, but not sure if that is related or not. I even tried copying that dist/commonjs to my root and under node_modules, but still same error.
It runs fine when I run locally with:
lambda-local -l index.js -h handler -e eventHelloWorld.json
Screenshot of errorMessage:
And last but not least, my package.json looks like this:
{
"name": "HebrewVocab",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"alexa-sdk": "^1.0.18",
"commonjs": "0.0.1",
"npm": "^5.5.1"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
What else can I try? I posted in Amazon support forum, but no answer, so my project is stuck until I get this figured out.
Update 11/07/2017:
Okay, I just made one crazy observation. The .zip created by the above Powershell creates a different size .zip than doing a Windows right-click, "Send to" Compressed Folder. If I compare the two zips using Total Command "Synchronize Directories", all the files and structure are identical in content. Yet the one created from the manual Windows zip works, and the one created by Powershell gives the error reported originally in this thread.
The one created by Powershell is slightly smaller 5,019,123 vs 5,032,770. I tried some of the other powershell compression options, but they created much larger files (turning it off yielded about a 30 MB file).
I have entered the twilight zone - any ideas?
​
For Windows, I ended up using 7-zip as follows (in a Powershell file, so $ZipFileName is a variable defined on a previous line).
& "c:\Program Files\7-Zip\7z.exe" a -r $ZipFileName index.js package.json client_secret.json GoogleCalendarAPI.js node_modules .credentials calendar-nodejs-quickstart.json
I ran into the same issue using a PowerShell script to zip and upload code for a lambda function to be called by an Alexa skill. According to issue #2140 in the PowerShell github repo, Compress-Archive produces archives that are incompatible with OS X, and I suspect any Unix derived OS.
I ended up using bash -c 'zip -r filename *' as mentioned here since I already had the linux subsystem for windows installed. I initially tried Compress-7Zip (also mentioned), but it was very slow, to the point that I thought it had hung the first couple of times I tried it.
You can zip the old school way like this:
function ZipFiles( $zipfilename, $sourcedir )
{
Add-Type -Assembly System.IO.Compression.FileSystem
$compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal
[System.IO.Compression.ZipFile]::CreateFromDirectory($sourcedir,
$zipfilename, $compressionLevel, $false)
}
$zipdest = (Get-Item .\ | Select-Object -ExpandProperty FullName) + '\lambda.zip'
$zippath = (Get-Item .\lambda | Select-Object -ExpandProperty FullName)
ZipFiles $zipdest $zippath

Puppet and Windows directory permissions

I can't believe how difficult puppet is being with Windows - particularly windows permissions! I have a very simple pp file that I'm trying to execute:
case $operatingsystem {
...
'Windows': {
file { 'c:/puppet/':
ensure => directory,
owner => 'myUser',
group => 'Administrators',
mode => '0777',
}
}
}
This seems as simple as it could get - create a directory called "c:\puppet" and let everyone have access - IT'S NOT WORKING! It creates a directory, but nobody has ANY permissions (except special permissions). I am in the administrators group, so I can delete it and access it, but I want to drop stuff inside and be able to install from there (since apparently an "http" source doesn't work directly on Windows ...).
Is ANYONE else using puppet for Windows, or am I just using the wrong tool for this job? I am getting very frustrated, and the documentation seems reasonable, but without simple examples of how I'm trying to use puppet I'm getting completely stuck.
have you checked out
https://forge.puppetlabs.com/puppetlabs/acl
from their docs you can do something like..
acl { 'c:/puppet':
permissions => [
{ identity => 'Administrator', rights => ['full'] },
{ identity => 'myuser', rights => ['read','execute'] }
owner => 'myuser',
],
}
I've come up with a solution that seems to be systems administration by blunt force trauma:
exec { 'fix_acls':
command => 'cmd.exe /c "takeown /r /f c:\puppet && icacls c:\puppet /grant SYSTEM:(OI)(CI)F myUser:(OI)(CI)F /T"',
path => $::path,
}
This gives myUser and SYSTEM access, I could also do this with USERS in general I think, but it seems there must be a better way.

Resources