-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generate ssh keys, install vim dependencies,
- Loading branch information
Showing
2 changed files
with
45 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,56 @@ | ||
#!/usr/bin/env bash | ||
|
||
link_file() | ||
{ | ||
local conf_file=$1 | ||
|
||
echo -n "Setup $conf_file" | ||
ln -s "${PWD}/${conf_file}" "$HOME/${conf_file}" &> /dev/null | ||
[ "$?" -eq "0" ] && echo " ... DONE." || echo " ... MAY ALREADY EXISTS." | ||
} | ||
# install required tools | ||
sudo apt install xsel $> /dev/null | ||
|
||
|
||
# setup gitconfig | ||
ln -s "$PWD/gitconfig" "$HOME/.gitconfig" &2>/dev/null | ||
link_file gitconfig | ||
|
||
# setup bashrc | ||
# if ~/.bashrc present already, create new .mybashrc and add "source .mybashrc" in .bashrc | ||
if [ -f "$HOME/.bashrc" ]; then | ||
echo "source $PWD/bashrc.funcs" >> $HOME/.bashrc | ||
echo "source $PWD/bashrc" >> $HOME/.bashrc | ||
if [ ! -w "$HOME/.bashrc" ]; then | ||
echo "NOTE: .bashrc file locked" | ||
else | ||
echo "source $PWD/bashrc.funcs" >> $HOME/.bashrc | ||
echo "source $PWD/bashrc" >> $HOME/.bashrc | ||
chmod -w "$HOME/.bashrc" | ||
fi | ||
else | ||
echo "WARNING: bashrc setup failed, system .bashrc not found." | ||
fi | ||
|
||
# setup vimrc | ||
mkdir -p $HOME/.vim | ||
if [ ! -d "$HOME/.vim/autoload" ]; then | ||
git clone https://github.com/tpope/vim-pathogen.git $HOME/.vim/ | ||
fi | ||
link_file vimrc | ||
|
||
# SSH config | ||
# Create key-pair for github account and add in ssh-config | ||
|
||
KFILE="$HOME/.ssh/gh" | ||
SSH_CONF="$HOME/.ssh/config" | ||
|
||
if [ ! -f "$KFILE" ]; then | ||
ssh-keygen -t rsa -b 4096 -f "$KFILE" -N '' | ||
gh_ssh=""" | ||
Host github.com\n | ||
HostName githun.com\n | ||
IdentityFile $KFILE\n | ||
""" | ||
touch "$SSH_CONF" | ||
echo -e $gh_ssh >> "$SSH_CONF" | ||
cat "$KFILE.pub" | xsel -ib | ||
notify-send "Public key copied to clipboard" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters