mirror of https://github.com/bjeanes/dotfiles.git
Added some awesome Terminal commands and a few more aliases/functions
parent
cc8a32db88
commit
8d3f6e1511
14
aliases
14
aliases
|
@ -40,10 +40,14 @@ alias showfile='/usr/bin/SetFile -a "v"'
|
|||
|
||||
alias colorslist="set | egrep 'COLOR_\w*'" # lists all the colors
|
||||
|
||||
function f() {
|
||||
find * -name $1
|
||||
}
|
||||
function f() { find * -name $1; }
|
||||
|
||||
function manpdf() {
|
||||
man -t $@ | open -f -a Preview
|
||||
function manpdf() { man -t $@ | open -f -a Preview; }
|
||||
|
||||
function osinfo() {
|
||||
x1="$(/usr/bin/sw_vers -productName)"
|
||||
x2="$(/usr/bin/sw_vers -productVersion)"
|
||||
x3="$(/usr/bin/sw_vers -buildVersion)"
|
||||
x4="$(/usr/bin/arch)"
|
||||
echo "${x1} - ${x2} - ${x3} - ${x4}"
|
||||
}
|
|
@ -32,7 +32,7 @@
|
|||
{
|
||||
# These declarations must go within braces in order to be able to silence
|
||||
# readonly variable errors.
|
||||
BASH_COMPLETION="${BASH_COMPLETION:-/etc/bash_completion}"
|
||||
BASH_COMPLETION="${BASH_COMPLETION:-~/.dot-files/bash_completion}"
|
||||
BASH_COMPLETION_DIR="${BASH_COMPLETION_DIR:=/etc/bash_completion.d}"
|
||||
} 2>/dev/null || :
|
||||
readonly BASH_COMPLETION BASH_COMPLETION_DIR
|
||||
|
|
64
terminal
64
terminal
|
@ -0,0 +1,64 @@
|
|||
# From http://codesnippets.joyent.com/posts/show/1516
|
||||
|
||||
# Minimise terminal window to Dock
|
||||
function mintw() { printf "\e[2t"; return 0; }
|
||||
|
||||
# Send Terminal window to background
|
||||
function bgtw() { printf "\e[6t"; return 0; }
|
||||
|
||||
function hidetw() {
|
||||
/usr/bin/osascript -e 'tell application "System Events" to set visible of some item of ( get processes whose name = "Terminal" ) to false'
|
||||
return 0
|
||||
}
|
||||
|
||||
# positive integer test (including zero)
|
||||
function positive_int() { return $(test "$@" -eq "$@" > /dev/null 2>&1 && test "$@" -ge 0 > /dev/null 2>&1); }
|
||||
|
||||
# move the Terminal window
|
||||
function mvtw() {
|
||||
if [[ $# -eq 2 ]] && $(positive_int "$1") && $(positive_int "$2"); then
|
||||
printf "\e[3;${1};${2};t"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# resize the Terminal window
|
||||
function sizetw() {
|
||||
if [[ $# -eq 2 ]] && $(positive_int "$1") && $(positive_int "$2"); then
|
||||
printf "\e[8;${1};${2};t"
|
||||
/usr/bin/clear
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# full screen
|
||||
function fullscreen() { printf "\e[3;0;0;t\e[8;0;0t"; /usr/bin/clear; return 0; }
|
||||
|
||||
# default screen
|
||||
function defaultscreen() { printf "\e[8;35;150;t"; printf "\e[3;300;240;t"; /usr/bin/clear; return 0; }
|
||||
|
||||
# max columns
|
||||
function maxc() { printf "\e[3;0;0;t\e[8;50;0t"; /usr/bin/clear; return 0; }
|
||||
|
||||
# max rows
|
||||
function maxr() { printf "\e[3;0;0;t\e[8;0;100t"; /usr/bin/clear; return 0; }
|
||||
|
||||
# show number of lines & columns
|
||||
function lc() { printf "lines: $(/usr/bin/tput lines)\ncolums: $(/usr/bin/tput cols)\n"; return 0; }
|
||||
|
||||
unset -v TITLE PROMPT_COMMAND
|
||||
declare -x TITLE="Terminal"
|
||||
declare -x PROMPT_COMMAND='printf "\e]0;${TITLE}\a"'
|
||||
|
||||
function title() { declare -x TITLE="$@"; }
|
||||
|
||||
# open a new Terminal window in same location as current directory
|
||||
unset -f newin
|
||||
function newin() {
|
||||
/bin/pwd | /usr/bin/pbcopy
|
||||
/usr/bin/open -a Terminal
|
||||
/usr/bin/osascript -e 'tell application "Terminal" to do script with command "cd \"$(/usr/bin/pbpaste)\"; echo \" \" | /usr/bin/pbcopy; /usr/bin/clear"'
|
||||
return 0
|
||||
}
|
Loading…
Reference in New Issue