Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rm gitignore #111

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion scripts/color
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
#!/usr/bin/env bash

# TODO (Run this script as): color magenta && echo hello && color reset

#The sequence \033[35m sets the color to magenta
#and the sequence \033[0m resets the color to default
echo -ne "\033[35mhello\033[0m"
color() {
echo -ne "\033[$1;$2m"
}

declare -A color_mapping=(
# TODO: Add more color values
# Refer bash color codes
['black']=30
['red']=31
['green']=32
['yellow']=33
['blue']=34
['magenta']=35
['white']=37

)

if [[ $1 == 'reset' ]]; then
Expand Down
19 changes: 19 additions & 0 deletions scripts/password-generator
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,22 @@
# Issue: Implement Password Generation Functions
# Description:
# Create a function that generates passwords, The password should consist of uppercase letters, lowercase letters, numbers, and special characters. The function should take in a single argument, which is the length of the password to generate. The function should return the generated password.

generate(){
local length="$1"
local characters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()"

# ensure that minimum lenth is 4
length=$(( length >= 4 ? length : 4 ))

# genrate password script
password=$(head /dev/urandom | tr -dc "$characters" | fold -w "$length" | head -n 1)

#return the genrated password
echo "$password"
}

#print the passord of length $1
input_length="$1"
password=$(generate "$input_length")
echo "Generated password: $password"
19 changes: 19 additions & 0 deletions scripts/perms
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,22 @@
# 775 weather
# 664 ../README.md


#this function print the permission in octal format
getPerms() {
local file="$1"
if [[ -f "$file" ]]; then
local permissions=$(stat -c "%a" "$file")
echo "$permissions $file"
else
echo "Error: this '$file' is not a regular files"
fi
}

# it get the file from path variable
files=("$@")

# it loopp through the file and print permissions
for file in "${files[@]}"; do
get_perms "$file"
done
6 changes: 4 additions & 2 deletions scripts/rm-bins
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env bash

# Remove all the binary files (usually made after gcc) present inside current directory
# Refer "man find" for more information, you can also use modern tool like fd instead of find

#it remove the fies with is executable
fd --type f --executable -delete

17 changes: 15 additions & 2 deletions scripts/rm-gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
#!/usr/bin/env bash

# Removes all files written in .gitignore of any git repository (multiple) present inside current directory
# To find list of all git repos inside current directory you can use: "find . -name .git -type d -prune"


# Iterate through each Git repository found in the current directory
find . -name .git -type d -prune -exec bash -c '
for repo_dir; do
cd "$repo_dir/.." || exit

# get ingnore file pattern
ignored_patterns=$(cat .gitignore | grep -v "^#")

# Remove matching files (excluding .gitignore itself)
find . -type f ! -name .gitignore -regex "$ignored_patterns" -delete
done
' \;

4 changes: 2 additions & 2 deletions scripts/weather
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash

# TODO: Display weather of IIIT, Lucknow
# For more information see: https://wttr.in/:help
location="kanpur"
curl -s wttr.in/"$location" | tr -d '\r'
6 changes: 4 additions & 2 deletions scripts/wifi-ssid
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env bash

# Extract the wifi username (SSID)
# Refer: "iw dev wlan0 link" command output for this

ssid=$(iw dev wlan0 link | grep "ssid" | awk '{print $2}')