Clening of setup script. Add ssh config

This commit is contained in:
2023-10-17 09:47:25 +02:00
parent 2d63016f8a
commit 497f1b1fa6
3 changed files with 54 additions and 31 deletions

View File

@@ -4,13 +4,17 @@ function install_dependencies() {
sudo -n apt-get update
sudo -n DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
fish \
neovim
neovim \
tmux
}
function setup_ssh() {
mkdir -p ~/.ssh
touch ~/.ssh/config
chmod 644 ~/.ssh/config
cat << EOF >> ~/.ssh/config
Include ${HOME}/dotfiles/ssh.config
EOF
}
function setup_git() {
@@ -22,43 +26,50 @@ function setup_git() {
EOF
setup_ssh
cat << EOF >> ~/.ssh/config
Host *
AddKeysToAgent yes
IdentityFile ~/.ssh/thomas_rsa
VisualHostKey yes
Host github.com
User git
Host gitea
HostName git.thomasloven.com
User git
EOF
}
USER=`whoami`
function setup_tmux() {
cat << EOF > ~/.tmux.conf
source ${HOME}/dotfiles/tmux/tmux.conf
EOF
}
if [[ ${REMOTE_CONTAINERS} || ${DEVCONTAINER} ]]; then
function setup_fish() {
USER=`whoami`
sudo -n chsh $USER -s $(which fish)
# Force fish shell for devcontainers
echo "exec $(which fish) -l" >> ~/.profile
echo "exec $(which fish) -l" >> ~/.bashrc
echo "exec $(which fish) -l" >> ~/.zshrc
echo "INSTALLING IN DEVCONTAINER"
mkdir -p ~/.config/
ln -s ~/dotfiles/fish ~/.config/fish
}
fi
function setup_nvim() {
mkdir -p ~/.config/nvim/
ln -s ~/dotfiles/init.vim ~/.config/nvim/init.vim
}
install_dependencies
function main() {
sudo -n chsh $USER -s $(which fish)
echo "exec $(which fish) -l" >> ~/.profile
echo "exec $(which fish) -l" >> ~/.bashrc
echo "exec $(which fish) -l" >> ~/.zshrc
if [[ ${REMOTE_CONTAINERS} || ${DEVCONTAINER} ]]; then
echo "sv_SE.UTF-8 UTF-8" | sudo tee -a /etc/locale.gen
sudo locale-gen
echo "INSTALLING IN DEVCONTAINER"
setup_ssh
setup_git
fi
mkdir -p ~/.config/
ln -s ~/dotfiles/fish ~/.config/fish
mkdir -p ~/.config/nvim/
ln -s ~/dotfiles/init.vim ~/.config/nvim/init.vim
install_dependencies
echo "sv_SE.UTF-8 UTF-8" | sudo tee -a /etc/locale.gen
sudo locale-gen
setup_fish
setup_ssh
setup_git
setup_tmux
setup_nvim
}
main $@