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
}
}
}
}
Related
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!
I am wondering how to change the starting directory of my windows terminal from /home/user/ to C:/Users/user. I tried a few things I found, but nothings works. This is my current profile specified in the settings.json file:
{
"acrylicOpacity" : 1,
"closeOnExit" : true,
"colorScheme" : "One Half Dark",
"commandline" : "ubuntu",
"cursorColor" : "#FFFFFF",
"cursorShape" : "bar",
"fontFace" : "Consolas",
"fontSize" : 10,
"guid" : "{ba50f801-2d96-4517-a737-575f32f0fb61}",
"historySize" : 9001,
"icon" : "C:/Users/user/Pictures/ubuntu.png",
"name" : "Ubuntu",
"padding" : "0, 0, 0, 0",
"snapOnInput" : true,
"startingDirectory" : "C:\\Users\\user",
"useAcrylic" : true
}
but when I open the terminal the prompt is user#laptop:~$ and pwd gives /home/user/
If you mean wsl, you can set startingDirectory just like this:
"startingDirectory": "//wsl$/Ubuntu/home/user"
You can explore the path \\wsl$ in Windows Explorer.
This works for me (on Windows Terminal 1.0.1401.0, WSL2 and Ubuntu 20.04):
"startingDirectory": "C:/Users/user"
The issue was that there was an auto-generated ubuntu profile in addition to the one I created. I started using the auto-generated one and removed the "commandline" : "ubuntu" option and it now listens to the startingDirectory
for me it worked when i added the version number: //wsl$/Ubuntu-20.04/home/username
To change the starting directory of windows terminal:
Open windows terminal settings
Go to Ubuntu profile page and change "Starting Directory" to \\wsl$\Ubuntu\home\<user>
Note: I posted another answer cause it did not work for me using forward slashes
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.
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.
When running Ansible ad-hoc to remove users I was unable to feed multiple items to
module. Like this:
ansible -i my_inv all -m user -a"name={{ users }} state=absent" --check --extra-vars='{"users":["user1","user2"]}'
the output is:
server1 | SUCCESS => {
"changed": false,
"name": "['user1', 'user2']",
"state": "absent"
}
it seems to be not opening array correctly.
Making json file also didnt work.
{
"users":["user1","user2"]
}
Is there any way to do it without writing a role?
No.
name parameter of user module takes a string as an argument, not a list.
You need either to loop (and for that you'd need a play - not necessarily a role), or run ansible executable several times.