Recent Updates Toggle Comment Threads | Keyboard Shortcuts

  • diegor 8:53 am on July 13, 2015 Permalink | Reply
    Tags: bash, el capitan,   

    On El Capitan, bash, and history 

    As explained in this reddit, Apple made some changed for the bash users especially on saving bash sessions/histor. Whenever a user exits, it saves the history in ~/.bash_sessions/ directory. Until here, nothing strage until you don’t play with HISTFILESIZE and HISTSIZE environment variables.

    In /etc/bash_bashrc_Apple_Terminal (which is called by /etc/bashrc), the following piece of code can cause some issues when you have set HISTFILESIZE and HISTSIZE to a very high values:

            # Save new history commands.
            if [ $BASH_SESSION_HISTORY -eq 1 ]; then
                history -a
                cat "$BASH_SESSION_HISTFILE_NEW" >> "$BASH_SHARED_HISTFILE"
                cat "$BASH_SESSION_HISTFILE_NEW" >> "$BASH_SESSION_HISTFILE"
                # Empty this session's history file to keep track of
                # which commands have already been copied.
                : >| "$BASH_SESSION_HISTFILE_NEW"
                # Read/write the files via the history command so they
                # are truncated as appropriate.
                history -r "$BASH_SHARED_HISTFILE"
                history -w "$BASH_SHARED_HISTFILE"
                history -r "$BASH_SESSION_HISTFILE"
                history -w "$BASH_SESSION_HISTFILE"
            fi
    

    I had the HIST* variables set as:

    HISTFILESIZE=1000000000                                                         
    HISTSIZE=1000000
    

    and this is what happened when I logout from the shell.

    leonard:~ diegor$ logout
    + bash_update_session_state
    + bash_save_session_state
    + '[' 1 -eq 1 ']'
    + '[' -n /Users/diegor/.bash_sessions/97360883-85FB-4463-A9DF-1246FCD05977.session ']'
    + echo -n Saving session...
    Saving session...++ date
    + echo echo Restored session: Mon Jul 13 08:23:07 BST 2015
    + declare -F bash_session_save_state
    + '[' 1 -eq 1 ']'
    + history -a
    + cat /Users/diegor/.bash_sessions/97360883-85FB-4463-A9DF-1246FCD05977.historynew
    + cat /Users/diegor/.bash_sessions/97360883-85FB-4463-A9DF-1246FCD05977.historynew
    + :
    + history -r /Users/diegor/.bash_history
    

    Looking at the help of history, it is stated:

    The `-w' option writes out the current history to the history file;
    `-r' means to read the file and append the contents to the history list instead.
    

    which means: if you HIST*SIZE are very high, the size is going to grow a lot, with some implications (see three bullet points below)

    At this point you observe the following things:

    • the terminal is stuck on “Saving session…”
    • CPU usage goes high (you have to kill the bash process from another shell or System Monitor)
    • the size of ~/.bash_session is increasing overtime: every time you logout it increases by the size of the history file (in my case was 20MB)

    My suggestion is NOT to set those variables and let OSX deal with them.

    IHTH

     
  • diegor 10:41 pm on June 9, 2015 Permalink | Reply
    Tags: dual boot, , , UEFI, windows   

    Dual boot with Windows 8.1 and Linux on HP/Sony laptops 

    Branded laptops (e.g. HP, Sony, etc) don’t boot Linux. Just Windows. Yes, you got it. Just Windows. You can try to install Linux but it won’t be added to the boot manager. You can also try to configure GRUB as boot manager, but this will be overwritten by the Windows boot manager. Unfortunately there is no unique solution and every brand can adopt different strategies: googling around I’ve read that sometime the boot manager just boots entries where the name starts with Windows. Crazy!
    Everything started when my nice told me that Ubuntu wasn’t started anymore on her HP Pavillon. I said: “No problem, it’s a piece of cake”. At the time I installed Ubuntu she had Windows 8 and now she has Windows 8.1. This rang a bell. Maybe the update overwrote the UEFI configuration. Ok, it might be possible.
    I downloaded EasyBCD trying to add Ubuntu. It was kind of done but every time I rebooted the machine I couldn’t see the entry (I was using the Windows Boot Manager). I tried tens of times, every possible combination. I’ve played with bcdedit.exe under Windows, with efibootmanager under Linux, I’ve installed rEFInd but I had no luck at all. I’ve even disabled the fast boot on Windows 8.1.

    Nothing, nada, tabula rasa.

    I couldn’t boot to Linux unless I went to the kind of BIOS menu and selected the Linux partition. After spending few days after this, I bumped into this comment in a stackoverflow post. It states:

    “Yes! Renaming worked for me! I mounted the efi partition and copied the files ../EFI/ubuntu/grubx64.efi to ../EFI/Boot/ and to /EFI/Microsoft/Boot and changed the name of the file as follows. In the ../EFI/Boot directory I overwrote the bootx64.efi with the file and in the ../EFI/Microsoft/Boot I overwrote the bootmgfw.efi with the file. That was all I think. Thank you very much! – user296880 Jun 23 ’14 at 20:28″

    Well user296880, it did work for me too! Renaming file under the hood is really the last resort. A new upgrade might wipe everything and have to start again but I accept the risk.

    Searching a bit better I also bumped into this other post which explains exactly my situation.

    Said that, really good luck with that.

     
  • diegor 5:15 pm on May 9, 2015 Permalink | Reply
    Tags: ,   

    HOWTO: Change the message of a pushed commit 

    • git rebase -i
    • In you editor now change ‘pick’ to ‘reword’ on the line for the incorrect commit.
    • Once you have done, save and close.
    • Now the editor opens again with the message to correct. Do your correction, save and close
    • git push –force

    This method will rewrite the history of your repository. If someone pulled/fetched from the repo between the commit with the wrong message and when you correct it, he/she could have some issues. It would be useful to communicate to anyone involved about your action.

     
  • diegor 2:21 pm on March 27, 2015 Permalink | Reply
    Tags: cv, , latex, ,   

    My CV on github 

    I’ve always had my CV versioned. In the early days I used svn and then I moved to git. I had my own private repository but recently I have decided to move it to github. It is written in LaTeX and it uses ModernCV classes.
    You can get the pdf from my website/github or you can fork my repo to create your own CV starting from http://github.com/diegorusso/cv

     
  • diegor 10:48 pm on October 5, 2014 Permalink | Reply
    Tags: , , , vmware   

    HOWTO: Ctrl/Alt/Shift keys not working in VMWare 

    Sometime when using VMWare under linux, it makes impossible the usage of Ctrl/Alt/Shift keys on the virtualised OS. The solution is quite easy though. Open a terminal and type the following command:

    #> setxkbmap
    

    That’s it.

     
  • diegor 10:23 am on August 28, 2014 Permalink | Reply
    Tags: ,   

    HOWTO: check if I am in a screen session 

    #> echo $STY

    If you are in a screen session, you’ll see something similar to

    #> echo $STY
    5413.ttys001.leonard

    If you aren’t, you’ll see nothing.

    #> echo $STY
    
    #>

     
  • diegor 5:03 pm on August 14, 2014 Permalink | Reply
    Tags: ,   

    HOWTO: restore a deleted file in git 

    #> git rev-list -n 1 HEAD -- path_to_file  #this gives you the commit's hash
    #> git checkout commit_hash^ -- path_to_file # it restores the file

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel