Working on my SSH on gitbash. On the part where I type in vim ~/.ssh/config
It's completely blank so I enter the info below and want to save. How do I scroll down to --Insert-- to type in ":wq" to save it? I tried the tab button, pg dn, enter, arrow button.
Host *
AddKeysToAgent ...
IdentityFile ...
~
~
~
--Insert-
You can use the following command: Esc + :wq
Related
This is my .tmux.conf
setw -g mouse on
set-option -s set-clipboard off
bind-key -T copy-mode MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -selection clipboard -i"
Works well on a linux machine locally. Mouse selection is copied to system clipboard automatically.
However, in a remote session (iTerm + Mac), it doesn't work. Text isn't copied to the client's system clipboard. Apparently I have to use OSC 52. Here is a helper script.
You can use the script like so:
echo "whatever text" | osc52.sh
Now "whatever text" is copied to the client's system clipboard.
However I can't get the script to work with tmux mouse selection:
setw -g mouse on
set-option -s set-clipboard off
osc52="~/osc52.sh"
bind-key -T copy-mode MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "$osc52"
Any help is appreciated. Thanks!
This is not the way to use OSC 52. You can't send it from a script - all output from commands run from copy-pipe is ignored.
Instead, you need to configure tmux itself to do it. Try the following:
1) Remove the bind-key command and just leave MouseDragEnd1Pane as the default which is copy-selection.
2) Change set-clipboard off to set-clipboard on. Remember to restart tmux entirely after changing .tmux.conf.
3) Make sure TERM outside tmux is xterm or xterm-256color so that tmux adds the Ms capability from the default terminal-overrides. This should be the default in iTerm2. Make sure you are not removing it from terminal-overrides in .tmux.conf.
4) In iTerm2, I think you need to turn on this option, "Applications in terminal may access clipboard":
To add key in Gitbash Make sure to use to enable ssh agent first.
eval $(ssh-agent -s)
[enter image description here][1]
Now you can add ssh key in git bash using below command.
if you are doing it in windows Git Bash.
ssh-add /c/keyname
How to check if the key is added.
ssh-add -L
you should see the ssh key added here .
Below are the steps:
Open Git Bash and run below command on command prompt to generate public-private key pair ssh-keygen -t rsa -b 4096 -C "your_email#gmail.com"
When you are prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location.
Enter a file in which to save the key (/c/Users/username/.ssh/id_rsa):[Press enter]
At the prompt, type a secure passphrase. You can press enter if you want to leave it blank but its not recommended.
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
Go to /c/Users/username/.ssh/ folder and open id_rsa.pub file and copy entire contents of it.
Finally, go to Github -> Settings -> SSH And GPG keys -> Click New RSA (Green Button). Give some meaningful title to the key and paste the public key copied in step 4 above. Now click on Add SSH Key button.
Congrats, you have added public key to github successfully and now you can use gitbash to access github repositories.
Usually, I take a look from git GUI (in Windows). There is a menu about SSL (or SSH) and you can view the imported key.
I'm running a RPi 3 as an infoscreen. Im just starting chromium with the xinit command from rc.local, so far so good. I'm having trouble to hide the cursor. When i do this from command line (SSH) when the screen is running this works just fine:
DISPLAY="0.0 ; export DISPLAY
unclutter -idle 0.1 -root
But I cant find out where to put this so this starts automaticly. It seems that setting DISPLAY in the rc.local file doesnt work. When i try to run unclutter without setting DISPLAY it can't open the display. Where do I set the DISPLAY variable at startup?
I would find it better for the script to run at login, and this is how you would do it:
You can add your script executable command to the bottom of .bashrc that will run your script every time you log in.
Make sure you are in the pi folder:
$ cd ~
Create a file and write the script to run in the file:
$ sudo nano superscript
Save and exit: Ctrl+X, Y, Enter
Open up .bashrc for configuration:
$ sudo nano .bashrc
Scroll down (Down arrow key) to the bottom and add the line: ./superscript
Save and exit: Ctrl+X, Y, Enter
Here is what my dashboard looks like:
Not really sure where to add an SSH key. Anyone have any idea?
You need to sign in. Green button top right.
Click 'profile settings' on the left side menu.
Click SSH Keys and follow the instructions on the page.
Go to your GitLab account: https://gitlab.com/
Click on Settings on the top right drop-down, which will appear once you select the icon(white-fox image [specific to my profile]).
Click on Settings on the top right drop-down, which will appear once you select the icon(white-fox image).
Click on SSH Keys:
Add/Paste the SSH Key.
How to generate the ssh key: Download gitbash or putty:
After downloading gitbash/putty follow the steps:
Open a terminal on Linux or macOS, or Git Bash / WSL on Windows.
Generate a new ED25519 SSH key pair:
ssh-keygen -t ed25519 -C "email#example.com"
Or, if you want to use RSA:
ssh-keygen -t rsa -b 4096 -C "email#example.com"
It will generate the key in => C:\Users\yourname.ssh directory.
Copy the public key and paste in the gitlab location:
Command to run on gitbash to clone the repository:
ssh-agent $(ssh-add C:\Users\youname\.ssh\id_rsa; git clone git#gitlab.com:xyz/SpringBootStarter.git)
Just follow the official guides to Create and Add SSH keys.
Goto https://gitlab.com/profile/keys.
If you are a new user a banner will show at the top of each project page.
You won't be able to pull or push project code via SSH until you add
an SSH key to your profile
However, you can dismiss this warning.
First, you need to do open terminal after that type
mkdir -p ~/.ssh
echo public_key_string >> ~/.ssh/authorized_keys
chmod -R go= ~/.ssh
chown -R shabeer:shabeer ~/.ssh
ssh-keygen or ssh-keygen -t ed25519 -C "mail#example.com"
xclip -sel clip < ~/.ssh/id_ed25519.pub
~/.ssh/gitlab_rsa.pub
in this time can see your key and copy it, After that Go to the Gitlab settings and chose SSH Keys, you can see there have to option add that copied key
I frequently find myself wanting to repeat a command, and while !! is useful, I'd like to bind that to ctrl-w or something like that. Is there a way to do that?
EDIT: I'm aware that the up arrow does what I want, however I would rather not have to leave the home row. Being an avid Vim user has taught me the value of staying on the home keys.
I looked at this post about adding a shortcut to access the info command and tried to extrapolate something out of it, but had no success. Zsh yelled at me about zle not being active or something.
I know this will rely on knowledge of how my shell is configured, so below I've pasted some relevant code, as well as a link to my entire .zshrc and dotfiles in general.
# oh-my-zsh plugins. zsh-aliases and drush are custom plugins.
plugins=( git z tmux web-search colored-man zsh-aliases drush)
ZSH_TMUX_AUTOSTART=true
#... $PATH, start background process (clipboard integration for tmux,
# glances system monitor), history options, editor, all truncated for brevity.
# use vim mode
bindkey -v
#show insert/normal mode in prompt
function zle-line-init zle-keymap-select {
RPS1="${${KEYMAP/vicmd/NORMAL}/(main|viins)/INSERT}"
RPS2=$RPS1
zle reset-prompt
}
zle -N zle-line-init
zle -N zle-keymap-select
# rebind ctrl-r
bindkey -M vicmd '^R' history-incremental-search-backward
bindkey -M viins '^R' history-incremental-search-backward
Full configs: https://github.com/yramagicman/dotfiles
Just the .zshrc: https://github.com/yramagicman/dotfiles/blob/master/.zshrc
custom plugins:
https://github.com/yramagicman/drush-zsh-plugin
https://github.com/yramagicman/zsh-aliases
To get the last command from the history you can use the up-history widget. This is by default bound to Ctrl+P in vicmd mode, so pressing Esc followed by Ctrl+P and then Enter (which invokes the widget accept-line) would do the trick.
If you want to bind it to a single shortcut, you have to write your own widget. You can add this to your ~/.zshrc:
# define function that retrieves and runs last command
function run-again {
# get previous history item
zle up-history
# confirm command
zle accept-line
}
# define run-again widget from function of the same name
zle -N run-again
# bind widget to Ctrl+X in viins mode
bindkey -M viins '^X' run-again
# bind widget to Ctrl+X in vicmd mode
bindkey -M vicmd '^X' run-again
For the example I chose Ctrl+X as shortcut because by default it is unbound in vicmd mode and self-inserts in in viins mode, whereas Ctrl+W is already bound to vi-backward-kill-word in viins. Of course you could overwrite the default binding if you do not use it anyway or bind the widget only in mode.
EDIT: Alternative that doesn't break Esc/ search:
accept-line() { [ -z "$BUFFER" ] && zle up-history; zle ".$WIDGET"; }
zle -N zle-line-init
Redefine default Enter command so it inserts last command if the buffer is empty. Inspired by this answer.
ORIGINAL:
I have this in my .zshrc:
last_if_empty() {
[ -z "$BUFFER" ] && zle up-history
zle accept-line
}
zle -N last_if_empty
bindkey -M viins '^M' last_if_empty
It remaps Enter to Run last command if nothing has been typed on the screen.
Unfortunately it seems to break Esc/ search (Enter key doesn't work). I use Ctrl+R so it doesn't bother me, but might be a dealbreaker.