Commit 4e6838f5 authored by Simon May's avatar Simon May
Browse files

Add alias/functions to git fetch without checkout and to get the newest file in a directory

parent f1ff81c6
#!/bin/bash
# getting the newest file in a directory
nth-last() {
num=1
if [ -n "$1" ]; then
num="$1"
fi
tail -"$num" | head -1
}
newest-file() {
num=1
if [ -n "$2" ]; then
num="$2"
fi
realpath -m --relative-base=. "$1"/$(ls -1rt "$1" | nth-last "$num")
}
# Add an “alert” alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# add aliases for ls color support
if [ -x /usr/bin/dircolors ]; then
alias ls='ls --color=auto'
......@@ -15,9 +36,6 @@ alias ll='ls -hlF'
alias lla='ls -ahlF'
alias llr='ls -ahlFrt'
# Add an “alert” alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# cd aliases
alias cd..='cd ..'
......@@ -27,6 +45,11 @@ alias ..='cd ..'
alias cp='cp -i --reflink=auto'
alias mv='mv -i'
# git aliases
git-fetch-branch() {
git fetch origin "$1:$1"
}
# diff aliases
alias gd='git diff --no-index'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment