Delete unused functions
This commit is contained in:
parent
0708bd6cc0
commit
a792af4779
|
@ -177,121 +177,7 @@ fzf-locate-widget() {
|
|||
zle -N fzf-locate-widget
|
||||
bindkey '\ei' fzf-locate-widget
|
||||
|
||||
## Docker stuff: https://medium.com/@calbertts/docker-and-fuzzy-finder-fzf-4c6416f5e0b5
|
||||
runc() {
|
||||
export FZF_DEFAULT_OPTS='--height 90% --reverse --border'
|
||||
local image=$(docker images --format '{{.Repository}}:{{.Tag}}' | fzf-tmux --reverse --multi)
|
||||
if [[ $image != '' ]]; then
|
||||
echo -e "\n \033[1mDocker image:\033[0m" $image
|
||||
read -rs $'opt? \e[1mOptions: \e[0m'
|
||||
# TODO: No lo coge con -z aun estando vacio
|
||||
if [[ -z $opt ]]
|
||||
then
|
||||
opt="-it --rm"
|
||||
fi
|
||||
printf " \033[1mChoose the command: \033[0m"
|
||||
local cmd=$(echo -e "/bin/bash\nsh" | fzf-tmux --reverse --multi)
|
||||
if [[ $cmd == '' ]]; then
|
||||
read -e -p $' \e[1mCustom command: \e[0m' cmd
|
||||
fi
|
||||
echo -e " \033[1mCommand: \033[0m" $cmd
|
||||
|
||||
export FZF_DEFAULT_COMMAND='find ./ -type d -maxdepth 1 -exec basename {} \;'
|
||||
printf " \033[1mChoose the volume: \033[0m"
|
||||
local volume=$(fzf-tmux --reverse --multi)
|
||||
local curDir=${PWD##*/}
|
||||
if [[ $volume == '.' ]]; then
|
||||
echo -e " \033[1mVolume: \033[0m" $volume
|
||||
volume="`pwd`:/$curDir -w /$curDir"
|
||||
else
|
||||
echo -e " \033[1mVolume: \033[0m" $volume
|
||||
volume="`pwd`/$volume:/$volume -w /$volume"
|
||||
fi
|
||||
|
||||
export FZF_DEFAULT_COMMAND=""
|
||||
export FZF_DEFAULT_OPTS=""
|
||||
|
||||
history -s runc
|
||||
history -s docker run $opt -v $volume $image $cmd
|
||||
echo ''
|
||||
docker run $options -v $volume $image $cmd
|
||||
fi
|
||||
}
|
||||
|
||||
stopc() {
|
||||
export FZF_DEFAULT_OPTS='--height 90% --reverse --border'
|
||||
local container=$(docker ps --format '{{.Names}} => {{.Image}}' | fzf-tmux --reverse --multi | awk -F '\\=>' '{print $1}')
|
||||
if [[ $container != '' ]]; then
|
||||
echo -e "\n \033[1mDocker container:\033[0m" $container
|
||||
printf " \033[1mRemove?: \033[0m"
|
||||
local cmd=$(echo -e "No\nYes" | fzf-tmux --reverse --multi)
|
||||
if [[ $cmd != '' ]]; then
|
||||
if [[ $cmd == 'No' ]]; then
|
||||
echo -e "\n Stopping $container ...\n"
|
||||
history -s stopc
|
||||
history -s docker stop $container
|
||||
docker stop $container > /dev/null
|
||||
else
|
||||
echo -e "\n Stopping $container ..."
|
||||
history -s stopc
|
||||
history -s docker stop $container
|
||||
docker stop $container > /dev/null
|
||||
|
||||
echo -e " Removing $container ...\n"
|
||||
history -s stopc
|
||||
history -s docker rm $container
|
||||
docker rm $container > /dev/null
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
export FZF_DEFAULT_OPTS=""
|
||||
}
|
||||
|
||||
runinc() {
|
||||
export FZF_DEFAULT_OPTS='--height 90% --reverse --border'
|
||||
local container=$(docker ps --format '{{.Names}} => {{.Image}}' | fzf-tmux --reverse --multi | awk -F '\\=>' '{print $1}')
|
||||
if [[ $container != '' ]]; then
|
||||
echo -e "\n \033[1mDocker container:\033[0m" $container
|
||||
read -e -p $' \e[1mOptions: \e[0m' -i "-it" options
|
||||
if [[ $@ == '' ]]; then
|
||||
read -e -p $' \e[1mCommand: \e[0m' cmd
|
||||
else
|
||||
cmd="$@"
|
||||
fi
|
||||
echo ''
|
||||
history -s runinc "$@"
|
||||
history -s docker exec $options $container $cmd
|
||||
docker exec $options $container $cmd
|
||||
echo ''
|
||||
fi
|
||||
export FZF_DEFAULT_OPTS=""
|
||||
}
|
||||
|
||||
showipc() {
|
||||
export FZF_DEFAULT_OPTS='--height 90% --reverse --border'
|
||||
local container=$(docker ps -a --format '{{.Names}} => {{.Image}}' | fzf-tmux --reverse --multi | awk -F '\\=>' '{print $1}')
|
||||
|
||||
if [[ $container != '' ]]; then
|
||||
local network=$(docker inspect $container -f '{{.NetworkSettings.Networks}}' | awk -F 'map\\[|:' '{print $2}')
|
||||
echo -e "\n \033[1mDocker container:\033[0m" $container
|
||||
history -s showipc
|
||||
history -s docker inspect -f "{{.NetworkSettings.Networks.${network}.IPAddress}}" $container
|
||||
echo -e " \033[1mNetwork:\033[0m" $network
|
||||
echo -e " \033[1mIP Address:\033[0m" $(docker inspect -f "{{.NetworkSettings.Networks.${network}.IPAddress}}" $container) "\n"
|
||||
fi
|
||||
}
|
||||
|
||||
## Git stuff
|
||||
# fbr - checkout git branch (including remote branches), sorted by most recent commit, limit 30 last branches
|
||||
unalias gbr
|
||||
gbr() {
|
||||
local branches branch
|
||||
branches=$(git for-each-ref --count=30 --sort=-committerdate refs/heads/ --format="%(refname:short)") &&
|
||||
branch=$(echo "$branches" |
|
||||
fzf-tmux -d $(( 2 + $(wc -l <<< "$branches") )) +m) &&
|
||||
git checkout $(echo "$branch" | sed "s/.* //" | sed "s#remotes/[^/]*/##")
|
||||
}
|
||||
|
||||
# fco - checkout git branch/tag
|
||||
unalias gco
|
||||
gco() {
|
||||
|
@ -344,19 +230,6 @@ fshow() {
|
|||
FZF-EOF"
|
||||
}
|
||||
|
||||
alias glNoGraph='git log --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr% C(auto)%an" "$@"'
|
||||
local _gitLogLineToHash="echo {} | grep -o '[a-f0-9]\{7\}' | head -1"
|
||||
local _viewGitLogLine="$_gitLogLineToHash | xargs -I % sh -c 'git show --color=always % | diff-so-fancy'"
|
||||
|
||||
# fcoc_preview - checkout git commit with previews
|
||||
fcoc_preview() {
|
||||
local commit
|
||||
commit=$( glNoGraph |
|
||||
fzf --no-sort --reverse --tiebreak=index --no-multi \
|
||||
--ansi --preview $_viewGitLogLine ) &&
|
||||
git checkout $(echo "$commit" | sed "s/ .*//")
|
||||
}
|
||||
|
||||
# fshow_preview - git commit browser with previews
|
||||
fshow_preview() {
|
||||
glNoGraph |
|
||||
|
@ -376,32 +249,6 @@ fcs() {
|
|||
echo -n $(echo "$commit" | sed "s/ .*//")
|
||||
}
|
||||
|
||||
# fuzzy grep open via rg
|
||||
vg() {
|
||||
local file
|
||||
|
||||
file="$(ag --nobreak --noheading $@ | fzf -0 -1 | awk -F: '{print $1 " +" $2}')"
|
||||
|
||||
if [[ -n $file ]]
|
||||
then
|
||||
vim $file
|
||||
fi
|
||||
}
|
||||
|
||||
# fd - cd to selected directory
|
||||
fd() {
|
||||
local dir
|
||||
dir=$(find ${1:-.} -path '*/\.*' -prune \
|
||||
-o -type d -print 2> /dev/null | fzf +m) &&
|
||||
cd "$dir"
|
||||
}
|
||||
# like normal z when used with arguments but displays an fzf prompt when used without.
|
||||
unalias z 2> /dev/null
|
||||
z() {
|
||||
[ $# -gt 0 ] && _z "$*" && return
|
||||
cd "$(_z -l 2>&1 | fzf --height 40% --nth 2.. --reverse --inline-info +s --tac --query "${*##-* }" | sed 's/^[0-9,.]* *//')"
|
||||
}
|
||||
|
||||
# Clean docker
|
||||
function docker_clean(){
|
||||
echo "Deleting stopped containers..."
|
||||
|
|
Loading…
Reference in New Issue