Skip to content

Commit

Permalink
fix: WSL2 compatibility and warning if xclip no exist
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuscomh committed Feb 1, 2025
1 parent 6b833c3 commit cb61b6f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# shellPass - Shell Script Password Generator

[![Release](https://img.shields.io/badge/release-3.3.1-brightgreen)](https://github.com/mateuscomh/shellPass/releases)
[![Release](https://img.shields.io/badge/release-3.4.1-brightgreen)](https://github.com/mateuscomh/shellPass/releases)
[![Build Status](https://github.com/mateuscomh/shellPass/actions/workflows/super-linter.yml/badge.svg)](https://github.com/mateuscomh/shellPass/actions/workflows/super-linter.yml)

## Overview
Expand Down
16 changes: 12 additions & 4 deletions shellPass.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export LANG=C
#----------------------------------------------------|
# Matheus Martins 3mhenrique@gmail.com
# https://github.com/mateuscomh/yoURL
# 30/03/2021 3.2.0 GPL3
# 30/03/2021 3.4.1 GPL3
# Generate secure passwords on terminal
# Depends: xclip on GNU/Linux / pbcopy on IOS
#----------------------------------------------------|
Expand All @@ -14,7 +14,7 @@ BOLD=$(tput bold)
ITALIC=$(tput dim)

main() {
local VERSION="Ver:3.3.1"
local VERSION="Ver:3.4.1"
local AUTHOR="Matheus Martins-3mhenrique@gmail.com"
local USAGE="Generate random passwords from CLI
███████╗██╗ ██╗███████╗██╗ ██╗ ██████╗ █████╗ ▄▄███▄▄·▄▄███▄▄·
Expand Down Expand Up @@ -83,11 +83,19 @@ _writeinfile() {
}

_makePass() {
# PASS=$(cat /dev/urandom LC_ALL=C | tr -dc "$CPX" | head -c "$MAX")
PASS=$(tr -dc "$CPX" </dev/urandom | head -c "$MAX")
case $(uname -s) in
Darwin) printf %s "$PASS" | pbcopy 2>/dev/null ;;
Linux) command -v xclip >/dev/null && { printf %s "$PASS" | xclip -sel copy; } ;;
Linux)
if grep -iq Microsoft /proc/version; then
printf "%s" "$PASS" | clip.exe
elif command -v xxclip >/dev/null; then
printf "%s" "$PASS" | xclip -sel clip
else
echo "$PASS"
exit 1
fi
;;
*)
echo "This is compatible only for GNU/Linux, MacOS or WSL2"
exit 1
Expand Down

0 comments on commit cb61b6f

Please sign in to comment.