Tag: tips and tricks

  • programmatically install packages with emacs27 and above

    In the emacs community, this is often a frequent question how can you install packages, while M-x package-list and M-x package-install can be a lot of help, you do not want to do it every time you install emacs, a better way is to add your packages in init.el and let emacs programmatically download and install you most frequent used packages.

    Here is a quick step on how you can achieve this with your init.el file is to use package-refresh-contents, but this will only work with the packages already present in your emacs library, basically this will just refresh those packages to their latest version and that’s it.

    But how we can download packages which we need on a machine where we are setting emacs for the first time.

    The first step is to add your elpa and melpa repositories, I do this by adding the following in my inti.el file, this add the repos and initialize them

    ;; load emacs package repostiroies.<br>(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")<br>("marmalade" . "http://marmalade-repo.org/packages/")<br>("melpa" . "https://melpa.org/packages/")<br>("elpy" . "https://jorgenschaefer.github.io/packages/")))

    next, we initialize the package list code

    (package-initialize)
    (when (not package-archive-contents)
      (package-refresh-contents))
    

    next, I have created my own variable for my packages where I keep all my packages

    (defvar myPackages
      '(better-defaults
        ein
        elpy
        flycheck
        material-theme
        py-autopep8))

    and here the variable is called using package-install function already initialized with package-initialize command

    (mapc #'(lambda (package)
        (unless (package-installed-p package)
          (package-install package)))
          myPackages)

    This provides me with the ability to avoid touching my main package installation code every time and I need to simply update my package list variable, which does package-install in my next emacs run, or I just call eval-buffer and reread the init.el file.

  • processes thread of a user

    There are options with ps itself for better filter options, than may be doing it with grep, worth a try.

    $ ps -LF -u user

  • chown me to who you are

    use the other folder permission as reference. Here, changing the permission of all files in folder to the permission similar to the parent folder.

    chown –reference=. ./*

  • zombie hunting

    find the zombie processes.

    ps aux | awk ‘$8 == “Z” { print }’

  • Pop up windows in kde and gnome.

    I use this primarily to pop up something while I am usually working on doing some coding and need a reminder.

    zenity –info –text “Remember the milk”

    This pops up a window telling me what to do. Setting this with “at” helps me schedule it too.