Showing posts with label mac. Show all posts
Showing posts with label mac. Show all posts

Sunday, September 13, 2015

How to View All Environment Variable and Their Values

Mac:

Open a terminal window and type printenv
~$ printenv

Windows (DOS):

Open a Command Prompt and type set
c:\Users\username? set


Windows (Powershell):


Open a Powershell window and type Get-Childitem env:
PS C:\Users\username> Get-Childitem env:               


Links
Mac/Unix Bash Shell
Dos
Powershell

Friday, August 21, 2015

How to Add Your Current Git Branch to Your Terminal Prompt in Unix/Mac OSX?

1. Download the git-prompt.sh file from github using the curl command in the terminal window.
~ ? curl -Lo .git-prompt.sh https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh           

2. Add the following to your .bash_profile or .bashrc file:
if [ -f ~/.git-prompt.sh ]; then                                                                                            
   source ~/.git-prompt.sh                                                                                                  
   export PS1='\W\e[1;32m$(__git_ps1 "(%s)")\e[m\$ '                                                            
fi                                                                                                                                       

This small script adds an if statement to check if the file exists, sets the source to .git-prompt.sh, and set the PS1 variable to point to the __git_ps1 function in the .git-prompt.sh file.  The \e[1;32m and \e[m\ are color tags used to color the branch text.  

When you navigate to a folder that contains a git repository you should see something like the following:
GitProjectFolder (Master) $ git checkout NewBranch                                                           
GitProjectFolder (NewBranch) $                                                                                         


Links
Change the Terminal Command Prompt
Customizing the Color of Your Terminal Prompt

Tuesday, August 18, 2015

Customizing the Color of Your Terminal Prompt

I posted a quick tip a couple of weeks ago about on how to Change the Terminal Command Prompt.

I want to take it one step further and add custom color to the prompt and/or to a portion of the prompt.

 currentDirectory$   export PS1='\e[1;32m\W\e[m\$'                                                   
 currentDirectory$                                                                                                    

I found this link to be a good bash prompt overview of how to customize your terminal prompt and has a list of fore and background colors show below:

Foreground colors, Normal (non-bold) is the default, so the 0; prefix is optional.
\e[0;30m = Dark Gray
\e[1;30m = Bold Dark Gray
\e[0;31m = Red
\e[1;31m = Bold Red
\e[0;32m = Green
\e[1;32m = Bold Green
\e[0;33m = Yellow
\e[1;33m = Bold Yellow
\e[0;34m = Blue
\e[1;34m = Bold Blue
\e[0;35m = Purple
\e[1;35m = Bold Purple
\e[0;36m = Turquoise
\e[1;36m = Bold Turquoise
\e[0;37m = Light Gray
\e[1;37m = Bold Light Gray
Background colors:
\e[40m = Dark Gray
\e[41m = Red
\e[42m = Green
\e[43m = Yellow
\e[44m = Blue
\e[45m = Purple
\e[46m = Turquoise
\e[47m = Light Gray

Sunday, August 2, 2015

Creating an Empty File in Unix/Mac OS X (Touch)

touch someEmptyFile.txt
  1. Start terminal
  2. Type touch somefilename

Set Command Line Path

export PATH="/USERS/joesmith/bin:$PATH"
  1. Put the following in you .bashrc or .bash_profile in you root/home directory:   export PATH="/USERS/joesmith/bin:$PATH"
  2. Restart Terminal


Create Alias Command in Bash

alias ll='ls -lahG'
  1. Put the following in you .bashrc or .bash_profile in you root/home directory:   alias ll='ls -lahG'
  2. Restart Terminal


Change the Terminal Command Prompt

export PS1="\w/\u$ "
  1. Put the following in you .bashrc or .bash_profile in you root/home directory:   export PS1= "\w/\u$ "
  2. Restart Terminal

Links
Bash Prompt Basics


Tuesday, September 11, 2012

Use a Mac Wireless Keyboard with a Windows7 PC?

The procedure to connect your wireless keyboard in Windows7 is:



  1. Go to Start Menu and select "Devices & Printers" option. 
  2. Press the power button on your wireless keyboard. 
  3. In the opened window at upper left side click on "Add a device". 
  4. The keyboard will appear as an icon, when it appears select it and click "Next" 
  5. Windows generates an 6 digit code to pair your kb, type this and press "Enter" key. 
  6. Now it works in Windows 7. 


Notes: Windows Key is Cmd Key Fn doesn't work natively. For Home, End, PageUp, PageDown, Delete, etc use UAWKS


Steps 1-4 work will also allow you to connect your wireless Mac Magic Mouse
reference