Change some scripts a bit
This commit is contained in:
parent
22d3634415
commit
3c6b8fd06c
5 changed files with 96 additions and 5 deletions
43
bin/.bin/dmenu/password-manager
Executable file
43
bin/.bin/dmenu/password-manager
Executable file
|
@ -0,0 +1,43 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
PASSWORDS="$HOME/.password-store"
|
||||||
|
|
||||||
|
|
||||||
|
function copy_password(){
|
||||||
|
local password="$1"
|
||||||
|
local sleep_argv0="jh password store sleep on display $DISPLAY"
|
||||||
|
local before="$(xclip -o -selection clipboard 2>/dev/null | base64)"
|
||||||
|
pkill -f "^$sleep_argv0" 2>/dev/null && sleep 0.5
|
||||||
|
local pw=$(pass "$selection" | head -n 1)
|
||||||
|
echo "$pw" | xclip -selection "primary"
|
||||||
|
echo "$pw" | xclip -selection "clipboard"
|
||||||
|
notify-send "Password put on clipboard" "Will be removed in 10 seconds"
|
||||||
|
(
|
||||||
|
( exec -a "$sleep_argv0" bash <<<"trap 'kill %1' TERM; sleep '10' & wait" )
|
||||||
|
|
||||||
|
echo "$before" | base64 -d | xclip -selection "primary"
|
||||||
|
echo "$before" | base64 -d | xclip -selection "clipboard"
|
||||||
|
|
||||||
|
notify-send "Password Clearerd"
|
||||||
|
|
||||||
|
) >/dev/null 2>&1 & disown
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -d "$PASSWORDS" ]; then
|
||||||
|
cd "$PASSWORDS"
|
||||||
|
selection=$((echo "NEW";find . -type f -name '*.gpg' | sed 's/.gpg$//' | sed 's/^.\///') | rofi -dmenu -i -l 20)
|
||||||
|
if [ -n "$selection" ]; then
|
||||||
|
if [[ "$selection" == "NEW" ]]; then
|
||||||
|
dir="$(find . -type d -not -path \*.git\* |rofi -dmenu -p Directory | sed 's/^.\/?//')"
|
||||||
|
if [ ! -d "$dir" ]; then
|
||||||
|
mkdir -p "$dir"
|
||||||
|
fi
|
||||||
|
name="$(rofi -dmenu -p Name -lines 0)"
|
||||||
|
# Todo - create new passwords
|
||||||
|
else
|
||||||
|
copy_password "$selection"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
notify-send "$BOOKMARKS doesn't exist"
|
||||||
|
fi
|
|
@ -10,13 +10,14 @@ if [[ "$1" = "surf-download" ]]; then
|
||||||
url="$4"
|
url="$4"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
path="~/Downloads/"
|
path="$HOME/Downloads/"
|
||||||
project=$(project current --path)
|
project=$(project current --path)
|
||||||
if [ -n "$project" ]; then
|
if [ -n "$project" ]; then
|
||||||
path="$project/Downloads/"
|
path="$project/Downloads/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkcd -p "$path"
|
|
||||||
|
mkdir -p "$path"
|
||||||
cd "$path"
|
cd "$path"
|
||||||
|
|
||||||
echo "$useragent"
|
echo "$useragent"
|
||||||
|
@ -24,4 +25,8 @@ echo "$cookiefile"
|
||||||
echo "$referer"
|
echo "$referer"
|
||||||
echo "$url"
|
echo "$url"
|
||||||
|
|
||||||
curl -g -L -J -O -A "$useragent" -b "$cookiefile" -c "$cookiefile" -e "$referer" "$url"
|
if command -v aria2c; then
|
||||||
|
aria2c -U "$useragent" --referer "$referer" --load-cookies $cookiefile --save-cookies $cookiefile "$url"
|
||||||
|
else
|
||||||
|
curl -k -g -L -J -O -A "$useragent" -b "$cookiefile" -c "$cookiefile" -e "$referer" "$url"
|
||||||
|
fi
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Came from here: https://raw.githubusercontent.com/21y4d/nmapAutomator/master/nmapAutomator.sh
|
|
||||||
#by 21y4d
|
|
||||||
|
|
||||||
RED='\033[0;31m'
|
RED='\033[0;31m'
|
||||||
YELLOW='\033[0;33m'
|
YELLOW='\033[0;33m'
|
||||||
|
|
|
@ -19,6 +19,36 @@ function listhosts(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_hosts(){
|
||||||
|
local current="$(project current --path)"
|
||||||
|
index="$current/index.yaml"
|
||||||
|
if [ ! -f "$index" ]; then
|
||||||
|
echo ""
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
if [ $(yq -r '.hosts | length ' "$index" ) -gt 0 ]; then
|
||||||
|
yq -r '.hosts[]| select(.domain) | [.ip, .domain ] | join(",,")' "$index" | tr ',' '\t'
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function host_file(){
|
||||||
|
|
||||||
|
sed '/# Project specific hosts/,$ d' /etc/hosts > /tmp/newhosts
|
||||||
|
cat /tmp/newhosts > /etc/hosts
|
||||||
|
rm /tmp/newhosts
|
||||||
|
|
||||||
|
local current="$(project current --path)"
|
||||||
|
if [ -n "$current" ]; then
|
||||||
|
(
|
||||||
|
echo "# Project specific hosts - Everything after this line will be deleted when the project is changed"
|
||||||
|
get_hosts
|
||||||
|
) >> /etc/hosts
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function getip(){
|
function getip(){
|
||||||
local current="$(project current --path)"
|
local current="$(project current --path)"
|
||||||
index="$current/index.yaml"
|
index="$current/index.yaml"
|
||||||
|
@ -44,8 +74,12 @@ function getip(){
|
||||||
}
|
}
|
||||||
|
|
||||||
function addip(){
|
function addip(){
|
||||||
|
local current="$(project current --path)"
|
||||||
|
index="$current/index.yaml"
|
||||||
echo -n "Name: "
|
echo -n "Name: "
|
||||||
read name < /dev/tty
|
read name < /dev/tty
|
||||||
|
echo -n "Domain: "
|
||||||
|
read domain < /dev/tty
|
||||||
echo -n "IP: "
|
echo -n "IP: "
|
||||||
read ip < /dev/tty
|
read ip < /dev/tty
|
||||||
echo -n "Description: "
|
echo -n "Description: "
|
||||||
|
@ -54,15 +88,20 @@ function addip(){
|
||||||
if [ -n "$name" ]; then
|
if [ -n "$name" ]; then
|
||||||
host="$(echo $host | jq ".name=\"$name\"" )"
|
host="$(echo $host | jq ".name=\"$name\"" )"
|
||||||
fi
|
fi
|
||||||
|
if [ -n "$domain" ]; then
|
||||||
|
host="$(echo $host | jq ".domain=\"$domain\"" )"
|
||||||
|
fi
|
||||||
if [ -n "$ip" ]; then
|
if [ -n "$ip" ]; then
|
||||||
host="$(echo $host | jq ".ip=\"$ip\"" )"
|
host="$(echo $host | jq ".ip=\"$ip\"" )"
|
||||||
fi
|
fi
|
||||||
if [ -n "$description" ]; then
|
if [ -n "$description" ]; then
|
||||||
host="$(echo $host | jq ".description=\"$description\"" )"
|
host="$(echo $host | jq ".description=\"$description\"" )"
|
||||||
fi
|
fi
|
||||||
|
echo $host
|
||||||
yq --yaml-output ".hosts |= .+ [$host]" "$index" > newindex
|
yq --yaml-output ".hosts |= .+ [$host]" "$index" > newindex
|
||||||
rm "$index"
|
rm "$index"
|
||||||
mv newindex "$index"
|
mv newindex "$index"
|
||||||
|
host_file
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
@ -77,6 +116,10 @@ case "$1" in
|
||||||
list)
|
list)
|
||||||
listhosts
|
listhosts
|
||||||
;;
|
;;
|
||||||
|
hosts_file)
|
||||||
|
shift
|
||||||
|
host_file "$@"
|
||||||
|
;;
|
||||||
ip)
|
ip)
|
||||||
getip
|
getip
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -28,6 +28,7 @@ function unset_project(){
|
||||||
rm "$SYMLINC" 2> /dev/null
|
rm "$SYMLINC" 2> /dev/null
|
||||||
# See note about SIGWINCH below
|
# See note about SIGWINCH below
|
||||||
pkill -u $USER -SIGWINCH zsh
|
pkill -u $USER -SIGWINCH zsh
|
||||||
|
project hosts hosts_file
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +40,7 @@ function set_project(){
|
||||||
fi
|
fi
|
||||||
ln -s "$switchto" "$SYMLINC"
|
ln -s "$switchto" "$SYMLINC"
|
||||||
pkill -u $USER -SIGWINCH zsh
|
pkill -u $USER -SIGWINCH zsh
|
||||||
|
project hosts hosts_file
|
||||||
else
|
else
|
||||||
echo "No such directory $switchto"
|
echo "No such directory $switchto"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue