3

I have a project with many Japanese kanji/kana folder and file names, like this:

提案書/
フォルダ/
工数.sh
設計書.sh

It takes so much time to change directories or open a file:

  • Type the first part of the command, for instance cd
  • Switch IME to Japanese
  • Type the Latin characters for the first kanji character(s)
  • Press the conversion key of your IME (usually Enter or Space)
  • Switch IME back to Latin characters
  • Press TAB to auto-complete

QUESTION: Is there something faster?

This would be my dream:

  • Type the first part of the command, for instance cd
  • Type the first Latin characters characters of the kanjis, as you would if IME was activated and press TAB. The autocompletion realizes there is no Latin characters file/folder with this name, and uses a Latin -characters-to-kanji library to see what else may match.
  • IME? Input something something, I guess? Please edit and clarify. – terdon Mar 24 '17 at 11:09
  • @terdon: IME = input method editor, e.g. ibus. Doesn't matter for this question, because he wants something inbuilt for bash, which AFAIK doesn't exist. You'd have to extend autocompletion to do that. – dirkt Mar 24 '17 at 11:14
  • @terdon: Edited, is it better? Should I describe what an IME is within the question? – Nicolas Raoul Mar 24 '17 at 11:20
  • If bash does not have this feature or anything close, maybe this question should be migrated to Software Recommendations? – Nicolas Raoul Mar 24 '17 at 11:24
  • Yes, thanks. I'm sure others know what IME is but since I didn't, I assume that not everyone will find it clear. As for migrating, no, this wouldn't be on topic on Software Recommendations; not it in its current form, anyway. Have a look at this meta post there and maybe post a question on their site following those guidelines. – terdon Mar 24 '17 at 11:41
0

Not really an answer but it was too long as a comment so. :-P

Switching IME should not be much of an effort. For me it's just a hotkey. It's supposed to be used this way (switched on whenever necessary). It might seem annoying when you list it like that but if you're used to it you barely notice (the switch is instant, and who complains about having to press the shift key to get upper case characters?).

More difficult problem is to know what to type :) to get a decent result from the IME you usually have to type whole words. If you just give it 'shi' you get a ton of possibilities...

If there aren't many files you could go with zsh and use the TAB key to cycle through files. So these are tab completions for each single TAB press in zsh (i. e. cat TAB TAB TAB TAB TAB:)

cat あ.txt
cat ち.txt # dunno why it chose this
cat い.txt
cat う.txt
cat え.txt
cat お.txt
cat か.txt
...

I'm not sure if you could use something like custom bash custom autocompletion filters to achieve the Pseudo-IME solution you wanted. There is kakasi to convert kanji to kana, and converting ascii to kana is easy enough (converting kanji to ascii is ambiguous, as you can write ascii several ways to achieve the same result like nn and n could both be interpreted as depending on context).

If there is an ASCII portion in the filename, you might also append that to narrow the choices down, in your example above you had a few .sh files so (back in zsh) you TAB for *.sh and it won't offer you the others.

Or just use the good olde mouse select copy paste.

Good luck.

  • I switch IME thousand of times a day, but somehow it feels much more painful in the terminal. By the way it is not just one unnecessary key press but three: Enable→convert→disable. – Nicolas Raoul Mar 24 '17 at 12:55
  • While full conversion would require full words, here the autocompletion only has to choose between the files/folders presents. In the example in the question, just typing s would autocomplete to 設計書.sh without having to type <enable>sekkei<space><disable> – Nicolas Raoul Mar 24 '17 at 12:59
  • You implementation idea of using kanji/kana→romaji rather than the opposite is excellent. The autocompletion would expand the files (提案書teiansho, 明日ashita&asu, etc), which is extremely fast, then match. – Nicolas Raoul Mar 24 '17 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.