A handy dmenu shortcut for killing frozen program

Sometimes an app or window becomes unresponsive, and you might dont want to goto task manager and select the correct name and kill its process instead you’d want a keybind thats just let you select the program or process you want to kill within seconds for that you may need a killer program

Dependancies are:

  • notify-send or dunst
  • dmenu
  • xkill
#!/bin/bash
pid=$(ps -u $USER -o pid,%mem,%cpu,comm | sort -b -k2 -r | sed -n '1!p' | dmenu -i -l 15 | awk '{print $1}')
kill -15 $pid 2>/dev/null
notify-send "you killed process"

Tip

We can even use xkill from dmenu and click on the unresponsive app with mouse to kill it

Sometimes you have a file say pdf, image or textfile sometime even zip file to send in a hurry We can use nullpointer like site to upload that file and get shorturl for it in a second and we can automate this process with dmenu and handy keybind

#!/bin/bash
file=$(find $HOME -type f | dmenu -i -l 25)
curl -F "file=@$file" 0x0.st | xclip -selection c
notify-send "your file in link"

Wants to have your own ascii style file manager

The power of fzf is that you can even make a file manager out of it heres the basic one liner for exact

ls -a | fzf -m --layout=reverse-list --border --margin 5% --padding 3% --no-info --prompt= --pointer=🎃 --marker=🕸️ --header=🍁Fuzzy Surfer --preview='prv {}' --height 70

Miscellaneous

copy all files except softlinks

cp -p ls -l|grep ^'-r'|awk -F" " '{print $9}' direcotry/

`ls -l|grep ^'-r'|awk -F" " '{print $9}'`
it's fetching only files which start with -r
	directory start with "d"
	soft link start with "l"
	file start with "-"

To delete all files except one!

  • using find
    find . \! -name 'file' -delete

  • using zsh:
    setopt extendedglob echo ^foo rm ^foo

  • using bash:
    shopt -s extglob rm -v !("filename")

rm -v !("filename1"|"filename2")
to delete all except filename1 and filename2

Bash Specific Use Globignore variable
GLOBIGNORE=*.iso:*.txt
rm *
unset GLOBIGNORE
it will remove all except iso and text file