BashConfig
## Content
* [Project description](#chapter-0)
* [SSH](#chapter-1)
* [Tips](#chapter-2)
## Project description
Bash config files
## SSH
Create ssh key on local device
1. `ssh-keygen`
2. Save to `~/.ssh`
3. Enter passphrase
4. Copy content of `~/.ssh/id_rsa.pub` key to remote `~/.ssh/authorized_keys`
\
Add aliases for ssh to `~/.ssh/config`:
```
Host host_name
HostName ip
Port 22
User root
IdentityFile ~/.ssh/id_rsa
```
\
Using aliases:
```bash
ssh host_name
sftp host_name
```
## Tips
### Bash
| Command | Description |
|:------------------: | :------------------ |
|```Alt + . ``` ```Esc + .``` | Last object |
|```Ctrl + r``` | Search by bash_history |
|```Ctrl + l``` | Clear, like command clear |
### Vim
| Command | Description |
|:------------------: | :------------------------------------ |
|```Ctrl + [``` | Analog Esc |
|```d -> Ctrl + End``` | Delete from cursor to end of file |
| ```u``` | Undo |
| ```Ctrl + r``` | Redo |
| ```22G``` | Go to line 22
#### Update .bashrc .bash_aliases by ssh
```bash
ssh hosting 'rm -rf ~/BashConfig; git clone https://github.com/TheK4n/BashConfig && cp BashConfig/.bash* ~/BashConfig; rm -rf ~/BashConfig'
```
### Autostart
```bash
sudo vim /etc/systemd/system/.service
sudo systemctl daemon-reload
sudo systemctl start .service
sudo systemctl status .service
sudo systemctl enable .service
```
#### file "/etc/systemd/system/.service"
```text
[Unit]
Description=
After=network.target
[Service]
Type=simple
User=
Group=
ExecStart=
ExecReload=
WorkingDirectory=
KillMode=process
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
```
### Autocomplete
#### file "/etc/bash_completion.d/ssh"
```bash
_ssh() {
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts=$(grep '^Host' ~/.ssh/config ~/.ssh/config.d/* 2>/dev/null | grep -v '[?*]' | cut -d ' ' -f 2-)
COMPREPLY=( $(compgen -W "$opts" -- ${cur}) )
return 0
}
complete -F _ssh ssh
```