Skip to content

Instantly share code, notes, and snippets.

View aravindkumarsvg's full-sized avatar

Aravind Kumar SVG aravindkumarsvg

View GitHub Profile
@aravindkumarsvg
aravindkumarsvg / set-prompt.ps1
Last active April 30, 2024 23:14
Sets the git branch name in the powershell prompt like git bash
# Add this function to the Profile script
# Use the following command to generate the Profile script
#
# $profileTest = Test-Path $PROFILE
# if ($profileTest -eq $FALSE) {
# New-Item $PROFILE -Type File
# }
#
# OR
#
@aravindkumarsvg
aravindkumarsvg / operate-chefdk.sh
Last active June 1, 2021 11:40
Shell Script to install, uninstall ChefDK
#!/bin/bash
# =============================================
# Installs and Uninstalls the ChefDK
# =============================================
#
# -i Install ChefDK
# -u Uninstall ChefDK
# -c Verify ChefDK
# -h Show Help
@aravindkumarsvg
aravindkumarsvg / git-prompt.sh
Last active July 19, 2017 02:26
Git prompt for Bash shell
# Reference https://gist.github.com/justintv/168835
# Used in Elementery OS terminal
# Add to ~/.bashrc file
# Sets the Git branch name in the PS1 prompt
function git_prompt_setter() {
local RED="\\\[\\\033[1;31m\\\]"
local NORMAL="\\\[\\\033[00m\\\]"
# Modifies the existing prompt and adds the git branch name
PS1=$(echo $PS1 | sed 's/\(\\\?[$#]\)\s*$/'"$RED"'\$\(__git_ps1\)'"$NORMAL"'\1 / ' )
@aravindkumarsvg
aravindkumarsvg / docker_image-remover.sh
Created July 14, 2017 16:04
Removes the Docker images and also able to add some exclusions for image deletion
#!/bin/bash
#================================================
# Removes the Docker images based on conditions
#================================================
# Variable Declaration
declare -A image_exclusion=( ["node"]="8-alpine" ["jenkins"]="latest" )
# Checks whether image has been excluded or not
@aravindkumarsvg
aravindkumarsvg / check-network.sh
Created July 20, 2017 15:00
Checks for the Network connection
#!/bin/bash
########################################################
#
# Checks for Network connection by using Ping utility
#
########################################################
# Main flow of Execution
main() {
@aravindkumarsvg
aravindkumarsvg / restart-network_manager.sh
Last active August 12, 2017 10:21
Automatically restart network manager in case of connection timeouts due to wifi problems
#!/bin/bash
#############################################################
#
# Restarts the Network Manager automatically when the
# Network disconnects, because of wifi connectivity problem
#
#############################################################
# Function which checks for the root user execution
@aravindkumarsvg
aravindkumarsvg / delete-dupfiles.sh
Last active July 13, 2018 18:49
Replaces the duplicate files with the hard link to the file which comes first in the lexical sorting
#!/bin/bash
#################################################################################
# #
# - Removes the duplicate normal files from the given directory and makes them #
# as the hard link for the non removed file. #
# - The non removed file is the one which comes first in the lexical ordering #
# - Script uses fdupes utility to find out the duplicate files #
# #
# = Usage: bash script.sh duplicate_files_folder #
# utility function which is used to create and change
# to the given directory name
# Add to the .bashrc file
# usage:
# mkcd directory_name
mkcd() {
local directory_name="${1}"
if [ -z $directory_name ]
then
echo "Pass the directory name as the argument!!!" > /dev/stderr
@aravindkumarsvg
aravindkumarsvg / get-swap_using_process.sh
Created March 29, 2018 10:39
Gets the processes which is using the swap space
#!/bin/bash
# Loops through the proc directory
for processId in `ls /proc/`; do
# Checks for the status file for a process
if [[ $processId =~ ^[0-9]+$ && -r "/proc/${processId}/status" ]]; then
# Gets the swap space usage for the process
swapUsage=`grep VmSwap "/proc/${processId}/status" | awk '{print $2}'`
if [[ ! -z $swapUsage && $swapUsage > 0 ]]; then
# Gets the process name
@aravindkumarsvg
aravindkumarsvg / npm-audit_report-generation.sh
Last active December 9, 2021 18:31
Generates npm audit report for multiple directories and searching for multiple package.json inside those given directories
#!/bin/bash
# Global variable declarations
format="plain"
directories=()
current_directory=`pwd`
report_directory="${current_directory}/report/"
fresh_report_directory="0"
# usage