SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#26 2012-03-15 13:36:49

2ManyDogs
dv#!
From: elsewhere
Registered: 2011-11-22
Posts: 1,346

Re: @script

After you added the code to .bashrc, you need to start a new terminal (so .bashrc gets reloaded) or run this:

source ~/.bashrc

(not very complete in my answers, this morning, am I? sorry, I'm still on my first cup of tea)

Last edited by 2ManyDogs (2012-03-15 13:37:37)


Be eggsalad to each other.

Offline

Be excellent to each other!

#27 2012-03-15 13:45:12

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: @script

your ~/.bashrc is loaded on starting a terminal. when you add something to your .bashrc and your terminal is still open, it isn't getting reloaded. after editing your .bashrc, always do this:

. ~/.bashrc

or (exactly the same but longer)

source ~/.bashrc

Offline

#28 2012-03-15 13:45:30

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: @script

damnit 2manydogs! beat me to it again!

Offline

#29 2012-03-15 13:46:44

kri5
#! Die Hard
From: L.G.C. UK
Registered: 2011-11-10
Posts: 568

Re: @script

^ big_smile

OK confirmed ~/scripts is in my path, still says command not found when i try executing

@script

does the actual script have to be added to the .bashrc as in your post or just the scripts folder in which it is contained?


#! Waldorf - 64bit - Xfce

Offline

#30 2012-03-15 13:49:30

2ManyDogs
dv#!
From: elsewhere
Registered: 2011-11-22
Posts: 1,346

Re: @script

You should not need to add the name of the script to .bashrc. Something else is broken here.

Rhowaldt, can you help? I need to work on the scrotwm review. hmm


Be eggsalad to each other.

Offline

#31 2012-03-15 13:52:18

kri5
#! Die Hard
From: L.G.C. UK
Registered: 2011-11-10
Posts: 568

Re: @script

^ Yes. I'm waiting for that review to! lol


#! Waldorf - 64bit - Xfce

Offline

#32 2012-03-15 13:56:05

kri5
#! Die Hard
From: L.G.C. UK
Registered: 2011-11-10
Posts: 568

Re: @script

2ManyDogs wrote:

Sorry, I should have explained that. If you don't know, it probably isn't, but to check do this:

echo $PATH

Then if it's not there, open ~/.bashrc, and add this at the end:

#add @scripts and bin folders to path
PATH=$PATH:~/scripts/@scripts:~/bin
export PATH

If that doesn't work we can try something else.

Fixed it, I removed the '@scripts' from the .bashrc and it now works. big_smile

Thanks!


#! Waldorf - 64bit - Xfce

Offline

#33 2012-03-15 14:00:52

2ManyDogs
dv#!
From: elsewhere
Registered: 2011-11-22
Posts: 1,346

Re: @script

Sorry, I thought @scripts was the name of the folder. Glad you got it sorted (and now you know a lot more about paths and scripts!) smile


Be eggsalad to each other.

Offline

#34 2012-03-15 15:35:00

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: @script

@2manyWMs: feel free to go to your Master Task when you need to. i'll help out on my own script, i posted it myself after all smile

@kri5: good to see you fixed it. as 2many said, you're learning fast by messing stuff up smile

in case you want to know more about all of this stuff, check out the link titled 'bash' in my signature. but even if you do, a definitive first read would be here: http://tldp.org/LDP/Bash-Beginners-Guide/html/
that link explains from scripts to the $PATH environment variable and all sorts of other stuff you need to know when working with Bash.
good luck!

Offline

#35 2012-03-16 12:41:52

kri5
#! Die Hard
From: L.G.C. UK
Registered: 2011-11-10
Posts: 568

Re: @script

^ Thanks for the links and advice, i have bookmarked them for reading later.  big_smile


#! Waldorf - 64bit - Xfce

Offline

#36 2012-05-14 05:27:07

Komrade_Toast
Member
From: The Toaster
Registered: 2012-04-12
Posts: 30

Re: @script

Just wanted to say that this script has been invaluable to me. I absolutely love it. Here is the modified version i use on my system:

#!/bin/bash
#== Creates or opens a script in ~/bin

_LOCATION="$HOME/bin"
_PATH=""

if [ $# -lt 1 ]; then
    echo "Use '@script <scriptname> [<location>]'."
    exit
fi
if [ $2 ]; then
    if [ ! -d "$2" ]; then
        echo "Location does not exist."
        exit
    else
        _LOCATION="$2"
    fi
fi


_PATH="$_LOCATION/$1"
if [ -f $_PATH ]; then
    nano $_PATH
else
    touch $_PATH
    chmod +x $_PATH
    nano $_PATH
fi

The only difference is that it checks to see if the file exits, and only opens it otherwise, it doesn't bother marking it executable (as it already should be). I used to have a separate script called @edit which edited existing scripts for me, but then i merged them into one.

Last edited by Komrade_Toast (2012-05-14 05:27:26)

Offline

#37 2012-05-14 09:27:46

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: @script

^ thanks Komrade Toast! appreciate it. the merge seems logical, good thinking. glad you are as happy with the script as i am.

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo