- Installation
sudo port install bash
- Add it to your shells: add installed bash to
/etc/shells
sudo vim /etc/shells
function [] = batchConvert(funhandle, indir, outdir, varargin) | |
%BATCHCONVERT Convert multiple files with given conversion function | |
% BATCHCONVERT(FUNC, INDIR, OUTDIR) converts every file or directory in | |
% INDIR using conversion funtion FUNC and save the converted files to | |
% OUTDIR with the same names as in INDIR. | |
% | |
% FUNC is a function handle that takes source filename and target | |
% directory as input variables. For example, if FUNC = @foo, then | |
% BATCHCONVERT calls foo(infile, outfile) to every infile in INDIR. | |
% |
cut -d ':' -f 1,3 /etc/passwd | sort -t ':' -k2n - | tr ':' '\t' |
# Copy public-key to remote-machine for public-key authentication | |
ssh-copy-id someuser@remote-machine | |
# To specify port number | |
ssh-copy-id "someuser@remote-machine -p port_number" |
function [] = batchProcess(funhandle, indir, varargin) | |
%BATCHPROCESS Process multiple files with given processing function | |
% BATCHPROCESS(FUNC, INDIR) processes every file or directory in | |
% INDIR using processing funtion FUNC. | |
% | |
% FUNC is a function handle that takes source filename and target | |
% directory as input variables. For example, if FUNC = @foo, then | |
% BATCHPROCESS calls foo(infile) to every infile in INDIR. | |
% | |
% BATCHPROCESS(..., 'para1', value1, 'para2', value2, ...) takes extra |
%% checking minimum arguments requried | |
minargs = 3; | |
maxargs = inf; | |
n_exargs = length(varargin); | |
try | |
narginchk(minargs, maxargs); | |
catch err | |
if strcmp(err.identifier,'MATLAB:narginchk:notEnoughInputs') | |
error('batchconvert:notEnoughInputs',... |
# Initalize git repository | |
git init | |
git add . | |
git commit -m "first commit" | |
# Initialize git repository on Dropbox folder as remote branch | |
cd ~/Dropbox/git | |
git init --bare project.git | |
# Add remote to local git repository |
function [combination] = batchCombine(funhandle, indir, varargin) | |
%BATCHCOMBINE Process multiple files and combine the results into a cell array | |
% BATCHCOMBINE(FUNC, INDIR) processes every file or directory in | |
% INDIR using processing funtion FUNC. | |
% | |
% FUNC is a function handle that takes source filename as input variables. | |
% For example, if FUNC = @foo, then BATCHCOMBINE calls foo(infile) to | |
% every infile in INDIR. | |
% | |
% BATCHCOMBINE(..., 'para1', value1, 'para2', value2, ...) takes extra |
# Use tar to direct output to standard output "-" and use gzip to compress | |
tar -cf - <source_file> | gzip -1 > <destination_file> | |
# Same effect, be sure to put <destination_file> directly behind -f option | |
tar -czf <destination_file> <source_file> | |
# Untar | |
tar -xzf <tar_file> |
# change directory and sync Finder window | |
sd () { | |
# change terminal directory | |
cd "$@" || return | |
# sync Finder window or open new one if not exists | |
osascript -e "tell application \"Finder\" | |
if front Finder window exists then | |
set target of front Finder window to (""\"$PWD\""" as POSIX file) | |
else | |
open (""\"$PWD\""" as POSIX file) |