You are not logged in.

#1 2009-08-10 18:04:19

SpeedVin
Member
From: Poland
Registered: 2009-04-29
Posts: 955

[Solved] Help with handy scipt.

Hello
Today I have an idea for a script that will display all dir's (in curent directory) in dmenu and when we select one I will to it wink
Here it is:

#!/bin/bash
ls | dmenu -fn glisp -nb "#100" -nf "#b9c0af" -sb "#000" -sf "#afff2f" -i
cd $pwd/

Dmenu dispaly's good but after I select dir it saysi only the name of dir I select neutral
How to cat the output of dmenu?
Thanks for help! wink

Last edited by SpeedVin (2009-08-11 08:16:55)


Shell Scripter | C/C++/Python/Java Coder | ZSH

Offline

#2 2009-08-10 19:07:48

raf_kig
Member
Registered: 2008-11-28
Posts: 143

Re: [Solved] Help with handy scipt.

#!/bin/bash
cd "$(ls | dmenu -fn glisp -nb "#100" -nf "#b9c0af" -sb "#000" -sf "#afff2f" -i)"

Regards,

raf

Last edited by raf_kig (2009-08-10 19:08:57)

Offline

#3 2009-08-10 19:12:46

rson451
Member
From: Annapolis, MD USA
Registered: 2007-04-15
Posts: 1,233
Website

Re: [Solved] Help with handy scipt.

Unless I misunderstand you, this won't work.  The cd will last until the end of the shell script and you will then be moved back to the directory the script was started from.

#!/bin/bash
cd /
ls

This little script will demonstrate that.

Last edited by rson451 (2009-08-10 19:13:20)


archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson

Offline

#4 2009-08-10 19:14:56

scragar
Member
Registered: 2009-07-14
Posts: 108

Re: [Solved] Help with handy scipt.

Then make it a function or an alias.

alias cdmenu='cd "$(ls | dmenu -fn glisp -nb "#100" -nf "#b9c0af" -sb "#000" -sf "#afff2f" -i)"'

Offline

#5 2009-08-10 19:16:33

raf_kig
Member
Registered: 2008-11-28
Posts: 143

Re: [Solved] Help with handy scipt.

Yeah, it won't work if executed, but sourcing it will work

i'd suggest using an alias like

alias bla='cd "$(ls | dmenu -fn glisp -nb "#100" -nf "#b9c0af" -sb "#000" -sf "#afff2f" -i)"'

Offline

#6 2009-08-11 06:32:20

SpeedVin
Member
From: Poland
Registered: 2009-04-29
Posts: 955

Re: [Solved] Help with handy scipt.

raf_kig wrote:
#!/bin/bash
cd "$(ls | dmenu -fn glisp -nb "#100" -nf "#b9c0af" -sb "#000" -sf "#afff2f" -i)"

Regards,

raf

Thanks
I tried your solution but it won't go to directory sad
Script's have exec right's .


Shell Scripter | C/C++/Python/Java Coder | ZSH

Offline

#7 2009-08-11 08:10:30

raf_kig
Member
Registered: 2008-11-28
Posts: 143

Re: [Solved] Help with handy scipt.

As rson451 correctly said: This won't work if you execute it. You have two options:

1) source myscript.sh
instead of running it

2) use an alias like scragar/I posted

Regards,

raf

Offline

#8 2009-08-11 08:15:46

SpeedVin
Member
From: Poland
Registered: 2009-04-29
Posts: 955

Re: [Solved] Help with handy scipt.

raf_kig wrote:

As rson451 correctly said: This won't work if you execute it. You have two options:

1) source myscript.sh
instead of running it

2) use an alias like scragar/I posted

Regards,

raf

Yeah you were right thanks wink


Shell Scripter | C/C++/Python/Java Coder | ZSH

Offline

Board footer

Powered by FluxBB