added some functions and aliases
This commit is contained in:
parent
f335351904
commit
671131407e
|
@ -2,3 +2,12 @@
|
|||
alias ll='ls -alF'
|
||||
alias la='ls -A'
|
||||
alias l='ls -CF'
|
||||
|
||||
# git aliases
|
||||
|
||||
alias gs='git status'
|
||||
alias ga='git add'
|
||||
alias gc='git commit'
|
||||
alias gp='git push'
|
||||
alias gl='git log'
|
||||
|
||||
|
|
|
@ -7,3 +7,80 @@ ssh() {
|
|||
command ssh "$@"
|
||||
exit
|
||||
}
|
||||
|
||||
# Creates a new directory and immediately changes into it
|
||||
mkcd() {
|
||||
mkdir -p "$1" && cd "$1"
|
||||
}
|
||||
|
||||
# Extract compressed files easily
|
||||
extract() {
|
||||
if [ -f "$1" ] ; then
|
||||
case "$1" in
|
||||
*.tar.bz2) tar xvjf "$1" ;;
|
||||
*.tar.gz) tar xvzf "$1" ;;
|
||||
*.tar.xz) tar Jxvf "$1" ;;
|
||||
*.bz2) bunzip2 "$1" ;;
|
||||
*.rar) unrar x "$1" ;;
|
||||
*.gz) gunzip "$1" ;;
|
||||
*.tar) tar xvf "$1" ;;
|
||||
*.tbz2) tar xvjf "$1" ;;
|
||||
*.tgz) tar xvzf "$1" ;;
|
||||
*.zip) unzip "$1" ;;
|
||||
*.Z) uncompress "$1" ;;
|
||||
*.7z) 7z x "$1" ;;
|
||||
*) echo "'$1' cannot be extracted via extract()" ;;
|
||||
esac
|
||||
else
|
||||
echo "'$1' is not a valid file"
|
||||
fi
|
||||
}
|
||||
|
||||
# Show your current public IP address to the clipboard
|
||||
showip() {
|
||||
curl -s http://ifconfig.me ; echo "" #| tr -d '\n' | pbcopy
|
||||
# echo "Public IP Address copied to clipboard!"
|
||||
}
|
||||
|
||||
# Get the weather forecast for a given location.
|
||||
weather() {
|
||||
if [ -n "$1" ]; then
|
||||
curl wttr.in/"$1"
|
||||
else
|
||||
curl wttr.in
|
||||
fi
|
||||
}
|
||||
|
||||
# Fetch common .gitignore templates and append them to the current .gitignore file
|
||||
gitignore() {
|
||||
curl -sL "https://www.gitignore.io/api/$1" >> .gitignore
|
||||
}
|
||||
|
||||
# A quick way to search for a file in the current directory.
|
||||
qfind() {
|
||||
find . -name "$1"
|
||||
}
|
||||
|
||||
# Go up a specified number of directories (or one level if no argument provided)
|
||||
up() {
|
||||
local p=""
|
||||
for ((i=1; i<=$1; i++)); do
|
||||
p="../$p"
|
||||
done
|
||||
cd "$p" || return
|
||||
}
|
||||
|
||||
# Get the current timestamp (useful for creating timestamped files)
|
||||
timestamp() {
|
||||
date +%Y-%m-%d_%H-%M-%S
|
||||
}
|
||||
|
||||
# Create a backup of a file or directory with a timestamp appended to its name
|
||||
backup() {
|
||||
cp -r "$1" "$1_$(timestamp)"
|
||||
}
|
||||
|
||||
# URL-encode a given string (useful for creating encoded URLs in scripts)
|
||||
urlencode() {
|
||||
echo -n "$1" | xxd -plain | tr -d '\n' | sed 's/\(..\)/%\1/g'
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue