Update more scripts to be just scripts
This commit is contained in:
parent
163debc8a0
commit
611a41562e
12
scripts/_diffr
Normal file
12
scripts/_diffr
Normal file
|
@ -0,0 +1,12 @@
|
|||
#!/bin/sh
|
||||
|
||||
exec diffr \
|
||||
--colors 'refine-added:foreground:green:underline' \
|
||||
--colors 'refine-added:background:none' \
|
||||
--colors 'refine-removed:foreground:red:underline' \
|
||||
--colors 'refine-removed:background:none' \
|
||||
--colors 'added:foreground:green' \
|
||||
--colors 'added:background:none' \
|
||||
--colors 'removed:foreground:red' \
|
||||
--colors 'removed:background:none' \
|
||||
"$@"
|
|
@ -16,21 +16,20 @@
|
|||
inherit name runtimeInputs;
|
||||
text = ''exec ${script_body} "$@"'';
|
||||
checkPhase = "";
|
||||
})
|
||||
);
|
||||
}));
|
||||
create_scripts =
|
||||
lib.mapAttrs (name: deps: create_script name ./${name} deps);
|
||||
in create_scripts {
|
||||
br = [ ];
|
||||
bmenu = [ bemenu dhist fish j4-dmenu-desktop jq sway ];
|
||||
_diffr = [ diffr ];
|
||||
kak-pager = [ fish _diffr ];
|
||||
terminal = [ alacritty ];
|
||||
wpass = [ bmenu fd pass sd wl-clipboard wtype ];
|
||||
screenshotsh =
|
||||
[ capitaine-cursors grim jq sway wl-clipboard xdg-user-dirs ];
|
||||
} // lib.mapAttrs import_script {
|
||||
wdmenu = ./wdmenu.nix;
|
||||
wlauncher = ./wlauncher.nix;
|
||||
# bmenu = ./bmenu.nix;
|
||||
_diffr = ./diffr.nix;
|
||||
kak-pager = ./kak-pager.nix;
|
||||
terminal = ./terminal.nix;
|
||||
wpass = ./wpass.nix;
|
||||
screenshotsh = ./screenshotsh.nix;
|
||||
_gpg-unlock = ./_gpg-unlock.nix;
|
||||
})
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
pkgs.writeShellScriptBin "diffr" ''
|
||||
exec ${pkgs.diffr}/bin/diffr \
|
||||
--colors 'refine-added:foreground:green:underline' \
|
||||
--colors 'refine-added:background:none' \
|
||||
--colors 'refine-removed:foreground:red:underline' \
|
||||
--colors 'refine-removed:background:none' \
|
||||
--colors 'added:foreground:green' \
|
||||
--colors 'added:background:none' \
|
||||
--colors 'removed:foreground:red' \
|
||||
--colors 'removed:background:none' \
|
||||
$@
|
||||
''
|
33
scripts/kak-pager
Normal file
33
scripts/kak-pager
Normal file
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env fish
|
||||
|
||||
if test (count $argv) -ne 0
|
||||
for i in $argv
|
||||
cat "$i"
|
||||
end | eval (status filename)
|
||||
exit 0
|
||||
end
|
||||
|
||||
set term_line_count (tput lines)
|
||||
|
||||
while read line
|
||||
set -a input_lines "$line"
|
||||
|
||||
set input_line_count (printf "%s\n" $input_lines | wc -l)
|
||||
|
||||
if test "$term_line_count" -lt "$input_line_count"
|
||||
begin
|
||||
printf "%s\n" $input_lines
|
||||
cat
|
||||
end | kak -e '
|
||||
exec <a-o>
|
||||
map global normal q :q<ret>;
|
||||
rmhl global/number-lines;
|
||||
set global scrolloff 10,0;
|
||||
'
|
||||
|
||||
exit 0
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
printf "%s\n" $input_lines
|
|
@ -1,36 +0,0 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
pkgs.writeScriptBin "kak-pager" ''
|
||||
#!/usr/bin/env fish
|
||||
|
||||
if test (count $argv) -ne 0
|
||||
for i in $argv
|
||||
cat "$i"
|
||||
end | eval (status filename)
|
||||
exit 0
|
||||
end
|
||||
|
||||
set term_line_count (tput lines)
|
||||
|
||||
while read line
|
||||
set -a input_lines "$line"
|
||||
|
||||
set input_line_count (printf "%s\n" $input_lines | wc -l)
|
||||
|
||||
if test "$term_line_count" -lt "$input_line_count"
|
||||
begin
|
||||
printf "%s\n" $input_lines
|
||||
cat
|
||||
end | kak -e '
|
||||
exec <a-o>
|
||||
map global normal q :q<ret>;
|
||||
rmhl global/number-lines;
|
||||
set global scrolloff 10,0;
|
||||
'
|
||||
|
||||
exit 0
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
printf "%s\n" $input_lines
|
||||
''
|
49
scripts/screenshotsh
Normal file
49
scripts/screenshotsh
Normal file
|
@ -0,0 +1,49 @@
|
|||
#!/bin/sh
|
||||
|
||||
export XCURSOR_SIZE=40
|
||||
export XCURSOR_THEME='capitaine-cursors-light'
|
||||
|
||||
screenshot="grim"
|
||||
copy="wl-copy -t image/png"
|
||||
|
||||
if which xdg-user-dir >/dev/null 2>&1; then
|
||||
DESTFOLDER="$(xdg-user-dir PICTURES)"
|
||||
else
|
||||
for i in Images Imagens Pictures Fotos ""; do
|
||||
DESTFOLDER="$HOME/$i"
|
||||
test -d "$DESTFOLDER" &&
|
||||
break
|
||||
done
|
||||
fi
|
||||
|
||||
DESTFOLDER="$DESTFOLDER/Screenshots"
|
||||
mkdir -p "$DESTFOLDER"
|
||||
DESTFILE="$DESTFOLDER/$(date +'%Y-%m-%d-%H%M%S_screenshot.png')"
|
||||
|
||||
case $1 in
|
||||
def)
|
||||
# Screenshot to file
|
||||
$screenshot "$DESTFILE"
|
||||
echo "$DESTFILE"
|
||||
;;
|
||||
|
||||
area)
|
||||
# Screen area to file
|
||||
$screenshot -g "$(slurp -d -b 30303088)" "$DESTFILE"
|
||||
echo "$DESTFILE"
|
||||
;;
|
||||
area-clip)
|
||||
# Screen area to clipboard
|
||||
$screenshot -g "$(slurp -d -b 30303088)" - | $copy
|
||||
;;
|
||||
|
||||
clip)
|
||||
# Focused monitor to clipboard
|
||||
cur_output=$(swaymsg -t get_outputs |
|
||||
jq -r '.[] | select(.focused) | .name')
|
||||
|
||||
test -n "$cur_output" &&
|
||||
$screenshot -o "$cur_output" - | $copy ||
|
||||
$screenshot - | $copy
|
||||
;;
|
||||
esac
|
|
@ -1,50 +0,0 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
pkgs.writeShellScriptBin "screenshotsh" ''
|
||||
export XCURSOR_SIZE=40
|
||||
export XCURSOR_THEME='capitaine-cursors-light' # ${pkgs.capitaine-cursors}
|
||||
|
||||
screenshot="${pkgs.grim}/bin/grim"
|
||||
copy="${pkgs.wl-clipboard}/bin/wl-copy -t image/png"
|
||||
|
||||
if which xdg-user-dir >/dev/null 2>&1; then
|
||||
DESTFOLDER="$(${pkgs.capitaine-cursors}/bin/xdg-user-dir PICTURES)"
|
||||
else
|
||||
for i in Images Imagens Pictures Fotos ""; do
|
||||
DESTFOLDER="$HOME/$i"
|
||||
test -d "$DESTFOLDER" &&
|
||||
break
|
||||
done
|
||||
fi
|
||||
|
||||
DESTFOLDER="$DESTFOLDER/Screenshots"
|
||||
mkdir -p "$DESTFOLDER"
|
||||
DESTFILE="$DESTFOLDER/$(date +'%Y-%m-%d-%H%M%S_screenshot.png')"
|
||||
|
||||
case $1 in
|
||||
def)
|
||||
# Screenshot to file
|
||||
$screenshot "$DESTFILE"
|
||||
echo "$DESTFILE"
|
||||
;;
|
||||
|
||||
area)
|
||||
# Screen area to file
|
||||
$screenshot -g "$(slurp -d -b 30303088)" "$DESTFILE"
|
||||
echo "$DESTFILE"
|
||||
;;
|
||||
area-clip)
|
||||
# Screen area to clipboard
|
||||
$screenshot -g "$(slurp -d -b 30303088)" - | $copy
|
||||
;;
|
||||
|
||||
clip)
|
||||
# Focused monitor to clipboard
|
||||
cur_output=$(${pkgs.sway}/bin/swaymsg -t get_outputs |
|
||||
${pkgs.jq}/bin/jq -r '.[] | select(.focused) | .name')
|
||||
|
||||
test -n "$cur_output" &&
|
||||
$screenshot -o "$cur_output" - | $copy ||
|
||||
$screenshot - | $copy
|
||||
;;
|
||||
esac
|
||||
''
|
20
scripts/terminal
Normal file
20
scripts/terminal
Normal file
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
|
||||
CLASS="terminal"
|
||||
|
||||
while test $# -gt 0;do
|
||||
case $1 in
|
||||
-c|--class)
|
||||
shift
|
||||
CLASS=$1
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
test $# -gt 0 &&
|
||||
exec alacritty --class "$CLASS" -e $@ ||
|
||||
exec alacritty --class "$CLASS"
|
|
@ -1,23 +0,0 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
pkgs.writeScriptBin "terminal" ''
|
||||
#!/bin/sh
|
||||
|
||||
CLASS="terminal"
|
||||
|
||||
while test $# -gt 0;do
|
||||
case $1 in
|
||||
-c|--class)
|
||||
shift
|
||||
CLASS=$1
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
test $# -gt 0 &&
|
||||
exec alacritty --class "$CLASS" -e $@ ||
|
||||
exec alacritty --class "$CLASS"
|
||||
''
|
43
scripts/wpass
Normal file
43
scripts/wpass
Normal file
|
@ -0,0 +1,43 @@
|
|||
_gpg-unlock
|
||||
set -xe
|
||||
|
||||
find_file() {
|
||||
fd --strip-cwd-prefix '\.gpg$' |
|
||||
sd ".gpg$" "" |
|
||||
bmenu -p "Password" $@
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
test -n "$PASSWORD_STORE_DIR" &&
|
||||
cd "$PASSWORD_STORE_DIR" ||
|
||||
cd "$HOME/.password-store"
|
||||
|
||||
entry=`find_file "$@"`
|
||||
|
||||
test -n "$entry" || exit 0
|
||||
|
||||
username=`pass show "$entry" 2>/dev/null | perl -ne 'print $2 if /^(login|user|email): (.*)/'`
|
||||
password=`pass show "$entry" 2>/dev/null | head -n 1`
|
||||
|
||||
action=`printf "Autotype\nUsername -> $username\nPassword" | bmenu -p Action`
|
||||
|
||||
case $action in
|
||||
Autotype)
|
||||
autotype
|
||||
;;
|
||||
Username*)
|
||||
printf '%s' "$username" | wl-copy;;
|
||||
Password)
|
||||
printf '%s' "$password" | wl-copy;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
autotype(){
|
||||
env wtype -s 100 "$username"
|
||||
env wtype -s 100 -k tab
|
||||
env wtype -s 100 "$password"
|
||||
}
|
||||
|
||||
main
|
|
@ -1,50 +0,0 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
pkgs.writeShellScriptBin "wpass" ''
|
||||
_gpg-unlock
|
||||
set -xe
|
||||
|
||||
wtype=${pkgs.wtype}/bin/wtype
|
||||
# dmenu=${pkgs.bmenu}/bin/bmenu
|
||||
dmenu="wdmenu -i"
|
||||
|
||||
find_file() {
|
||||
${pkgs.fd}/bin/fd --strip-cwd-prefix '\.gpg$' |
|
||||
${pkgs.sd}/bin/sd ".gpg$" "" |
|
||||
$dmenu -p "Password" $@
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
test -n "$PASSWORD_STORE_DIR" &&
|
||||
cd "$PASSWORD_STORE_DIR" ||
|
||||
cd "$HOME/.password-store"
|
||||
|
||||
entry=`find_file "$@"`
|
||||
|
||||
test -n "$entry" || exit 0
|
||||
|
||||
username=`${pkgs.pass}/bin/pass show "$entry" 2>/dev/null | perl -ne 'print $2 if /^(login|user|email): (.*)/'`
|
||||
password=`${pkgs.pass}/bin/pass show "$entry" 2>/dev/null | head -n 1`
|
||||
|
||||
action=`printf "Autotype\nUsername -> $username\nPassword" | $dmenu -p Action`
|
||||
|
||||
case $action in
|
||||
Autotype)
|
||||
autotype
|
||||
;;
|
||||
Username*)
|
||||
printf '%s' "$username" | ${pkgs.wl-clipboard}/bin/wl-copy;;
|
||||
Password)
|
||||
printf '%s' "$password" | ${pkgs.wl-clipboard}/bin/wl-copy;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
autotype(){
|
||||
env $wtype -s 100 "$username"
|
||||
env $wtype -s 100 -k tab
|
||||
env $wtype -s 100 "$password"
|
||||
}
|
||||
|
||||
main
|
||||
''
|
|
@ -20,9 +20,9 @@ in {
|
|||
autoStash = true;
|
||||
};
|
||||
pager = {
|
||||
log = "${pkgs._diffr}/bin/diffr | ${pkgs.kak-pager}/bin/kak-pager";
|
||||
show = "${pkgs._diffr}/bin/diffr | ${pkgs.kak-pager}/bin/kak-pager";
|
||||
diff = "${pkgs._diffr}/bin/diffr | ${pkgs.kak-pager}/bin/kak-pager";
|
||||
log = "${pkgs._diffr}/bin/_diffr | ${pkgs.kak-pager}/bin/kak-pager";
|
||||
show = "${pkgs._diffr}/bin/_diffr | ${pkgs.kak-pager}/bin/kak-pager";
|
||||
diff = "${pkgs._diffr}/bin/_diffr | ${pkgs.kak-pager}/bin/kak-pager";
|
||||
};
|
||||
alias = {
|
||||
graph = "log --graph --oneline --all";
|
||||
|
|
Loading…
Reference in a new issue