Showing posts with label Linux for dummies. Show all posts
Showing posts with label Linux for dummies. Show all posts

Fix boot record after moving linux mint partitions to another disk

1. Copying partition is straightforward. Made using gparted.

2. Create bootable USB stick (Startup disk creator in Linux mint), boot from it.
Assume we have following partitions:
  • boot /sdb1 (don't really know how it works)
  • root /sdb2
  • home /sdb3
3. Do
sudo mount /dev/sda2 /mnt
 
## if you have boot partition:
# sudo mount /dev/sda1 /mnt/boot

sudo grub-install --root-directory=/mnt /dev/sda




Source of GRUB instructions

autocomplete from history in terminal (in linux mint)

create a file .inputrc

in your home directory and put there
"\e[A": history-search-backward
"\e[B": history-search-forward
set show-all-if-ambiguous on
set completion-ignore-case on
TAB: menu-complete



Restart your terminal.

How you can autocomplete from history using Up and down keys.


Keyboard layout switching. Toggle between 2 of 3 languages.

 Let's say you have 3 languages on your linux machine: English, Russian and Belarusian. You frequently switch between EN and RU. Sometimes you write something in EN and BY. So you don't want to press Alt+Shift three times constantly, only when writing something in Belarusian.
I have made a followin script for that:


#!/bin/bash
current=`setxkbmap -query | grep layout|cut  -d ',' -f 2`
echo $current
if [ "$current" == "by" ]
then
    notify-send -t 500 -i keyboard "Keyboard layouts: US/RU"
    setxkbmap -model pc105 -layout us,ru -variant altgr-intl, -option grp:alt_shift_toggle
else
    notify-send -t 500 -i keyboard "Keyboard layouts: US/BY"
    setxkbmap -model pc105 -layout us,by -variant altgr-intl, -option grp:alt_shift_toggle
fi


Here I assume that Alt+Shift will be used to switch languages inside a group.
Save the scipt in /usr/local/bin as toggle_en_ru.sh (for example).
Add execution permissions. Like
sudo chmod +x /usr/local/bin/toggle_en_ru.sh

Go to keyboard layouts settings and add a new shortcut. Assign a shortcut for switching between languages groups. I decided to use Win+Space for language pairs (EN/RU <-> EN/BY) switching.


Sources and ideas from:
http://superuser.com/questions/505466/2-and-more-keyboard-layout-groups-in-linux-changed-by-different-hot-key


Querying existing configuration:
$setxkbmap -query