LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-30-2016, 09:51 AM   #1
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 2,065

Rep: Reputation: Disabled
what is this called within an if statment?


Code:
if [[ -n <---
that bolded switch: what is the google-able nomenclature for that so I can look them up, and know what they all mean; because I know their is more then one, -z , -n , -f etc...

I'm trying to get an if statment working within .bashrc so that it reconizes a certin terminal then does only what I want or do not want a specific terminal to do, or not do when I open it up. as I got like 4 or 5 installed because they are free, and I like variety.
 
Old 01-30-2016, 10:04 AM   #2
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 2,065

Original Poster
Rep: Reputation: Disabled
AH HA -- I found it after all...

TEST(1) User Commands
 
Old 01-30-2016, 10:32 AM   #3
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
just a comment:
[ and test are the same, see man test, but [[ is a bash builtin, not the same, but quite similar. see man bash and look for conditional expressions
 
Old 01-30-2016, 11:16 AM   #4
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 2,065

Original Poster
Rep: Reputation: Disabled
This is what I was working on...

I desided to go with a case statment instead after I put more thought to it.

to get each terminal to do seperate things depending on which terminal is opened...

place within .bashrc one can now have a seperate promt and whatever else they want within each terminal they use ~

Code:
which_term(){
    term=$(ps -p $(ps -p $$ -o ppid=) -o args=);
    found=0;
    case $term in
        *terminator*)
            found=1
            echo "terminator"  
            ;;
        *terminology*)
            found=1
           
            export PS1=" \[\e[31m\]\[\e[35m\]\u\[\e[m\]\[\e[36m\]@\[\e[m\]\[\e[35m\]\h\[\e[m\] \[\e[32m\]\T\[\e[m\] \[\e[36m\]\w\[\e[m\]\[\e[31m\] >>$\[\e[m\]\`nonzero_return\` "  

            if [ -f /usr/bin/screenfetch ]; then screenfetch; fi
            ;;
        urxvt*)
            found=1
    
	    PS1='\u@\h \W>>\$' 
            ;;
        eterm*)
            found=1
            echo "eterm "  
            ;;
        ## Try and guess for any others
        *)
            for v in '-version' '--version' '-V' '-v'
            do
                $term "$v" &>/dev/null && eval $term $v && found=1 && break
            done
            ;;
    esac
    ## If none of the version arguments worked, try and get the 
    ## package version
    [ $found -eq 0 ] && echo "$term " $(dpkg -l $term | awk '/^ii/{print $3}')    
}	 
 

which_term # <- call the function within .bashrc so it runs as soon as you request a terminal to open
I'm still tweeking it ~

Last edited by BW-userx; 01-30-2016 at 11:34 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Bash Shell Scripting - DiskSpace Case - Select Statment gdizzle Programming 2 04-30-2015 09:59 PM
using 'echo' in a system statment in php evilchild Programming 3 09-23-2004 03:27 PM
so much errors (if statment ) huno Programming 4 07-20-2004 11:18 AM
PHP If statment agallant Programming 3 07-04-2004 10:02 AM
not able to run mysql statment Robin01 Linux - General 1 03-19-2004 08:03 PM


All times are GMT -5. The time now is 03:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration