maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   .zshrc for N900 (updated, now works for me[tm]) (https://talk.maemo.org/showthread.php?t=68685)

avx 2011-01-20 18:44

.zshrc for N900 (updated, now works for me[tm])
 
// couldn't find a better place, move/merge if needed.

Update: now works flawless for me. Guide is rewritten from the original.

There's still a chance to brick the device, but not permanently, so reflashing is possible. You've been warned, you'd better have a backup.

A .deb would be really useful, if you're capable of doing so, please don't hesitate :)

--

I made some modifications to my desktop's .zshrc to better fit (my) needs on the N900:
  • more efficient use of the screenspace
  • a lot less typing needed
  • some useful functions
  • files directly linked to apps(i.e. './movie.avi' loads it in mplayer, ...)
  • workaround for some hard to press keys(at least on my layout[de])
  • ...

I'd like to share this with you, so maybe someone else can benefit and I'd be glad to receive patches(diffs) or additions.

Getting started:

a) you need to be able to become root

b) you need extras-{devel,testing} both enabled

c) open the terminal
d) become root
e) fetch this file: http://phorcix.org/proj/n900/conf/zsh-setup
f) run
Code:

sh /path/to/zsh-setup
The script first tests, if wget and libncursesw5 are already installed, if not, it apt-gets both of them. After that, it downloads and extracts the tarball containing zsh. Then it makes the needed chmod/chown to get compinit working, downloads the config- and env-files and finally changes the default shell to zsh for the user-account (if you also want it for root, uncomment the corresponding line - risky!).

When all this is done, have a quick look over the command's output and make sure, there are no errors. If everything looks ok, reboot the device.
Note:ZSHs first start will take a relatively long time, since it's building the entries needed for autocompletion. This is one time only, so after that, it shouldn't be slow at all.

--

A little overview of what's possible with it - please forgive me, if I use zsh-terms too often...

a) auto_cd is on, thus
Code:

cd /some/path
now also simply works as
Code:

/some/path
b) some named-directories are setup, thus
Code:

cd ~cam
changes the directory to '/home/user/MyDocs/DCIM/'
of course
Code:

cp somefile ~cam/
also works

some other named-dirs are also setup, namely for the paths of documents, sounds, images, videos, backups and some more

c) shortcuts for things like apt-get are setup, thus i.e.
Code:

agi nc
autocompletes. Same for apt-get {auto}remove/purge, apt-cache search, etc.

d) ' P ' works as ' | '

e) easy layout switching, in my case de<->dvorak

f) '+'/'-' to turn up/down the volume

g) easy 'chmod'/'chown', ie '755 file'

h) shortcuts for a lot of commands, i.e. A,E,G,L -> awk,echo,grep,less and more

i) associations for most commonly used files, espacially media is assigned to mplayer

j) setup to 55 colums, so its easily editable on the N900 in vim with 'set number'

--

Love, praise, thoughts, critics, deathwishes are welcome.

In the hope that someone finds it useful, cheers,
avx

PS: a little screeny of what my setup looks like, can be found in this post

Char 2011-01-21 18:28

Re: .zshrc for N900
 
thank you, this is great
edit: damn, had to reflash too :(

avx 2011-01-22 20:02

Re: .zshrc for N900
 
Quote:

Originally Posted by Char (Post 925602)
edit: damn, had to reflash too :(

Sorry for that, hope you didn't loose too much data of value.

I'm looking into this, I guess the init-scripts are borked, but I'm not sure, yet.

epitaph 2011-01-22 20:07

Re: .zshrc for N900
 
Could u please make a .deb package?

avx 2011-01-22 20:30

Re: .zshrc for N900
 
Quote:

Originally Posted by epitaph (Post 926314)
Could u please make a .deb package?

For what, the config?

Maybe I could, but I'd need to read up on it, since I'm more of the .ebuild guy ;)

Char 2011-01-23 10:07

Re: .zshrc for N900
 
Quote:

Originally Posted by avx (Post 926311)
Sorry for that, hope you didn't loose too much data of value.

I'm looking into this, I guess the init-scripts are borked, but I'm not sure, yet.

emmc was saved and my latest backup was recent enough so all's good

do hope you figure out how to get it running properly though! :)

BernardB 2011-01-23 16:44

Re: .zshrc for N900
 
The bricking issue appears to be that zsh is used to execute /etc/X11/Xsession at startup. The output of run-parts in that script is delimited by newlines, which ash and bash recognise as field separators and split appropriately when it is used in the following for loop. Zsh isn't splitting at newlines and tries to execute the entire output of run-parts as one command.

Does somebody who's willing to risk bricking their phone want to try adding this line to your /home/user/.profile ? It shouldn't brick it :) It should get busybox to run zsh in xterms and ssh sessions.

Code:

[ -n "$PS1" ] && [ "$0" != "/etc/X11/Xsession" ] && exec /bin/zsh "$@" || :
Make sure it's all on one line. Spelt out, it says "if I am an interactive shell, and I'm not running the Xsession script, then run zsh instead, otherwise return 0"

I'm 99% confident that it will do the right thing(tm), but not confident enough to try it myself before I board a plane in a few hours. Please forgive my sensibility :)

avx 2011-01-23 16:51

Re: .zshrc for N900
 
Thanks, BernardB, will try that later tonight.

Also thanks for the hint on Xsession, I'll have a look at that, too and hopefully found a solution.

BernardB 2011-01-23 16:52

Re: .zshrc for N900
 
Oh, what may also work (and be slightly more efficient as it avoids starting two shells each time), is to set zsh as your default shell, but to add this line to your .zshenv file:

Code:

[ "$0" = "/etc/X11/Xsession" ] && emulate sh || :
I checked that it allows Xsession to run correctly, but I still haven't been game to boot my phone with it like that. Wouldn't mind confirmation of that either :)

avx 2011-01-23 17:22

Re: .zshrc for N900
 
Does anyone of you know, if/how I could get access when it stops at the moving balls? Either drop me into a shell or connect to my wlan and enable ssh?


All times are GMT. The time now is 00:22.

vBulletin® Version 3.8.8