Difference between revisions of "Bash"

From John Freier
Jump to: navigation, search
Line 45: Line 45:
 
== To set the CD Path ==
 
== To set the CD Path ==
 
   $CDPATH
 
   $CDPATH
 +
 +
== Alternative Screen ==
 +
This happens when you run a command a new screen appears and then is closed when done.
 +
 +
To turn this feature off.
 +
  export LESS="-FRX"
 +
 +
This new screen is actually LESS and it just needs different flags.

Revision as of 14:27, 22 March 2023

Keyboard Shortcuts

To send the current line to VIM for editing.

 ctrl+x ctrl+e

One line conditional

Both the following lines will write to the screen "false"

 [[ 1 == 0 ]] || echo "text"
 [[ 1 == 1 ]] && echo "text"


Check for environment variable

This will check to see if an variable is set

 if [[ -z "$var" ]]; then
   echo "var is not set"
 fi


Change the command prompt.

To change the command prompt, export the below value.

 export PS1=">"

or

 export PS1="${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)"


Alias

To find the command associated with an alias.

 type [alias_name]

To list all aliases, just type 'alias'.

 alias

To create an alias.

 alias myproject='cd /Users/jfreier/Projects/my_project'

Edit in VIM

To bring a command line in to VIM for editing

 ctrl+x ctrl+e

Echo commands

This will print all commands that are ran.

 set -x

To set the CD Path

 $CDPATH

Alternative Screen

This happens when you run a command a new screen appears and then is closed when done.

To turn this feature off.

 export LESS="-FRX"

This new screen is actually LESS and it just needs different flags.