LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-27-2020, 12:02 AM   #1
blueray
Member
 
Registered: Feb 2020
Location: Bangladesh
Distribution: Debian, Ubuntu, Linux Mint
Posts: 136

Rep: Reputation: 2
zle widget printing blank line before the next prompt


I am using the following widget so that I do not have to write git clone to clone a repo.

Code:
function _accept-line-with-url {

    if  [[ $BUFFER =~ ^https.*git ]]
    then
        printf "\n"
        git clone $BUFFER && cd "$(basename $BUFFER .git)"

        zle kill-whole-line
        zle .accept-line
    else 
        zle .accept-line
    fi 
}

zle -N accept-line _accept-line-with-url
However, it has a small problem.

Code:
~/Desktop% https://github.com/chmln/sd.git
Cloning into 'sd'...
remote: Enumerating objects: 78, done.
remote: Counting objects: 100% (78/78), done.
remote: Compressing objects: 100% (57/57), done.
remote: Total 792 (delta 34), reused 48 (delta 15), pack-reused 714
Receiving objects: 100% (792/792), 239.98 KiB | 308.00 KiB/s, done.
Resolving deltas: 100% (456/456), done.
                               
Desktop/sd:master=%
If you look at Desktop/sd:master=% , It is printing an extra blank line before this prompt. Why is that blank line there? How can I remove it?
 
Old 07-27-2020, 12:48 AM   #2
blueray
Member
 
Registered: Feb 2020
Location: Bangladesh
Distribution: Debian, Ubuntu, Linux Mint
Posts: 136

Original Poster
Rep: Reputation: 2
OP here, The solution that is working for me is

Code:
function _accept-line-with-url {

    if  [[ $BUFFER =~ ^https.*git ]]
    then

        echo $BUFFER >> $HISTFILE
        fc -R

        BUFFERz="git clone $BUFFER && cd $(basename $BUFFER .git)"
        zle .kill-whole-line
        BUFFER=$BUFFERz
        zle .accept-line
    else 
        zle .accept-line
    fi 
}

zle -N accept-line _accept-line-with-url
 
  


Reply

Tags
zsh



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] bash wait for one line to finish before going to the next line Mike_V Programming 6 01-10-2011 06:20 PM
print line if next line blank raefdhaon Linux - Newbie 4 08-02-2010 01:18 PM
Showing a widget above a widget in GTK aarontwc Programming 4 11-26-2008 11:40 AM
grab the line below a blank line and the line above the next blank line awk or perl? Pantomime Linux - General 7 06-26-2008 08:13 AM
Text login prompt before XDM and before shutdown BuilderQ Linux - Software 1 11-24-2007 01:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration