Skip to content

Instantly share code, notes, and snippets.

@oneeyedman
Last active September 29, 2023 08:59
Show Gist options
  • Save oneeyedman/97361d543b9c0d77d52ff9bdf14ca1f6 to your computer and use it in GitHub Desktop.
Save oneeyedman/97361d543b9c0d77d52ff9bdf14ca1f6 to your computer and use it in GitHub Desktop.
#GIT
alias add!='git add .; status!'
alias status!='git status'
alias commit!='git commit'
alias commmit!='git commit -m'
alias push!='git push'
alias pull!='git pull'
alias main!='git checkout main'
alias dev!='git checkout dev'
alias develop!='git checkout develop'
alias mergedev!='git merge dev'
alias amend!='git commit --amend'
alias goto!='git checkout'
alias branches!='git branch -a'
alias recent!='git branch --sort=-committerdate'
alias discard!='git checkout -- .'
alias fetch!='git fetch'
alias updatebranches!='git remote prune origin'
alias merge!='git merge'
alias clone!='git clone '
alias graphs!='git log --all --decorate --oneline --graph'
alias configautopush!='git config --add --bool push.autoSetupRemote true'
# Create TAG
function newGitTag
git tag -a $argv
git push origin $argv
end
alias newtag!=newGitTag
# Create new local branch
function newGitBranch
git checkout -b $argv
end
alias newbranch!=newGitBranch
# Delete local branch
function deleteLocalGitBranch
# delete local
git branch -d $argv
end
alias deletelocalbranch!=deleteLocalGitBranch
# Delete local/remote branch
function deleteGitBranch
# delete remote
git push origin --delete $argv
# delete local
git branch -d $argv
end
alias deletebranch!=deleteGitBranch
function fish_prompt
set -l __last_command_exit_status $status
if not set -q -g __fish_arrow_functions_defined
set -g __fish_arrow_functions_defined
function _git_branch_name
set -l branch (git symbolic-ref --quiet HEAD 2>/dev/null)
if set -q branch[1]
echo (string replace -r '^refs/heads/' '' $branch)
else
echo (git rev-parse --short HEAD 2>/dev/null)
end
end
function _is_git_dirty
not command git diff-index --cached --quiet HEAD -- &>/dev/null
or not command git diff --no-ext-diff --quiet --exit-code &>/dev/null
end
function _is_git_repo
type -q git
or return 1
git rev-parse --git-dir >/dev/null 2>&1
end
function _hg_branch_name
echo (hg branch 2>/dev/null)
end
function _is_hg_dirty
set -l stat (hg status -mard 2>/dev/null)
test -n "$stat"
end
function _is_hg_repo
fish_print_hg_root >/dev/null
end
function _repo_branch_name
_$argv[1]_branch_name
end
function _is_repo_dirty
_is_$argv[1]_dirty
end
function _repo_type
if _is_hg_repo
echo hg
return 0
else if _is_git_repo
echo git
return 0
end
return 1
end
end
set -l cyan (set_color -o cyan)
set -l yellow (set_color FFCC00)
set -l red (set_color -o red)
set -l paradigma_red (set_color FF4745)
set -l green (set_color -o green)
set -l blue (set_color 008AFF)
set -l normal (set_color normal)
set -l gray (set_color 9B9B9B)
set -l icon_color "$yellow"
if test $__last_command_exit_status != 0
set icon_color "$red"
end
set -l isRoot "$icon_color"
if fish_is_root_user
set isRoot "$icon_color"
end
set -l cwd $normal(basename (prompt_pwd))
set -l repo_info
if set -l repo_type (_repo_type)
set -l repo_branch $gray(_repo_branch_name $repo_type)
set repo_info "$normal($repo_branch$normal)"
if _is_repo_dirty $repo_type
set -l dirty "$yellow •"
set repo_info "$normal($repo_branch$dirty $normal)"
end
end
echo $isRoot'º-)' $normal'//'$cwd $repo_info '$ '
end
function fish_title
set -q argv[1]; or set argv fish
# Looks like ~/d/fish: git log
# or /e/apt: fish
echo //(fish_prompt_pwd_dir_length=1 basename (prompt_pwd)): $argv;
end
# TERMINAL AWESOMENESS
alias wmad!='curl -s http://wttr.in/Madrid | head -7'
alias walc!='curl -s http://wttr.in/Alcorcon | head -7'
alias ip!="curl http://ipecho.net/plain ; echo"
alias path!='pwd | pbcopy'
alias config!='code ~/.config/fish'
# Editor
alias code!='code .'
alias open!='open .'
# New Folder shortcut
function newfolder
# Create and open a folder
mkdir $argv
cd $argv
end
alias ndir!=newfolder
# Remind me my terminal stuff
function show_stuff
set -l indent " → "
echo ""
echo -e "$indent wmad! \033[38;2;125;125;125m// Tiempo en Madrid\033[0m"
echo -e "$indent walc! \033[38;2;125;125;125m// Tiempo en Alcorcón\033[0m"
echo -e "$indent ip! \033[38;2;125;125;125m// Mi IP\033[0m"
echo -e "$indent path! \033[38;2;125;125;125m// Copia la ruta actual al portapapeles\033[0m"
echo -e "$indent config! \033[38;2;125;125;125m// Abre el fichero de configuración de fish\033[0m"
echo ""
end
alias stuff!=show_stuff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment