This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function prefix(str, sep) { | |
// prefix("foo.bar.txt", ".") => foo | |
return str && str.substring(0, str.indexOf(sep)); | |
} | |
function suffix(str, sep, excludeSep) { | |
// suffix("foo.bar.txt", ".") => .txt | |
// suffix("foo.bar.txt", ".", true) => txt | |
return str && str.substring(str.lastIndexOf(sep) + (excludeSep === true ? sep.length : 0)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" These mappings are based on the default key movement scheme of Vim (h, j, k, l) | |
" For example, when you want to move to the left tab, press Alt + h | |
" When you want to move to the window underneath, press Shift + Alt + j | |
" Paste the below code to your Vim settings file ( ~/.vimrc ) | |
" Map Alt(Meta) key combinations | |
execute "set <M-l>=\el" | |
execute "set <M-h>=\eh" | |
execute "set <M-L>=\eL" | |
execute "set <M-H>=\eH" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
checkBackupTarget() { | |
[ ! "$1" ] \ | |
&& echo "Usage: $FUNCNAME [ directory-to-backup ]" \ | |
&& echo "Note: the path should be relative" \ | |
&& return 2 | |
local tgtPath=$1 | |
[ ! -d "$tgtPath" ] \ | |
&& printf "$FUNCNAME : \"%s\" does NOT exist!!!\n" "$tgtPath" \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on run {input, parameters} | |
tell application "Finder" | |
set dir_path to quoted form of (POSIX path of (folder of the front window as alias)) | |
end tell | |
CD_to(dir_path) | |
end run | |
on CD_to(theDir) | |
tell application "iTerm" | |
activate |
NewerOlder