add fancy preview script

This commit is contained in:
elkowar 2020-09-25 20:56:00 +02:00
parent a61f9cc7c7
commit 081e82bee3
7 changed files with 39 additions and 13 deletions

View file

@ -1,10 +1,4 @@
{
"optOut": false,
"lastUpdateCheck": 1600193922234,
"update": {
"latest": "6.14.8",
"current": "6.14.6",
"type": "patch",
"name": "npm"
}
"lastUpdateCheck": 1600877130940
}

View file

@ -505,6 +505,7 @@ main = do
currentScreenCount :: Int <- countScreens
let monitorIndices = [0..currentScreenCount - 1]
-- create a fifo named pipe for every monitor (called /tmp/xmonad-state-bar0, etc)
for_ monitorIndices (\idx -> safeSpawn "mkfifo" ["/tmp/xmonad-state-bar" ++ show idx])
@ -550,7 +551,7 @@ main = do
mySwallowEventHook = WindowSwallowing.swallowEventHook
(className =? "Alacritty" <||> className =? "Termite" <||> className =? "NOPE Thunar")
(not <$> (className =? "Dragon" <||> className =? "noswallow"))
((not <$> (className =? "Dragon" <||> className =? "noswallow")) <||> className =? "re") -- remove that last part
activateWindowEventHook :: Event -> X All
@ -587,6 +588,7 @@ fullscreenFixEventHook (ClientMessageEvent _ _ _ dpy win typ (_:dats)) = do
return $ All True
fullscreenFixEventHook _ = return $ All True

View file

@ -55,8 +55,9 @@ in
nodePackages.bash-language-server
nodePackages.dockerfile-language-server-nodejs
cargo-outdated
(addFlags bat "bat" "--theme base16")
manix
catimg
bat
cachix
]
@ -76,6 +77,8 @@ in
bpytop
cargo-watch
cargo-expand
gdbgui
lldb
]
)
(

View file

@ -84,8 +84,8 @@ let
realpath=\''${(Qe)~realpath}
"
zstyle ':fzf-tab:complete:cd:*' extra-opts --preview=$extract'exa --icons -1 --color=always $realpath'
zstyle ':fzf-tab:complete:nvim:*' extra-opts --preview=$extract'bat -p --color=always $realpath'
zstyle ':fzf-tab:complete:*:*' extra-opts --preview=$extract'/home/leon/scripts/preview.sh $realpath'
#zstyle ':fzf-tab:complete:nvim:*' extra-opts --preview=$extract'bat -p --color=always $realpath'
#zstyle ':fzf-tab:complete:ls:*' extra-opts --preview=$extract'exa --icons -1 --color=always $realpath'
#zstyle ':fzf-tab:complete:*:*' extra-opts --preview=$extract'if [ -f $realpath ]; then bat -p --color=always $realpath; else exa --icons -1 --color=always $realpath; fi'

View file

@ -1 +1 @@
/nix/store/7k8wg1pbvh785v443d28kb42sgi17wy6-options.json
/nix/store/sxyn1651vx2vznd3f35484qm5qf8in8x-options.json

27
files/scripts/preview.sh Executable file
View file

@ -0,0 +1,27 @@
#!/bin/sh
case "$(file --mime-type "$1")" in
*text*)
bat --color always --plain --theme base16 "$1"
;;
*image* | *pdf)
if command -v timg; then
timg -g50x50 -E -F "$1"
elif command -v catimg; then
catimg -w 100 -r 2 "$1"
else
echo "Install timg or catimg to view images!"
fi
;;
*directory*)
exa --icons -1 --color=always "$1"
;;
*)
echo "unknown file format"
;;
esac