The officially official Devuan Forum!

You are not logged in.

#1 2020-12-04 12:56:58

dice
Member
Registered: 2020-11-22
Posts: 559  
Website

post your interesting bashrc commands

Thought this might be a fun thread or is this forum just about devuan in general and no community off topic banter?

either way i found these few interesting, lets see yours.

bash-history-top()
{
        history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
}

cl()
{
    echo "$(tput cols)x$(tput lines)"
}

man-to-pdf()
{
    man -t "$1" | ps2pdf - "$1.pdf"
}

Last one (man-to-pdf) needs ghostscript installed.

Offline

#2 2020-12-04 21:21:22

alphalpha
Member
From: Germany
Registered: 2018-01-23
Posts: 137  

Re: post your interesting bashrc commands

i use this one to open iso images or usb devices that contain bootable distros with qemu

check_kvm() { [ -e /dev/kvm ] && KVM_FLAG="-enable-kvm -cpu host" }
emu32() { ISO="$1"; check_kvm; QEMU_CMD="sudo qemu-system-i386 ${KVM_FLAG} -m 2560 -drive format=raw,file=$ISO"; `echo $QEMU_CMD` }
emu64() { ISO="$1"; check_kvm; QEMU_CMD="sudo qemu-system-x86_64 ${KVM_FLAG} -m 2560 -drive format=raw,file=$ISO"; `echo $QEMU_CMD` }
alias emu="emu64"

and this one to search and open files in my archives

find-open() {
if [ "$1" ]; then
  [ "$2" ] && DIR="$2" || DIR="."
  STRING="$(find "$DIR" -iname "*$1*" | fzf)"
  [ "$STRING" ] && xdg-open "$STRING"
else
  echo "Example: find-open 'STRING' 'PATH' -> lists all matches of 'STRING' in 'PATH' and opens the selection"
  echo "         if 'PATH' is not defined, find will look in the working directory'"
fi
}

Offline

#3 2020-12-04 21:47:02

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: post your interesting bashrc commands

I use this to launch a QEMU/KVM virtual machine along with virt-viewer and a shared directory (with the path to the disk image as the argument):

function vlaunch {
   qemu-system-x86_64 -enable-kvm \
                      -m 4G \
                      -cpu host \
                      -smp cores=4 \
                      -drive file="$1",format=raw,cache=none,if=virtio \
                      -soundhw hda \
                      -vga qxl \
                      -device virtio-serial-pci \
                      -device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 \
                      -chardev spicevmc,id=spicechannel0,name=vdagent \
                      -spice unix,addr=/tmp/vm_spice.socket,disable-ticketing \
                      -device nec-usb-xhci,id=usb \
                      -chardev spicevmc,name=usbredir,id=usbredirchardev1 \
                      -device usb-redir,chardev=usbredirchardev1,id=usbredirdev1 \
                      -chardev spicevmc,name=usbredir,id=usbredirchardev2 \
                      -device usb-redir,chardev=usbredirchardev2,id=usbredirdev2 \
                      -fsdev local,id=qemu_dev,path=/home/empty/Public,security_model=none \
                      -device virtio-9p-pci,fsdev=qemu_dev,mount_tag=qemu_mount &
   remote-viewer "spice+unix:///tmp/vm_spice.socket"
}

See http://forums.debian.net/viewtopic.php?f=16&t=144775 for more on this.

But that's in $ENV (~/.kshrc) because I use Korn Shell rather than bloaty old bash :-)


Brianna Ghey — Rest In Power

Offline

#4 2020-12-05 12:19:55

dice
Member
Registered: 2020-11-22
Posts: 559  
Website

Re: post your interesting bashrc commands

Thanks for contributing.

Ive only played around in qemu a handful of times, im not one for virtualization, id rather use bare metal. Not trying to take away from qemu, it has its place and is a useful piece of software.

As for bash, well it does the job head on a stick. Lazy reply here but ive always found ksh lacking in regards to tab completion, i suppose there is some nifty tricks to be learned to get the functionality of bash-completion. How would one implement equivalents to bash-completion and inputrc for better user interaction or are these more of a limitation / security risk ?

Offline

#5 2020-12-05 12:47:07

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: post your interesting bashrc commands

No, Korn Shell only offers simple completion and has no command option completion (AFAIK). I've never really missed it though.

If you want a fully featured interactive shell then you should try zsh instead, especially with either fizsh or grml's sublime configuration. The latter's completion system is *much* better than the one offered with bash.

EDIT: but don't bother with oh-my-zsh, that's a buggy pile of shite.

Last edited by Head_on_a_Stick (2020-12-05 12:49:06)


Brianna Ghey — Rest In Power

Offline

#6 2020-12-22 14:19:10

dice
Member
Registered: 2020-11-22
Posts: 559  
Website

Re: post your interesting bashrc commands

messing around with a minimal exit menu script.

get_exit () {
read -n 1 -p "(e)xit, (r)eboot, (s)hutdown, (l)ock  " exit;

case $exit in
    e)
       pkill xinit;;
    r)
        sudo reboot;;
    s)
        sudo poweroff;;
    l)
       xscreensaver-command -l;;
esac

}

this could be a separate script as well, ive called an xterm using the following line as a keybind from my window manager. This places a small xterm in the center of the screen and all i need do is press whatever button needed or press escape to quit the xterm.

xterm -geo 50x1+400+300 -e exit-menu

Last edited by dice (2020-12-22 14:32:18)

Offline

#7 2020-12-25 02:09:17

GlennW
Member
From: Brisbane, Australia
Registered: 2019-07-18
Posts: 582  

Re: post your interesting bashrc commands

Other than coloured user, I have this...

	alias su='su -'

Last edited by GlennW (2020-12-25 02:09:29)


pic from 1993, new guitar day.

Offline

#8 2021-05-27 14:07:11

dice
Member
Registered: 2020-11-22
Posts: 559  
Website

Re: post your interesting bashrc commands

create a binary clock.

watch -n 1 'echo "obase=2;`date +%s`" | bc'

Offline

#9 2021-05-27 14:09:19

dice
Member
Registered: 2020-11-22
Posts: 559  
Website

Re: post your interesting bashrc commands

How fast is your system?

Read 32GB zero’s and throw them away.

dd if=/dev/zero of=/dev/null bs=1M count=32768

Offline

#10 2021-05-27 22:46:20

GlennW
Member
From: Brisbane, Australia
Registered: 2019-07-18
Posts: 582  

Re: post your interesting bashrc commands

dice wrote:

How fast is your system?

Read 32GB zero’s and throw them away.

dd if=/dev/zero of=/dev/null bs=1M count=32768

How fast is fast? :-)

glenn@GamesBox ~ $ dd if=/dev/zero of=/dev/null bs=1M count=32768
32768+0 records in
32768+0 records out
34359738368 bytes (34 GB, 32 GiB) copied, 1.45917 s, 23.5 GB/s

pic from 1993, new guitar day.

Offline

#11 2021-05-28 10:33:34

dice
Member
Registered: 2020-11-22
Posts: 559  
Website

Re: post your interesting bashrc commands

^ faster than mine wink

i got 10.0 GB/s

Offline

#12 2021-05-29 15:15:46

MLEvD
Member
Registered: 2021-02-14
Posts: 140  

Re: post your interesting bashrc commands

I got 2.9 GB/s with radio stream playing, 3.5 GB/s with radio stream stopped.

Offline

#13 2021-06-04 14:18:22

starbreaker
Member
From: United States
Registered: 2021-06-03
Posts: 23  
Website

Re: post your interesting bashrc commands

8.8GB/s on a ThinkPad T60. Not bad for 2007.

starbreaker@netzach:~$ time dd if=/dev/zero of=/dev/null bs=1M count=65536
65536+0 records in
65536+0 records out
68719476736 bytes (69 GB, 64 GiB) copied, 7.80361 s, 8.8 GB/s

"Out of order? [BLEEP!] Even in the future nothing works."
desktop: refurbished ThinkCentre M92p (i7, 32GB RAM, 1TB SSD, 2TB HDD)
laptop: refurbished Thinkpad T60 (Core 2 Duo, 3GB RAM, 1TB SSD)
gemini capsule: starbreaker.org

Offline

Board footer