Abbreviations:
ARGV: Argument Vector
c(): combine ? not sure
Tuesday, July 29, 2014
Wednesday, July 9, 2014
Useful Mac Terminal Commands
Here are some terminal commands which I wish I knew earlier.
1.pushd
pushd and popd are used to store and change directories.
A trick is by using
move back and forth between two folders.
2.clean the screen
This is same as
In addition, it also works in the console of Rstudio where
3.screen for ssh connection
When executing a program in a remote computer by ssh,
if the connection lost, the execution will be aborted,
4.alias for frequently used commands
5.move to the beginning or the end of the line
6.Execute last command as root - sudo !!
Use
6.Open current directory in Finder from command line
7.Edit bash_profile to enhance the functionality of shell
8.Name the tab
1.pushd
pushd and popd are used to store and change directories.
A trick is by using
pushd
without any parameter, you canmove back and forth between two folders.
a short example
pushd ~/data
pushd ~/analysis
pushd # now the directory is changed to ~/data
pushd # now the directory is changed to ~/analysis
2.clean the screen
This is same as
clear
command but I prefer to type 2 keystrokes vs 6 keystrokesIn addition, it also works in the console of Rstudio where
clear
does not.control + L
3.screen for ssh connection
When executing a program in a remote computer by ssh,
if the connection lost, the execution will be aborted,
screen
command can solve this perfectly.4.alias for frequently used commands
alias ep="nano ~/.bash_profile"
alias sp="source ~/.bash_profile"
alias cdr="cd ~/Documents/repo/"
alias cdd="cd ~/Dropbox/"
alias ll="ls -Gl"
alias play="~/apps/spotify play"
alias pause="~/apps/spotify pause"
alias n="~/apps/spotify next"
alias p="~/apps/spotify prev"
5.move to the beginning or the end of the line
Control + a # to the beginning
Control + e # to the end
6.Execute last command as root - sudo !!
A short example - forget to add sudo when install ruby gem
$ gem install gnuplot
Fetching: gnuplot-2.6.2.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
Use
sudo !!
as a shortcut for sudo gem install gnuplot
$ sudo !!
sudo gem install gnuplot
Fetching: gnuplot-2.6.2.gem (100%)
Successfully installed gnuplot-2.6.2
Parsing documentation for gnuplot-2.6.2
Installing ri documentation for gnuplot-2.6.2
6.Open current directory in Finder from command line
open .
7.Edit bash_profile to enhance the functionality of shell
# change the style and color of the prompt
PS1='\e[0;32m\u: \e[0;31m\w \e[0;30m'
# add autocomplete for git
if [ -f ~/.git-completion.bash ]; then
source ~/.git-completion.bash
fi
8.Name the tab
# add a function to bash_profile
# nt for nametab
function nt {
echo -ne "\033]1;$1\007"
}
Monday, July 7, 2014
TextMate Shortcuts
It is super handy to deal with some routine yet trivial tasks with a few TextMate tricks.
Here I list some shortcuts which I found most useful.
Column wise selection
This allows selection and direct editing on vertical columns.
Auto completion of the code
In many IDEs,
Find and Replace in Project Folder
This allows quick replace in a bunch of files inside the same project folder.
Selection of whole line
Change Indent
This is very useful for Python when there is a block of code need to be indented.
Comment current line
If you do
clip board history viewer
Duplicate current line
Insert Comment Banner
Open Home directory in sidebar
Insert Burdle Item
I did a google search during the writing and found a number of great posts and resources:
Essential TextMate Shortcuts, Tips and Techniques
TextMate shortcuts you should be using
PDF version of the TextMate cheat Sheet.
Here I list some shortcuts which I found most useful.
Option + Left Drag with mouse
This allows selection and direct editing on vertical columns.
Esc
In many IDEs,
Tab
is used for auto completion, similarly you can use Esc
key to do this.Command + Shift + F
This allows quick replace in a bunch of files inside the same project folder.
Control + Command + left Arrow or Right Arrow
Shift + Command + L
Command + [ or ]
This is very useful for Python when there is a block of code need to be indented.
Command + /
If you do
Command + /
two times, it will uncomment the line. You can also first selected the code block and then comment all together.Control + Option + Command + v
Control + Shift + d
Control + Shift + b
Shift + Command + h
Control + Command + t
I did a google search during the writing and found a number of great posts and resources:
Essential TextMate Shortcuts, Tips and Techniques
TextMate shortcuts you should be using
PDF version of the TextMate cheat Sheet.
Subscribe to:
Posts (Atom)