Skip to content

Instantly share code, notes, and snippets.

@UnderGrounder96
Last active September 27, 2023 19:19
Show Gist options
  • Save UnderGrounder96/32182a6c102e4545b68d119c0901c965 to your computer and use it in GitHub Desktop.
Save UnderGrounder96/32182a6c102e4545b68d119c0901c965 to your computer and use it in GitHub Desktop.
Fresh Linux install script
# User specific aliases and functions
alias diffs="sdiff -s" # sdiff -s <(cat -n ${1}) <(cat -n ${2})
alias ggrep="grep -nir --exclude=*{.md,.txt,*lock*} --exclude-dir={.git,node_modules,*cache*,log}"
# git
alias g="git"
alias gc="g config"
alias gcl="g config --list"
alias gcg="g config --global"
# docker
alias d="docker"
alias dsp="d system prune -af --volumes"
alias dc="docker-compose"
alias dcd="dc down"
alias dcu="dc up -d --build"
alias dcl="dc logs -tf"
alias dcdu="dcd && dcu"
alias dcul="dcu && dcl"
alias dcdul="dcd && dcu && dcl"
# vagrant
alias vs="vagrant ssh"
alias vsc="vagrant ssh -c"
alias vd="vagrant destroy -f"
alias vr="vagrant reload -f"
alias vu="vagrant up"
alias vh="vagrant halt -f"
alias vhs="vh;vs"
alias vrs="vr;vs"
alias vus="vu;vs"
alias vdus="vd;vu;vs"
alias vdu="vd;vu"
alias vscp='f(){ vagrant scp ":$1" .; unset -f f; }; f'
# kubectl
alias k="kubectl"
#!/usr/bin/env bash
function _pushd_tmp(){
export TMP_DIR=$(mktemp -d)
pushd "$TMP_DIR"
}
function _popd_tmp(){
popd
# rm -rf $TMP_DIR
}
function _logger_info(){
echo -e "\n[$(date '+%d/%b/%Y %H:%M:%S')]: $*...\n"
}
function _git_config(){
_logger_info "Downloading .bash_git"
curl -L https://raw.github.com/git/git/master/contrib/completion/git-prompt.sh > ~/.bash_git
_logger_info "Configuring GIT"
git config --list
git config --global user.name "Lucio Afonso"
git config --global user.email "lucioafonso@icloud.com"
git config --global core.eol lf
git config --global color.ui "true"
git config --global core.editor "vim"
git config --global core.autocrlf input
git config --global credential.helper "store"
git config --global push.autoSetupRemote true
git config --global push.default current
# git aliases
git config --global alias.i "init"
git config --global alias.cl "clone"
git config --global alias.s "status"
git config --global alias.st "stash"
git config --global alias.stp "stash pop"
git config --global alias.a "add -A"
git config --global alias.cm "commit -m"
git config --global alias.cam "commit -am"
git config --global alias.ca "commit --amend --no-edit"
git config --global alias.caa "commit -a --amend --no-edit"
git config --global alias.ch "checkout"
git config --global alias.chb "checkout -b"
git config --global alias.b "branch"
git config --global alias.bd "branch -D"
git config --global alias.al "! git config --get-regexp ^alias\. | sed -e s/^alias\.// -e s/\ /\ =\ /"
git config --global alias.lg1 "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all"
git config --global alias.lg2 "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all"
git config --global alias.rh "reset --hard"
git config --global alias.rhom "reset --hard origin/master"
git config --global alias.f "fetch"
git config --global alias.fa "fetch --all"
git config --global alias.p "push"
git config --global alias.po "push origin"
git config --global alias.pu "push upstream"
git config --global alias.pfo "push -f origin"
git config --global alias.pfu "push -f upstream"
git config --global alias.pdo "push --delete origin" # backwards compatibility
git config --global alias.pl "pull"
git config --global alias.plo "pull origin"
git config --global alias.plu "pull upstream"
}
function _extras(){
_logger_info "Setting files sorting to 'Type'"
gsettings set org.gnome.nautilus.preferences default-sort-order 'type'
_logger_info "Setting up ssh-keygen"
ssh-keygen && cat ~/.ssh/*.pub
echo "fs.inotify.max_user_watches='524288'" | sudo tee -a /etc/sysctl.conf
: # true/pass
}
#!/usr/bin/env bash
. common.sh
function yum_install(){
_logger_info "Performing yum update and installing $*"
sudo yum update -y
for ARG in "$*"; do
sudo yum install -y ${ARG}
done
}
function include_to_files(){
# start ~/.bash_profile
# User specific environment and startup programs
export JAVA_HOME="$(dirname $(dirname $(readlink $(readlink $(which javac)))))"
export PATH="$PATH:$JAVA_HOME/bin"
export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
export PATH="$PATH:$HOME/.local/bin:$HOME/bin:/usr/local/bin"
# end ~/.bash_profile
# start ~/.bashrc
# User specific environment
if [ -f ~/.bash_git ]; then
. ~/.bash_git
GIT_PS1='\[\033[01;35m\]$(__git_ps1)\[\033[00m\]\n'
export PS1="\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\W\[\033[00m\]$GIT_PS1"
fi
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# end ~/.bashrc
}
function exclusive(){
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'
yum_install code
_logger_info "Installing Google Chrome"
curl https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm > chrome.rpm
yum_install ./chrome.rpm
# Keyring:
# Go to Passwords and Keys
# Under "Passwords" delete the Login keyring underneath
# When starting Chrome, provide an empty passwd
SETUP=$(curl -sL https://github.com/nodesource/distributions/tree/master/rpm | grep -Eo 'setup_[0-9]{2,3}.x' | sort -ur )
SETUP=$(echo ${SETUP} | cut -d' ' -f1)
curl -sL https://rpm.nodesource.com/${SETUP} | sudo -E bash # setup nodejs installation
_logger_info "Purging unwanted packages"
sudo yum remove -y firefox
}
function main(){
_logger_info "Starting ${0}"
_pushd_tmp
_logger_info "Installing development tools"
yum_install "epel-release yum-utils @development"
exclusive
_logger_info "Installing wanted packages"
yum_install "nodejs ansible python3 libselinux-python3"
_logger_info "Calling all other functions"
_git_config; _extras;
_logger_info "Performing clean_up"
_popd_tmp
_logger_info "All done! Exiting ${0}"
exit 0
}
main
#!/usr/bin/env bash
. common.sh
####
# cat /etc/apt/apt.conf.d/70debconf
# // Pre-configure all packages with debconf before they are installed.
# // If you don't like it, comment it out.
# DPkg::Pre-Invoke {"/usr/bin/apt update || true";};
# DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt || true";};
####
function apt_install(){
_logger_info "Performing apt update and installing $*"
sudo apt update
for ARG in "$*"; do
sudo apt install -y ${ARG}
done
}
function include_to_files(){
# start ~/.profile
# execute numlockx if it exists
if [ -x /usr/bin/numlockx ]; then
/usr/bin/numlockx on
fi
alias diffs="sdiff -s"
# end ~/.profile
# start ~/.bashrc
# include .bash_git if it exists
force_color_prompt=yes
# ...
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w\[\033[00m\] '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h \w '
fi
if [ -f ~/.bash_git ]; then
. ~/.bash_git
GIT_PS1='\[\033[01;35m\]$(__git_ps1)\[\033[00m\]\n'
export PS1="$PS1$GIT_PS1"
fi
unset color_prompt force_color_prompt
# end ~/.bashrc
}
function exclusive(){
_logger_info "Installing VS Code"
wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"
apt_install 'code'
_logger_info "Installing Google Chrome"
curl -L https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb > chrome.deb
sudo dpkg -i chrome.deb
# Keyring:
# Go to Passwords and Keys
# Under "Passwords" delete the Login keyring underneath
# When starting Chrome, provide an empty passwd
SETUP=$(curl -sL https://github.com/nodesource/distributions/tree/master/deb | grep -Eo 'setup_[0-9]{2,3}.x' | sort -ur )
SETUP=$(echo ${SETUP} | cut -d' ' -f1)
curl -L https://deb.nodesource.com/${SETUP} | sudo -E bash # setup nodejs installation
_logger_info "Purging unwanted packages"
sudo apt purge -y firefox thunderbird
touch ~/Templates/Empty\ Document # Adds new line to right-click
}
function main(){
_logger_info "Starting ${0}"
_pushd_tmp
_logger_info "Installing development tools"
apt_install "build-essential curl"
exclusive
_logger_info "Installing wanted packages"
apt_install "nodejs git vim wget python3 python3-venv python3-pip numlockx software-properties-common apt-transport-https"
_logger_info "Calling all other functions"
_git_config; _extras;
_logger_info "Performing clean_up"
_popd_tmp
_logger_info "All done! Exiting ${0}"
exit 0
}
main
{
"cSpell.userWords": ["Kubernetes", "afonso", "configmap", "ngnix"],
"editor.rulers": [80],
"editor.wordWrap": "on",
"editor.tabSize": 2,
"editor.fontSize": 14,
"editor.hover.delay": 1500,
"editor.linkedEditing": true,
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.fontFamily": "'Cascadia Code', Consolas, 'Courier New', monospace",
"editor.fontLigatures": true,
"editor.tabCompletion": "on",
"editor.cursorBlinking": "expand",
"editor.minimap.enabled": false,
"editor.detectIndentation": false,
"editor.scrollBeyondLastLine": false,
"editor.suggestSelection": "first",
"editor.codeActionsOnSave": {
"source.fixAll": true
}, // |=> https://github.com/microsoft/cascadia-code/releases
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "comment",
"settings": {
"fontStyle": "italic"
}
}
]
},
"emmet.includeLanguages": {
"javascript": "javascriptreact"
},
"extensions.autoCheckUpdates": false,
"extensions.autoUpdate": false,
"explorer.confirmDelete": false,
"explorer.confirmDragAndDrop": false,
"deno.enable": true,
"files.eol": "\n",
"files.autoSave": "afterDelay",
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"files.associations": {
"*.jsx": "javascriptreact"
},
"files.exclude": {
"**/.classpath": true,
"**/.factorypath": true,
"**/.project": true,
"**/.settings": true,
"**/.vagrant": true,
"**/node_modules/**": true,
"*cache*": true,
"*lock*": true
},
"files.watcherExclude": {
"**/**cache**/**": true,
"**/**report**/**": true,
"**/log**/**": true,
"**/public/**": true
},
"git.ignoreLegacyWarning": true,
"javascript.updateImportsOnFileMove.enabled": "always",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"update.mode": "none",
"window.restoreFullscreen": true,
"workbench.enableExperiments": false,
"workbench.iconTheme": "material-icon-theme",
"workbench.startupEditor": "newUntitledFile",
"files.autoSaveDelay": 500,
"security.workspace.trust.untrustedFiles": "open",
"code-runner.enableAppInsights": false,
"workbench.editorAssociations": {
"*.ipynb": "jupyter-notebook"
},
"git.autofetch": true,
"git.confirmSync": false,
"vs-kubernetes": {
"vscode-kubernetes.minikube-path.mac": "/Users/la/.vs-kubernetes/tools/minikube/darwin-arm64/minikube",
"vscode-kubernetes.helm-path.mac": "/Users/la/.vs-kubernetes/tools/helm/darwin-arm64/helm",
"vscode-kubernetes.kubectl-path.linux": "/home/la/.vs-kubernetes/tools/kubectl/kubectl",
"vscode-kubernetes.minikube-path.linux": "/home/la/.vs-kubernetes/tools/minikube/linux-amd64/minikube",
"vscode-kubernetes.helm-path.linux": "/home/la/.vs-kubernetes/tools/helm/linux-amd64/helm",
"vs-kubernetes.minikube-show-information-expiration": "2024-02-20T11:38:56.062Z"
},
"gitlens.hovers.currentLine.over": "line",
"gitlens.currentLine.enabled": false,
"gitlens.codeLens.enabled": false,
"notebook.cellToolbarLocation": {
"default": "right",
"jupyter-notebook": "left"
},
"[html]": {
"editor.defaultFormatter": "vscode.html-language-features"
},
"eslint.format.enable": true,
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[yaml]": {
"editor.defaultFormatter": "redhat.vscode-yaml"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[css]": {
"editor.defaultFormatter": "vscode.css-language-features"
},
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"rest-client.previewOption": "exchange",
"rest-client.requestNameAsResponseTabTitle": true,
"rest-client.previewResponsePanelTakeFocus": false,
"rest-client.defaultHeaders": {
"Accept": "*/*",
"User-Agent": "vscode-restclient",
"Accept-Encoding": "gzip, deflate, br",
"Content-Type": "application/json",
"Connection": "keep-alive"
},
"rest-client.environmentVariables": {
"$shared": {
"version": "v1"
},
"dev": {
"hostname": "localhost"
}
},
"rest-client.enableTelemetry": false,
"redhat.telemetry.enabled": false,
"sonarlint.disableTelemetry": true,
"telemetry.telemetryLevel": "error",
"git.openRepositoryInParentFolders": "never",
"terminal.integrated.enableMultiLinePasteWarning": false,
"ansible.validation.lint.enabled": false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment