一个人的角落,也许并没人会看到这里~~ 祝福你,工作顺心,学习快乐~

应用技巧

grub-mkconfig 没有Windows项

不知道什么时候开始,我的grub2-mkconfig

找不到Windows的启动项了, 说严重也不严重,但小问题堆起来也会成为大问题的 于是乎,追根溯源, Windows 项原本是在/etc/grub.d/30_os-prober生成

查看其代码,发现使用了os-prober寻找其他系统. 运行发现没有输出,可以确定是这个东西在抽风了

回头一想,之前由于部分主板EFI记动的时候,会检测是否存在/EFI/Microsoft/Boot/bootmfgw.efi,如果存在的话,会直接启动他,所以将其改名了. 将其改回再测试,os-prober可心正常找到Windows项了

于是乎,os-prober要改的话基本没戏,还是写脚本吧,

 vi /etc/grub.d/40_custom

直接将启动项加入就行了.

关于 grub 请详见官方文档!

Bash快捷键 记录备忘

生活在 Bash Shell 中,熟记以下快捷键,将极大的提高你的命令行操作效率。

编辑命令

  • Ctrl + a :移到命令行首
  • Ctrl + e :移到命令行尾
  • Ctrl + f :按字符前移(右向)
  • Ctrl + b :按字符后移(左向)
  • Alt + f :按单词前移(右向)
  • Alt + b :按单词后移(左向)
  • Ctrl + xx:在命令行首和光标之间移动
  • Ctrl + u :从光标处删除至命令行首
  • Ctrl + k :从光标处删除至命令行尾
  • Ctrl + w :从光标处删除至字首
  • Alt + d :从光标处删除至字尾
  • Ctrl + d :删除光标处的字符
  • Ctrl + h :删除光标前的字符
  • Ctrl + y :粘贴至光标后
  • Alt + c :从光标处更改为首字母大写的单词
  • Alt + u :从光标处更改为全部大写的单词
  • Alt + l :从光标处更改为全部小写的单词
  • Ctrl + t :交换光标处和之前的字符
  • Alt + t :交换光标处和之前的单词
  • Alt + Backspace:与 Ctrl + w 相同类似,分隔符有些差别 [感谢 rezilla 指正]

Add Sublime Text to your context menu on right click

When opening a text file, you may be used to right click on the file to be opened and then choose the application which can open the file from the context menu. On the context menu, you may see a menu item like "Edit with Notepad++".

Nowadays many people especially programmers like to use Sublime Text, but by default this application will not show on the context menu when you right click on a file. There is now frequent request to add this application to the context menu. Here we show a simple batch file which can help you achieve this.

Below is the batch code :

@echo off
SET sublimeTextPath=C:\Program Files\Sublime Text 3\sublime_text.exe

REM ADD REGISTRY KEYS
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3"         /t REG_SZ /v "" /d "Open with Sublime Text 3"   /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3"         /t REG_EXPAND_SZ /v "Icon" /d "%sublimeTextPath%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%sublimeTextPath% \"%%1\"" /f

pause

You just need to copy above code into the text editor you like and save it as a batch file. Note, please change the sublimeTextPath to the sublime_text.exe on your system. Then, what you need to do is right click on the batch file you saved and "Run as administrator" and it should show below:

This means you have successfully added Sublime Text to your context menu. Then you can verify this by right clicking on any text file and you should see below:

Please note that you need to run the batch file as administrator, otherwise you will see errors on the command line console.

Vim: Save file in read-only mode without restart your work

Open a file as normal, forgetting to use “sudo”, and therefore viewing a read-only file.

Then mistakenly try to edit the read-only file in the traditional manner.

:w !sudo tee%

At this point we will be presented with the content of the file and a prompt to press ENTER or type another command.

To simply save the file and move on we just press ENTER, and then press the letter “O” (oh).

(NOTE: “L” seems to do pretty much the same thing.)

The file will be saved but remains open in vi/vim for more editing or reading.

We can now exit normally by typing “:q!” since the file is still open as “read-only”.

What the command does:
:w = Write a file.
!sudo = Call shell sudo command.
tee = The output of the vi/vim write command is redirected using tee.
% = Triggers the use of the current filename.
Simply put, the ‘tee’ command is run as sudo and follows the vi/vim command on the current filename given.

Must issue sudo alsa force-reload on reboot (Ubuntu)

I have a problem, I have got sound working...

But only when I issue the Code:

sudo alsa force-reload

It will when play the sound that was queued to play, like the login sound.

Everytime when I restart, I have to do Code:

sudo alsa force-reload 

in order for sound to work.

 

Solution :

	sudo gedit /etc/default/acpi-support
	# Add modules to this list to have them removed before suspend and reloaded
# on resume. An example would be MODULES="em8300 yenta_socket"
#
# Note that network cards and USB controllers will automatically be unloaded
# unless they're listed in MODULES_WHITELIST
MODULES="soundcore"