From 18ca3d2c2d6085a33359eebdb3e46c9d2a216c0a Mon Sep 17 00:00:00 2001 From: Tim Susa Date: Wed, 18 Dec 2019 13:52:45 +0100 Subject: [PATCH] Init commit --- aliases | 18 + htoprc | 26 ++ install.sh | 97 +++++ motd/00-header | 36 ++ motd/10-sysinfo | 38 ++ motd/90-footer | 24 ++ nanorc | 264 +++++++++++++ p10k.zsh | 957 ++++++++++++++++++++++++++++++++++++++++++++++++ tmux | 1 + yaml.nanorc | 36 ++ zshrc | 22 ++ 11 files changed, 1519 insertions(+) create mode 100644 aliases create mode 100644 htoprc create mode 100755 install.sh create mode 100755 motd/00-header create mode 100755 motd/10-sysinfo create mode 100755 motd/90-footer create mode 100644 nanorc create mode 100644 p10k.zsh create mode 100644 tmux create mode 100644 yaml.nanorc create mode 100644 zshrc diff --git a/aliases b/aliases new file mode 100644 index 0000000..963c039 --- /dev/null +++ b/aliases @@ -0,0 +1,18 @@ +## Aliases +alias ll='ls -la' +alias ..='cd ..' +alias grep='grep --color=auto' +alias ports='netstat -an | grep LISTEN' +alias df='df -h' +alias cdh='cd $HOME' +alias cdo='cd /opt' +alias zrc='nano $HOME/.zshrc' +alias c='clear' +alias h='history' +alias top='htop' + +if [ "$(uname)" = "Darwin" ]; then + alias ls='ls -G' +else + alias ls='ls --color=auto' +fi diff --git a/htoprc b/htoprc new file mode 100644 index 0000000..8e9be53 --- /dev/null +++ b/htoprc @@ -0,0 +1,26 @@ +# Beware! This file is rewritten by htop when settings are changed in the interface. +# The parser is also very primitive, and not human-friendly. +fields=50 0 48 17 18 38 39 40 2 46 47 49 1 +sort_key=111 +sort_direction=1 +hide_threads=1 +hide_kernel_threads=1 +hide_userland_threads=1 +shadow_other_users=0 +show_thread_names=0 +show_program_path=1 +highlight_base_name=0 +highlight_megabytes=0 +highlight_threads=0 +tree_view=1 +header_margin=1 +detailed_cpu_time=1 +cpu_count_from_zero=1 +update_process_names=0 +account_guest_in_cpu_meter=0 +color_scheme=6 +delay=15 +left_meters=CPU AllCPUs +left_meter_modes=2 1 +right_meters=Blank Clock Uptime LoadAverage Tasks Swap Memory +right_meter_modes=2 2 2 2 2 2 2 diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..ffcaa89 --- /dev/null +++ b/install.sh @@ -0,0 +1,97 @@ +#!/bin/bash + +## Define Arrays +packages=( "zsh" "htop" "figlet" "tmux" "curl" ) +configfiles=( ".zshrc" ".antigen.zsh" ".p10k.zsh" ".tmux.conf" ".config/htop/htoprc" "/usr/share/nano/yaml.nanorc" ) +configfileslinux=( "/etc/nanorc" ) +motdfiles=( "/etc/update-motd.d/00-header" "/etc/update-motd.d/10-uname" "/etc/update-motd.d/10-sysinfo" "/etc/update-motd.d/90-footer" ) + + +cd ~ + +if test -d ~/.config/htop; then + echo Htop folder found - skipping removing. +else +mkdir ~/.config/htop +fi + + +## Install packages + +if [ "$(uname)" = "Darwin" ]; then + echo MacOS found - no installation of packages needed. +else +for i in "${packages[@]}" +do + +dpkg -s $i &> /dev/null + +if [ $? -eq 0 ]; then +echo $i is installed - skipping. + else + $i is missing. Installing now. + apt install -y $i + fi + done +fi + +## Remove Config Files + +for j in "${configfiles[@]}" +do + rm $j +done + +if [ "$(uname)" != "Darwin" ]; then + for l in "${configfileslinux[@]}" + do + rm $j + done +fi + + +## Remove Motd Files +if [ "$(uname)" = "Darwin" ]; then + echo MacOS found - no motd files to remove. +else +for k in "${motdfiles[@]}" +do + if test -f $k; then + rm $k + fi +done +fi + +## Install Antigen +curl -L git.io/antigen > .antigen.zsh + +## Create Symlinks +ln -s ~/.zshconfig/zshrc .zshrc +ln -s ~/.zshconfig/yaml.nanorc /usr/share/nano/yaml.nanorc +ln -s ~/.zshconfig/tmux .tmux.conf +ln -s ~/.zshconfig/htoprc .config/htop/htoprc +ln -s ~/.zshconfig/p10k.zsh .p10k.zsh +if [ "$(uname)" != "Darwin" ]; then + ln -s ~/.zshconfig/nanorc /etc/nanorc +else + echo MacOS found - No linking of Nanorc needed. +fi + + + +## Make ZSH as default Shell +if [ "$(uname)" = "Darwin" ]; then + echo MacOS found - ZSH is already default shell. +else +chsh -s $(which zsh) +fi + + +## Copy Files, fix permissions +if [ "$(uname)" = "Darwin" ]; then + echo MacOS found - No motd changes needed. +else +cp ~/.zshconfig/motd/* /etc/update-motd.d/ +chmod +x /etc/update-motd.d/* +echo > /etc/motd +fi diff --git a/motd/00-header b/motd/00-header new file mode 100755 index 0000000..5f0f92b --- /dev/null +++ b/motd/00-header @@ -0,0 +1,36 @@ +#!/bin/sh +# +# 00-header - create the header of the MOTD +# Copyright (c) 2013 Nick Charlton +# Copyright (c) 2009-2010 Canonical Ltd. +# +# Authors: Nick Charlton +# Dustin Kirkland +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +[ -r /etc/lsb-release ] && . /etc/lsb-release + +if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then + # Fall back to using the very slow lsb_release utility + DISTRIB_DESCRIPTION=$(lsb_release -s -d) +fi + +figlet $(hostname) +#figlet ...NevaKee.de.. + +#printf "\n" +#printf "Welcome to %s (%s).\n" "$DISTRIB_DESCRIPTION" "$(uname -r)" +#printf "\n" diff --git a/motd/10-sysinfo b/motd/10-sysinfo new file mode 100755 index 0000000..3053b5e --- /dev/null +++ b/motd/10-sysinfo @@ -0,0 +1,38 @@ +#!/bin/bash +# +# 10-sysinfo - generate the system information +# Copyright (c) 2013 Nick Charlton +# +# Authors: Nick Charlton +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +cpuallusage=`ps aux | awk {'sum+=$3;print sum'} | tail -n 1 | awk '{printf "%.0f\n", $1}'` +cpucores=`cat /proc/cpuinfo | grep "model name" | wc -l` +cpuusage=$((cpuallusage / cpucores)) + +# \033[0;34m+ \033[0;37mCPU usage \033[0;34m= \033[1;32m$cpuusage% + +echo -e "\033[0;34m+++++++++++++++++: \033[0;37mSystem Data\033[0;34m :+++++++++++++++++++++++++++++ +\033[0;34m+ \033[0;37mDate and Time \033[0;34m= \033[1;32m`date` +\033[0;34m+ \033[0;37mKernel \033[0;34m= \033[1;32m`uname -r` +\033[0;34m+ \033[0;37mUptime \033[0;34m= \033[1;32m`uptime | grep -ohe 'up .*' | sed 's/,//g' | awk '{ printf $2" "$3 }'` +\033[0;34m+ \033[0;37mLoad \033[0;34m= \033[1;32m`cat /proc/loadavg | awk '{print $1}'` `cat /proc/loadavg | awk '{print $2}'` `cat /proc/loadavg | awk '{print $3}'` +\033[0;34m+ \033[0;37mCPU model \033[0;34m= \033[1;32m$cpucores x `cat /proc/cpuinfo | grep -m 1 "model name" | awk -F ": " '{print $2}'` +\033[0;34m+ \033[0;37mMemory \033[0;34m= \033[1;32mUsed `free -m | head -n 3 | tail -n 1 | awk {'print $3'}` MB out of `free -m | head -n 2 | tail -n 1 | awk {'print $2'}` MB +\033[0;34m+ \033[0;37mHDD \033[0;34m= \033[1;32mUsed `df -h / | tail -n 1 | awk {'print $3'}` out of `df -h / | tail -n 1 | awk {'print $2'}` +\033[0;34m+ \033[0;37mProcesses \033[0;34m= \033[1;32m`ps aux | wc -l` of `ulimit -u` MAX +\033[0;34m+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\033[0;37m +" diff --git a/motd/90-footer b/motd/90-footer new file mode 100755 index 0000000..10ca498 --- /dev/null +++ b/motd/90-footer @@ -0,0 +1,24 @@ +#!/bin/sh +# +# 99-footer - write the admin's footer to the MOTD +# Copyright (c) 2013 Nick Charlton +# Copyright (c) 2009-2010 Canonical Ltd. +# +# Authors: Nick Charlton +# Dustin Kirkland +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +#[ -f /etc/motd.tail ] && cat /etc/motd.tail || true diff --git a/nanorc b/nanorc new file mode 100644 index 0000000..cdd8069 --- /dev/null +++ b/nanorc @@ -0,0 +1,264 @@ +## Sample initialization file for GNU nano. +## +## Please note that you must have configured nano with --enable-nanorc +## for this file to be read! Also note that this file should not be in +## DOS or Mac format, and that characters specially interpreted by the +## shell should not be escaped here. +## +## To make sure an option is disabled, use "unset